changeset 442:52e031261eaa

Create a new 'gnv' section in config file. gnv-artifacts/trunk@490 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 29 Dec 2009 10:09:26 +0000
parents 31a12ff53f99
children da21c256a0ba
files gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/conf.xml gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java gnv-artifacts/src/main/java/de/intevation/gnv/utils/StringUtils.java
diffstat 4 files changed, 53 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Tue Dec 29 06:53:31 2009 +0000
+++ b/gnv-artifacts/ChangeLog	Tue Dec 29 10:09:26 2009 +0000
@@ -1,3 +1,17 @@
+2009-12-29	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* doc/conf/conf.xml: Moved chart template and palette config
+	  into new section 'gnv'.
+
+	* src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java:
+	  Adjusted to new 'gnv' section in config.
+	  Stores chat template under 'gnv.chart.template' and palettes
+	  under 'gnv.color.palettes'.
+	  Added authors.
+
+	* src/main/java/de/intevation/gnv/utils/StringUtils.java: Fixed
+	  index out of bounds issue.
+
 2009-12-29	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/gnv/raster/Filter.java: New.
--- a/gnv-artifacts/doc/conf/conf.xml	Tue Dec 29 06:53:31 2009 +0000
+++ b/gnv-artifacts/doc/conf/conf.xml	Tue Dec 29 10:09:26 2009 +0000
@@ -385,30 +385,34 @@
         
         <artifact name="horizontalCrossSectionMesh" xlink:href="${artifacts.config.dir}/products/horizontalcrosssection/conf_mesh.xml" />
     </artifacts>
-    <charttemplate>
-        <!--    This section configures the path to the template used to create
-                charts. -->
-        <configuration>${artifacts.config.dir}/charttemplate.xml</configuration>
-    </charttemplate>
-    <palettes>
-        <!-- This section configures the palettes used in 2D diagrams. -->
-        <palette name="flow-velocity" 
-                 parameter-ids="11"
-                 description="Palette for flow velocity"
-                 file="${artifacts.config.dir}/palette/flow-velocity.xml"/>
-        <palette name="salinity"
-                 parameter-ids="2"
-                 description="Palette for salinity"
-                 file="${artifacts.config.dir}/palette/salinity.xml"/>
-        <palette name="water-levels"
-                 parameter-ids="35"
-                 description="Palette for water levels"
-                 file="${artifacts.config.dir}/palette/water-levels.xml"/>
-        <palette name="water-temperature"
-                 parameter-ids="1"
-                 description="Palette for water temperature"
-                 file="${artifacts.config.dir}/palette/water-temperature.xml"/>
-    </palettes>
+    <gnv>
+        <!-- This section configures special parameters 
+             of the GNV artifacts. -->
+        <charttemplate>
+            <!--    This section configures the path to the template used to create
+                    charts. -->
+            <configuration>${artifacts.config.dir}/charttemplate.xml</configuration>
+        </charttemplate>
+        <palettes>
+            <!-- This section configures the palettes used in 2D diagrams. -->
+            <palette name="flow-velocity" 
+                     parameter-ids="11"
+                     description="Palette for flow velocity"
+                     file="${artifacts.config.dir}/palette/flow-velocity.xml"/>
+            <palette name="salinity"
+                     parameter-ids="2"
+                     description="Palette for salinity"
+                     file="${artifacts.config.dir}/palette/salinity.xml"/>
+            <palette name="water-levels"
+                     parameter-ids="35"
+                     description="Palette for water levels"
+                     file="${artifacts.config.dir}/palette/water-levels.xml"/>
+            <palette name="water-temperature"
+                     parameter-ids="1"
+                     description="Palette for water temperature"
+                     file="${artifacts.config.dir}/palette/water-temperature.xml"/>
+        </palettes>
+    </gnv>
     <ehcache>
         <!--  In this Section the Path to Configurationfile for the EHCache,
               which is unsed to store the Results of the Artifacts ,
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Tue Dec 29 06:53:31 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Tue Dec 29 10:09:26 2009 +0000
@@ -38,8 +38,9 @@
 import de.intevation.artifactdatabase.XMLUtils;
 
 /**
- * @author Tim Englich <tim.englich@intevation.de>
- * 
+ * @author Tim Englich         (tim.englich@intevation.de)
+ * @author Ingo Weinzierl      (iweinzierl@intevation.de)
+ * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
  */
 public class GNVArtifactContextFactory implements ArtifactContextFactory {
     /**
@@ -57,18 +58,18 @@
         "/artifact-database/ehcache/configuration";
 
     private final static String CHARTCONFIGNODEPATH = 
-        "/artifact-database/charttemplate/configuration";
+        "/artifact-database/gnv/charttemplate/configuration";
 
     public final static String PALETTES_PATH =
-        "/artifact-database/palettes";
+        "/artifact-database/gnv/palettes";
 
     public final static String PALETTE_ITEMS =
         "palette";
 
     public final static String PALETTES =
-        "color.palettes";
+        "gnv.color.palettes";
 
-    public final static String CHARTTEMPLATE = "template";
+    public final static String CHARTTEMPLATE = "gnv.chart.template";
 
     /**
      * Constructor
@@ -164,14 +165,14 @@
 
         HashMap<Integer, PaletteManager> palettes = new HashMap();
 
-        Node node = Config.getNodeXPath(config, PALETTES_PATH);
+        Element node = (Element)Config.getNodeXPath(config, PALETTES_PATH);
 
         if (node == null) {
             log.error("No palettes found");
         }
         else {
-            NodeList pals = Config.getNodeSetXPath(PALETTE_ITEMS);
-            for (int i = 0, N = pals == null ? 0 : pals.getLength(); i < N; ++i) {
+            NodeList pals = node.getElementsByTagName(PALETTE_ITEMS);
+            for (int i = 0, N = pals==null?0:pals.getLength(); i < N; ++i) {
                 Element pal = (Element)pals.item(i);
                 String name         = pal.getAttribute("name");
                 String description  = pal.getAttribute("description");
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/StringUtils.java	Tue Dec 29 06:53:31 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/StringUtils.java	Tue Dec 29 10:09:26 2009 +0000
@@ -12,7 +12,7 @@
         if (haystack == null) {
             return new String [] { straw };
         }
-        String [] nhaystack = new String[haystack.length];
+        String [] nhaystack = new String[haystack.length + 1];
         System.arraycopy(haystack, 0, nhaystack, 0, haystack.length);
         nhaystack[haystack.length] = straw;
         return nhaystack;

http://dive4elements.wald.intevation.org