changeset 724:9ba6bb85d6dd

Integrate lookup for MapFileTemplate for the different Layer. gnv-artifacts/trunk@754 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 09 Mar 2010 12:54:05 +0000
parents 199982e8866e
children dde7f51dbe1e
files gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/queries.properties gnv-artifacts/src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java
diffstat 4 files changed, 46 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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  <tim.englich@intevation.de>
+
+	* 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  <tim.englich@intevation.de>
 
 	* src/main/java/de/intevation/gnv/state/layer/LayerOutputState.java (out): 
--- 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 = ? 
 
--- 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());
--- 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() {

http://dive4elements.wald.intevation.org