Extract function

This commit is contained in:
Daniel García Aubert
2018-03-09 15:49:03 +01:00
parent 02f93f3a14
commit cbb08f5642

View File

@@ -76,21 +76,7 @@ MapController.prototype.composeCreateMapMiddleware = function (useTemplate = fal
this.prepareContext,
initProfiler(isTemplateInstantiation),
checkJsonContentType(),
useTemplate ?
checkInstantiteLayergroup() :
checkCreateLayergroup(),
useTemplate ?
getTemplate(
this.templateMaps,
this.pgConnection,
this.metadataBackend,
this.userLimitsApi,
this.mapConfigAdapter
) :
prepareAdapterMapConfig(this.mapConfigAdapter),
useTemplate ?
instantiateLayergroup(this.mapBackend, this.userLimitsApi) :
createLayergroup (this.mapBackend, this.userLimitsApi),
this.getCreateMapMiddlewares(useTemplate),
incrementMapViewCount(this.metadataBackend),
augmentLayergroupData(),
getAffectedTables(this.pgConnection, this.layergroupAffectedTables),
@@ -111,6 +97,28 @@ MapController.prototype.composeCreateMapMiddleware = function (useTemplate = fal
];
};
MapController.prototype.getCreateMapMiddlewares = function (useTemplate) {
if (useTemplate) {
return [
checkInstantiteLayergroup(),
getTemplate(
this.templateMaps,
this.pgConnection,
this.metadataBackend,
this.userLimitsApi,
this.mapConfigAdapter
),
instantiateLayergroup(this.mapBackend, this.userLimitsApi)
];
}
return [
checkCreateLayergroup(),
prepareAdapterMapConfig(this.mapConfigAdapter),
createLayergroup (this.mapBackend, this.userLimitsApi)
];
}
function initProfiler (isTemplateInstantiation) {
const operation = isTemplateInstantiation ? 'instance_template' : 'createmap';