changeset 722:4800230fba8a

Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet. flys-artifacts/trunk@2200 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 22 Jun 2011 10:36:27 +0000
parents 7298d58a1f5a
children 8900966ad945
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.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/LocationDistanceSelect.java
diffstat 6 files changed, 76 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jun 22 09:19:16 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jun 22 10:36:27 2011 +0000
@@ -1,3 +1,24 @@
+2011-06-21  Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	Improved situtation on rendering "Abflusskurve am Pegel". Not
+	fully working, yet.
+
+	* doc/conf/artifacts/winfo.xml: Generate facets for the location path, too.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Misspelled
+	  the facet which prevented the facets from being to the outputs.
+
+	* src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java:
+	  Extended to store the hash and the state id of the producing artifact/state
+	  else it results in NPEs because the data is calculated on later (wrong) states.
+
+	* src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java:
+	  Store the state id and the hash in the facet, too.
+
+	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Add two
+	  method to do calculations for a state the artifact is currently not in
+	  and fetching the current state id.
+
 2011-06-21  Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* doc/conf/artifacts/winfo.xml: Generate facets for "Abflusskurven am Pegel"
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Jun 22 09:19:16 2011 +0000
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Jun 22 10:36:27 2011 +0000
@@ -45,8 +45,7 @@
             <outputmodes>
                 <outputmode name="discharge_curve" description="output.discharge_curve" mime-type="image/png">
                     <facets>
-                        <facet name="discharge_curve.w" description="facet.discharge_curve.w"/>
-                        <facet name="discharge_curve.q" description="facet.discharge_curve.q"/>
+                        <facet name="discharge_curve.curve" description="facet.discharge_curve.curve"/>
                     </facets>
                 </outputmode>
             </outputmodes>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Wed Jun 22 09:19:16 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Wed Jun 22 10:36:27 2011 +0000
@@ -280,7 +280,7 @@
      *
      * @return the identifier of the current state.
      */
-    protected String getCurrentStateId() {
+    public String getCurrentStateId() {
         return currentStateId;
     }
 
@@ -321,6 +321,13 @@
         return engine.getState(getCurrentStateId());
     }
 
+    protected State getState(Object context, String stateID) {
+        FLYSContext flysContext = getFlysContext(context);
+        StateEngine engine      = (StateEngine) flysContext.get(
+            FLYSContext.STATE_ENGINE_KEY);
+        return engine.getState(stateID);
+    }
+
 
     /**
      * Returns the vector of previous state identifiers.
@@ -1035,7 +1042,7 @@
             Object value = entry.getValue().getValue();
 
             hash ^= ((long)key.hashCode() << shift) 
-                 |  ((long)value.hashCode() << (shift + shift));
+                 |  ((long)value.hashCode() << (shift + 3));
             shift += 2;
         }
 
@@ -1077,13 +1084,27 @@
         boolean     generateFacets
     ) {
         DefaultState current = (DefaultState) getCurrentState(context);
+        return compute(context, hash, current, type, generateFacets);
+    }
 
-        logger.debug("Create ComputeCallback for state: " + current.getID());
+    public Object compute(
+        CallContext context,
+        String      stateID,
+        String      hash,
+        ComputeType type, 
+        boolean     generateFacets
+    ) {
+        DefaultState current = stateID == null
+            ? (DefaultState)getCurrentState(context)
+            : (DefaultState)getState(context, stateID);
+
+        if (hash == null) {
+            hash = hash();
+        }
 
         return compute(context, hash, current, type, generateFacets);
     }
 
-
     public Object compute(
         CallContext   context,
         String        key,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Wed Jun 22 09:19:16 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Wed Jun 22 10:36:27 2011 +0000
@@ -11,7 +11,7 @@
 
     String COMPUTED_DISCHARGE_Q = "computed_discharge_curve.q";
 
-    String DISCHARGE_CURVE = "computed_discharge_curve.curve";
+    String DISCHARGE_CURVE = "discharge_curve.curve";
 
     String DURATION_W = "duration_curve.w";
     String DURATION_Q = "duration_curve.q";
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Wed Jun 22 09:19:16 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Wed Jun 22 10:36:27 2011 +0000
@@ -15,11 +15,28 @@
 
     private static Logger logger = Logger.getLogger(WaterlevelFacet.class);
 
+    protected ComputeType type;
+    protected String      stateID;
+    protected String      hash;
 
     public WaterlevelFacet(int index, String name, String description) {
-        super(index, name, description);
+        this(index, name, description, ComputeType.ADVANCE, null, null);
     }
 
+    public WaterlevelFacet(
+        int         index, 
+        String      name, 
+        String      description,
+        ComputeType type,
+        String      stateID,
+        String      hash
+
+    ) {
+        super(index, name, description);
+        this.type    = type;
+        this.stateID = stateID;
+        this.hash    = hash;
+    }
 
     public Object getData(Artifact artifact, CallContext context) {
         logger.debug("Get data for waterlevels at index: " + index);
@@ -27,7 +44,7 @@
         WINFOArtifact winfo = (WINFOArtifact)artifact;
 
         CalculationResult res = (CalculationResult)
-            winfo.compute(context, ComputeType.ADVANCE, false);
+            winfo.compute(context, stateID, hash, type, false);
 
         WQKms [] wqkms = (WQKms [])res.getData();
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Wed Jun 22 09:19:16 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java	Wed Jun 22 10:36:27 2011 +0000
@@ -313,6 +313,8 @@
         List<Facet>  facets, 
         Object       old
     ) {
+        logger.debug("computeFeed");
+
         WINFOArtifact winfo = (WINFOArtifact)artifact;
 
         CalculationResult res = old instanceof CalculationResult
@@ -320,14 +322,20 @@
             : winfo.getDischargeCurveData();
 
         if (facets == null) {
+            logger.debug("generate no facets");
             return res;
         }
 
         WQKms [] wqkms = (WQKms [])res.getData();
 
+        logger.debug("generate " + wqkms.length + " facets.");
+
+        String stateID = winfo.getCurrentStateId();
+
         for (int i = 0; i < wqkms.length; ++i) {
             String name = wqkms[i].getName();
-            facets.add(new WaterlevelFacet(i, DISCHARGE_CURVE, name));
+            facets.add(new WaterlevelFacet(
+                i, DISCHARGE_CURVE, name, ComputeType.FEED, stateID, hash));
         }
 
 

http://dive4elements.wald.intevation.org