changeset 1737:d26911cac2e4

Create label from data String to revive names in client. flys-artifacts/trunk@3026 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 19 Oct 2011 11:00:13 +0000 (2011-10-19)
parents 0155cbaba182
children 6cdc7a77d3d4
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java
diffstat 2 files changed, 32 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Oct 19 09:59:07 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Oct 19 11:00:13 2011 +0000
@@ -1,3 +1,12 @@
+2011-10-19	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Create (data) Label from data string (client will be adjusted to send
+	the name).
+
+	* src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java:
+	  Create label from input data string, documentation added, junk
+	  removed.
+
 2011-10-19	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java(zoom):
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java	Wed Oct 19 09:59:07 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelPairSelectState.java	Wed Oct 19 11:00:13 2011 +0000
@@ -23,7 +23,9 @@
 import de.intevation.flys.utils.FLYSUtils;
 import de.intevation.flys.utils.StringUtil;
 
-
+/**
+ * State in which the user selects 1 to n pairs of Waterlevels and alikes.
+ */
 public class WaterlevelPairSelectState
 extends      DefaultState
 implements   FacetTypes
@@ -33,11 +35,7 @@
          WaterlevelPairSelectState.class);
 
 
-    // TODO fix (state.winfo.waterlevel)
-    // own id is state.winfo.waterlevel_pair_select
-    public static final String WINFO_WDIFFERENCES_STATE_ID
-        = "state.winfo.w_differences";
-
+    /** Trivial constructor. */
     public WaterlevelPairSelectState() {
     }
 
@@ -49,6 +47,9 @@
     }
 
 
+    /**
+     * Overridden to do nothing.
+     */
     @Override
     public Object computeAdvance(
         FLYSArtifact artifact,
@@ -58,13 +59,14 @@
         Object       old
     ) {
         //Get data and do stuff, do not calculate
-        return old;
+        return "";
     }
 
 
-
     /**
      * Create elements for document (prepopulated with data, if any).
+     * @param artifact FLYSArtifact to get data from.
+     * @param name DataName, expceted to be "diffids".
      */
     @Override
     protected Element[] createItems(
@@ -122,7 +124,6 @@
     }
 
 
-    // TODO merge implementations with WaterlevelSelectState
     /**
      * Get name to display for selected watelerlevels (for example "Q=123")
      * from the CalculationResult. 
@@ -137,48 +138,27 @@
             String[] minuendParts = StringUtil
                 .unbracket(recommendations[i+0])
                 .split(";");
+            if(minuendParts.length >= 4) {
+                displayString += "(" + minuendParts[3];
+            }
+            else {
+                displayString += "([error]";
+            }
+
+            displayString += " - ";
+
             String[] subtrahendParts = StringUtil
                 .unbracket(recommendations[i+1])
                 .split(";");
-
-            FLYSArtifact artifact1 = FLYSUtils.getArtifact(minuendParts[0], cc);
-    
-            CalculationResult rawData1 = (CalculationResult) artifact1.compute(
-                cc,
-                null,
-                "state.winfo.waterlevel",
-                ComputeType.ADVANCE,
-                false);
-            WQKms[] wqkms1 = (WQKms[]) rawData1.getData();
-    
-            int idx1 = -1;
-            try {
-                idx1 = Integer.parseInt(minuendParts[2]);
+            if(subtrahendParts.length >= 4) {
+                displayString += subtrahendParts[3] + ") ";
             }
-            catch (NumberFormatException nfe) { /* do nothing */ }
-
-            FLYSArtifact artifact2 = FLYSUtils.getArtifact(subtrahendParts[0], cc);
-    
-            CalculationResult rawData2 = (CalculationResult) artifact2.compute(
-                cc,
-                null,
-                "state.winfo.waterlevel",
-                ComputeType.ADVANCE,
-                false);
-            WQKms[] wqkms2 = (WQKms[]) rawData2.getData();
-    
-            int idx2 = -1;
-            try {
-                idx2 = Integer.parseInt(subtrahendParts[2]);
+            else {
+                displayString += "[error])";
             }
-            catch (NumberFormatException nfe) { /* do nothing */ }
-
-            displayString += "(" + StringUtil.wWrap(wqkms1[idx1].getName()) 
-                + " - " + StringUtil.wWrap(wqkms2[idx2].getName()) + ")";
         }
 
         return new String[] { displayString };
     }
-
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org