changeset 1652:46a2a5dc98b7

In W-Difference-calculation, respect indices of selected facets. flys-artifacts/trunk@2844 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 27 Sep 2011 14:03:06 +0000
parents a7def20539fb
children 73794985a899
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java
diffstat 2 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Sep 27 13:45:13 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Sep 27 14:03:06 2011 +0000
@@ -1,3 +1,10 @@
+2011-09-27  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	In W-Difference Calculation, respect indices of selected facets.
+
+	* src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java:
+	  (computeAdvance): Respect index of selected facets.
+
 2011-09-27	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	flys/issue317: (Querprofil-Diagramm: Referenzen auf CrossSectionApp entfernen)
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java	Tue Sep 27 13:45:13 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java	Tue Sep 27 14:03:06 2011 +0000
@@ -64,7 +64,8 @@
 
 
     /**
-     * Return List of WKms that are difference of pairs.
+     * Return CalculationResult with Array of WKms that are difference of
+     * Waterlevels. Add respective facets (DifferencesCurveFacet, DataFacet).
      */
     @Override
     public Object computeAdvance(
@@ -97,8 +98,14 @@
         List<WKms> wkmss = new ArrayList<WKms>();
 
         for(int i = 0; i < datas.length /2; i++) {
-            String uuid1 = WaterlevelSelectState.strip(datas[i+0]).split(";")[0];
-            String uuid2 = WaterlevelSelectState.strip(datas[i+1]).split(";")[0];
+            // e.g.:
+            // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1
+            String[] def1  = WaterlevelSelectState.strip(datas[i+0]).split(";");
+            String[] def2  = WaterlevelSelectState.strip(datas[i+1]).split(";");
+            String   uuid1 = def1[0];
+            String   uuid2 = def2[0];
+            int      idx1  = Integer.parseInt(def1[2]);
+            int      idx2  = Integer.parseInt(def2[2]);
     
             WINFOArtifact flys1 = (WINFOArtifact) FLYSUtils.getArtifact(
                 uuid1,
@@ -127,20 +134,16 @@
                 if (datas.length > 2) {
                     logger.error("Cannot keep more than one calculation.");
                 }
-                facetName = "W (" + minuend[0].getName() + ") - W (" + subtrahend[0].getName() + ")";
-                WKms wkms = WKmsOperation.SUBTRACTION.operate(minuend[0], subtrahend[0]);
+                facetName = "W (" + minuend[idx1].getName() + ") - W (" + subtrahend[idx2].getName() + ")";
+                WKms wkms = WKmsOperation.SUBTRACTION.operate(minuend[idx1], subtrahend[idx2]);
                 wkms.setName(facetName);
                 wkmss.add(wkms);
                 logger.debug("WKMSSubtraction happened");
             }
     
             if (facets != null) {
-                // TODO: pass computetype and state id.
-                //, ComputeType.ADVANCE, getID(), hash));
-                //facets.add(new DataFacet(W_DIFFERENCES, facetName));
                 facets.add(new DifferenceCurveFacet(i, W_DIFFERENCES, facetName,
                     ComputeType.ADVANCE, id, hash));
-                //facets.add(new WaterlevelFacet
                 facets.add(new DataFacet(CSV, "CSV data"));
             }
             else {
@@ -148,9 +151,9 @@
             }
         }
 
-        CalculationResult result = new CalculationResult();
+        // TODO Evaluate whether null is okay as reports.
         WKms[] diffs = wkmss.toArray(new WKms[wkmss.size()]);
-        result.setData(diffs);
+        CalculationResult result = new CalculationResult(diffs, null);
         return result;
     }
 }

http://dive4elements.wald.intevation.org