changeset 8302:8578babdb2c8

Configured gauge discharge curve to use a default D4EArtifact and two states to hold the parameters and outs. * Updated configuration * Added new states * Updated facet
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 22 Sep 2014 17:05:37 +0200
parents d08e3737ab2d
children 519023ce3500
files artifacts/doc/conf/artifacts/gaugedischargecurve.xml artifacts/doc/conf/conf.xml artifacts/src/main/java/org/dive4elements/river/artifacts/model/GaugeDischargeCurveFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeDischargeCurveState.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeDischargeInitState.java
diffstat 5 files changed, 98 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/gaugedischargecurve.xml	Wed Sep 17 19:46:19 2014 +0200
+++ b/artifacts/doc/conf/artifacts/gaugedischargecurve.xml	Mon Sep 22 17:05:37 2014 +0200
@@ -1,39 +1,46 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <artifact name="gaugedischargecurve">
     <states>
-         <state id="state.gaugedischargecurve.static" description="state.gaugedischargecurve.static" state="org.dive4elements.river.artifacts.states.StaticState">
-            <data name="river" type="String" />
-            <data name="reference_gauge" type="Long" />
-            <data name="gauge_name" type="String" />
-            <outputmodes>
-                <outputmode name="discharge_curve" description="output.discharge_curve" mime-type="image/png" type="chart">
-                    <facets>
-                        <facet name="gauge_discharge_curve"/>
-                        <facet name="mainvalues.q" description="mainvalues.q"/>
-                        <facet name="computed_discharge_curve.mainvalues.w" description="mainvalues.w"/>
-                        <facet name="discharge_curve.curve" description="facet.discharge_curve.curve"/>
-                        <facet name="heightmarks_points" description="facet.other.wqkms"/>
-                        <facet name="other.wqkms" description="facet.other.wqkms"/>
-                        <facet name="other.wq"    description="Point-like data like fixations"/>
-                        <facet name="other.wkms"  description="Point-like data like fixations"/>
-                        <facet name="other.wkms.interpol" description="Height over km, like flood protections."/>
-                        <facet name="computed_discharge_curve.manualpoints" description="Manuelle Punkte"/>
-                        <facet name="other.w.interpol" description="Interpolated (likely single) W Values"/>
-                        <facet name="other.wqkms.w" description="facet.other.wqkms"/>
-                    </facets>
-                </outputmode>
-                <outputmode name="computed_dischargecurve_at_export" description="output.computed_dischargecurve_at_export" mime-type="text/plain" type="export">
-                    <facets>
-                        <facet name="at" description="facet.gauge_discharge_curve_export.at"/>
-                    </facets>
-                </outputmode>
-                <outputmode name="computed_dischargecurve_export" description="output.computed_dischargecurve_export" mime-type="text/plain" type="export">
-                    <facets>
-                        <facet name="csv" description="facet.computed_dischargecurve_export.csv" />
-                        <facet name="pdf" description="facet.computed_dischargecurve_export.pdf" />
-                    </facets>
-                </outputmode>
-            </outputmodes>
-         </state>
+        <state id="state.gaugedischargecurve.init" description="state.gaugedischargecurve.init" state="org.dive4elements.river.artifacts.states.GaugeDischargeInitState">
+            <data name="river" type="String"/>
+            <data name="reference_gauge" type="Long"/>
+            <data name="ld_locations" type="Double"/>
+            <data name="gauge_name" type="String"/>
+        </state>
+        <transition transition="org.dive4elements.river.artifacts.transitions.DefaultTransition">
+            <from state="state.gaugedischargecurve.init"/>
+            <to state="state.gaugedischargecurve.static"/>
+        </transition>
+        <state id="state.gaugedischargecurve.static" description="state.gaugedischargecurve.static" state="org.dive4elements.river.artifacts.states.GaugeDischargeCurveState">
+           <outputmodes>
+               <outputmode name="discharge_curve" description="output.discharge_curve" mime-type="image/png" type="chart">
+                   <facets>
+                       <facet name="gauge_discharge_curve"/>
+                       <facet name="mainvalues.q" description="mainvalues.q"/>
+                       <facet name="computed_discharge_curve.mainvalues.w" description="mainvalues.w"/>
+                       <facet name="discharge_curve.curve" description="facet.discharge_curve.curve"/>
+                       <facet name="heightmarks_points" description="facet.other.wqkms"/>
+                       <facet name="other.wqkms" description="facet.other.wqkms"/>
+                       <facet name="other.wq"    description="Point-like data like fixations"/>
+                       <facet name="other.wkms"  description="Point-like data like fixations"/>
+                       <facet name="other.wkms.interpol" description="Height over km, like flood protections."/>
+                       <facet name="computed_discharge_curve.manualpoints" description="Manuelle Punkte"/>
+                       <facet name="other.w.interpol" description="Interpolated (likely single) W Values"/>
+                       <facet name="other.wqkms.w" description="facet.other.wqkms"/>
+                   </facets>
+               </outputmode>
+               <outputmode name="computed_dischargecurve_at_export" description="output.computed_dischargecurve_at_export" mime-type="text/plain" type="export">
+                   <facets>
+                       <facet name="at" description="facet.gauge_discharge_curve_export.at"/>
+                   </facets>
+               </outputmode>
+               <outputmode name="computed_dischargecurve_export" description="output.computed_dischargecurve_export" mime-type="text/plain" type="export">
+                   <facets>
+                       <facet name="csv" description="facet.computed_dischargecurve_export.csv" />
+                       <facet name="pdf" description="facet.computed_dischargecurve_export.pdf" />
+                   </facets>
+               </outputmode>
+           </outputmodes>
+        </state>
     </states>
 </artifact>
--- a/artifacts/doc/conf/conf.xml	Wed Sep 17 19:46:19 2014 +0200
+++ b/artifacts/doc/conf/conf.xml	Mon Sep 22 17:05:37 2014 +0200
@@ -11,6 +11,7 @@
     <!ENTITY zoom-scales SYSTEM "zoom-scales.xml">
     <!ENTITY modules SYSTEM "modules.xml">
     <!ENTITY porosity-artifact  SYSTEM "artifacts/porosity.xml">
+    <!ENTITY gaugedischargecurve-artifact  SYSTEM "artifacts/gaugedischargecurve.xml">
     <!ENTITY sedimentload-artifact  SYSTEM "artifacts/sedimentload.xml">
     <!ENTITY sedimentload-ls-artifact  SYSTEM "artifacts/sedimentload-ls.xml">
 
@@ -146,7 +147,7 @@
 
             <artifact-factory name="gaugedischargecurve" description="Factory to create an artifact to show a discharge curve for a gauge."
                 ttl="3600000"
-                artifact="org.dive4elements.river.artifacts.GaugeDischargeCurveArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory>
+                artifact="org.dive4elements.river.artifacts.D4EArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory>
             <artifact-factory name="flowvelocitymodel" description="Factory to create an artifact to show measured flow velocities."
                 ttl="3600000"
                 artifact="org.dive4elements.river.artifacts.FlowVelocityModelArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory>
@@ -289,10 +290,10 @@
         <artifact name="staticwqkms" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/staticwqkms.xml" />
         <artifact name="fixanalysis" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/fixanalysis.xml" />
         <artifact name="gaugedischarge" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/gaugedischarge.xml" />
-        <artifact name="gaugedischargecurve" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/gaugedischargecurve.xml" />
         <artifact name="qsector" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/qsector.xml" />
         <artifact name="staticsqrelation" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/sqrelation.xml" />
         &porosity-artifact;
+        &gaugedischargecurve-artifact;
         &sedimentload-artifact;
         &sedimentload-ls-artifact;
     </artifacts>
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/GaugeDischargeCurveFacet.java	Wed Sep 17 19:46:19 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/GaugeDischargeCurveFacet.java	Mon Sep 22 17:05:37 2014 +0200
@@ -31,14 +31,17 @@
  * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a>
  */
 public class GaugeDischargeCurveFacet
-extends      DefaultFacet
+extends      DataFacet
 implements FacetTypes
 {
     private static final Logger log =
         Logger.getLogger(GaugeDischargeCurveFacet.class);
 
+    public GaugeDischargeCurveFacet() {
+    }
+
     public GaugeDischargeCurveFacet(String name, String description) {
-        super(0, name, description);
+        super(name, description);
     }
 
     @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeDischargeCurveState.java	Mon Sep 22 17:05:37 2014 +0200
@@ -0,0 +1,37 @@
+package org.dive4elements.river.artifacts.states;
+
+import java.util.List;
+
+import org.dive4elements.artifactdatabase.state.Facet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.model.GaugeDischargeCurveFacet;
+import org.dive4elements.river.artifacts.resources.Resources;
+
+
+public class GaugeDischargeCurveState
+extends DefaultState
+{
+
+    @Override
+    public Object computeAdvance(
+        D4EArtifact artifact,
+        String hash,
+        CallContext context,
+        List<Facet> facets,
+        Object old
+    ) {
+        RiverAccess access = new RiverAccess(artifact);
+        String description = Resources.format(context.getMeta(),
+                "facet.gauge_discharge_curve.description",
+                "Discharge curve on gauge",
+                access.getRiverName(),
+                artifact.getDataAsString("gauge_name"));
+        facets.add(new GaugeDischargeCurveFacet("gauge_discharge_curve", description));
+        facets.add(new GaugeDischargeCurveFacet("at", "gauge_discharge_curve"));
+        facets.add(new GaugeDischargeCurveFacet("csv", "gauge_discharge_curve"));
+        facets.add(new GaugeDischargeCurveFacet("pdf", "gauge_discharge_curve"));
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeDischargeInitState.java	Mon Sep 22 17:05:37 2014 +0200
@@ -0,0 +1,12 @@
+package org.dive4elements.river.artifacts.states;
+
+
+public class GaugeDischargeInitState
+extends DefaultState
+{
+
+    @Override
+    protected String getUIProvider() {
+        return "gauge_discharge_curve";
+    }
+}

http://dive4elements.wald.intevation.org