changeset 1725:d9afb16d1fd4

Store parameterization in data, not in fields. flys-artifacts/trunk@3007 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 18 Oct 2011 13:28:39 +0000
parents 0349dd524f9c
children e3b9164a85fe
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java
diffstat 2 files changed, 24 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Oct 18 13:26:15 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Oct 18 13:28:39 2011 +0000
@@ -1,3 +1,10 @@
+2011-10-18	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Store parameterization in data, not in Artifact.
+
+	* src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java:
+	  Resolve col_pos and wst_id field, use data instead.
+
 2011-10-18	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Add convenience-method to add defaultdata (string).
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java	Tue Oct 18 13:26:15 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java	Tue Oct 18 13:28:39 2011 +0000
@@ -7,6 +7,8 @@
 
 import org.w3c.dom.Document;
 
+import de.intevation.artifactdatabase.data.DefaultStateData;
+
 import de.intevation.artifactdatabase.state.Facet;
 import de.intevation.artifactdatabase.state.DefaultOutput;
 import de.intevation.artifactdatabase.state.State;
@@ -50,10 +52,6 @@
     /** One and only state to be in. */
     protected transient State state = null;
 
-    protected int col_pos;
-
-    protected int wst_id;
-
 
     /**
      * Trivial Constructor.
@@ -79,6 +77,7 @@
         state = new StaticState(
             "state.additional_wkms.static",
             "state.additional_wkms.static");
+
         List<Facet> fs = new ArrayList<Facet>();
         logger.debug(XMLUtils.toString(data));
         String code = XMLUtils.xpathString(
@@ -86,19 +85,22 @@
 
         logger.debug("makes: " + code);
 
+        // TODO Go for JSON, one day.
         //ex.: flood_protection-wstv-114-12
         if (code != null) {
             String [] parts = code.split("-");
-            int col = Integer.valueOf(parts[2]);
-            int wst = Integer.valueOf(parts[3]);
-            // These shall be put in data (addData)
-            this.col_pos = col;
-            this.wst_id  = wst;
-            // addDataAsString?
+
+            if (parts.length >= 4) {
+                try {
+                    Integer.valueOf(parts[2]);
+                    Integer.valueOf(parts[3]);
+                    addStringData("col_pos", parts[2]);
+                    addStringData("wst_id",  parts[3]);
+                }
+                catch (Exception e) {}
+            }
         }
 
-        // Will get col_id and wst_id
-        
         Facet facet = new WKmsFacet(Resources.getMsg(callMeta,
                    "facet.discharge_curves.mainvalues.w",
                    "facet.discharge_curves.mainvalues.w"));
@@ -112,6 +114,7 @@
 
     /**
      * Initialize the static state with output.
+     * @return static state
      */
     protected State spawnState() {
         state = new StaticState(
@@ -201,8 +204,8 @@
         // TODO KIND is not needed.
         return WKmsFactory.getWKms(
             WKmsFactory.KIND_PROTECTION,
-            this.col_pos,
-            this.wst_id);
+            Integer.valueOf(getDataAsString("col_pos")),
+            Integer.valueOf(getDataAsString("wst_id")));
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org