changeset 7653:e609722a1e86

issue1020 and others: Let StaticWQKmsState spawn other facets, implement computeAdvance.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 05 Dec 2013 17:38:10 +0100
parents 974c858a5042
children 197bd0958cba
files artifacts/src/main/java/org/dive4elements/river/artifacts/states/StaticWQKmsState.java
diffstat 1 files changed, 38 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/StaticWQKmsState.java	Thu Dec 05 17:34:10 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/StaticWQKmsState.java	Thu Dec 05 17:38:10 2013 +0100
@@ -23,6 +23,7 @@
 import org.dive4elements.river.artifacts.StaticWQKmsArtifact;
 
 import org.dive4elements.river.artifacts.model.CrossSectionWaterLineFacet;
+import org.dive4elements.river.artifacts.model.DataFacet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.RelativePointFacet;
 import org.dive4elements.river.artifacts.model.WQKms;
@@ -59,7 +60,10 @@
         Object        old
     ) {
         String id = getID();
+        String code = artifact.getDataAsString("ids");
+        String [] parts = code.split("-");
 
+        // Return from cache, if present.
         WQKms res = old instanceof WQKms
             ? (WQKms)old
             : artifact.getWQKms();
@@ -70,6 +74,18 @@
             return res;
         }
 
+        String wkmsName = wqkms.getName();
+
+        Facet wqfacet = new WQKmsFacet(
+            STATIC_WQ,
+            wkmsName);
+        facets.add(wqfacet);
+
+        if (parts[0].equals("officials_wq")) {
+            // Early stop. We only want wq-points in that case.
+            return res;
+        }
+
         /*
          * TODO: re-enable HEIGHTMARKS_POINTS-thing
 
@@ -92,7 +108,7 @@
             }
         }
 
-        String wkmsName = wqkms.getName();
+        // issue1494: Only spawn qfacet if discharges are given
         if (!qEmpty) {
             Facet qfacet = new WQKmsFacet(
                 STATIC_WQKMS_Q,
@@ -109,12 +125,12 @@
         Facet rpFacet = new RelativePointFacet(wkmsName);
         facets.add(rpFacet);
 
-        wkmsName = "W (" + wkmsName + ")";
-
         Facet csFacet = new CrossSectionWaterLineFacet(0,
              wkmsName);
         facets.add(csFacet);
 
+        wkmsName = "W (" + wkmsName + ")";
+
         Facet wfacet = new WQKmsFacet(
             STATIC_WQKMS_W,
             wkmsName
@@ -126,9 +142,26 @@
                 wkmsName)*/);
         facets.add(wfacet);
 
+        Facet wstfacet = new DataFacet(
+            WST,
+            wkmsName,
+            ComputeType.ADVANCE, hash, id);
+        facets.add(wstfacet);
+
         return res;
     }
 
+    @Override
+    public Object computeAdvance(
+        D4EArtifact artifact,
+        String       hash,
+        CallContext  context,
+        List<Facet>  facets,
+        Object       old
+    ) {
+        return compute((StaticWQKmsArtifact) artifact, context.getMeta(),
+            hash, facets, old);
+    }
 
     /**
      * Get data, create the facets.
@@ -160,8 +193,8 @@
         CallMeta     meta,
         List<Facet>  facets
     ) {
-        return compute((StaticWQKmsArtifact) artifact, meta, hash, facets,
-            null);
+        return compute((StaticWQKmsArtifact) artifact, meta,
+            hash, facets, null);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org