diff gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java @ 443:da21c256a0ba

"horizontale Schnittprofile" are now configured via conf.xml gnv-artifacts/trunk@491 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 29 Dec 2009 14:54:17 +0000
parents 52e031261eaa
children 85f48e287fb3
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Tue Dec 29 10:09:26 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Tue Dec 29 14:54:17 2009 +0000
@@ -18,7 +18,6 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
-import org.w3c.dom.Node;
 
 import de.intevation.gnv.geobackend.base.connectionpool.ConnectionPoolFactory;
 
@@ -66,10 +65,8 @@
     public final static String PALETTE_ITEMS =
         "palette";
 
-    public final static String PALETTES =
-        "gnv.color.palettes";
-
-    public final static String CHARTTEMPLATE = "gnv.chart.template";
+    public final static String HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES =
+        "/artifact-database/gnv/horizontal-cross-section-profile/samples/@number";
 
     /**
      * Constructor
@@ -121,6 +118,7 @@
 
             configureChartTemplate(config, returnValue);
 
+            configureHorizontalCrossSectionProfile(config, returnValue);
 
         } catch (FileNotFoundException e) {
             log.error(e, e);
@@ -132,6 +130,39 @@
         return returnValue;
     }
 
+    protected void configureHorizontalCrossSectionProfile(
+        Document           config,
+        GNVArtifactContext context
+    )
+    {
+        log.info("configuration of horizontal cross section profile");
+
+        String numSamples = Config.getStringXPath(
+            config,
+            HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES);
+
+        Integer samples =
+            GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES;
+
+        if (numSamples == null) {
+            log.warn("No number of samples found.");
+        }
+        else {
+            try {
+                samples = Integer.valueOf(numSamples);
+            }
+            catch (NumberFormatException nfe) {
+                log.warn("Invalid integer for number of samples");
+            }
+        }
+
+        log.info("# horizontal cross section profile samples: " + samples);
+
+        context.put(
+            GNVArtifactContext.HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES_KEY,
+            samples);
+    }
+
     protected void configureChartTemplate(
         Document           config,
         GNVArtifactContext context
@@ -140,21 +171,28 @@
         String chartConfigFile = Config.getStringXPath(
             config, CHARTCONFIGNODEPATH
         );
-        chartConfigFile = Config.replaceConfigDir(chartConfigFile);
-        log.debug("Parse xml configuration of " + chartConfigFile);
 
-        Document tmpl = XMLUtils.parseDocument(new File(chartConfigFile));
         XMLChartTheme theme = new XMLChartTheme("XMLChartTheme");
-        if (tmpl != null) {
-            theme.applyXMLConfiguration(tmpl);
+
+        if (chartConfigFile == null) {
+            log.warn("no configuration file for chart template found");
         }
         else {
-            log.error(
-                "Cannot load chart template from '" +
-                chartConfigFile + "'");
+            chartConfigFile = Config.replaceConfigDir(chartConfigFile);
+            log.debug("Parse xml configuration of " + chartConfigFile);
+
+            Document tmpl = XMLUtils.parseDocument(new File(chartConfigFile));
+            if (tmpl != null) {
+                theme.applyXMLConfiguration(tmpl);
+            }
+            else {
+                log.error(
+                    "Cannot load chart template from '" +
+                    chartConfigFile + "'");
+            }
         }
 
-        context.put(CHARTTEMPLATE, theme);
+        context.put(GNVArtifactContext.CHART_TEMPLATE_KEY, theme);
     }
 
     protected void configurePalettes(
@@ -221,7 +259,7 @@
             } // for all palettes
         }
 
-        context.put(PALETTES, palettes);
+        context.put(GNVArtifactContext.PALETTES_KEY, palettes);
     }
 
     /**

http://dive4elements.wald.intevation.org