[PATCH] bundu bezugswst work

Wald Commits scm-commit at wald.intevation.org
Wed Jul 18 15:35:03 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1531920893 -7200
# Node ID c7e5285d434f616ed420f18f54860955e1c9bf1b
# Parent  465347d129907fab579c620aabd71f01299a42ac
bundu bezugswst work

diff -r 465347d12990 -r c7e5285d434f artifacts/doc/conf/artifacts/bundu.xml
--- a/artifacts/doc/conf/artifacts/bundu.xml	Wed Jul 18 12:20:01 2018 +0200
+++ b/artifacts/doc/conf/artifacts/bundu.xml	Wed Jul 18 15:34:53 2018 +0200
@@ -124,7 +124,7 @@
             <facet name="csv" description="facet.fix_deltawt.csv" />
             <facet name="pdf" description="facet.fix_deltawt.pdf" />
           </facets>
-        </outputmode> 
+        </outputmode>
         <outputmode name="fix_parameters_export" description="output.fix_parameters_export" mine-type="text/plain" type="export">
           <facets>
             <facet name="fix_parameters" description="facet.fix_parameters.csv" />
@@ -325,8 +325,9 @@
     </transition>
 
 
-    <state id="state.bundu.yearselect" helpText="state.bundu.yearselect" description="state.bundu.yearselect" state="org.dive4elements.river.artifacts.bundu.bezugswst.LoadSingleYearSelectState">
-      <data name="singleyear" type="String" />
+    <state id="state.bundu.yearselect" helpText="state.bundu.yearselect" description="state.bundu.yearselect" state="org.dive4elements.river.artifacts.bundu.bezugswst.FixationPeriod">
+      <data name="singleyear" type="String" /> 
+      <data name="events_temp" type="intarray" /> <!--necessary, because they will be set automatically -->
     </state>
 
 
@@ -338,15 +339,52 @@
 
     <state id="state.bundu.fixationchoice" helpText="state.bundu.fixationchoice" description="state.bundu.fixationchoice" state="org.dive4elements.river.artifacts.bundu.bezugswst.FixationChoice">
       <data name="fix_choice" type="String" />
+      <data name="q1" type="Integer" />
+      <data name="q2" type="Integer" /> <!-- necessary, because they will be set automatically -->
+      <data name="start" type="Long" /> <!--copy from Period, to fill it in LoadQSeriesSelectState (necessary for auto-select events) -->
+      <data name="end" type="Long" />
+      <data name="events" type="intarray" />
     </state>
- 
-   
-   <!-- <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+
+
+
+
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
       <from state="state.bundu.fixationchoice" />
-      <to state="state.bundu.yearselect" />
-      <condition data="fix_choice" value="bundu_bezugswst" operator="equal" />
+      <to state="state.bundu.wst.fix.year_length" />
+      <condition data="fix_choice" value="state.bundu.fix.auto" operator="equal" />
     </transition>
-    TODO: to be continued -->  
+
+
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+      <from state="state.bundu.fixationchoice" />
+      <to state="state.bundu.gaugerange" />
+      <condition data="fix_choice" value="state.bundu.fix.manual" operator="equal" />
+    </transition>
+
+
+
+
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+      <from state="state.bundu.gaugerange" />
+      <to state="state.bundu.eventselect" />
+      <condition data="calculation_mode" value="bundu_bezugswst" operator="equal" />
+    </transition>
+
+
+    <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
+      <from state="state.bundu.eventselect" />
+      <to state="state.bundu.wst.fix.year_length" />
+      <condition data="calculation_mode" value="bundu_bezugswst" operator="equal" />
+    </transition>
+
+
+    <state id="state.bundu.wst.fix.year_length" helpText="help.state.bundu.wst.fix.year_length" description="state.bundu.wst.fix.year_length" state="org.dive4elements.river.artifacts.bundu.bezugswst.LoadQSeriesSelectState">
+      <data name="year_input_q_series" type="String" />
+      <data name="start" type="Long" /> <!-- copy from Period, to fill it in LoadQSeriesSelectState -->
+      <data name="end" type="Long" />
+    </state>
+
 
 
 
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java	Wed Jul 18 15:34:53 2018 +0200
@@ -0,0 +1,128 @@
+/* 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.bundu.bezugswst;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.FixAnalysisAccess;
+
+public class BunduAccess extends FixAnalysisAccess {
+
+    private static Logger log = Logger.getLogger(BunduAccess.class);
+
+    // Alles, was in super steht, auskommentiert. TODO: endgültig löschen, nachdem ich es etwas verstanden habe
+
+    // protected DateRange referencePeriod;
+    // protected DateRange[] analysisPeriods;
+    //
+    // protected double[] qs;
+
+    public BunduAccess(final D4EArtifact artifact) {
+        super(artifact);
+    }
+
+    public boolean isAutoSelect() {
+        final String fixChoice = this.artifact.getDataAsString("fix_choice");
+        if (fixChoice != null && fixChoice.equals("state.bundu.fix.auto")) {
+            return true;
+        }
+        return false;
+    }
+
+    public Integer getBezugsJahr() {
+        return this.artifact.getDataAsInteger("singleyear");
+    }
+
+    public int[] getEventsTemp() {
+        return getIntArray("events_temp");
+    }
+
+    // /** Access the reference date period, return null in case of 'errors'. */
+    // public DateRange getReferencePeriod() {
+    // if (this.referencePeriod == null) {
+    // final StateData refStart = artifact.getData("ref_start");
+    // final StateData refEnd = artifact.getData("ref_end");
+    //
+    // if (refStart == null || refEnd == null) {
+    // log.warn("missing 'ref_start' or 'ref_start' value");
+    // return null;
+    // }
+    //
+    // try {
+    // long rs = Long.parseLong((String) refStart.getValue());
+    // long re = Long.parseLong((String) refEnd.getValue());
+    //
+    // if (rs > re) {
+    // final long t = rs;
+    // rs = re;
+    // re = t;
+    // }
+    //
+    // final Date from = new Date(rs);
+    // final Date to = new Date(re);
+    // this.referencePeriod = new DateRange(from, to);
+    // }
+    // catch (final NumberFormatException nfe) {
+    // log.warn("ref_start or ref_end is not an integer.");
+    // }
+    // }
+    //
+    // return this.referencePeriod;
+    // }
+
+    // @Override
+    // public DateRange[] getAnalysisPeriods() {
+    // if (this.analysisPeriods == null) {
+    // this.analysisPeriods = getDateRange("ana_data");
+    // }
+    //
+    // return this.analysisPeriods;
+    // }
+
+    /**
+     * @return DateRange object ranging from eldest to youngest date
+     *         of analysis and reference periods.
+     */
+    // @Override
+    // public DateRange getDateRange() {
+    // final DateRange refP = getReferencePeriod();
+    //
+    // if (refP == null) {
+    // return null;
+    // }
+    //
+    // Date from = refP.getFrom();
+    // Date to = refP.getTo();
+    //
+    // final DateRange[] rs = getAnalysisPeriods();
+    // for (final DateRange r : rs) {
+    // if (r.getFrom().before(from)) {
+    // from = r.getFrom();
+    // }
+    // if (r.getTo().after(to)) {
+    // to = r.getTo();
+    // }
+    // }
+    //
+    // return new DateRange(from, to);
+    // }
+
+    // @Override
+    // public double[] getQs() {
+    // if (this.qs == null) {
+    // this.qs = getDoubleArray("qs");
+    // }
+    //
+    // if (log.isDebugEnabled() && this.qs != null) {
+    // log.debug("qs: " + Arrays.toString(this.qs));
+    // }
+    // return this.qs;
+    // }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java	Wed Jul 18 15:34:53 2018 +0200
@@ -11,8 +11,14 @@
 import java.util.LinkedHashMap;
 
 import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.artifacts.common.utils.XMLUtils;
+import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
+import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.states.RadioSelect;
+import org.dive4elements.river.artifacts.states.fixation.EventSelect;
+import org.w3c.dom.Element;
 
 /**
  * @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
@@ -21,6 +27,11 @@
     private static final long serialVersionUID = 1L;
 
     @Override
+    protected final String getUIProvider() {
+        return "custom_fixation_radio_panel";
+    }
+
+    @Override
     protected LinkedHashMap<String, String> makeEntries(final CallMeta meta, final Artifact artifact) {
         final LinkedHashMap<String, String> entries = new LinkedHashMap<>();
         entries.put("state.bundu.fix.auto", null);
@@ -28,4 +39,46 @@
         return entries;
     }
 
+    @Override
+    protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) {
+
+        final Element[] elements = super.createItems(ec, artifact, name, context);
+        final Element[] elementsAndYear = new Element[elements.length + 2];
+
+        for (int i = 0; i < elements.length; i++) {
+            elementsAndYear[i] = elements[i];
+        }
+        // add Bezugsjahr
+        // REMEBER: we need it for getLabelFor later
+        final BunduAccess access = new BunduAccess((D4EArtifact) artifact);
+        final int[] eventsTemp = access.getEventsTemp();
+        final StringBuilder builder = new StringBuilder();
+        if (eventsTemp != null) {
+            for (final int event : eventsTemp) {
+                builder.append(event).append(";");
+            }
+        } else {
+            builder.append("");// no values
+        }
+        elementsAndYear[elements.length] = createItem(ec, new String[] { "ignore_events_temp", builder.toString() });
+
+        final int year = access.getBezugsJahr();
+
+        elementsAndYear[elements.length + 1] = createItem(ec, new String[] { "ignore_singleyear", String.valueOf(year) });
+
+        return elementsAndYear;
+
+    }
+
+    @Override
+    protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value,
+            final String type) {
+        if (name.equals("events")) {
+            return EventSelect.createStaticDataPublic(flys, creator, cc, name, value, type);
+
+        } else {
+            return super.createStaticData(flys, creator, cc, name, value, type);
+        }
+    }
+
 }
\ No newline at end of file
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationManual.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationManual.java	Wed Jul 18 15:34:53 2018 +0200
@@ -0,0 +1,33 @@
+/* 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.bundu.bezugswst;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.river.artifacts.states.DefaultState;
+
+/**
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public class FixationManual extends DefaultState {
+
+    /** The log used in this class. */
+    private static Logger log = Logger.getLogger(FixationManual.class);
+
+    /**
+     * The default constructor that initializes an empty State object.
+     */
+    public FixationManual() {
+    }
+
+    @Override
+    protected String getUIProvider() {
+        return "bundu.fix.period_panel";
+    }
+
+}
\ No newline at end of file
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationPeriod.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationPeriod.java	Wed Jul 18 15:34:53 2018 +0200
@@ -0,0 +1,33 @@
+/* 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.bundu.bezugswst;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.river.artifacts.states.DefaultState;
+
+/**
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public class FixationPeriod extends DefaultState {
+
+    /** The log used in this class. */
+    private static Logger log = Logger.getLogger(FixationPeriod.class);
+
+    /**
+     * The default constructor that initializes an empty State object.
+     */
+    public FixationPeriod() {
+    }
+
+    @Override
+    protected String getUIProvider() {
+        return "bundu.fix.period_panel";
+    }
+
+}
\ No newline at end of file
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/LoadQSeriesSelectState.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/LoadQSeriesSelectState.java	Wed Jul 18 15:34:53 2018 +0200
@@ -0,0 +1,30 @@
+/* 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.bundu.bezugswst;
+
+import org.dive4elements.river.artifacts.states.DefaultState;
+
+public class LoadQSeriesSelectState extends DefaultState {
+    private static final long serialVersionUID = 1L;
+
+    final String datakey = "year_input_q_series";
+
+    /**
+     * The default constructor that initializes an empty State object.
+     */
+    public LoadQSeriesSelectState() {
+    }
+
+    /** Year Select Widget. */
+    @Override
+    protected String getUIProvider() {
+        return "bundu.wst.state.load_single_q_series";
+    }
+
+}
\ No newline at end of file
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/LoadSingleYearSelectState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/LoadSingleYearSelectState.java	Wed Jul 18 12:20:01 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/* 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.bundu.bezugswst;
-
-import java.util.HashMap;
-import java.util.List;
-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.D4EArtifact;
-import org.dive4elements.river.artifacts.access.RiverAccess;
-import org.dive4elements.river.artifacts.model.CollisionHibernateFactory;
-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 LoadSingleYearSelectState extends DefaultState {
-    private static final long serialVersionUID = 1L;
-    /** The log used in this class. */
-    private static Logger log = Logger.getLogger(LoadSingleYearSelectState.class);
-
-    /**
-     * The default constructor that initializes an empty State object.
-     */
-    public LoadSingleYearSelectState() {
-    }
-
-    /** Year Select Widget. */
-    @Override
-    protected String getUIProvider() {
-        return "common.state.load_single_year_select.show_hint";
-    }
-
-    @Override
-    protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) {
-        final String dataKey = "singleyear";
-        try {
-            if (dataKey.equals(name)) {
-
-                final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); // pinKeycolum; nicht zu verweschseln mit
-                                                                                                                      // datakey..artifact.
-
-                helper.addColumn(0, "pinfrom", "60", "common.client.ui.selection", "ICON", "CENTER", "from");
-                helper.addColumn(1, "year", "60", "year", "INTEGER", "LEFT", null);
-
-                final RiverAccess access = new RiverAccess((D4EArtifact) artifact);
-                final List<Collision> collisions = CollisionHibernateFactory.getCollisionsByRiver(access.getRiver());// TODO: DATASOURCE?! Has to be
-                                                                                                                     // uinfo.inundation_duration
-                // (Überflutungsdauern Aue) irgendwas...
-
-                for (final Collision coll : collisions) {
-                    final Integer year = coll.getYear();
-                    final Map<String, String> row = new HashMap<>();
-                    row.put("year", year.toString()); // Nullpointer-Check?
-                    helper.addRow(row);
-
-                }
-                helper.submitMapToXml();
-            }
-        }
-        catch (final IllegalArgumentException iae) {
-            iae.printStackTrace();
-        }
-    }
-
-    @Override
-    public boolean validate(final Artifact artifact) throws IllegalArgumentException {
-        return true;
-        // final CollisionLoadYearEpochAccess access = new CollisionLoadYearEpochAccess((D4EArtifact) artifact);
-        //
-        // // Second year should be later than first.
-        // if (access.getYears() == null || access.getYears().length == 0)
-        // return true; // TODO: richtig in CollisionLoadYear... implementieren
-        // // throw new IllegalArgumentException("error_years_wrong");
-        //
-        // return true;
-    }
-}
\ No newline at end of file
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/java/org/dive4elements/river/artifacts/states/RadioSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/RadioSelect.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/RadioSelect.java	Wed Jul 18 15:34:53 2018 +0200
@@ -36,7 +36,7 @@
                                                                                                     // verrutscht
 
     @Override
-    protected final String getUIProvider() {
+    protected String getUIProvider() {
         return "radio_panel";
     }
 
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/EventSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/EventSelect.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/EventSelect.java	Wed Jul 18 15:34:53 2018 +0200
@@ -11,23 +11,17 @@
 import java.util.List;
 
 import org.apache.log4j.Logger;
-
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.model.FixingsOverview;
+import org.dive4elements.river.artifacts.model.FixingsOverview.Fixing;
+import org.dive4elements.river.artifacts.model.FixingsOverview.IdFilter;
+import org.dive4elements.river.artifacts.model.FixingsOverviewFactory;
+import org.dive4elements.river.artifacts.states.DefaultState;
+import org.dive4elements.river.utils.RiverUtils;
 import org.w3c.dom.Element;
 
-import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
-
-import org.dive4elements.artifacts.CallContext;
-
-import org.dive4elements.river.artifacts.states.DefaultState;
-import org.dive4elements.river.artifacts.D4EArtifact;
-import org.dive4elements.river.utils.RiverUtils;
-
-import org.dive4elements.river.artifacts.model.FixingsOverview;
-import org.dive4elements.river.artifacts.model.FixingsOverviewFactory;
-import org.dive4elements.river.artifacts.model.FixingsOverview.IdFilter;
-import org.dive4elements.river.artifacts.model.FixingsOverview.Fixing;
-
-
 /**
  * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
  */
@@ -36,7 +30,6 @@
     /** The log used in this class. */
     private static Logger log = Logger.getLogger(EventSelect.class);
 
-
     /**
      * The default constructor that initializes an empty State object.
      */
@@ -49,55 +42,39 @@
     }
 
     @Override
-    protected Element createStaticData(
-        D4EArtifact   flys,
-        ElementCreator creator,
-        CallContext    cc,
-        String         name,
-        String         value,
-        String         type
-    ) {
-        int[] array = RiverUtils.intArrayFromString(value);
+    protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value,
+            final String type) {
+        return this.createStaticDataPublic(flys, creator, cc, name, value, type);
+    }
 
-        Element dataElement = creator.create("data");
+    public final static Element createStaticDataPublic(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name,
+            final String value, final String type) {
+        final int[] array = RiverUtils.intArrayFromString(value);
+
+        final Element dataElement = creator.create("data");
         creator.addAttr(dataElement, "name", name, true);
         creator.addAttr(dataElement, "type", type, true);
 
-        String river = RiverUtils.getRiver(flys).getName();
+        final String river = RiverUtils.getRiver(flys).getName();
 
-        FixingsOverview overview = FixingsOverviewFactory.getOverview(river);
+        final FixingsOverview overview = FixingsOverviewFactory.getOverview(river);
 
-        for (int i = 0; i < array.length; i++) {
-            Element itemElement = creator.create("item");
-            creator.addAttr(
-                itemElement,
-                "value",
-                String.valueOf(array[i]),
-                true);
+        for (final int element : array) {
+            final Element itemElement = creator.create("item");
+            creator.addAttr(itemElement, "value", String.valueOf(element), true);
 
-            creator.addAttr(
-                itemElement,
-                "label",
-                getLabel(cc, array[i], overview),
-                true);
+            creator.addAttr(itemElement, "label", getLabelForEvent(cc, element, overview), true);
             dataElement.appendChild(itemElement);
         }
         return dataElement;
     }
 
-
-    public static String getLabel(
-        CallContext cc,
-        int value,
-        FixingsOverview overview
-    ) {
+    private static final String getLabelForEvent(final CallContext cc, final int value, final FixingsOverview overview) {
         log.debug("Create label for value: " + value);
 
-        IdFilter filter = new IdFilter(value);
-        List<Fixing.Column> columns = overview.filter(null, filter);
-        return  columns.isEmpty()
-            ? ""
-            : columns.get(0).getDescription();
+        final IdFilter filter = new IdFilter(value);
+        final List<Fixing.Column> columns = overview.filter(null, filter);
+        return columns.isEmpty() ? "" : columns.get(0).getDescription();
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties	Wed Jul 18 12:20:01 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Wed Jul 18 15:34:53 2018 +0200
@@ -1202,6 +1202,8 @@
 help.state.bundu.vollmer.qs=${help.url}/OnlineHilfe/bunduierungsanalyse#help.state.bundu.vollmer.qs
 help.state.bundu.vollmer.compute=${help.url}/OnlineHilfe/bunduierungsanalyse#help.state.bundu.vollmer.compute
 
+state.bundu.wst.fix.year_length = L\u00e4nge der Abflusszeitreihe (Ausgehend vom Bezugsjahr in die Vergangenheit)
+
 common.client.ui.selection = Selection
 common.client.ui.from = from
 common.client.ui.to = to
diff -r 465347d12990 -r c7e5285d434f artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Wed Jul 18 12:20:01 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Wed Jul 18 15:34:53 2018 +0200
@@ -1202,6 +1202,8 @@
 help.state.bundu.vollmer.qs=${help.url}/OnlineHilfe/bunduierungsanalyse#help.state.bundu.vollmer.qs
 help.state.bundu.vollmer.compute=${help.url}/OnlineHilfe/bunduierungsanalyse#help.state.bundu.vollmer.compute
 
+state.bundu.wst.fix.year_length = L\u00e4nge der Abflusszeitreihe (Ausgehend vom Bezugsjahr in die Vergangenheit)
+
 common.client.ui.selection = Auswahl
 common.client.ui.from = von
 common.client.ui.to = bis
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Wed Jul 18 15:34:53 2018 +0200
@@ -1580,4 +1580,8 @@
     String uinfo_vegetation_zone_overlap();
 
     String uinfo_vegetation_zone_has_gaps();
+
+    String bundu_bezugswst_fix_choice_title();
+
+    String bundu_bezugswst_auto_event_choice();
 }
\ No newline at end of file
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Wed Jul 18 15:34:53 2018 +0200
@@ -843,6 +843,8 @@
 uinfo_salix_input_complete = Die gesamte Strecke ist bereits mit Werten belegt.
 
 bundu = Betrieb und Unterhaltung 
+bundu_bezugswst_fix_choice_title= Fixierungsauswahl
+bundu_bezugswst_auto_event_choice = Automatische Ereignisauswahl
 
 chart_settings_export_metadata = Show Meta-Data
 export_csv_title = Title: 
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Wed Jul 18 15:34:53 2018 +0200
@@ -843,6 +843,8 @@
 uinfo_salix_input_complete = Die gesamte Strecke ist bereits mit Werten belegt.
 
 bundu = Betrieb und Unterhaltung
+bundu_bezugswst_fix_choice_title= Fixierungsauswahl
+bundu_bezugswst_auto_event_choice = Automatische Ereignisauswahl
 
 chart_settings_export_metadata = Metadaten anzeigen
 export_csv_title = Titel: 
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractSingleItemPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractSingleItemPanel.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractSingleItemPanel.java	Wed Jul 18 15:34:53 2018 +0200
@@ -115,9 +115,9 @@
 
     @Override
     protected final Data[] getData() {
-        final List<String> errors = this.validate();
+        final List<String> errors = this.validate(); // do not allow advance state
         if (errors.size() > 0) {
-            showErrors(errors); // TODO: do not allow advance state
+            showErrors(errors);
         }
         if (this.inputItem != null && !this.inputItem.getValueAsString().isEmpty()) {
             final List<Data> data = new ArrayList<Data>();
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RadioPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RadioPanel.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RadioPanel.java	Wed Jul 18 15:34:53 2018 +0200
@@ -71,8 +71,10 @@
         final LinkedHashMap<String, String> elems = new LinkedHashMap<String, String>();
         for (final DataItem item : items) {
             GWT.log(item.getStringValue() + "; " + item.getLabel());
-            elems.put(item.getStringValue(), item.getLabel());
-            this.valueLabelMap.put(item.getStringValue(), item.getLabel());
+            if (!item.getLabel().startsWith("ignore_")) {
+                elems.put(item.getStringValue(), item.getLabel());
+                this.valueLabelMap.put(item.getStringValue(), item.getLabel());
+            }
         }
         rgi.setValueMap(elems);
         rgi.setDefaultValue(items[0].getStringValue());
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java	Wed Jul 18 15:34:53 2018 +0200
@@ -9,6 +9,9 @@
 package org.dive4elements.river.client.client.ui;
 
 import org.dive4elements.river.client.client.FLYSConstants;
+import org.dive4elements.river.client.client.ui.bundu.CustomFixationChoiceRadioPanel;
+import org.dive4elements.river.client.client.ui.bundu.QSeriesLengthPanel;
+import org.dive4elements.river.client.client.ui.fixation.BunduFixPeriodPanel;
 import org.dive4elements.river.client.client.ui.fixation.FixEventSelect;
 import org.dive4elements.river.client.client.ui.fixation.FixFunctionSelect;
 import org.dive4elements.river.client.client.ui.fixation.FixGaugeSelectPanel;
@@ -117,7 +120,17 @@
             return new FixLocationPanel();
         } else if (uiProvider.equals("fix.period_panel")) {
             return new FixPeriodPanel();
-        } else if (uiProvider.equals("fix.period_ref_panel")) {
+        }
+
+        else if (uiProvider.equals("bundu.fix.period_panel")) {
+            return new BunduFixPeriodPanel();
+        }
+
+        else if (uiProvider.equals("bundu.wst.state.load_single_q_series")) {
+            return new QSeriesLengthPanel();
+        }
+
+        else if (uiProvider.equals("fix.period_ref_panel")) {
             return new FixPeriodPanel("ref_start", "ref_end");
         } else if (uiProvider.equals("fix.period_ana_panel")) {
             return new FixMultiPeriodPanel();
@@ -147,6 +160,8 @@
             return new RadioPanel();
         } else if (uiProvider.equals("radio_panel")) {
             return new RadioPanel();
+        } else if (uiProvider.equals("custom_fixation_radio_panel")) {
+            return new CustomFixationChoiceRadioPanel();
         } else if (uiProvider.equals("bedquality_periods_select")) {
             return new BedMultiPeriodPanel();
         } else if (uiProvider.equals("bedheights_twin_panel")) {
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/CustomFixationChoiceRadioPanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/CustomFixationChoiceRadioPanel.java	Wed Jul 18 15:34:53 2018 +0200
@@ -0,0 +1,168 @@
+/* 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.client.client.ui.bundu;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import org.dive4elements.river.client.client.ui.RadioPanel;
+import org.dive4elements.river.client.client.ui.fixation.FixEventSelect;
+import org.dive4elements.river.client.client.ui.fixation.FixGaugeSelectPanel;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.DefaultData;
+import org.dive4elements.river.client.shared.model.DefaultDataItem;
+import org.dive4elements.river.client.shared.model.IntDataItem;
+import org.dive4elements.river.client.shared.model.IntegerArrayData;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+public class CustomFixationChoiceRadioPanel extends RadioPanel {
+
+    private static final long serialVersionUID = 3357071563224461043L;
+
+    private String events[];
+    private int bezugsjahr = 0;
+
+    @Override
+    public Canvas createOld(final DataList dataList) { // wild überschrieben :-(
+        final List<Data> list = dataList.getAll();
+
+        final VLayout root = new VLayout();
+        final HLayout layoutChoice = new HLayout();
+        layoutChoice.setHeight(35);
+        layoutChoice.setWidth(400);
+
+        for (final Data item : list) {
+            if ("fix_choice".equals(item.getLabel())) {
+                final Label labelLabel = new Label(this.MSG.bundu_bezugswst_fix_choice_title());
+                final Label valueLabel = new Label(item.getItems()[0].getLabel());
+
+                labelLabel.setWidth(200);
+                valueLabel.setWidth(180);
+                layoutChoice.addMember(labelLabel);
+                layoutChoice.addMember(valueLabel);
+                final Canvas back = getBackButton(dataList.getState());
+                layoutChoice.addMember(back);
+                root.addMember(layoutChoice);
+            }
+        }
+
+        final Data data = getData(list, "events");
+        if (data != null) {
+
+            final VLayout dataLayout = FixEventSelect.getEventDataLayout(data);
+
+            final HLayout layout = new HLayout();
+            layout.setWidth("400px");
+            final Label label = new Label(this.MSG.bundu_bezugswst_auto_event_choice());
+            label.setWidth("200px");
+            layout.addMember(label);
+            layout.addMember(dataLayout);
+            root.addMember(layout);
+        }
+
+        return root;
+    }
+
+    @Override
+    public Canvas create(final DataList dataList) { // wild überschrieben :-(
+        final Data data = dataList.get(0);
+        final DataItem[] items = data.getItems();
+        for (final DataItem item : items) {
+            if (item.getLabel().equals("ignore_events_temp")) {
+                if (!item.getStringValue().equals(""))
+                    this.events = (item.getStringValue().split(";"));
+
+            } else if (item.getLabel().equals("ignore_singleyear")) {
+                this.bezugsjahr = Integer.valueOf(item.getStringValue());
+            }
+        }
+        return super.create(dataList);
+    }
+
+    @Override
+    protected Data[] getData() { // TODO: wild überschreiben :-(
+        final String value = this.form.getValueAsString("selection");
+        final List<Data> data = new ArrayList<Data>();
+
+        // Default-values for data. they have to be reset, if user switches from auto to manual
+        IntegerArrayData iad = new IntegerArrayData("events", "events", new IntDataItem[] {});
+        DataItem firstItem = new DefaultDataItem(null, null, "");
+        DataItem secItem = new DefaultDataItem(null, null, "");
+        DataItem startItem = new DefaultDataItem(null, null, "");
+        DataItem endItem = new DefaultDataItem(null, null, "");
+
+        final DataItem item = new DefaultDataItem("fix_choice", "fix_choice", value);
+        data.add(new DefaultData("fix_choice", null, null, new DataItem[] { item }));
+
+        if (value.equals("state.bundu.fix.auto")) {
+            // set gauges: (do not appear in create old, but need to be set for calculation purpose
+            final LinkedHashMap<String, String> map = FixGaugeSelectPanel.getMapValues(this.MSG);
+            final String mnq = this.MSG.gauge_mnq();
+            final String hq5 = this.MSG.gauge_hq5();
+            String firstKey = "-1";
+            String secondKey = "-1";
+            // irgendwie hässlich, aber sicher (man kann die Map ändern und kriegt hier den richtigen Index)
+            final Iterator<String> iterator = map.keySet().iterator();
+            while (iterator.hasNext()) {
+                final String key = iterator.next();
+                final String mapValue = map.get(key);
+                if (mnq.equals(mapValue)) {
+                    firstKey = key;
+                }
+                if (hq5.equals(mapValue)) {
+                    secondKey = key;
+                }
+            }
+            firstItem = new DefaultDataItem("q1", "q1", firstKey);
+            secItem = new DefaultDataItem("q2", "q2", secondKey);
+
+            // make start, end
+            final DateTimeFormat df = DateTimeFormat.getFormat("dd.MM.yyyy");
+            /// EVENT SELECTION... have to appear in selectOld somehow...
+            startItem = new DefaultDataItem("start", "start", String.valueOf(df.parse("01.01." + (this.bezugsjahr - 5)).getTime()));
+            endItem = new DefaultDataItem("end", "end", String.valueOf(df.parse("31.12." + (this.bezugsjahr + 5)).getTime()));
+
+            /// MAKE EVENTS (muss glaube ich zum schluss erst erscheinen...
+            if (this.events != null) {
+                final IntDataItem[] arr = new IntDataItem[this.events.length];
+                for (int i = 0; i < this.events.length; i++) {
+                    try {
+                        final String s = this.events[i];
+                        final Integer v = new Integer(s);
+                        arr[i] = new IntDataItem("id", "id", v.intValue());
+                    }
+                    catch (final NumberFormatException nfe) {
+                        continue;
+                    }
+                }
+                iad = new IntegerArrayData("events", "events", arr); // overrides "real" events with events_temp from previous state...
+            }
+        }
+
+        data.add(iad);
+
+        data.add(new DefaultData("q1", null, null, new DataItem[] { firstItem }));
+        data.add(new DefaultData("q2", null, null, new DataItem[] { secItem }));
+        data.add(new DefaultData("start", null, null, new DataItem[] { startItem }));
+        data.add(new DefaultData("end", null, null, new DataItem[] { endItem }));
+
+        return data.toArray(new Data[data.size()]);
+
+    }
+
+}
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/QSeriesLengthPanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/QSeriesLengthPanel.java	Wed Jul 18 15:34:53 2018 +0200
@@ -0,0 +1,134 @@
+/* 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.client.client.ui.bundu;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.dive4elements.river.client.client.ui.AbstractUIProvider;
+import org.dive4elements.river.client.client.ui.PanelHelper;
+import org.dive4elements.river.client.client.ui.ValidationHelper;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.DefaultData;
+import org.dive4elements.river.client.shared.model.DefaultDataItem;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+public class QSeriesLengthPanel extends AbstractUIProvider {
+    private static final long serialVersionUID = 1L;
+
+    private TextItem inputItem;
+
+    protected String getDatakey() {
+        return "year_input_q_series";
+    }
+
+    private Canvas createWidget(final DataList data) {
+        final VLayout layout = new VLayout();
+
+        final Label title = new Label(data.get(0).getDescription());
+        title.setHeight("35px");
+
+        final DynamicForm form = new DynamicForm();
+
+        form.setNumCols(4);
+        this.inputItem = PanelHelper.createItem("NAME_TO_PREVENT_ERROR_MSG");
+        this.inputItem.setValue(40);
+        this.inputItem.setShowTitle(false);
+        this.inputItem.setWidth(100);
+        final StaticTextItem textItem = new StaticTextItem("IRRELEVANT_NAME");
+
+        textItem.setValue("[a]"); // internationalisieren?
+        textItem.setShowTitle(false);
+        form.setFields(this.inputItem);
+
+        form.setFields(this.inputItem, textItem);
+
+        layout.addMember(title);
+        layout.addMember(form);
+        return layout;
+    }
+
+    @Override
+    protected final Data[] getData() { // THIS is a Copy from abstractSingleItemPanel :-(
+        final List<String> errors = this.validate(); // do not allow advance state
+        if (errors.size() > 0) {
+            showErrors(errors);
+        }
+        if (this.inputItem != null && !this.inputItem.getValueAsString().isEmpty()) {
+            final List<Data> data = new ArrayList<Data>();
+
+            final DataItem yearsdata = new DefaultDataItem(getDatakey(), getDatakey(), this.inputItem.getValueAsString().trim());
+            data.add(new DefaultData(getDatakey(), null, null, new DataItem[] { yearsdata }));
+
+            return data.toArray(new Data[data.size()]);
+        }
+        return new Data[0];
+    }
+
+    @Override
+    public Canvas createOld(final DataList dataList) {// THIS is a Copy from abstractSingleItemPanel :-(
+        final List<Data> items = dataList.getAll();
+        final Data years = getData(items, getDatakey());
+        final DataItem[] yearsItems = years.getItems();
+
+        final String v1 = yearsItems[0].getStringValue().replace(" ", ", ");
+
+        final Label old = new Label(v1);
+        final HLayout layout = new HLayout();
+        layout.setWidth("400px");
+
+        final Label label = new Label(dataList.getLabel());
+        label.setWidth("200px");
+
+        final Canvas back = getBackButton(dataList.getState());
+
+        layout.addMember(label);
+        layout.addMember(old);
+        layout.addMember(back);
+
+        return layout;
+    }
+
+    @Override
+    public Canvas create(final DataList data) {
+        final VLayout layout = new VLayout();
+
+        final Canvas submit = getNextButton();
+        final Canvas widget = createWidget(data);
+
+        layout.addMember(widget);
+        layout.addMember(submit);
+
+        return layout;
+    }
+
+    @Override
+    public List<String> validate() {
+        final List<String> errors = new ArrayList<String>();
+        errors.addAll(ValidationHelper.checkForEmpty(this.inputItem, this.MSG));
+        try {
+            Integer.valueOf(this.inputItem.getValueAsString());
+        }
+        catch (final NumberFormatException e) {
+            errors.add(this.MSG.error_invalid_integer());
+        }
+        return errors;
+
+    }
+
+}
\ No newline at end of file
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/BunduFixPeriodPanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/BunduFixPeriodPanel.java	Wed Jul 18 15:34:53 2018 +0200
@@ -0,0 +1,200 @@
+/* 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.client.client.ui.fixation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.dive4elements.river.client.client.FLYSConstants;
+import org.dive4elements.river.client.client.ui.PanelHelper;
+import org.dive4elements.river.client.client.ui.ValidationHelper;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.DefaultData;
+import org.dive4elements.river.client.shared.model.DefaultDataItem;
+import org.dive4elements.river.client.shared.model.FixingsOverviewInfo;
+import org.dive4elements.river.client.shared.model.FixingsOverviewInfo.FixEvent;
+import org.dive4elements.river.client.shared.model.IntDataItem;
+import org.dive4elements.river.client.shared.model.IntegerArrayData;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+/**
+ * This UIProvider creates a panel for location or distance input.
+ *
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public class BunduFixPeriodPanel extends FixationPanel {
+    private static final long serialVersionUID = 1L;
+    /** The message class that provides i18n strings. */
+    protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
+    private TextItem inputItem;
+
+    long start;
+    long end;
+
+    private final ArrayList<FixEvent> events = new ArrayList<FixEvent>();
+
+    protected String getDatakey() {
+        return "singleyear";
+    }
+
+    @Override
+    public Canvas createWidget(final DataList data) {
+        instances.put(this.artifact.getUuid(), this);
+        final VLayout layout = new VLayout();
+
+        final Label title = new Label(data.get(0).getDescription());
+        title.setHeight("25px");
+
+        final DynamicForm form = new DynamicForm();
+        form.setNumCols(4);
+
+        this.inputItem = PanelHelper.createItem("YEAR_INPUT");
+        this.inputItem.setShowHint(true);
+        this.inputItem.setHint(this.MSG.common_input_hint_year());
+        this.inputItem.setShowHintInField(true);
+        this.inputItem.setShowTitle(false);
+        form.setFields(this.inputItem);
+
+        layout.addMember(title);
+        layout.addMember(form);
+
+        return layout;
+    }
+
+    @Override
+    public Canvas createOld(final DataList dataList) {
+        final List<Data> items = dataList.getAll();
+        final Data years = getData(items, getDatakey());
+        final DataItem[] yearsItems = years.getItems();
+
+        final String v1 = yearsItems[0].getStringValue().replace(" ", ", "); // multi.. single only allowed.. TODO: make createOld expecting single (general
+                                                                             // refactoring necessary)
+
+        final Label old = new Label(v1);
+        final HLayout layout = new HLayout();
+        layout.setWidth("400px");
+
+        final Label label = new Label(dataList.getLabel());
+        label.setWidth("200px");
+
+        final Canvas back = getBackButton(dataList.getState());
+
+        layout.addMember(label);
+        layout.addMember(old);
+        layout.addMember(back);
+
+        return layout;
+    }
+
+    /**
+     * This method returns the selected data.
+     *
+     * @return the selected/inserted data.
+     */
+    @Override
+    public Data[] getData() {
+        final List<String> errors = this.validate();
+        if (errors.size() > 0) {
+            showErrors(errors); // TODO: do not allow advance state
+        }
+        long startMillis = 0;
+        long endMillis = 0;
+        final DateTimeFormat df = DateTimeFormat.getFormat("dd.MM.yyyy");
+        if (this.inputItem != null && !this.inputItem.getValueAsString().isEmpty()) {
+            final List<Data> data = new ArrayList<Data>();
+            final String bezugsjahr = this.inputItem.getValueAsString().trim();
+            final DataItem yearsdata = new DefaultDataItem(getDatakey(), getDatakey(), bezugsjahr);
+            data.add(new DefaultData(getDatakey(), null, null, new DataItem[] { yearsdata }));
+
+            // start/end
+
+            final int bezugsjahrInt = Integer.valueOf(bezugsjahr);
+
+            startMillis = df.parse("01.01." + (bezugsjahrInt - 5)).getTime();
+            // ist; radio-auswahl erfolgt aber erst im nächsten schritt
+            endMillis = df.parse("31.12." + (bezugsjahrInt + 5)).getTime();
+
+            // events:
+            if (this.events.size() > 0) {
+                // filter by start/end
+                final ArrayList<FixEvent> temp = new ArrayList<FixEvent>();
+
+                for (final FixEvent e : this.events) {
+                    final long time = df.parse(e.getDate()).getTime();
+                    if (!(time >= startMillis && time <= endMillis)) {
+                        temp.add(e);
+                    }
+                }
+                this.events.removeAll(temp);
+
+                final IntDataItem[] arr = new IntDataItem[this.events.size()];
+                for (int i = 0, E = this.events.size(); i < E; i++) {
+                    try {
+                        final Integer v = new Integer(this.events.get(i).getCId());
+                        arr[i] = new IntDataItem("id", "id", v.intValue());
+                    }
+                    catch (final NumberFormatException nfe) {
+                        return data.toArray(new Data[data.size()]);
+                    }
+                }
+
+                final IntegerArrayData iad = new IntegerArrayData("events_temp", "events_temp", arr);
+
+                data.add(iad);
+            }
+
+            return data.toArray(new Data[data.size()]);
+        }
+        return new Data[0];
+    }
+
+    @Override
+    public final List<String> validate() {
+        final List<String> errors = new ArrayList<String>();
+        errors.addAll(ValidationHelper.checkForEmpty(this.inputItem, this.MSG));
+        try {
+            final int year = Integer.valueOf(this.inputItem.getValueAsString());
+            if (year < 1000 || year > 9999) {
+                errors.add(this.MSG.wrongFormat() + "(" + this.MSG.common_input_hint_year() + ")");
+            }
+        }
+        catch (final NumberFormatException e) {
+            errors.add(this.MSG.error_invalid_integer());
+        }
+        return errors;
+    }
+
+    @Override
+    public void setValues(final String cid, final boolean checked) {
+        // No user interaction, do nothing.
+    }
+
+    @Override
+    public boolean renderCheckboxes() {
+        // No selection, return false.
+        return false;
+    }
+
+    @Override
+    public void success(final FixingsOverviewInfo fixInfo) {
+        for (final FixEvent fe : fixInfo.getEvents()) {
+            this.events.add(fe);
+        }
+    }
+}
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixEventSelect.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixEventSelect.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixEventSelect.java	Wed Jul 18 15:34:53 2018 +0200
@@ -61,6 +61,24 @@
         final List<Data> list = dataList.getAll();
 
         final Data data = getData(list, "events");
+        final Canvas dataLayout = getEventDataLayout(data);
+
+        final HLayout layout = new HLayout();
+        layout.setWidth("400px");
+
+        final Label label = new Label(dataList.getLabel());
+        label.setWidth("200px");
+
+        final Canvas back = getBackButton(dataList.getState());
+
+        layout.addMember(label);
+        layout.addMember(dataLayout);
+        layout.addMember(back);
+
+        return layout;
+    }
+
+    public static final VLayout getEventDataLayout(final Data data) {
 
         final VLayout dataLayout = new VLayout();
         dataLayout.setWidth(130);
@@ -87,19 +105,7 @@
             }
         }
 
-        final HLayout layout = new HLayout();
-        layout.setWidth("400px");
-
-        final Label label = new Label(dataList.getLabel());
-        label.setWidth("200px");
-
-        final Canvas back = getBackButton(dataList.getState());
-
-        layout.addMember(label);
-        layout.addMember(dataLayout);
-        layout.addMember(back);
-
-        return layout;
+        return dataLayout;
     }
 
     /**
@@ -154,10 +160,4 @@
         }
     }
 
-    // public void dumpGWT(String cid) {
-    // GWT.log("Setting values for cId: " + cid);
-    // GWT.log("River: " + fixInfo.getRiver());
-    // GWT.log("Date: " + fixInfo.getEventByCId(cid).getDate());
-    // GWT.log("Name: " + fixInfo.getEventByCId(cid).getDescription());
-    // }
 }
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixGaugeSelectPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixGaugeSelectPanel.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixGaugeSelectPanel.java	Wed Jul 18 15:34:53 2018 +0200
@@ -48,11 +48,16 @@
     protected LinkedHashMap<String, String> mapValues;
 
     public FixGaugeSelectPanel() {
-        this.mapValues = new LinkedHashMap<String, String>();
-        this.mapValues.put("0", this.MESSAGES.gauge_mnq());
-        this.mapValues.put("1", this.MESSAGES.gauge_mq());
-        this.mapValues.put("2", this.MESSAGES.gauge_mhq());
-        this.mapValues.put("3", this.MESSAGES.gauge_hq5());
+        this.mapValues = getMapValues(this.MESSAGES);
+    }
+
+    public static final LinkedHashMap<String, String> getMapValues(final FLYSConstants MSG) {
+        final LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
+        mapValues.put("0", MSG.gauge_mnq());
+        mapValues.put("1", MSG.gauge_mq());
+        mapValues.put("2", MSG.gauge_mhq());
+        mapValues.put("3", MSG.gauge_hq5());
+        return mapValues;
     }
 
     @Override
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/Limit5SalixBehaviour.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/Limit5SalixBehaviour.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/Limit5SalixBehaviour.java	Wed Jul 18 15:34:53 2018 +0200
@@ -51,7 +51,7 @@
     @Override
     public List<String> validate(final List<String> errors, final String inputValueString) {
         if (inputValueString != null) {
-            final String[] values = inputValueString.trim().split(" ");
+            final String[] values = inputValueString.trim().replace("  ", " ").split(" ");
             if (values.length > 5) {
                 errors.add(this.MSG.error_limit_exceeded_salix());
             }
diff -r 465347d12990 -r c7e5285d434f gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/ValidationBehaviourSingleMultiInputItem.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/ValidationBehaviourSingleMultiInputItem.java	Wed Jul 18 12:20:01 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/ValidationBehaviourSingleMultiInputItem.java	Wed Jul 18 15:34:53 2018 +0200
@@ -65,6 +65,7 @@
             Integer.parseInt(sValue);
         }
         catch (final NumberFormatException e) {
+
             errors.add(this.MSG.wrongFormat() + ": " + sValue);
 
         }


More information about the Dive4Elements-commits mailing list