changeset 2746:4634cf5574f7

Let DurationCurveFacet provide relevant data via Blackboard. flys-artifacts/trunk@4481 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 23 May 2012 20:34:02 +0000
parents b63017afbca8
children 94c6f4ad9b98
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java
diffstat 2 files changed, 57 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed May 23 19:31:26 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed May 23 20:34:02 2012 +0000
@@ -1,3 +1,8 @@
+2012-05-23	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java:
+	  Be a DataProvider, provide the duration curve and its km.
+
 2012-05-23	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java	Wed May 23 19:31:26 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DurationCurveFacet.java	Wed May 23 20:34:02 2012 +0000
@@ -1,5 +1,8 @@
 package de.intevation.flys.artifacts.model;
 
+import java.util.List;
+import java.util.ArrayList;
+
 import org.apache.log4j.Logger;
 
 import de.intevation.artifacts.Artifact;
@@ -8,15 +11,25 @@
 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.states.DefaultState.ComputeType;
 
 
+/**
+ * Data of a duration curve.
+ */
 public class DurationCurveFacet extends DefaultFacet {
 
     private static Logger logger = Logger.getLogger(DurationCurveFacet.class);
 
+    /** Blackboard data provider key for durationcurve (wqday) data. */
+    public static String BB_DURATIONCURVE = "durationcurve";
+
+    /** Blackboard data provider key for km of durationcurve. */
+    public static String BB_DURATIONCURVE_KM = "durationcurve.km";
+
     public DurationCurveFacet() {
     }
 
@@ -25,6 +38,9 @@
     }
 
 
+    /**
+     * Expose state computation from WINFOArtifact.
+     */
     public Object getData(Artifact artifact, CallContext context) {
         logger.debug("Get data for duration curve data");
 
@@ -36,6 +52,42 @@
         return cr.getData();
     }
 
+
+    @Override
+    public List getStaticDataProviderKeys(Artifact art) {
+        List list = new ArrayList();
+        list.add(BB_DURATIONCURVE);
+        list.add(BB_DURATIONCURVE_KM);
+        return list;
+    }
+
+
+    /**
+     * Can provide whatever getData returns and additionally the location.
+     * @param key      will respond on BB_DURATIONCURVE +KM
+     * @param param    ignored
+     * @param context  ignored
+     * @return whatever getData delivers or location.
+     */
+    @Override
+    public Object provideBlackboardData(Artifact artifact,
+        Object key,
+        Object param,
+        CallContext context
+    ) {
+        if (key.equals(BB_DURATIONCURVE)) {
+            return getData(artifact, context);
+        }
+        else if (key.equals(BB_DURATIONCURVE_KM)) {
+            return ((FLYSArtifact)artifact).getDataAsString("ld_locations");
+        }
+        else {
+            return null;
+        }
+    }
+
+
+    /** Create a deep copy. */
     @Override 
     public Facet deepCopy() {
         DurationCurveFacet copy = new DurationCurveFacet();

http://dive4elements.wald.intevation.org