# HG changeset patch # User Tim Englich # Date 1268139245 0 # Node ID 9ba6bb85d6dda12e72748f04dd79ec5d7ac4289e # Parent 199982e8866e610b8e1317d43e01a7581ce66166 Integrate lookup for MapFileTemplate for the different Layer. gnv-artifacts/trunk@754 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 199982e8866e -r 9ba6bb85d6dd gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Tue Mar 09 11:42:57 2010 +0000 +++ b/gnv-artifacts/ChangeLog Tue Mar 09 12:54:05 2010 +0000 @@ -1,3 +1,28 @@ +2010-03-09 Tim Englich + + * doc/conf/queries.properties: + Modified the Query for the lookup of the Tablename and the Whereclaus to + a choosen Layer. Now also the Templateid containing the Mapservice-ID and + the Layer-Id was added to the Query. + + * src/main/java/de/intevation/gnv/utils/MapfileGenerator.java (templateExists): + Add a method which will return if a given Template exists. + this could be used for determining if a specialized Template for a Layer + is given or the Default one should be used. + + * src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java (getWMS): + Integrate lookup for MapFileTemplate for the different Layer. + If a special Template should be used it must be storde according to the + following Syntax in the Folder which contain all other Mapfile-Templates. + + layer_{ID_MAPSERVICE}_${ID_LAYER} e.g. layer_BSH_IMS_CONTIS_Resources_2 + + If there is no Template matching the given Name the Defaulttemplates + layer_point, + layer_polygon or + layer_linestring + will be used. + 2010-03-09 Tim Englich * src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java (out): diff -r 199982e8866e -r 9ba6bb85d6dd gnv-artifacts/doc/conf/queries.properties --- a/gnv-artifacts/doc/conf/queries.properties Tue Mar 09 11:42:57 2010 +0000 +++ b/gnv-artifacts/doc/conf/queries.properties Tue Mar 09 12:54:05 2010 +0000 @@ -1229,8 +1229,7 @@ layer_request_data = SELECT ID_FEATURECLASS, \ QUERY_STRING, \ - TITLE, \ - LAYER_NAME \ + ID_MAPSERVICE || '_' ||ID_LAYER \ FROM MEDIAN.LAYER_HAS_SUBTYPES \ WHERE ROW_ID = ? diff -r 199982e8866e -r 9ba6bb85d6dd gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java Tue Mar 09 11:42:57 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java Tue Mar 09 12:54:05 2010 +0000 @@ -80,6 +80,8 @@ private String geometryType = null; + private String templateID = null; + public static final String SHAPEFILE_NAME = "data.shp"; /** @@ -150,6 +152,7 @@ Result resultValue = it.next(); String table = resultValue.getString(0); String where = resultValue.getString(1); + templateID = resultValue.getString(2); if (this.geometryID != null){ InputData geometryInputData = this.inputData.get(this.geometryID); @@ -365,6 +368,7 @@ String path = shapeFilePath; shapeFilePath = null; geometryType = null; + templateID = null; return path; } } @@ -389,8 +393,12 @@ if (data != null && (path = writeToShapeFile(uuid, data, callContext)) != null) { - String paramType = LAYER_MODEL+"_"+this.geometryType.toLowerCase(); - + String paramType = LAYER_MODEL+"_"+templateID; + + if (!MapfileGenerator.getInstance().templateExists(paramType)){ + // If the template doesn't exist the Defaulttemplates will be used. + paramType = LAYER_MODEL+"_"+this.geometryType.toLowerCase(); + } Document meta = MetaWriter.writeLayerMeta(callContext, uuid, path, paramType, this.determineGeometryType()); diff -r 199982e8866e -r 9ba6bb85d6dd gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java Tue Mar 09 11:42:57 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java Tue Mar 09 12:54:05 2010 +0000 @@ -1,10 +1,5 @@ package de.intevation.gnv.utils; -import de.intevation.artifactdatabase.Config; -import de.intevation.artifactdatabase.XMLUtils; -import de.intevation.artifacts.ArtifactNamespaceContext; -import de.intevation.gnv.wms.LayerInfo; - import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; @@ -18,15 +13,18 @@ import javax.xml.xpath.XPathConstants; import org.apache.log4j.Logger; - import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; - import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import de.intevation.artifactdatabase.Config; +import de.intevation.artifactdatabase.XMLUtils; +import de.intevation.artifacts.ArtifactNamespaceContext; +import de.intevation.gnv.wms.LayerInfo; + /** * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) @@ -126,6 +124,11 @@ logger.debug("THREAD END"); } } + + public boolean templateExists(String templateID){ + Template template = getTemplateByName(templateID); + return template != null; + } protected void generate() {