diff --git a/lib/cartodb/models/mapconfig/provider/named-map-provider.js b/lib/cartodb/models/mapconfig/provider/named-map-provider.js index 67522669..598162ba 100644 --- a/lib/cartodb/models/mapconfig/provider/named-map-provider.js +++ b/lib/cartodb/models/mapconfig/provider/named-map-provider.js @@ -7,6 +7,7 @@ var MapConfig = require('windshaft').model.MapConfig; var templateName = require('../../../backends/template_maps').templateName; var QueryTables = require('cartodb-query-tables'); var SqlWrapMapConfigAdapter = require('./../adapter/sql-wrap-mapconfig-adapter'); +var MapConfigAdapter = require('./../adapter'); /** * @constructor @@ -25,6 +26,14 @@ function NamedMapMapConfigProvider(templateMaps, pgConnection, metadataBackend, this.overviewsAdapter = overviewsAdapter; this.sqlWrapMapConfigAdapter = new SqlWrapMapConfigAdapter(); + this.mapConfigAdapter = new MapConfigAdapter([ + this.sqlWrapMapConfigAdapter, + this.analysisMapConfigAdapter, + this.namedLayersAdapter, + this.overviewsAdapter, + this.turboCartoAdapter + ]); + this.owner = owner; this.templateName = templateName(templateId); this.config = config; @@ -114,28 +123,7 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) { apiKey: apiKey } }; - return requestMapConfig; - }, - function prepareSqlWrap(err, requestMapConfig) { - assert.ifError(err); - self.sqlWrapMapConfigAdapter.getMapConfig(user, requestMapConfig, rendererParams, context, this); - }, - function prepareAnalysisLayers(err, requestMapConfig) { - assert.ifError(err); - self.analysisMapConfigAdapter.getMapConfig(user, requestMapConfig, rendererParams, context, this); - }, - function prepareLayergroup(err, _mapConfig) { - assert.ifError(err); - self.analysesResults = context.analysesResults || []; - self.namedLayersAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, this); - }, - function addOverviewsInformation(err, _mapConfig) { - assert.ifError(err); - self.overviewsAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, this); - }, - function parseTurboCarto(err, _mapConfig) { - assert.ifError(err); - self.turboCartoAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context, this); + self.mapConfigAdapter.getMapConfig(self.owner, requestMapConfig, rendererParams, context, this); }, function prepareContextLimits(err, _mapConfig) { assert.ifError(err); @@ -145,6 +133,7 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) { function cacheAndReturnMapConfig(err, renderLimits) { self.err = err; self.mapConfig = (mapConfig === null) ? null : new MapConfig(mapConfig, context.datasource); + self.analysesResults = context.analysesResults || []; self.rendererParams = rendererParams; self.context.limits = renderLimits || {}; return callback(self.err, self.mapConfig, self.rendererParams, self.context);