changeset 930:3fd891d5228d

The DataFacets are now able to store the ID of the create which created them. flys-artifacts/trunk@2292 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 06 Jul 2011 13:37:52 +0000
parents 960dc6328e70
children 057cc0bf4aef
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java
diffstat 3 files changed, 41 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jul 06 09:18:31 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jul 06 13:37:52 2011 +0000
@@ -1,3 +1,13 @@
+2011-07-06  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/DataFacet.java:
+	  DataFacet are now able to store the ID of the state which has created
+	  this Facet.
+
+	* src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java:
+	  Initialize DataFacets with the ID of this state. This is necessary to
+	  renew the waterlevel data if it is no longer existing in the cache.
+
 2011-07-06  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/ReportFacet.java: A
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java	Wed Jul 06 09:18:31 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DataFacet.java	Wed Jul 06 13:37:52 2011 +0000
@@ -14,6 +14,7 @@
 {
     protected ComputeType type;
     protected String      hash;
+    protected String      stateId;
 
     public DataFacet(String name, String description) {
         this(name, description, ComputeType.ADVANCE);
@@ -34,10 +35,27 @@
         this.hash = hash;
     }
 
+
+    public DataFacet(
+        String      name,
+        String      description,
+        ComputeType type,
+        String      hash,
+        String      stateId
+    ) {
+        super(name, description);
+        this.type    = type;
+        this.hash    = hash;
+        this.stateId = stateId;
+    }
+
     public Object getData(Artifact artifact, CallContext context) {
         FLYSArtifact flys = (FLYSArtifact)artifact;
-        return flys.compute(
-            context, hash != null ? hash : flys.hash(), type, false);
+        String    theHash = hash != null ? hash : flys.hash();
+
+        return stateId != null && stateId.length() > 0
+            ? flys.compute(context, stateId, theHash, type, false)
+            : flys.compute(context, theHash, type, false);
     }
 }
 // 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	Wed Jul 06 09:18:31 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java	Wed Jul 06 13:37:52 2011 +0000
@@ -60,6 +60,8 @@
     ) {
         WINFOArtifact winfo = (WINFOArtifact)artifact;
 
+        String id = getID();
+
         CalculationResult res = old instanceof CalculationResult
             ? (CalculationResult)old
             : winfo.getWaterlevelData();
@@ -86,26 +88,27 @@
             logger.debug("Create facet: " + nameW);
             logger.debug("Create facet: " + nameQ);
 
-            Facet w = new WaterlevelFacet(i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, getID(), winfo.hash());
-            Facet q = new WaterlevelFacet(i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, getID(), winfo.hash());
+            Facet w = new WaterlevelFacet(
+                i, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, id, hash);
+            Facet q = new WaterlevelFacet(
+                i, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, id, hash);
 
             facets.add(w);
             facets.add(q);
         }
 
         if (wqkms.length > 0) {
-            Facet wst = new DataFacet(WST, "WST data");
-            Facet csv = new DataFacet(CSV, "CSV data");
+            Facet wst = new DataFacet(
+                WST, "WST data", ComputeType.ADVANCE, hash, id);
+            Facet csv = new DataFacet(
+                CSV, "CSV data", ComputeType.ADVANCE, hash, id);
 
             facets.add(wst);
             facets.add(csv);
         }
 
         if (res.getReport().hasProblems()) {
-            facets.add(new ReportFacet(
-                ComputeType.ADVANCE,
-                winfo.hash(),
-                getID()));
+            facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
         }
 
         return res;

http://dive4elements.wald.intevation.org