Use context for datasource 2/2

This commit is contained in:
Raul Ochoa 2016-05-23 19:14:03 +02:00
parent e9d1951d48
commit 02cb80daa1
2 changed files with 10 additions and 67 deletions

View File

@ -170,43 +170,15 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
},
function beforeLayergroupCreate(err, requestMapConfig) {
assert.ifError(err);
var next = this;
self.namedLayersAdapter.getMapConfig(user, requestMapConfig, req.params, context,
function(err, requestMapConfig, datasource) {
if (err) {
return next(err);
}
return next(null, requestMapConfig, datasource);
}
);
self.namedLayersAdapter.getMapConfig(user, requestMapConfig, req.params, context, this);
},
function addOverviewsInformation(err, requestMapConfig, datasource) {
function addOverviewsInformation(err, requestMapConfig) {
assert.ifError(err);
var next = this;
self.overviewsAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context,
function(err, requestMapConfig) {
if (err) {
return next(err);
}
return next(null, requestMapConfig, datasource);
}
);
self.overviewsAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context, this);
},
function parseTurboCarto(err, requestMapConfig, datasource) {
function parseTurboCarto(err, requestMapConfig) {
assert.ifError(err);
var next = this;
self.turboCartoAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context,
function (err, requestMapConfig) {
if (err) {
return next(err);
}
return next(null, requestMapConfig, datasource);
}
);
self.turboCartoAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context, this);
},
function createLayergroup(err, requestMapConfig) {
assert.ifError(err);

View File

@ -56,7 +56,6 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
var self = this;
var mapConfig = null;
var datasource = null;
var rendererParams;
var apiKey;
@ -127,44 +126,16 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
},
function prepareLayergroup(err, _mapConfig) {
assert.ifError(err);
var next = this;
self.analysesResults = context.analysesResults || [];
self.namedLayersAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context,
function(err, _mapConfig, datasource) {
if (err) {
return next(err);
}
return next(null, _mapConfig, datasource);
}
);
self.namedLayersAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, this);
},
function addOverviewsInformation(err, _mapConfig, datasource) {
function addOverviewsInformation(err, _mapConfig) {
assert.ifError(err);
var next = this;
self.overviewsAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context,
function(err, _mapConfig) {
if (err) {
return next(err);
}
return next(null, _mapConfig, datasource);
}
);
self.overviewsAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, this);
},
function parseTurboCarto(err, _mapConfig, datasource) {
function parseTurboCarto(err, _mapConfig) {
assert.ifError(err);
var next = this;
self.turboCartoAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context,
function (err, _mapConfig) {
if (err) {
return next(err);
}
return next(null, _mapConfig, datasource);
}
);
self.turboCartoAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, this);
},
function prepareContextLimits(err, _mapConfig) {
assert.ifError(err);