changeset 2195:e14beb93a854

"Bezugslinenverfahren": Added stub loop for creating facets. flys-artifacts/trunk@3811 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 27 Jan 2012 17:17:45 +0000
parents 05984871520f
children 5f3726f31f00
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java
diffstat 3 files changed, 92 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jan 27 15:43:04 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jan 27 17:17:45 2012 +0000
@@ -1,3 +1,11 @@
+2012-01-27	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java:
+	  Added stub loop for creating facets.
+
+	* src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java:
+	  Cosmetics.
+
 2012-01-27	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java	Fri Jan 27 15:43:04 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java	Fri Jan 27 17:17:45 2012 +0000
@@ -1,9 +1,68 @@
 package de.intevation.flys.artifacts.states;
 
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.ReportFacet;
+import de.intevation.flys.artifacts.model.WW;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
 public class ReferenceCurveState
 extends      DefaultState
+implements   FacetTypes
 {
+    private static Logger log = Logger.getLogger(ReferenceCurveState.class);
+
     public ReferenceCurveState() {
     }
+
+    @Override
+    public Object computeAdvance(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets,
+        Object       old
+    ) {
+
+        if (!(artifact instanceof WINFOArtifact)) {
+            return null;
+        }
+
+        WINFOArtifact winfo = (WINFOArtifact)artifact;
+
+        CalculationResult res = old instanceof CalculationResult
+            ? (CalculationResult)old
+            : winfo.getReferenceCurveData();
+
+        if (facets == null) {
+            return res;
+        }
+
+        WW [] wws = (WW [])res.getData();
+
+        for (int i = 0; i < wws.length; ++i) {
+            // TODO: Add data facets.
+        }
+
+        if (wws.length > 0) {
+            // TODO: Add CSV/PDF facets.
+        }
+
+        if (res.getReport().hasProblems()) {
+            facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
+        }
+
+        return res;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Fri Jan 27 15:43:04 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Fri Jan 27 17:17:45 2012 +0000
@@ -1,29 +1,28 @@
 package de.intevation.flys.artifacts.states;
 
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.flys.artifacts.ChartArtifact;
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.WINFOArtifact;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet;
+import de.intevation.flys.artifacts.model.DataFacet;
+import de.intevation.flys.artifacts.model.EmptyFacet;
+import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.ReportFacet;
+import de.intevation.flys.artifacts.model.WQKms;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
+
+import de.intevation.flys.utils.FLYSUtils;
+
 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.ChartArtifact;
-
-import de.intevation.flys.artifacts.model.DataFacet;
-import de.intevation.flys.artifacts.model.EmptyFacet;
-
-import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet;
-import de.intevation.flys.artifacts.model.CalculationResult;
-import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.ReportFacet;
-import de.intevation.flys.artifacts.model.WaterlevelFacet;
-import de.intevation.flys.artifacts.model.WQKms;
-import de.intevation.flys.utils.FLYSUtils;
-
-
 public class WaterlevelState
 extends      DefaultState
 implements   FacetTypes
@@ -62,6 +61,8 @@
             return res;
         }
 
+        boolean debug = logger.isDebugEnabled();
+
         WQKms [] wqkms = (WQKms []) res.getData();
 
         for (int i = 0; i < wqkms.length; i++) {
@@ -70,8 +71,10 @@
             String nameW = FLYSUtils.createWspWTitle(winfo, cc, name);
             String nameQ = FLYSUtils.createWspQTitle(winfo, cc, name);
 
-            logger.debug("Create facet: " + nameW);
-            logger.debug("Create facet: " + nameQ);
+            if (debug) {
+                logger.debug("Create facet: " + nameW);
+                logger.debug("Create facet: " + nameQ);
+            }
 
             Facet w = new WaterlevelFacet(
                 i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash);

http://dive4elements.wald.intevation.org