changeset 1038:9981452c7e75

First step: Added a new state handling the selection between vector or scalar and a new transition in timeseries to provide vector values (issue27). gnv-artifacts/trunk@1110 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 18 May 2010 16:28:05 +0000
parents da4306683186
children 3be83ac4cfde
files gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/products/timeseries/conf_timeseriespoint.xml gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java gnv-artifacts/src/main/java/de/intevation/gnv/state/SingleInputState.java gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java gnv-artifacts/src/main/java/de/intevation/gnv/state/SwitchModeState.java gnv-artifacts/src/main/resources/lang/artifactMessages.properties gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties
diffstat 11 files changed, 203 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Tue May 18 16:28:05 2010 +0000
@@ -1,3 +1,28 @@
+2010-05-18  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	  Issue27 - First step to provide vector values.
+
+	* doc/conf/products/timeseries/conf_timeseriespoint.xml: Added a further
+	  step to choose between vector or scalar values.
+
+	  TODO: Configure the parameterization path for working with vector values.
+
+	* src/main/java/de/intevation/gnv/state/SwitchModeState.java: A new state
+	  that allows users to choose between scalar or vector values.
+
+	* src/main/java/de/intevation/gnv/state/StateBase.java,
+	  src/main/java/de/intevation/gnv/state/MeasurementState.java,
+	  src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java,
+	  src/main/java/de/intevation/gnv/state/SingleInputState.java: Adjusted
+	  method signature of getDescriptionForInputData(.) - added the CallContext
+	  as further parameter that is necessary to retrieve the current locale.
+
+	* src/main/resources/lang/artifactMessages.properties,
+	  src/main/resources/lang/artifactMessages_de_DE.properties,
+	  src/main/resources/lang/artifactMessages_en.properties,
+	  src/main/resources/lang/artifactMessages_de.properties: Added labels for
+	  the user interface.
+
 2010-05-18  Tim Englich  <tim.englich@intevation.de>
 
 	* doc/conf/queries.properties: 
--- a/gnv-artifacts/doc/conf/products/timeseries/conf_timeseriespoint.xml	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/doc/conf/products/timeseries/conf_timeseriespoint.xml	Tue May 18 16:28:05 2010 +0000
@@ -144,7 +144,7 @@
        
        <transition transition="de.intevation.gnv.transition.DefaultTransition">
             <from state="timeseries_without_geom"/>
-            <to state="timeseries_parameter"/>
+            <to state="timeseries_vector_scalar"/>
         </transition>
        
         <state id="timeseries_timeseriespoint" description="timeseries_timeseriespoint" state="de.intevation.gnv.state.DefaultState">
@@ -158,12 +158,35 @@
                 <inputvalue name="featureid" type="Integer" multiselect="false" usedinquery="0"/>
             </inputvalues>
         </state>
-        
+
         <transition transition="de.intevation.gnv.transition.DefaultTransition">
             <from state="timeseries_timeseriespoint"/>
             <to state="timeseries_parameter"/>
         </transition>
-        
+
+        <state id="timeseries_vector_scalar" description="timeseries_vector_scalar" state="de.intevation.gnv.state.SwitchModeState">
+            <dataname>vectorscalar</dataname>
+            <data-multiselect>false</data-multiselect>
+            <inputvalues>
+                <inputvalue name="sourceid" type="Integer" multiselect="false" usedinquery="1"/>
+                <inputvalue name="fisname" type="String" multiselect="false" usedinquery="0"/>
+                <inputvalue name="featureid" type="Integer" multiselect="false" usedinquery="0"/>
+                <inputvalue name="vectorscalar" type="String" multiselect="false" usedinquery="0"/>
+            </inputvalues>
+        </state>
+
+        <transition transition="de.intevation.gnv.transition.ValueCompareTransition">
+            <from state="timeseries_vector_scalar"/>
+            <to state="timeseries_parameter"/>
+            <condition inputvalue="vectorscalar" value="scalar" operator="equal"/>
+        </transition>
+
+        <transition transition="de.intevation.gnv.transition.ValueCompareTransition">
+            <from state="timeseries_vector_scalar"/>
+            <to state="timeseries_parameter_vector"/>
+            <condition inputvalue="vectorscalar" value="vector" operator="equal"/>
+        </transition>
+
         <state id="timeseries_parameter" description="timeseries_parameter" state="de.intevation.gnv.state.DefaultState">
             <queryID>timeseries_parameter</queryID>
             <dataname>parameterid</dataname>
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/DefaultAutoResumeState.java	Tue May 18 16:28:05 2010 +0000
@@ -1,5 +1,7 @@
 package de.intevation.gnv.state;
 
+import de.intevation.artifacts.CallContext;
+
 import de.intevation.gnv.geobackend.base.Result;
 
 import java.util.ArrayList;
@@ -34,7 +36,8 @@
 
 
     @Override
-    protected String[] getDescriptionForInputData(InputData data, String uuid) {
+    protected String[] getDescriptionForInputData(
+        InputData data, CallContext context, String uuid) {
         return new String[0];
     }
 }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java	Tue May 18 16:28:05 2010 +0000
@@ -398,7 +398,8 @@
                 tupel[1]);
 
             if (name.equals(dataName)) {
-                String[] desc = getDescriptionForInputData(extended, uuid);
+                String[] desc = getDescriptionForInputData(
+                    extended, context, uuid);
                 extended.setDescription(desc);
             }
 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/SingleInputState.java	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/SingleInputState.java	Tue May 18 16:28:05 2010 +0000
@@ -101,7 +101,7 @@
             tmpItem.getValue(), inputValue.getType());
 
         if (valid) {
-            String[] desc = getDescriptionForInputData(tmpItem, uuid);
+            String[] desc = getDescriptionForInputData(tmpItem, context, uuid);
             tmpItem.setDescription(desc);
 
             this.inputData.put(tmpItem.getName(), tmpItem);
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java	Tue May 18 16:28:05 2010 +0000
@@ -253,7 +253,8 @@
                     if (valid) {
 
                         if (tmpItem.getName().equals(this.dataName)){
-                            String[] desc = getDescriptionForInputData(tmpItem, uuid);
+                            String[] desc = getDescriptionForInputData(
+                                tmpItem, context, uuid);
                             tmpItem.setDescription(desc);
                         }
                         this.inputData.put(tmpItem.getName(), tmpItem);
@@ -301,7 +302,9 @@
     }
 
 
-    protected String[] getDescriptionForInputData(InputData data, String uuid) {
+    protected String[] getDescriptionForInputData(
+        InputData data, CallContext context, String uuid)
+    {
         // there is only one element in the list, so take the first
         Object obj = getDescibeData(uuid).get(0);
         List descs = new ArrayList();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/SwitchModeState.java	Tue May 18 16:28:05 2010 +0000
@@ -0,0 +1,128 @@
+package de.intevation.gnv.state;
+
+import de.intevation.artifactdatabase.XMLUtils;
+
+import de.intevation.artifacts.CallContext;
+import de.intevation.artifacts.CallMeta;
+import de.intevation.artifacts.PreferredLocale;
+
+import de.intevation.gnv.artifacts.ressource.RessourceFactory;
+
+import org.apache.log4j.Logger;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+/**
+ * This task of this <code>State</code> implementation is to switch between
+ * working with vector or scalar data.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class SwitchModeState extends StateBase {
+
+    public static final String VECTOR_VALUE = "vector";
+    public static final String SCALAR_VALUE = "scalar";
+
+    public static final String RESSOURCE_VECTOR = "vectorvalues";
+    public static final String RESSOURCE_SCALAR = "scalarvalues";
+
+    private static Logger logger = Logger.getLogger(SwitchModeState.class);
+
+    public SwitchModeState() {
+    }
+
+
+    @Override
+    protected void describeDynamic(
+        XMLUtils.ElementCreator artCreator,
+        XMLUtils.ElementCreator creator,
+        Document                document,
+        Node                    dynamic,
+        CallContext             context,
+        String                  uuid)
+    {
+        RessourceFactory ressource = RessourceFactory.getInstance();
+        CallMeta callMeta          = context.getMeta();
+        PreferredLocale[] locales  = callMeta.getLanguages();
+
+        Element selectNode = creator.create("select1");
+        creator.addAttr(selectNode, "ref", dataName);
+
+        Element labelNode = creator.create("label");
+        labelNode.setTextContent(ressource.getRessource(
+            locales, dataName, dataName));
+        selectNode.appendChild(labelNode);
+
+        selectNode.appendChild(createChoices(creator, context));
+        dynamic.appendChild(selectNode);
+        logger.debug("creating dynamic ui elements finished");
+    }
+
+
+    protected Node createChoices(
+        XMLUtils.ElementCreator creator,
+        CallContext             context)
+    {
+        RessourceFactory ressource = RessourceFactory.getInstance();
+        CallMeta callMeta          = context.getMeta();
+        PreferredLocale[] locales  = callMeta.getLanguages();
+
+        Element choiceNodes = creator.create("choices");
+
+        // add choice for scalar values
+        logger.debug("create choice for scalar values");
+        Element scalar = creator.create("item");
+        Element label  = creator.create("label");
+        label.setTextContent(ressource.getRessource(
+            locales, RESSOURCE_SCALAR, RESSOURCE_SCALAR));
+        scalar.appendChild(label);
+
+        Element value = creator.create("value");
+        value.setTextContent(SCALAR_VALUE);
+        scalar.appendChild(value);
+
+        // add choice for vector values
+        logger.debug("create choice for vector values");
+        Element vector = creator.create("item");
+        label  = creator.create("label");
+        label.setTextContent(ressource.getRessource(
+            locales, RESSOURCE_VECTOR, RESSOURCE_VECTOR));
+        vector.appendChild(label);
+
+        value = creator.create("value");
+        value.setTextContent(VECTOR_VALUE);
+        vector.appendChild(value);
+
+        choiceNodes.appendChild(scalar);
+        choiceNodes.appendChild(vector);
+
+        return choiceNodes;
+    }
+
+
+    @Override
+    protected String[] getDescriptionForInputData(
+        InputData data, CallContext context, String uuid)
+    {
+        RessourceFactory ressource = RessourceFactory.getInstance();
+        CallMeta callMeta          = context.getMeta();
+        PreferredLocale[] locales  = callMeta.getLanguages();
+
+        String value = data.getValue();
+
+        if (value != null && value.equals(SCALAR_VALUE)) {
+            return new String[] { ressource.getRessource(
+                locales, RESSOURCE_SCALAR, RESSOURCE_SCALAR) };
+        }
+        else if (value != null && value.equals(VECTOR_VALUE)) {
+            return new String[] { ressource.getRessource(
+                locales, RESSOURCE_VECTOR, RESSOURCE_VECTOR) };
+        }
+
+        return null;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gnv-artifacts/src/main/resources/lang/artifactMessages.properties	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/src/main/resources/lang/artifactMessages.properties	Tue May 18 16:28:05 2010 +0000
@@ -62,6 +62,9 @@
 coordinate.template.southeast={0}\u00b0S {1}'' {2}\u00b0E {3}''
 coordinate.template.northwest={0}\u00b0N {1}'' {2}\u00b0W {3}''
 coordinate.template.southwest={0}\u00b0S {1}'' {2}\u00b0W {3}''
+vectorscalar = Vector / Scalar values
+vectorvalues = Vector values
+scalarvalues = scalar values
 
 chart.timeseries.date.format=yyyy-MMM-dd
 chart.timeseries.title.xaxis=Time [UTC]
--- a/gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_de.properties	Tue May 18 16:28:05 2010 +0000
@@ -62,6 +62,9 @@
 coordinate.template.southeast={0}\u00b0S {1}'' {2}\u00b0O {3}''
 coordinate.template.northwest={0}\u00b0N {1}'' {2}\u00b0W {3}''
 coordinate.template.southwest={0}\u00b0S {1}'' {2}\u00b0W {3}''
+vectorscalar = Vektorielle / Skalare Werte
+vectorvalues = Vektorielle Werte
+scalarvalues = Skalare Werte
 
 chart.timeseries.date.format=dd-MMM-yyyy
 chart.timeseries.title.xaxis=Zeit [UTC]
--- a/gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_de_DE.properties	Tue May 18 16:28:05 2010 +0000
@@ -62,6 +62,9 @@
 coordinate.template.southeast={0}\u00b0S {1}'' {2}\u00b0O {3}''
 coordinate.template.northwest={0}\u00b0N {1}'' {2}\u00b0W {3}''
 coordinate.template.southwest={0}\u00b0S {1}'' {2}\u00b0W {3}''
+vectorscalar = Vektorielle / Skalare Werte
+vectorvalues = Vektorielle Werte
+scalarvalues = Skalare Werte
 
 chart.timeseries.date.format=dd-MMM-yyyy
 chart.timeseries.title.xaxis=Zeit [UTC]
--- a/gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties	Tue May 18 14:27:46 2010 +0000
+++ b/gnv-artifacts/src/main/resources/lang/artifactMessages_en.properties	Tue May 18 16:28:05 2010 +0000
@@ -62,6 +62,9 @@
 coordinate.template.southeast={0}\u00b0S {1}'' {2}\u00b0E {3}''
 coordinate.template.northwest={0}\u00b0N {1}'' {2}\u00b0W {3}''
 coordinate.template.southwest={0}\u00b0S {1}'' {2}\u00b0W {3}''
+vectorscalar = Vector / Scalar values
+vectorvalues = Vector values
+scalarvalues = scalar values
 
 
 chart.timeseries.date.format=yyyy-MMM-dd

http://dive4elements.wald.intevation.org