changeset 2734:89731cb8c385

More debugging of discharge curve issue. flys-artifacts/trunk@4467 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 22 May 2012 19:54:22 +0000
parents ac9a03ed32c1
children 930a2b65f96b
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeDischargeState.java
diffstat 2 files changed, 94 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue May 22 19:51:05 2012 +0000
+++ b/flys-artifacts/ChangeLog	Tue May 22 19:54:22 2012 +0000
@@ -1,3 +1,8 @@
+2012-05-22  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/GaugeDischargeState.java:
+	  More debugging of discharge curve issue.
+
 2012-05-22  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeDischargeState.java	Tue May 22 19:51:05 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeDischargeState.java	Tue May 22 19:54:22 2012 +0000
@@ -5,15 +5,23 @@
 import org.apache.log4j.Logger;
 
 import de.intevation.artifacts.CallMeta;
+import de.intevation.artifacts.CallContext;
 
 import de.intevation.artifactdatabase.state.Facet;
 
+import de.intevation.flys.artifacts.ChartArtifact;
+import de.intevation.flys.artifacts.GaugeDischargeArtifact;
 import de.intevation.flys.artifacts.FLYSArtifact;
 
 import de.intevation.flys.artifacts.model.GaugeDischargeFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WQKms;
+import de.intevation.flys.artifacts.model.ReportFacet;
+import de.intevation.flys.artifacts.model.EmptyFacet;
+import de.intevation.flys.artifacts.model.CalculationResult;
 
 import de.intevation.flys.artifacts.resources.Resources;
+import de.intevation.flys.utils.FLYSUtils;
 
 
 /**
@@ -62,8 +70,88 @@
 
         return null;
     }
-    // computeAdvance
     //WINFOArtifact#getDischargeCurveData
 
+
+    @Override
+    public Object computeAdvance(
+        FLYSArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets,
+        Object       old
+    ) {
+        // TODO why are the facets null here?
+        //if (facets == null) facets = new List<Facet>();
+        if (artifact instanceof GaugeDischargeArtifact) {
+            logger.debug("GaugeDischargeState.computeAdvance()");
+            GaugeDischargeArtifact dischargeArtifact = (GaugeDischargeArtifact) artifact;
+
+            CalculationResult res;
+
+            /*if (old instanceof CalculationResult) {
+                res = (CalculationResult) old;
+            }
+            else {*/
+                res = dischargeArtifact.getDischargeCurveData();
+            //}
+
+            WQKms[] wqkms = (WQKms[]) res.getData();
+
+            if (wqkms != null && facets != null) {
+                logger.debug("GaugeDischargeState.computeAdvance(): create facets");
+                // Create an i18ed name for a (w or q) duration curve facet.
+                Object[] args = new Object[] {
+                    FLYSUtils.getRiver(dischargeArtifact).getName(),
+                    FLYSUtils.getLocations(dischargeArtifact)[0]
+                };
+
+                String nameW = Resources.getMsg(
+                    context.getMeta(),
+                    "chart.duration.curve.curve.w",
+                    "",
+                    args);
+
+                String nameQ = Resources.getMsg(
+                    context.getMeta(),
+                    "chart.duration.curve.curve.q",
+                    "",
+                    args);
+
+                /*Facet w = new DurationCurveFacet(DURATION_W, nameW);
+                Facet q = new DurationCurveFacet(DURATION_Q, nameQ);
+
+                facets.add(w);*/
+                GaugeDischargeFacet facet = new GaugeDischargeFacet(
+                    0,
+                    "A"+DISCHARGE_CURVE,
+                    "A"+DISCHARGE_CURVE);
+                    //Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION));
+                facets.add(facet);
+
+                //facets.add(new DataFacet(CSV, "CSV data"));
+                //facets.add(new DataFacet(PDF, "PDF data"));
+
+                if (res.getReport().hasProblems()) {
+                    facets.add(new ReportFacet());
+                }
+            }
+            else {
+                if (wqkms == null)
+                logger.debug("GaugeDischargeState.computeAdvance(): wqkms 0");
+                else
+                logger.debug("GaugeDischargeState.computeAdvance(): facets 0");
+            }
+
+            return res;
+        }
+        else if (artifact instanceof ChartArtifact) {
+            ChartArtifact chart = (ChartArtifact)artifact;
+            facets.add(new EmptyFacet());
+            return null;
+        }
+        return null;
+    }
+
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org