Named layers adapter with getMapConfig signature

This commit is contained in:
Raul Ochoa
2016-05-23 18:03:45 +02:00
parent 70750d2c43
commit efcb73e0d1
6 changed files with 25 additions and 20 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ function NamedMapProviderCache(templateMaps, pgConnection, metadataBackend, anal
this.metadataBackend = metadataBackend;
this.userLimitsApi = userLimitsApi;
this.namedLayersAdapter = new MapConfigNamedLayersAdapter(templateMaps);
this.namedLayersAdapter = new MapConfigNamedLayersAdapter(templateMaps, pgConnection);
this.analysisMapConfigAdapter = new AnalysisMapConfigAdapter(analysisBackend);
this.overviewsAdapter = overviewsAdapter;
this.turboCartoAdapter = turboCartoAdapter;
+2 -2
View File
@@ -51,7 +51,7 @@ function MapController(authApi, pgConnection, templateMaps, mapBackend, metadata
this.turboCartoAdapter = turboCartoAdapter;
this.analysisMapConfigAdapter = new AnalysisMapConfigAdapter(analysisBackend);
this.namedLayersAdapter = new MapConfigNamedLayersAdapter(templateMaps);
this.namedLayersAdapter = new MapConfigNamedLayersAdapter(templateMaps, pgConnection);
this.overviewsAdapter = overviewsAdapter;
this.sqlWrapMapConfigAdapter = new SqlWrapMapConfigAdapter();
}
@@ -169,7 +169,7 @@ MapController.prototype.create = function(req, res, prepareConfigFn) {
assert.ifError(err);
var next = this;
analysesResults = _analysesResults;
self.namedLayersAdapter.getMapConfig(req.context.user, requestMapConfig, self.pgConnection,
self.namedLayersAdapter.getMapConfig(user, requestMapConfig, req.params, context,
function(err, requestMapConfig, datasource) {
if (err) {
return next(err);
@@ -2,13 +2,14 @@ var queue = require('queue-async');
var _ = require('underscore');
var Datasource = require('windshaft').model.Datasource;
function MapConfigNamedLayersAdapter(templateMaps) {
function MapConfigNamedLayersAdapter(templateMaps, pgConnection) {
this.templateMaps = templateMaps;
this.pgConnection = pgConnection;
}
module.exports = MapConfigNamedLayersAdapter;
MapConfigNamedLayersAdapter.prototype.getMapConfig = function(username, requestMapConfig, dbMetadata, callback) {
MapConfigNamedLayersAdapter.prototype.getMapConfig = function (user, requestMapConfig, params, context, callback) {
var self = this;
var layers = requestMapConfig.layers;
@@ -30,9 +31,9 @@ MapConfigNamedLayersAdapter.prototype.getMapConfig = function(username, requestM
var templateConfigParams = layer.options.config || {};
var templateAuthTokens = layer.options.auth_tokens;
self.templateMaps.getTemplate(username, templateName, function(err, template) {
self.templateMaps.getTemplate(user, templateName, function(err, template) {
if (err || !template) {
return done(new Error("Template '" + templateName + "' of user '" + username + "' not found"));
return done(new Error("Template '" + templateName + "' of user '" + user + "' not found"));
}
if (self.templateMaps.isAuthorized(template, templateAuthTokens)) {
@@ -108,7 +109,7 @@ MapConfigNamedLayersAdapter.prototype.getMapConfig = function(username, requestM
if (_.some(layers, isNamedTypeLayer)) {
// Lazy load dbAuth
dbMetadata.setDBAuth(username, dbAuth, function(err) {
this.pgConnection.setDBAuth(user, dbAuth, function(err) {
if (err) {
return callback(err);
}
@@ -126,7 +126,7 @@ NamedMapMapConfigProvider.prototype.getMapConfig = function(callback) {
assert.ifError(err);
var next = this;
self.analysesResults = analysesResults || [];
self.namedLayersAdapter.getMapConfig(self.owner, _mapConfig, self.pgConnection,
self.namedLayersAdapter.getMapConfig(self.owner, _mapConfig, rendererParams, context,
function(err, _mapConfig, datasource) {
if (err) {
return next(err);