changeset 1173:2490d6ef394e

Extended WDifferences bracnh of WINFO to have calculation in dedicated, new state. flys-artifacts/trunk@2753 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 15 Sep 2011 07:39:36 +0000
parents 23eb122c8ec1
children f58be0d661b9
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java
diffstat 4 files changed, 101 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Sep 14 14:58:06 2011 +0000
+++ b/flys-artifacts/ChangeLog	Thu Sep 15 07:39:36 2011 +0000
@@ -1,3 +1,16 @@
+2011-09-14  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+ Extend WDifferences branch to have calculations in dedicated, new state.
+
+	* doc/conf/artifacts/winfo.xml: Added new State and Transition in
+	  WDifferences-branch.
+
+	* src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java:
+	  New state.
+
+	* src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java:
+	  Specify to not take input, prepare getting other facets.
+
 2011-09-14  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/states/DGMSelect.java: This
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Sep 14 14:58:06 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Sep 15 07:39:36 2011 +0000
@@ -47,6 +47,12 @@
 
         <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
             <from state="state.winfo.calculation_mode"/>
+            <to state="state.winfo.waterlevel_pair_select"/>
+            <condition data="calculation_mode" value="calc.w.differences" operator="equal"/>
+        </transition>
+
+        <transition transition="de.intevation.flys.artifacts.transitions.ValueCompareTransition">
+            <from state="state.winfo.waterlevel_pair_select"/>
             <to state="state.winfo.w_differences"/>
             <condition data="calculation_mode" value="calc.w.differences" operator="equal"/>
         </transition>
@@ -140,9 +146,12 @@
             <data name="wq_values" type="WQTriple" />
         </state>
 
+        <state id="state.winfo.waterlevel_pair_select" description="state.winfo.waterlevel_pair_select" state="de.intevation.flys.artifacts.states.WaterlevelPairSelectState">
+            <data name="diffids" type="String" />
+        </state>
+
         <state id="state.winfo.w_differences" description="state.winfo.w_differences" state="de.intevation.flys.artifacts.states.WDifferencesState">
-            <data name="uuid1" type="String" />
-            <data name="uuid2" type="String" />
+            <data name="diffids" type="String" />
 
             <outputmodes>
                 <outputmode name="w_differences" description="output.w_differences" mime-type="image/png" type="chart">
@@ -150,8 +159,10 @@
                         <facet name="w_differences" description="facet.w_differences"/>
                     </facets>
                 </outputmode>
-                <outputmode name="w_differences_export" description="output.w_differences_export" mime-type="text/plain" type="export">
+                <outputmode name="w_differences_export" description="output.w_differences.export" mime-type="text/plain" type="export">
+                    <facets>
                         <facet name="csv" description="facet.w_differences.csv" />
+                    </facets>
                 </outputmode>
             </outputmodes>
         </state>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java	Wed Sep 14 14:58:06 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java	Thu Sep 15 07:39:36 2011 +0000
@@ -18,9 +18,11 @@
 import de.intevation.flys.artifacts.model.WQKms;
 
 import de.intevation.flys.artifacts.model.DataFacet;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
 
 import de.intevation.flys.utils.FLYSUtils;
 
+//import net.sf.json.JSONObject;
 
 public class WDifferencesState
 extends      DefaultState
@@ -29,14 +31,15 @@
     /** The logger that is used in this state. */
     private static Logger logger = Logger.getLogger(WDifferencesState.class);
 
+
     public WDifferencesState() {
     }
 
 
-    /** Specify to display a datacage_twin_panel. */
+    /** Specify to display nothing (this is kind of a "final" state). */
     @Override
     protected String getUIProvider() {
-        return "datacage_twin_panel";
+        return "noinput";
     }
 
 
@@ -49,6 +52,7 @@
         Object       old
     ) {
         WINFOArtifact winfo = (WINFOArtifact)artifact;
+        String id = getID();
 
         // Get a data item (uuids) or parameterization of the respective
         // artifacts.
@@ -79,6 +83,16 @@
             wkms = WKmsOperation.SUBTRACTION.operate(minuend[0], subtrahend[0]);
             facetName = "W ("+minuend[0].getName() + ") - W (" + subtrahend[0].getName()+")";
             logger.warn("Did a WKMSSubtraction");
+            // Add these datasets also as facets.
+            // TODO Store parameterization.
+            // Therefore need: getKmRange, getQs, getRiver, eventually getWs
+            Facet minuendAbsFacet = new WaterlevelFacet(0, LONGITUDINAL_W,
+                "Minuend: W (_todo_)", ComputeType.ADVANCE, id, hash);
+            Facet subtrahendAbsFacet = new WaterlevelFacet(1, LONGITUDINAL_W,
+                "Subtrahend: W (_todo_)", ComputeType.ADVANCE, id, hash);
+            //JSONObject jsonObject = new JSONObject().accumulate("string", 2.0f);
+            //facets.add(minuendAbsFacet);
+            //facets.add(subtrahendAbsFacet);
         }
 
         if (facets != null) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java	Thu Sep 15 07:39:36 2011 +0000
@@ -0,0 +1,58 @@
+package de.intevation.flys.artifacts.states;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
+
+import de.intevation.flys.artifacts.math.WKmsOperation;
+
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WKms;
+import de.intevation.flys.artifacts.model.WQKms;
+
+import de.intevation.flys.artifacts.model.DataFacet;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
+
+import de.intevation.flys.utils.FLYSUtils;
+
+import net.sf.json.JSONObject;
+
+public class WaterlevelPairSelectState
+extends      DefaultState
+implements   FacetTypes
+{
+    /** The logger that is used in this state. */
+    private static Logger logger = Logger.getLogger(WaterlevelPairSelectState.class);
+
+    public WaterlevelPairSelectState() {
+    }
+
+
+    /** Specify to display a datacage_twin_panel. */
+    @Override
+    protected String getUIProvider() {
+        return "datacage_twin_panel";
+    }
+
+
+    @Override
+    public Object computeAdvance(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets,
+        Object       old
+    ) {
+        //Get data and do stuff, do not calculate
+        //JSONObject jsonObject = new JSONObject().accumulate("string", 2.0f);
+        return "";
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org