diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java @ 709:3b7e9ddf6bb1

New model to transport data and error reports of calculations. flys-artifacts/trunk@2165 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 20 Jun 2011 12:32:32 +0000
parents 853dceead0f4
children 69c8541edcc7
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Sat Jun 18 20:20:34 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Mon Jun 20 12:32:32 2011 +0000
@@ -15,6 +15,7 @@
 import de.intevation.flys.artifacts.model.WQKms;
 
 import de.intevation.flys.artifacts.model.DataFacet;
+import de.intevation.flys.artifacts.model.CalculationResult;
 
 
 public class WaterlevelState
@@ -35,33 +36,26 @@
     ) {
         WINFOArtifact winfo = (WINFOArtifact)artifact;
 
-        WQKms [] res;
-
-        if (old instanceof WQKms []) {
-            res = (WQKms [])old;
-        }
-        else {
-            res = winfo.getWaterlevelData();
-            if (res == null) {
-                logger.debug("No results given.");
-                return null;
-            }
-        }
+        CalculationResult res = old instanceof CalculationResult
+            ? (CalculationResult)old
+            : winfo.getWaterlevelData();
 
         if (facets == null) {
             return res;
         }
 
-        for (int i = 0; i < res.length; i++) {
+        WQKms [] wqkms = (WQKms [])res.getData();
+
+        for (int i = 0; i < wqkms.length; i++) {
             String nameW = null;
             String nameQ = null;
 
             if (winfo.isQ()) {
-                nameQ = res[i].getName();
+                nameQ = wqkms[i].getName();
                 nameW = "W(" + nameQ + ")";
             }
             else {
-                nameW = res[i].getName();
+                nameW = wqkms[i].getName();
                 nameQ = "Q(" + nameQ + ")";
             }
 
@@ -75,7 +69,7 @@
             facets.add(q);
         }
 
-        if (res.length > 0) {
+        if (wqkms.length > 0) {
             Facet wst = new DataFacet(WST, "WST data");
             Facet csv = new DataFacet(CSV, "CSV data");
 

http://dive4elements.wald.intevation.org