Get connection at the begining of adapt layers functionality

This commit is contained in:
Daniel García Aubert 2017-12-11 19:12:10 +01:00
parent cc68b84212
commit d947700646

View File

@ -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,12 +109,7 @@ 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 adaptLayerPromises = requestMapConfig.layers.map((layer, index) => {
@ -133,7 +134,6 @@ module.exports = class AggregationMapConfigAdapter {
})
.then(requestMapConfig => callback(null, requestMapConfig))
.catch(err => callback(err));
});
}
_adaptLayer (connection, layer, index, isVectorOnlyMapConfig, mapConfig) {