Get connection at the begining of adapt layers functionality
This commit is contained in:
parent
cc68b84212
commit
d947700646
@ -27,7 +27,13 @@ module.exports = class AggregationMapConfigAdapter {
|
||||
return callback(error);
|
||||
}
|
||||
|
||||
this._adaptLayers(user, mapConfig, requestMapConfig, context, callback);
|
||||
this.pgConnection.getConnection(user, (err, connection) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
this._adaptLayers(connection, mapConfig, requestMapConfig, context, callback);
|
||||
});
|
||||
}
|
||||
|
||||
_hasMissingColumns (mapConfig) {
|
||||
@ -103,37 +109,31 @@ module.exports = class AggregationMapConfigAdapter {
|
||||
return aggregation !== undefined && (typeof aggregation === 'object' || typeof aggregation === 'boolean');
|
||||
}
|
||||
|
||||
_adaptLayers (user, mapConfig, requestMapConfig, context, callback) {
|
||||
this.pgConnection.getConnection(user, (err, connection) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
_adaptLayers (connection, mapConfig, requestMapConfig, context, callback) {
|
||||
const isVectorOnlyMapConfig = mapConfig.isVectorOnlyMapConfig();
|
||||
|
||||
const isVectorOnlyMapConfig = mapConfig.isVectorOnlyMapConfig();
|
||||
|
||||
const adaptLayerPromises = requestMapConfig.layers.map((layer, index) => {
|
||||
return this._adaptLayer(connection, layer, index, isVectorOnlyMapConfig, mapConfig);
|
||||
});
|
||||
|
||||
Promise.all(adaptLayerPromises)
|
||||
.then(results => {
|
||||
context.aggregation = {
|
||||
layers: []
|
||||
};
|
||||
|
||||
results.forEach(({ layer, index, adapted }) => {
|
||||
if (adapted) {
|
||||
requestMapConfig.layers[index] = layer;
|
||||
}
|
||||
const aggregatedFormats = this._getAggregationMetadata(isVectorOnlyMapConfig, layer, adapted);
|
||||
context.aggregation.layers.push(aggregatedFormats);
|
||||
});
|
||||
|
||||
return requestMapConfig;
|
||||
})
|
||||
.then(requestMapConfig => callback(null, requestMapConfig))
|
||||
.catch(err => callback(err));
|
||||
const adaptLayerPromises = requestMapConfig.layers.map((layer, index) => {
|
||||
return this._adaptLayer(connection, layer, index, isVectorOnlyMapConfig, mapConfig);
|
||||
});
|
||||
|
||||
Promise.all(adaptLayerPromises)
|
||||
.then(results => {
|
||||
context.aggregation = {
|
||||
layers: []
|
||||
};
|
||||
|
||||
results.forEach(({ layer, index, adapted }) => {
|
||||
if (adapted) {
|
||||
requestMapConfig.layers[index] = layer;
|
||||
}
|
||||
const aggregatedFormats = this._getAggregationMetadata(isVectorOnlyMapConfig, layer, adapted);
|
||||
context.aggregation.layers.push(aggregatedFormats);
|
||||
});
|
||||
|
||||
return requestMapConfig;
|
||||
})
|
||||
.then(requestMapConfig => callback(null, requestMapConfig))
|
||||
.catch(err => callback(err));
|
||||
}
|
||||
|
||||
_adaptLayer (connection, layer, index, isVectorOnlyMapConfig, mapConfig) {
|
||||
|
Loading…
Reference in New Issue
Block a user