changeset 5152:b26465581abf

Add a configurable path prefix to relative DGM path to allways have an absolute path.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 01 Mar 2013 10:35:38 +0100
parents 240ff7aeb6de
children 658dc517fd7b
files flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java
diffstat 3 files changed, 37 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/conf.xml	Fri Mar 01 10:04:57 2013 +0100
+++ b/flys-artifacts/doc/conf/conf.xml	Fri Mar 01 10:35:38 2013 +0100
@@ -394,9 +394,14 @@
             <zoom-scale river="Elbe" range="100" radius="5" />
             <zoom-scale river="Elbe" range="500" radius="10" />
         </zoom-scales>
+
         <minfo-sq>
             <!-- valid names: grubbs or std-dev -->
             <outlier-method name="grubbs"/>
         </minfo-sq>
+
+        <dgm-path>
+          /path/to/rivers/
+        </dgm-path>
     </options>
 </artifact-database>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java	Fri Mar 01 10:04:57 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/context/FLYSContextFactory.java	Fri Mar 01 10:35:38 2013 +0100
@@ -83,6 +83,9 @@
 
     private static final String XPATH_ZOOM_SCALES = "/artifact-database/options/zoom-scales/zoom-scale";
 
+    private static final String XPATH_DGM_PATH = "/artifact-database/options/dgm-path/text()";
+
+
     /**
      * Creates a new FLYSArtifactContext object and initialize all
      * components required by the application.
@@ -102,11 +105,22 @@
         configureFloodmapWMS(config, context);
         configureModules(config, context);
         configureZoomScales(config, context);
+        configureDGMPath(config, context);
 
         return context;
     }
 
 
+    private void configureDGMPath(Document config, FLYSContext context) {
+        String dgmPath = (String) XMLUtils.xpath(
+            config,
+            XPATH_DGM_PATH,
+            XPathConstants.STRING);
+
+        context.put("dgm-path", dgmPath);
+    }
+
+
     protected void configureZoomScales(Document config, FLYSContext context) {
         NodeList list = (NodeList)XMLUtils.xpath(
             config,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Fri Mar 01 10:04:57 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Fri Mar 01 10:35:38 2013 +0100
@@ -10,6 +10,7 @@
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
 import de.intevation.artifacts.GlobalContext;
+import de.intevation.artifacts.common.utils.Config;
 import de.intevation.artifacts.common.utils.FileTools;
 import de.intevation.flys.artifacts.access.RangeAccess;
 import de.intevation.flys.artifacts.FLYSArtifact;
@@ -43,6 +44,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.naming.Context;
+
 import org.apache.log4j.Logger;
 import org.geotools.feature.FeatureCollection;
 import org.geotools.feature.FeatureCollections;
@@ -307,7 +310,7 @@
         setUserShape(artifact, facetCreator, artifactDir, job);
         setAxis(artifact, artifactDir, job);
         setPro(artifact, artifactDir, job);
-        setDgm(artifact, job);
+        setDgm(artifact, job, context);
         setArea(artifact, artifactDir, job);
         setOutFile(artifact, job);
         setWsp(artifact, context, artifactDir, job);    // WSP
@@ -691,7 +694,11 @@
     }
 
 
-    protected void setDgm(FLYSArtifact artifact, WSPLGENJob job) {
+    protected void setDgm(
+        FLYSArtifact artifact,
+        WSPLGENJob job,
+        CallContext context
+    ) {
         String dgm_id = artifact.getDataAsString("dgm");
 
         int id = -1;
@@ -708,7 +715,15 @@
             return;
         }
 
-        job.setDgm(dgm.getPath());
+        File dgmPath = new File (dgm.getPath());
+        if (dgmPath.isAbsolute()) {
+            job.setDgm(dgm.getPath());
+        }
+        else {
+            FLYSContext fc = (FLYSContext)context.globalContext();
+            String prefix = (String) fc.get("dgm-path");
+            job.setDgm(prefix.trim() + dgm.getPath().trim());
+        }
     }
 
 

http://dive4elements.wald.intevation.org