changeset 696:708b270dfd30 facets-slt

OutGenerators use now facets to fetch necessary data. flys-artifacts/branches/facets-slt@2140 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 17 Jun 2011 09:19:43 +0000
parents 45cd58a2a2bb
children b972eba2ed8a
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java
diffstat 13 files changed, 213 insertions(+), 183 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Fri Jun 17 09:19:43 2011 +0000
@@ -53,7 +53,6 @@
 import de.intevation.flys.artifacts.model.Segment;
 
 import de.intevation.flys.artifacts.states.DefaultState;
-import de.intevation.flys.artifacts.states.CalculationSelect;
 import de.intevation.flys.artifacts.states.LocationDistanceSelect;
 
 
@@ -360,6 +359,23 @@
     }
 
 
+    public Facet getNativeFacet(Facet facet) {
+        String name  = facet.getName();
+        int    index = facet.getIndex();
+
+        for (Map.Entry<String, List<Facet>> entry: facets.entrySet()) {
+            for (Facet f: entry.getValue()) {
+                if (f.getName().equals(name) && f.getIndex() == index) {
+                    return f;
+                }
+            }
+        }
+
+        logger.warn("Could not find facet: " + name + " at " + index);
+        return null;
+    }
+
+
     /**
      * This method stores the data that is contained in the FEED document.
      *
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Fri Jun 17 09:19:43 2011 +0000
@@ -31,7 +31,6 @@
 import de.intevation.flys.artifacts.states.DefaultState;
 import de.intevation.flys.artifacts.context.FLYSContext;
 
-import de.intevation.flys.artifacts.model.ComputeCallback;
 import de.intevation.flys.artifacts.model.DischargeTables;
 import de.intevation.flys.artifacts.model.MainValuesFactory;
 import de.intevation.flys.artifacts.model.WQDay;
@@ -199,7 +198,7 @@
                 continue;
             }
 
-            logger.debug("Found " + fs.size() + " facets.");
+            logger.debug("Found " + fs.size() + " facets in previous states.");
 
             List<Output> generated = generateOutputs(list, fs);
 
@@ -218,7 +217,7 @@
                     if (fs != null && fs.size() > 0) {
                         List<Output> generated = generateOutputs(list, fs);
 
-                        logger.debug("Found " + fs.size() + " facets.");
+                        logger.debug("Found " + fs.size() + " current facets.");
 
                         ProtocolUtils.appendOutputModes(
                             creator, outs, generated);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java	Fri Jun 17 09:19:43 2011 +0000
@@ -0,0 +1,34 @@
+package de.intevation.flys.artifacts.model;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.DefaultFacet;
+
+import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.model.ComputeCallback.ComputeType;
+
+
+public class DurationCurveFacet extends DefaultFacet {
+
+    private static Logger logger = Logger.getLogger(DurationCurveFacet.class);
+
+
+    public DurationCurveFacet(int index, String name, String description) {
+        super(index, name, description);
+    }
+
+
+    public Object getData(Artifact artifact, CallContext context) {
+        logger.debug("Get data for duration curve data at index: " + index);
+
+        WINFOArtifact winfo = (WINFOArtifact) artifact;
+
+        WQDay[] wqday = (WQDay[]) winfo.compute(context, ComputeType.ADVANCE);
+
+        return wqday[index];
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Fri Jun 17 09:19:43 2011 +0000
@@ -11,7 +11,7 @@
 
     String COMPUTED_DISCHARGE_Q = "computed_discharge_curve.q";
 
-    String DURATION_W = "discharge_curve.w";
-    String DURATION_Q = "discharge_curve.q";
+    String DURATION_W = "duration_curve.w";
+    String DURATION_Q = "duration_curve.q";
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Fri Jun 17 09:19:43 2011 +0000
@@ -0,0 +1,34 @@
+package de.intevation.flys.artifacts.model;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.DefaultFacet;
+
+import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.model.ComputeCallback.ComputeType;
+
+
+public class WaterlevelFacet extends DefaultFacet {
+
+    private static Logger logger = Logger.getLogger(WaterlevelFacet.class);
+
+
+    public WaterlevelFacet(int index, String name, String description) {
+        super(index, name, description);
+    }
+
+
+    public Object getData(Artifact artifact, CallContext context) {
+        logger.debug("Get data for waterlevels at index: " + index);
+
+        WINFOArtifact winfo = (WINFOArtifact) artifact;
+
+        WQKms[] wqkms = (WQKms[]) winfo.compute(context, ComputeType.ADVANCE);
+
+        return wqkms[index];
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ComputedDischargeCurveState.java	Fri Jun 17 09:19:43 2011 +0000
@@ -6,7 +6,6 @@
 
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.artifactdatabase.state.DefaultFacet;
 import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
@@ -14,6 +13,7 @@
 import de.intevation.flys.artifacts.model.ComputeCallback;
 import de.intevation.flys.artifacts.model.ComputeCallbackAdapter;
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
 import de.intevation.flys.artifacts.model.WQKms;
 import de.intevation.flys.artifacts.resources.Resources;
 
@@ -66,11 +66,11 @@
                     "",
                     args);
 
-                Facet q = new DefaultFacet(0, DISCHARGE_LONGITUDINAL_Q, name);
+                Facet q = new WaterlevelFacet(0, COMPUTED_DISCHARGE_Q, name);
 
                 facets.add(q);
 
-                return res;
+                return new WQKms[] { res };
             }
         };
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java	Fri Jun 17 09:19:43 2011 +0000
@@ -6,7 +6,6 @@
 
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.artifactdatabase.state.DefaultFacet;
 import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
@@ -14,6 +13,7 @@
 import de.intevation.flys.artifacts.model.ComputeCallback;
 import de.intevation.flys.artifacts.model.ComputeCallbackAdapter;
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
 import de.intevation.flys.artifacts.model.WQKms;
 import de.intevation.flys.artifacts.model.WQCKms;
 
@@ -58,10 +58,10 @@
                         nameQ = "Q(" + nameQ + ")";
                     }
 
-                    Facet w = new DefaultFacet(
+                    Facet w = new WaterlevelFacet(
                         i, DISCHARGE_LONGITUDINAL_W, nameW);
 
-                    Facet q = new DefaultFacet(
+                    Facet q = new WaterlevelFacet(
                         i, DISCHARGE_LONGITUDINAL_Q, nameQ);
 
                     facets.add(w);
@@ -74,7 +74,7 @@
                             "Benutzerdefiniert",
                             "Benutzerdefiniert [korrigiert]");
 
-                        Facet c = new DefaultFacet(
+                        Facet c = new WaterlevelFacet(
                             i, DISCHARGE_LONGITUDINAL_C, nameC);
 
                         facets.add(c);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DurationCurveState.java	Fri Jun 17 09:19:43 2011 +0000
@@ -6,13 +6,13 @@
 
 import de.intevation.artifacts.CallContext;
 
-import de.intevation.artifactdatabase.state.DefaultFacet;
 import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.WINFOArtifact;
 import de.intevation.flys.artifacts.model.ComputeCallback;
 import de.intevation.flys.artifacts.model.ComputeCallbackAdapter;
+import de.intevation.flys.artifacts.model.DurationCurveFacet;
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQDay;
 import de.intevation.flys.artifacts.resources.Resources;
@@ -70,13 +70,13 @@
                     "",
                     args);
 
-                Facet w = new DefaultFacet(0, DURATION_W, nameW);
-                Facet q = new DefaultFacet(0, DURATION_Q, nameQ);
+                Facet w = new DurationCurveFacet(0, DURATION_W, nameW);
+                Facet q = new DurationCurveFacet(0, DURATION_Q, nameQ);
 
                 facets.add(w);
                 facets.add(q);
 
-                return res;
+                return new WQDay[] { res };
             }
         };
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Fri Jun 17 09:19:43 2011 +0000
@@ -11,7 +11,6 @@
 
 import de.intevation.artifacts.common.utils.XMLUtils;
 
-import de.intevation.artifactdatabase.state.DefaultFacet;
 import de.intevation.artifactdatabase.state.Facet;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
@@ -19,6 +18,7 @@
 import de.intevation.flys.artifacts.model.ComputeCallback;
 import de.intevation.flys.artifacts.model.ComputeCallbackAdapter;
 import de.intevation.flys.artifacts.model.FacetTypes;
+import de.intevation.flys.artifacts.model.WaterlevelFacet;
 import de.intevation.flys.artifacts.model.WQKms;
 
 
@@ -79,8 +79,8 @@
                     logger.debug("Create facet: " + nameW);
                     logger.debug("Create facet: " + nameQ);
 
-                    Facet w = new DefaultFacet(i, LONGITUDINAL_W, nameW);
-                    Facet q = new DefaultFacet(i, LONGITUDINAL_Q, nameQ);
+                    Facet w = new WaterlevelFacet(i, LONGITUDINAL_W, nameW);
+                    Facet q = new WaterlevelFacet(i, LONGITUDINAL_Q, nameQ);
 
                     facets.add(w);
                     facets.add(q);
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveGenerator.java	Fri Jun 17 09:19:43 2011 +0000
@@ -11,7 +11,8 @@
 
 import de.intevation.artifactdatabase.state.Facet;
 
-import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQKms;
 
 
@@ -20,8 +21,10 @@
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class ComputedDischargeCurveGenerator extends DischargeCurveGenerator {
-
+public class ComputedDischargeCurveGenerator
+extends      DischargeCurveGenerator
+implements   FacetTypes
+{
     /** The logger used in this generator.*/
     private static Logger logger =
         Logger.getLogger(ComputedDischargeCurveGenerator.class);
@@ -68,10 +71,24 @@
 
     @Override
     public void doOut(Artifact artifact, Facet facet, Document attr) {
-        logger.debug("ComputedDischargeCurveGenerator.doOut");
+        String name = facet != null ? facet.getName() : null;
 
-        WQKms wqkms = getData(artifact);
+        logger.debug("ComputedDischargeCurveGenerator.doOut: " + name);
 
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+        Facet        f    = flys.getNativeFacet(facet);
+
+        if (name != null && name.equals(COMPUTED_DISCHARGE_Q)) {
+            doQOut((WQKms) f.getData(artifact, context));
+        }
+        else {
+            logger.warn("Unknown facet type for computed discharge: " + name);
+            return;
+        }
+    }
+
+
+    protected void doQOut(WQKms wqkms) {
         int size = wqkms.size();
 
         double[][] data = new double[2][size];
@@ -88,15 +105,6 @@
     }
 
 
-    protected WQKms getData(Artifact artifact) {
-        logger.debug("ComputedDischargeCurveGenerator.getData");
-
-        WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
-
-        return winfoArtifact.getComputedDischargeCurveData();
-    }
-
-
     protected String getSeriesName(WQKms wqkms) {
         Object[] args = new Object[] {
             getRiverName(),
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Fri Jun 17 09:19:43 2011 +0000
@@ -16,7 +16,7 @@
 
 import de.intevation.artifactdatabase.state.Facet;
 
-import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.model.WQCKms;
 import de.intevation.flys.artifacts.model.WQKms;
 
@@ -33,13 +33,6 @@
         Logger.getLogger(DischargeLongitudinalSectionGenerator.class);
 
 
-    /** The facet for Ws.*/
-    public static final String FACET_W = "discharge_longitudinal_section.w";
-
-    /** The facet for Qs.*/
-    public static final String FACET_Q = "discharge_longitudinal_section.q";
-
-
     /** The storage for the corrected W series to be drawn in this chart.*/
     protected XYSeriesCollection cw;
 
@@ -97,69 +90,27 @@
     public void doOut(Artifact artifact, Facet facet, Document attr) {
         logger.debug("DischargeLongitudinalSectionGenerator.doOut");
 
-        if (facet != null && facet.equals(FACET_W)) {
-            doWOut(getDischargeLongitudinalSectionData(artifact));
+        String name = facet != null ? facet.getName() : null;
+
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+        Facet        f    = flys.getNativeFacet(facet);
+
+        if (name != null && name.equals(DISCHARGE_LONGITUDINAL_W)) {
+            doWOut((WQKms) f.getData(artifact, context));
         }
-        else if (facet != null && facet.equals(FACET_Q)) {
-            doQOut(getDischargeLongitudinalSectionData(artifact));
+        else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_Q)) {
+            doQOut((WQKms) f.getData(artifact, context));
+        }
+        else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_C)) {
+            doCorrectedWOut((WQCKms) f.getData(artifact, context));
         }
         else {
-            logger.warn("Unknown facet name: " + facet);
+            logger.warn("Unknown facet name: " + name);
             return;
         }
     }
 
 
-    protected WQKms[] getDischargeLongitudinalSectionData(Artifact artifact) {
-        WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
-        return winfoArtifact.getDischargeLongitudinalSectionData();
-    }
-
-
-    /**
-     * This method adds new Series for the wqkms objects. If there are instances
-     * of WQCKms in this array, there is a further curve that displays the
-     * corrected W values.
-     *
-     * @param wqkms An array of WQKms objects to be displayed.
-     */
-    protected void doWOut(WQKms[] wqkms) {
-        logger.debug("LongitudinalSectionGenerator.doWOut");
-
-        int idx = 0;
-        for (WQKms tmp: wqkms) {
-            if (tmp instanceof WQCKms) {
-                doCorrectedWOut((WQCKms) tmp);
-            }
-
-            doWOut(tmp);
-        }
-    }
-
-
-    /**
-     * Adds a new series for the W curve.
-     *
-     * @param wqkms The object that contains the W values.
-     */
-    protected void doWOut(WQKms wqkms) {
-        logger.debug("DischargeLongitudinalSectionGenerator.doWOut");
-
-        XYSeries series = new XYSeries(getSeriesName(wqkms, "W"));
-
-        double[] target = new double[4];
-        int      size   = wqkms.size();
-
-        for (int i = 0; i < size; i++) {
-            target = wqkms.get(i, target);
-
-            series.add(target[2], target[0]);
-        }
-
-        w.addSeries(series);
-    }
-
-
     /**
      * Adds a new series for the corrected W curve.
      *
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveGenerator.java	Fri Jun 17 09:19:43 2011 +0000
@@ -18,9 +18,8 @@
 
 import de.intevation.artifactdatabase.state.Facet;
 
-import de.intevation.flys.model.River;
-
-import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQDay;
 import de.intevation.flys.artifacts.resources.Resources;
 
@@ -30,11 +29,10 @@
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class DurationCurveGenerator extends XYChartGenerator {
-
-    public static final String I18N_DURATION_W = "chart.duration.curve.curve.w";
-    public static final String I18N_DURATION_Q = "chart.duration.curve.curve.q";
-
+public class DurationCurveGenerator
+extends      XYChartGenerator
+implements   FacetTypes
+{
     private static Logger logger =
         Logger.getLogger(DurationCurveGenerator.class);
 
@@ -45,11 +43,11 @@
     protected XYSeriesCollection q;
 
 
-    public static final String DURATION_CURVE_W =
-        "duration_curve.w";
+    public static final String I18N_DURATION_W =
+        "chart.duration.curve.curve.w";
 
-    public static final String DURATION_CURVE_Q =
-        "duration_curve.q";
+    public static final String I18N_DURATION_Q =
+        "chart.duration.curve.curve.q";
 
     public static final String I18N_CHART_TITLE =
         "chart.duration.curve.title";
@@ -161,7 +159,7 @@
 
     @Override
     public void doOut(Artifact artifact, Facet facet, Document attr) {
-        String name = facet.getName();
+        String name = facet != null ? facet.getName() : null;
 
         logger.debug("DurationCurveGenerator.doOut: " + name);
 
@@ -170,14 +168,14 @@
             return;
         }
 
-        WINFOArtifact winfo = (WINFOArtifact) artifact;
-        River         river = winfo.getRiver();
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+        Facet        f    = flys.getNativeFacet(facet);
 
-        if (name.equals(DURATION_CURVE_W)) {
-            doWOut(getDurationCurveData(artifact), river.getName());
+        if (name.equals(DURATION_W)) {
+            doWOut((WQDay) f.getData(artifact, context));
         }
-        else if (name.equals(DURATION_CURVE_Q)) {
-            doQOut(getDurationCurveData(artifact), river.getName());
+        else if (name.equals(DURATION_Q)) {
+            doQOut((WQDay) f.getData(artifact, context));
         }
         else {
             logger.warn("Unknown facet name: " + name);
@@ -192,12 +190,12 @@
      * @param wqdays The WQDay store that contains the Ws.
      * @param river The name of the river.
      */
-    protected void doWOut(WQDay wqdays, String river) {
+    protected void doWOut(WQDay wqdays) {
         logger.debug("DurationCurveGenerator.doWOut");
 
         // TODO find the correct series name
         XYSeries series = new XYSeries(
-            getSeriesName(river, DURATION_CURVE_W));
+            getSeriesName(getRiverName(), DURATION_W));
 
         int size = wqdays.size();
         for (int i = 0; i < size; i++) {
@@ -217,12 +215,12 @@
      * @param wqdays The WQDay store that contains the Qs.
      * @param river The name of the river.
      */
-    protected void doQOut(WQDay wqdays, String river) {
+    protected void doQOut(WQDay wqdays) {
         logger.debug("DurationCurveGenerator.doQOut");
 
         // TODO find the correct series name
         XYSeries series = new XYSeries(
-            getSeriesName(river, DURATION_CURVE_Q));
+            getSeriesName(getRiverName(), DURATION_Q));
 
         int size = wqdays.size();
         for (int i = 0; i < size; i++) {
@@ -236,20 +234,6 @@
     }
 
 
-    /**
-     * Returns the computed data for a duration curve based on the artifact's
-     * computation method.
-     *
-     * @param artifact The WINFO artifact.
-     *
-     * @return the computed data for a duration curve's W and Q facet.
-     */
-    protected WQDay getDurationCurveData(Artifact artifact) {
-        WINFOArtifact winfoArtifact = (WINFOArtifact) artifact;
-        return winfoArtifact.getDurationCurveData();
-    }
-
-
     protected String getSeriesName(String river, String type) {
         Object[] args = new Object[] { river };
 
@@ -257,14 +241,14 @@
             logger.warn("No duration curve type given.");
             return "n/a";
         }
-        else if (type.equals(DURATION_CURVE_W)) {
+        else if (type.equals(DURATION_W)) {
             return Resources.getMsg(
                 context.getMeta(),
                 I18N_DURATION_W,
                 "W",
                 args);
         }
-        else if (type.equals(DURATION_CURVE_Q)) {
+        else if (type.equals(DURATION_Q)) {
             return Resources.getMsg(
                 context.getMeta(),
                 I18N_DURATION_Q,
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Thu Jun 16 14:31:41 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Fri Jun 17 09:19:43 2011 +0000
@@ -23,6 +23,7 @@
 
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.WINFOArtifact;
+import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.WQKms;
 
 
@@ -31,8 +32,10 @@
  *
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class LongitudinalSectionGenerator extends XYChartGenerator {
-
+public class LongitudinalSectionGenerator
+extends      XYChartGenerator
+implements   FacetTypes
+{
     /** The logger that is used in this generator.*/
     private static Logger logger =
         Logger.getLogger(LongitudinalSectionGenerator.class);
@@ -191,11 +194,18 @@
             return;
         }
 
-        if (name.equals(LONGITUDINAL_SECTION_W)) {
-            doWOut(getWaterlevelData(artifact));
+        FLYSArtifact flys = (FLYSArtifact) artifact;
+        Facet        f    = flys.getNativeFacet(facet);
+
+        if (f == null) {
+            return;
         }
-        else if (name.equals(LONGITUDINAL_SECTION_Q)) {
-            doQOut(getWaterlevelData(artifact));
+
+        if (name.equals(LONGITUDINAL_W)) {
+            doWOut((WQKms) f.getData(artifact, context));
+        }
+        else if (name.equals(LONGITUDINAL_Q)) {
+            doQOut((WQKms) f.getData(artifact, context));
         }
         else {
             logger.warn("Unknown facet name: " + name);
@@ -226,33 +236,30 @@
      *
      * @param wqkms An array of WQKms values.
      */
-    protected void doWOut(WQKms[] wqkms) {
+    protected void doWOut(WQKms wqkms) {
         logger.debug("LongitudinalSectionGenerator.doWOut");
 
-        int idx = 0;
-        for (WQKms tmp: wqkms) {
-            XYSeries series = new XYSeries(getSeriesName(tmp, "W"));
-
-            double[] target = new double[3];
-            int      size   = tmp.size();
+        XYSeries series = new XYSeries(getSeriesName(wqkms, "W"));
 
-            if (logger.isDebugEnabled()) {
-                if (tmp.size() > 0) {
-                    logger.debug("Generate series: " + series.getKey());
-                    logger.debug("Start km: " + tmp.getKms(0));
-                    logger.debug("End   km: " + tmp.getKms(size-1));
-                    logger.debug("Values  : " + size);
-                }
+        double[] target = new double[3];
+        int      size   = wqkms.size();
+
+        if (logger.isDebugEnabled()) {
+            if (wqkms.size() > 0) {
+                logger.debug("Generate series: " + series.getKey());
+                logger.debug("Start km: " + wqkms.getKms(0));
+                logger.debug("End   km: " + wqkms.getKms(size-1));
+                logger.debug("Values  : " + size);
             }
-
-            for (int i = 0; i < size; i++) {
-                target = tmp.get(i, target);
+        }
 
-                series.add(target[2], target[0]);
-            }
+        for (int i = 0; i < size; i++) {
+            target = wqkms.get(i, target);
 
-            w.addSeries(series);
+            series.add(target[2], target[0]);
         }
+
+        w.addSeries(series);
     }
 
 
@@ -261,34 +268,31 @@
      *
      * @param wqkms An array of WQKms values.
      */
-    protected void doQOut(WQKms[] wqkms) {
+    protected void doQOut(WQKms wqkms) {
         logger.debug("LongitudinalSectionGenerator.doQOut");
 
-        int idx = 0;
-        for (WQKms tmp: wqkms) {
-            XYSeries series = new XYSeries(getSeriesName(tmp, "Q"));
-
-            double[] target = new double[3];
-            int      size   = tmp.size();
+        XYSeries series = new XYSeries(getSeriesName(wqkms, "Q"));
 
-            if (logger.isDebugEnabled()) {
-                if (tmp.size() > 0) {
-                    logger.debug("Generate series: " + series.getKey());
-                    logger.debug("Start km: " + tmp.getKms(0));
-                    logger.debug("End   km: " + tmp.getKms(size-1));
-                    logger.debug("Values  : " + size);
-                }
-            }
+        double[] target = new double[3];
+        int      size   = wqkms.size();
 
-            for (int i = 0; i < size; i++) {
-                target = tmp.get(i, target);
+        if (logger.isDebugEnabled()) {
+            if (wqkms.size() > 0) {
+                logger.debug("Generate series: " + series.getKey());
+                logger.debug("Start km: " + wqkms.getKms(0));
+                logger.debug("End   km: " + wqkms.getKms(size-1));
+                logger.debug("Values  : " + size);
+            }
+        }
 
-                //logger.debug("++ Q Tuple: " + target[2] + " -> " + target[1]);
-                series.add(target[2], target[1]);
-            }
+        for (int i = 0; i < size; i++) {
+            target = wqkms.get(i, target);
 
-            q.addSeries(series);
+            //logger.debug("++ Q Tuple: " + target[2] + " -> " + target[1]);
+            series.add(target[2], target[1]);
         }
+
+        q.addSeries(series);
     }
 
 

http://dive4elements.wald.intevation.org