changeset 9223:bfe97ad35df5

uinfo.salix.scen_historical workflow
author gernotbelger
date Wed, 04 Jul 2018 14:00:13 +0200
parents 5a0e8d76582e
children c3994657c15d
files artifacts/doc/conf/artifacts/uinfo.xml artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/LoadMultipleEpochSelectState.java artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/LoadMultipleYearSelectState.java artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/YearChoice.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties
diffstat 6 files changed, 256 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/uinfo.xml	Wed Jul 04 13:06:28 2018 +0200
+++ b/artifacts/doc/conf/artifacts/uinfo.xml	Wed Jul 04 14:00:13 2018 +0200
@@ -76,6 +76,59 @@
       <condition data="scenario_selection" value="scenarioType.option1" operator="equal" />
     </transition>
 
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+      <from state="state.uinfo.scenario_type" />
+      <to state="state.uinfo.year_epoch" />
+      <condition data="scenario_selection" value="scenarioType.option3" operator="equal" />
+    </transition>
+
+    <state id="state.uinfo.year_epoch" description="state.uinfo.year_epoch" state="org.dive4elements.river.artifacts.uinfo.salix.YearChoice" helpText="help.state.uinfo.year">
+      <data name="ye_select" type="String" />
+    </state>
+
+
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+      <from state="state.uinfo.year_epoch" />
+      <to state="state.uinfo.load.year" />
+      <condition data="ye_select" value="state.uinfo.year" operator="equal" />
+    </transition>
+
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+      <from state="state.uinfo.year_epoch" />
+      <to state="state.uinfo.load.epoch" />
+      <condition data="ye_select" value="state.uinfo.epoch" operator="equal" />
+    </transition>
+
+    <state id="state.uinfo.load.year" description="state.uinfo.load.year" state="org.dive4elements.river.artifacts.uinfo.salix.LoadMultipleYearSelectState" helpText="help.state.uinfo.load.year">
+      <data name="years" type="String" />
+    </state>
+
+    <state id="state.uinfo.load.epoch" description="state.uinfo.load.epoch" state="org.dive4elements.river.artifacts.uinfo.salix.LoadMultipleEpochSelectState" helpText="help.state.uinfo.load.epoch">
+      <data name="epochs" type="String" />
+    </state>
+
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+      <from state="state.uinfo.load.epoch" />
+      <to state="state.uinfo.distance_only_part.historical" />
+      <condition data="calculation_mode" value="uinfo_salix_line" operator="equal" />
+    </transition>
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+      <from state="state.uinfo.load.year" />
+      <to state="state.uinfo.distance_only_part.historical" />
+      <condition data="calculation_mode" value="uinfo_salix_line" operator="equal" />
+    </transition>
+
+    <state id="state.uinfo.distance_only_part.historical" description="state.uinfo.distance_only_part.historical" state="org.dive4elements.river.artifacts.states.DistanceOnlyPartSelect" helpText="help.state.uinfo.distance_only">
+      <data name="ld_from_part" type="Double" />
+      <data name="ld_to_part" type="Double" />
+    </state>
+
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+      <from state="state.uinfo.distance_only_part.historical" />
+      <to state="state.uinfo.salix_line" />
+      <condition data="calculation_mode" value="uinfo_salix_line" operator="equal" />
+    </transition>
+
     <state id="state.uinfo.inundation.scenario.regional" description="state.uinfo.inundation.scenario.regional" state="org.dive4elements.river.artifacts.uinfo.salix.LoadScenarioSelectLimit5" helpText="help.state.uinfo.use_scenario">
       <data name="sedimentheight" type="String" /> <!-- mittelwasserlage in cm! -->
     </state>
@@ -92,7 +145,7 @@
     </transition>
 
 
-<transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
       <from state="state.uinfo.inundation.scenario.regional" />
       <to state="state.uinfo.salix_line" />
       <condition data="calculation_mode" value="uinfo_salix_line" operator="equal" />
@@ -185,6 +238,7 @@
       <condition data="use_scenario" value="false" operator="equal" />
     </transition>
 
+
     <state id="state.uinfo.inundation.scenario" description="state.uinfo.inundation.scenario" state="org.dive4elements.river.artifacts.uinfo.inundationduration.LoadScenarioSelect" helpText="help.state.uinfo.use_scenario">
       <data name="sedimentheight" type="String" /> <!-- mittelwasserlage in cm! -->
     </state>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/LoadMultipleEpochSelectState.java	Wed Jul 04 14:00:13 2018 +0200
@@ -0,0 +1,76 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.artifacts.uinfo.salix;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
+import org.dive4elements.river.artifacts.states.AddTableDataHelper;
+import org.dive4elements.river.artifacts.states.DefaultState;
+import org.w3c.dom.Element;
+
+public class LoadMultipleEpochSelectState extends DefaultState {
+    /** The log used in this class. */
+    private static Logger log = Logger.getLogger(LoadMultipleEpochSelectState.class);
+
+    /**
+     * The default constructor that initializes an empty State object.
+     */
+    public LoadMultipleEpochSelectState() {
+    }
+
+    @Override
+    protected String getUIProvider() {
+        return "sinfo.collision.load_epoch_select";
+    }
+
+    @Override
+    protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) {
+        final String datakey = "epochs";
+        // TODO: MAKE DATASOURCE
+        try {
+            if (datakey.equals(name)) {
+
+                final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta());
+
+                helper.addColumn(0, "pinfrom", "40", "common.client.ui.from", "ICON", "CENTER", "from");
+                helper.addColumn(1, "pinto", "40", "common.client.ui.to", "ICON", "CENTER", "to");
+                helper.addColumn(2, "year", "60", "year", "INTEGER", "LEFT", null);
+
+                // final CollisionAccess access = new CollisionAccess((SINFOArtifact) artifact); // Der River wurde im vorigen State
+                // bereits gesetzt
+
+                // final List<Collision> collisions = CollisionHibernateFactory.getCollisionsByRiver(access.getRiver());
+                // for (final Collision coll : collisions) { // TODO: Filter on Range (?)
+                // final Integer year = coll.getYear();
+                final Map<String, String> row = new HashMap<>();
+                row.put("year", "1995");// year.toString()); // Nullpointer?
+                helper.addRow(row);
+                final Map<String, String> row2 = new HashMap<>();
+                row2.put("year", "1996");
+                helper.addRow(row2);
+                final Map<String, String> row3 = new HashMap<>();
+                row3.put("year", "1998");
+                helper.addRow(row3);
+
+                // }
+                helper.submitMapToXml();
+            }
+        }
+        catch (
+
+        final IllegalArgumentException iae) {
+            iae.printStackTrace();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/LoadMultipleYearSelectState.java	Wed Jul 04 14:00:13 2018 +0200
@@ -0,0 +1,88 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.artifacts.uinfo.salix;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
+import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
+import org.dive4elements.river.artifacts.sinfo.collision.CollisionAccess;
+import org.dive4elements.river.artifacts.states.AddTableDataHelper;
+import org.dive4elements.river.artifacts.states.DefaultState;
+import org.dive4elements.river.model.sinfo.Collision;
+import org.w3c.dom.Element;
+
+/** State in which to fetch years for sedminent load calculation. */
+public class LoadMultipleYearSelectState extends DefaultState {
+    private static final long serialVersionUID = 1L;
+    /** The log used in this class. */
+    private static Logger log = Logger.getLogger(LoadMultipleYearSelectState.class);
+
+    /**
+     * The default constructor that initializes an empty State object.
+     */
+    public LoadMultipleYearSelectState() {
+    }
+
+    /** Year Select Widget. */
+    @Override
+    protected String getUIProvider() {
+        return "sinfo.collision.load_year_select";
+    }
+
+    @Override
+    protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) {
+        // TODO: MAKE DATASOURCE
+        try {
+            final String dataKeyofState = "years";// siehe sinfo.xml
+            if (dataKeyofState.equals(name)) {
+
+                final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); // "year" not to be confused with datakey
+
+                helper.addColumn(0, "pinfrom", "60", "common.client.ui.selection", "ICON", "CENTER", "from");
+                helper.addColumn(1, "year", "60", "year", "INTEGER", "LEFT", null);
+
+                final CollisionAccess access = new CollisionAccess((SINFOArtifact) artifact); // Der River wurde im vorigen State bereits gesetzt
+
+                // final List<Collision> collisions = CollisionHibernateFactory.getCollisionsByRiver(access.getRiver());
+                // for (final Collision coll : collisions) {
+                for (final Integer year : Collision.getYearsOfRiver(access.getRiver())) {
+                    // final Integer year = coll.getYear();
+                    final Map<String, String> row = new HashMap<>();
+                    row.put("year", year.toString()); // Nullpointer?
+                    helper.addRow(row);
+                }
+                helper.submitMapToXml();
+            }
+        }
+        catch (final IllegalArgumentException iae) {
+            iae.printStackTrace();
+        }
+    }
+
+    @Override
+    public void validate(final Artifact artifact, final CallContext cc) throws IllegalArgumentException {
+        // TODO: check verstehen
+
+        final CollisionAccess access = new CollisionAccess((SINFOArtifact) artifact);
+
+        // Second year should be later than first.
+
+        // if (access.getYears() == null || access.getYears().length == 0)
+        // return true;
+        // throw new IllegalArgumentException("error_years_wrong");
+
+        // return true;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/YearChoice.java	Wed Jul 04 14:00:13 2018 +0200
@@ -0,0 +1,35 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.artifacts.uinfo.salix;
+
+import java.util.LinkedHashMap;
+
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.river.artifacts.states.RadioSelect;
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class YearChoice extends RadioSelect {
+    private static final long serialVersionUID = 1L;
+
+    public YearChoice() {
+        super();
+    }
+
+    @Override
+    protected LinkedHashMap<String, String> makeEntries(final CallMeta meta, final Artifact artifact) {
+        final LinkedHashMap<String, String> entries = new LinkedHashMap<>();
+        entries.put("state.uinfo.year", null);
+        entries.put("state.uinfo.epoch", null);
+        return entries;
+    }
+
+}
\ No newline at end of file
--- a/artifacts/src/main/resources/messages.properties	Wed Jul 04 13:06:28 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Wed Jul 04 14:00:13 2018 +0200
@@ -1065,6 +1065,7 @@
 scenarioType.option3 = Historische Betrachtung 
 help.state.uinfo.scenario_type=${help.url}/OnlineHilfe/UINFO#help.state.uinfo.scenario_type
 
+state.uinfo.distance_only_part.historical= Teilabschnitt
 state.uinfo.distance_only_part.from_regional= Teilabschnitt
 state.uinfo.distance_only_part = Teilabschnitt
 help.state.uinfo.distance_only_part = ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only_part 
--- a/artifacts/src/main/resources/messages_de.properties	Wed Jul 04 13:06:28 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Wed Jul 04 14:00:13 2018 +0200
@@ -1065,6 +1065,7 @@
 scenarioType.option3 = Historische Betrachtung 
 help.state.uinfo.scenario_type=${help.url}/OnlineHilfe/UINFO#help.state.uinfo.scenario_type
 
+state.uinfo.distance_only_part.historical= Teilabschnitt
 state.uinfo.distance_only_part.from_regional= Teilabschnitt 
 state.uinfo.distance_only_part = Teilabschnitt
 help.state.uinfo.distance_only_part = ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.distance_only_part 

http://dive4elements.wald.intevation.org