Unifiy getMapConfig signature

This commit is contained in:
Raul Ochoa 2016-05-23 16:44:14 +02:00
parent 12c44fda6f
commit 9c1db98f67
3 changed files with 18 additions and 27 deletions

View File

@ -137,7 +137,6 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
var analysesResults = [];
var user = req.context.user;
var params = req.params;
var context = {};
step(
@ -147,11 +146,11 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
prepareConfigFn,
function prepareSqlWrap(err, requestMapConfig) {
assert.ifError(err);
self.sqlWrapMapConfigAdapter.getMapConfig(user, requestMapConfig, params, context, this);
self.sqlWrapMapConfigAdapter.getMapConfig(user, requestMapConfig, req.params, context, this);
},
function prepareAnalysisLayers(err, requestMapConfig) {
assert.ifError(err);
var analysisConfiguration = {
context.analysisConfiguration = {
db: {
host: req.params.dbhost,
port: req.params.dbport,
@ -164,16 +163,7 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
apiKey: req.params.api_key
}
};
var filters = {};
if (req.params.filters) {
try {
filters = JSON.parse(req.params.filters);
} catch (e) {
// ignore
}
}
self.analysisMapConfigAdapter.getMapConfig(analysisConfiguration, requestMapConfig, filters, this);
self.analysisMapConfigAdapter.getMapConfig(user, requestMapConfig, req.params, context, this);
},
function beforeLayergroupCreate(err, requestMapConfig, _analysesResults) {
assert.ifError(err);

View File

@ -69,15 +69,25 @@ function getFilter(dataview, params) {
};
}
AnalysisMapConfigAdapter.prototype.getMapConfig = function(analysisConfiguration, requestMapConfig, filters, callback) {
AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfig, params, context, callback) {
// jshint maxcomplexity:7
var self = this;
filters = filters || {};
if (!shouldAdaptLayers(requestMapConfig)) {
return callback(null, requestMapConfig);
}
var analysisConfiguration = context.analysisConfiguration;
var filters = {};
if (params.filters) {
try {
filters = JSON.parse(params.filters);
} catch (e) {
// ignore
}
}
var dataviewsFilters = filters.dataviews || {};
debug(dataviewsFilters);
var dataviews = requestMapConfig.dataviews || {};

View File

@ -61,7 +61,6 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
var apiKey;
var user = this.owner;
var params = this.params;
var context = {};
step(
@ -103,11 +102,11 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
},
function prepareSqlWrap(err, requestMapConfig) {
assert.ifError(err);
self.sqlWrapMapConfigAdapter.getMapConfig(user, requestMapConfig, params, context, this);
self.sqlWrapMapConfigAdapter.getMapConfig(user, requestMapConfig, rendererParams, context, this);
},
function prepareAnalysisLayers(err, requestMapConfig) {
assert.ifError(err);
var analysisConfiguration = {
context.analysisConfiguration = {
db: {
host: rendererParams.dbhost,
port: rendererParams.dbport,
@ -121,15 +120,7 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
}
};
var filters = {};
if (self.params.filters) {
try {
filters = JSON.parse(self.params.filters);
} catch (e) {
// ignore
}
}
self.analysisMapConfigAdapter.getMapConfig(analysisConfiguration, requestMapConfig, filters, this);
self.analysisMapConfigAdapter.getMapConfig(user, requestMapConfig, rendererParams, context, this);
},
function prepareLayergroup(err, _mapConfig, analysesResults) {
assert.ifError(err);