changeset 9624:02ca823ec9c6

zu Pos 20 Nachtrag; infrastructureChoice
author dnt_bjoernsen <d.tironi@bjoernsen.de>
date Fri, 11 Oct 2019 18:30:36 +0200
parents 677ff7ed9a60
children 07f02019065e
files artifacts/doc/conf/meta-data.xml artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationAccess.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodInfrastructure.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureServerClientXChange.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties backend/src/main/java/org/dive4elements/river/model/sinfo/Infrastructure.java backend/src/main/java/org/dive4elements/river/model/sinfo/InfrastructureValue.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/FloodInfrastructurePanel.java gwt-client/src/main/java/org/dive4elements/river/client/shared/model/InfrastructureServerClientXChange.java
diffstat 11 files changed, 456 insertions(+), 131 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/meta-data.xml	Thu Oct 10 17:33:56 2019 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Fri Oct 11 18:30:36 2019 +0200
@@ -328,6 +328,9 @@
                   <dc:when test="$out = 'sinfo_floodduration_curve'">
                     <dc:call-macro name="floodduration_curve_system" />
                   </dc:when>
+                  <dc:when test="$out = 'sinfo_floodduration_infrastructures'">
+                    <dc:call-macro name="predefined_infrastructures" />
+                  </dc:when>
                   <dc:when test="$out = 'uinfo_salix_line'">
                     <dc:call-macro name="longitudinal-section-prototype" />
                   </dc:when>
@@ -792,7 +795,8 @@
     </dc:macro>
 
     <dc:macro name="fix-wq-curve">
-      <dc:filter expr="($out_name = 'fix_wq_curve' and
+      <dc:filter
+        expr="($out_name = 'fix_wq_curve' and
                        (starts-with($facet_name, 'fix_analysis_events_wq') or
                        starts-with($facet_name, 'fix_reference_events_wq') or
                        starts-with($facet_name, 'fix_sector_average_wq') or
@@ -1410,6 +1414,28 @@
       </uinfo>
     </dc:macro>
 
+    <!-- XXXXXXX -->
+    <dc:macro name="predefined_infrastructures">
+      <infrastructures TODO="i10n">
+        <dc:context connection="system">
+          <dc:statement>
+            SELECT *
+            FROM infrastructure
+            WHERE river_id = ${river_id}
+          </dc:statement>
+          <dc:group expr="$group_id">
+            <infrastructure_group description="{dc:group-key()}">
+              <dc:for-each>
+                <!-- name="{$annotation_type_id}" -->
+                 <!-- not necessary: target_out="{$out}" -->
+                <infrastructure_type description="{$FILENAME}" factory="FAKE_FACTORY" group_label="{$group_id}" group_id="{$group_id}" type_id="{$annotation_type_id}" type_label="{$annotation_type_id}" />
+              </dc:for-each>
+            </infrastructure_group>
+          </dc:group>
+        </dc:context>
+      </infrastructures>
+    </dc:macro>
+
     <!-- wst-data -->
 
     <!-- model-waterlevels -->
@@ -3498,7 +3524,8 @@
     </dc:macro>
 
     <dc:macro name="sinfo_flowdepths_minmax">
-      <dc:filter expr="$a_state = 'state.sinfo.flow_depth_minmax' and 
+      <dc:filter
+        expr="$a_state = 'state.sinfo.flow_depth_minmax' and 
                      ( $facet_name = 'sinfo_facet_flow_depth_min' or 
                        $facet_name = 'sinfo_facet_flow_depth_bedheight_min' or 
                        $facet_name = 'sinfo_facet_flow_depth_bedheight_max' or 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationAccess.java	Thu Oct 10 17:33:56 2019 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationAccess.java	Fri Oct 11 18:30:36 2019 +0200
@@ -10,10 +10,13 @@
 
 package org.dive4elements.river.artifacts.sinfo.flood_duration;
 
+import java.util.List;
+
 import org.apache.log4j.Logger;
 import org.dive4elements.river.artifacts.access.RangeAccess;
 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
 import org.dive4elements.river.artifacts.sinfo.SinfoCalcMode;
+import org.dive4elements.river.artifacts.sinfo.flood_duration.InfrastructureServerClientXChange.Element;
 import org.dive4elements.river.artifacts.sinfo.flood_duration.RiversideRadioChoice.RiversideChoiceKey;
 
 /**
@@ -48,4 +51,8 @@
     public boolean getIsWspl() {
         return super.getBoolean("wspl").booleanValue();
     }
+
+    public List<Element> getInfrastructureChoices() {
+        return InfrastructureServerClientXChange.parse(super.getString("flood_infrastructure"));
+    }
 }
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java	Thu Oct 10 17:33:56 2019 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculation.java	Fri Oct 11 18:30:36 2019 +0200
@@ -9,6 +9,7 @@
  */
 package org.dive4elements.river.artifacts.sinfo.flood_duration;
 
+import java.util.List;
 import java.util.Set;
 
 import org.apache.commons.lang.math.DoubleRange;
@@ -20,6 +21,7 @@
 import org.dive4elements.river.artifacts.model.river.RiverInfoProvider;
 import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
+import org.dive4elements.river.artifacts.sinfo.flood_duration.InfrastructureServerClientXChange.Element;
 import org.dive4elements.river.artifacts.sinfo.tkhstate.WinfoArtifactWrapper;
 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils;
 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
@@ -77,6 +79,11 @@
         final FloodDurationCalculator calculator = new FloodDurationCalculator(this.context, riverInfoProvider);
 
         // FIXME: fetch from access (fetchInfrastructureTypes only for test purposes)
+        final List<Element> infrastructureChoicesnew = access.getInfrastructureChoices();
+        // int groupID =;
+        // int annottionTypeId =;
+
+        // Deprecated denke ich.
         final Set<String> infrastructureChoices = Infrastructure.fetchInfrastructureTypes(riverInfoProvider.getRiver(), calcRange.getMinimumDouble(),
                 calcRange.getMaximumDouble(), access.getRiverside().getAttributeKey());
 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodInfrastructure.java	Thu Oct 10 17:33:56 2019 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodInfrastructure.java	Fri Oct 11 18:30:36 2019 +0200
@@ -8,7 +8,15 @@
 
 package org.dive4elements.river.artifacts.sinfo.flood_duration;
 
+import org.dive4elements.artifactdatabase.ProtocolUtils;
+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.states.DefaultState;
+import org.dive4elements.river.model.River;
+import org.w3c.dom.Element;
 
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
@@ -26,4 +34,22 @@
 
         return "flood_infrastructure_panel";
     }
+
+    @Override
+    protected Element[] createItems(final ElementCreator cr, final Artifact artifact, final String name, final CallContext context) {
+        if (name.equals(getDatakey())) {
+            final Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
+            final Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
+            final Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
+            final D4EArtifact flys = (D4EArtifact) artifact;
+            final River river = new RiverAccess(flys).getRiver();
+            final String s = flys.getDataAsString(getDatakey());
+
+            value.setTextContent(s);
+            item.appendChild(label);
+            item.appendChild(value);
+            return new Element[] { item };
+        }
+        return new Element[] {};
+    }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureServerClientXChange.java	Fri Oct 11 18:30:36 2019 +0200
@@ -0,0 +1,137 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * 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.sinfo.flood_duration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+public class InfrastructureServerClientXChange {
+
+    // IMMER ABGLEICHEN MIT InfrastructureServerClientXChange.class IM CLIENT
+
+    private static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR";
+
+    private static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR";
+
+    private final List<Element> m_objects = new ArrayList<>();
+
+    public static class Element {
+
+        private final String m_groupId;
+        private final String m_groupLabel;
+        private final String m_typeId;
+        private final String m_typeLabel;
+
+        public Element(final String groupId, final String groupLabel, final String typeId, final String typeLabel) {
+            this.m_groupId = groupId;
+            this.m_groupLabel = groupLabel;
+            this.m_typeId = typeId;
+            this.m_typeLabel = typeLabel;
+        }
+
+        @Override
+        public boolean equals(final Object o) {
+            if (o == this)
+                return true;
+
+            if (!(o instanceof Element))
+                return false;
+
+            final Element compare = (Element) o;
+
+            return this.toKey().equals(compare.toKey());
+        }
+
+        @Override
+        public int hashCode() {
+            return toKey().hashCode();
+        }
+
+        private String toKey() {
+            return "" + this.m_groupId + '#' + this.m_typeId;
+        }
+
+        public String getGroupId() {
+            return this.m_groupId;
+        }
+
+        public String getTypeLabel() {
+            return this.m_typeLabel;
+        }
+
+        public Object getTypeId() {
+            return this.m_typeId;
+        }
+
+        public Object getGroupLabel() {
+            return this.m_groupLabel;
+        }
+    }
+
+    public void parseAndAdd(final String raw) {
+        this.m_objects.addAll(parse(raw));
+    }
+
+    public static List<Element> parse(final String raw) {
+        final List<Element> objects = new ArrayList<>();
+        if (raw.contains(TABLE_ROW_SEPARATOR)) {
+            final String[] rows = raw.split(TABLE_ROW_SEPARATOR);
+            for (final String row : rows) {
+                if (row.contains(TABLE_CELL_SEPARATOR)) {
+                    final String[] result = row.split(TABLE_CELL_SEPARATOR);
+                    objects.add(new Element(result[0], result[1], result[2], result[3]));
+                }
+            }
+        }
+        return objects;
+    }
+
+    public boolean containsObject(final Element infrastr) {
+        return this.m_objects.contains(infrastr);
+    }
+
+    public InfrastructureServerClientXChange() {
+    }
+
+    public final String parseListToDataString() {
+
+        // java.util.Collections.sort(list);
+        final StringBuilder builder = new StringBuilder();
+        for (final Element object : this.m_objects) {
+            builder.append(object.getGroupId());
+            builder.append(TABLE_CELL_SEPARATOR);
+            builder.append(object.getGroupLabel());
+            builder.append(TABLE_CELL_SEPARATOR);
+            builder.append(object.getTypeId());
+            builder.append(TABLE_CELL_SEPARATOR);
+            builder.append(object.getTypeLabel());
+            builder.append(TABLE_ROW_SEPARATOR);
+        }
+        return builder.toString();
+
+    }
+
+    public void addObject(final Element infrastr) {
+        this.m_objects.add(infrastr);
+    }
+
+    public void removeObject(final Element infrastr) {
+        this.m_objects.remove(infrastr);
+    }
+
+    public List<Element> getItems() {
+        return this.m_objects; // doof, dass es jetzt doch öffentlich ist :-(
+    }
+
+}
\ No newline at end of file
--- a/artifacts/src/main/resources/messages.properties	Thu Oct 10 17:33:56 2019 +0200
+++ b/artifacts/src/main/resources/messages.properties	Fri Oct 11 18:30:36 2019 +0200
@@ -874,6 +874,8 @@
 state.sinfo.riverside.option3 = Both Bank
 help.state.sinfo.riverside= ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.riverside
 
+state.sinfo.flood_infrastructure= Infrastructure BWaStr Choice
+
 state.bundu.wst.qs = Input for DNE/Q data
 state.sinfo.wqinput = Input for W/Q data
 state.sinfo.wqinput.option = wqinput-option
--- a/artifacts/src/main/resources/messages_de.properties	Thu Oct 10 17:33:56 2019 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Fri Oct 11 18:30:36 2019 +0200
@@ -874,6 +874,8 @@
 state.sinfo.riverside.option3 = Beide Uferseiten
 help.state.sinfo.riverside= ${help.url}/OnlineHilfe/SINFO#help.state.sinfo.riverside
 
+state.sinfo.flood_infrastructure= Auswahl der Infrastrukturen BWaStr
+
 state.bundu.wst.qs = Eingabe f\u00fcr UD/Q Daten
 state.sinfo.wqinput = Eingabe f\u00fcr W/Q Daten
 state.sinfo.wqinput.option = wqinput-option
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/Infrastructure.java	Thu Oct 10 17:33:56 2019 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/Infrastructure.java	Fri Oct 11 18:30:36 2019 +0200
@@ -71,13 +71,11 @@
 
     private List<InfrastructureValue> values;
 
-
     /***** CONSTRUCTORS *****/
 
     public Infrastructure() {
     }
 
-
     public Infrastructure(final River river, final String filename, final String kmrange_info, final String notes, final AnnotationType type,
             final AnnotationType group, final Integer year, final String dataprovider, final String evaluation_by) {
         this.river = river;
@@ -92,7 +90,6 @@
         this.values = new ArrayList<>();
     }
 
-
     /***** METHODS *****/
 
     @Id
@@ -233,8 +230,8 @@
      * Fetches from the database the infrastructure groups and types of a river's km range and river side(s)
      * as tab-separated strings ordered by the infrastructure group, then the type
      */
-    public static Set<String> fetchInfrastructureTypes(final River river, final double kmLo, final double kmHi,
-            final AttributeKey riverside) {
+    @Deprecated
+    public static Set<String> fetchInfrastructureTypes(final River river, final double kmLo, final double kmHi, final AttributeKey riverside) {
         final Set<String> groupTypes = new HashSet<>();
         for (final Infrastructure ifs : fetchInfrastructureTypeList(river, kmLo, kmHi, riverside))
             groupTypes.add(ifs.getGroup().getName() + "\t" + ifs.getType().getName());
@@ -245,18 +242,13 @@
      * Fetches from the database the list of infrastructure types of a river's km range and river side(s)
      * ordered by type group
      */
-    private static List<Infrastructure> fetchInfrastructureTypeList(final River river, final double kmLo, final double kmHi,
-            final AttributeKey riverside) {
+    private static List<Infrastructure> fetchInfrastructureTypeList(final River river, final double kmLo, final double kmHi, final AttributeKey riverside) {
 
         final Session session = SessionHolder.HOLDER.get();
 
-        final Query query = session.createQuery("FROM Infrastructure"
-                + " WHERE (river=:river)"
-                + " AND (id IN (SELECT v.infrastructure.id FROM InfrastructureValue v"
-                + "  WHERE (v.station BETWEEN (:kmLo - 0.0001) AND (:kmHi + 0.0001))"
-                + InfrastructureValue.getRiversideClause(riverside, "v.", "attr_id")
-                + "))"
-                + " ORDER BY group, type");
+        final Query query = session.createQuery("FROM Infrastructure" + " WHERE (river=:river)"
+                + " AND (id IN (SELECT v.infrastructure.id FROM InfrastructureValue v" + "  WHERE (v.station BETWEEN (:kmLo - 0.0001) AND (:kmHi + 0.0001))"
+                + InfrastructureValue.getRiversideClause(riverside, "v.", "attr_id") + "))" + " ORDER BY group, type");
         query.setParameter("river", river);
         query.setParameter("kmLo", new Double(kmLo));
         query.setParameter("kmHi", new Double(kmHi));
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/InfrastructureValue.java	Thu Oct 10 17:33:56 2019 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/InfrastructureValue.java	Fri Oct 11 18:30:36 2019 +0200
@@ -32,7 +32,6 @@
 import org.hibernate.Query;
 import org.hibernate.Session;
 
-
 /**
  * Hibernate binding for the DB table infrastructure_values
  *
@@ -57,7 +56,6 @@
 
     private Double height;
 
-
     /***** CONSTRUCTORS *****/
 
     public InfrastructureValue() {
@@ -77,7 +75,6 @@
         this(infrastructure, Double.valueOf(km), attribute, Double.valueOf(height));
     }
 
-
     /***** METHODS *****/
 
     @Id
@@ -140,8 +137,8 @@
      */
     public static List<InfrastructureValue> getValues(final Infrastructure parent, final double kmLo, final double kmHi) {
         final Session session = SessionHolder.HOLDER.get();
-        final Query query = session.createQuery("FROM InfrastructureValue WHERE (infrastructure=:parent)"
-                + " AND (station >= :kmLo - 0.0001) AND (station <= :kmHi + 0.0001)");
+        final Query query = session
+                .createQuery("FROM InfrastructureValue WHERE (infrastructure=:parent)" + " AND (station >= :kmLo - 0.0001) AND (station <= :kmHi + 0.0001)");
         query.setParameter("parent", parent);
         query.setParameter("kmLo", new Double(kmLo));
         query.setParameter("kmHi", new Double(kmHi));
@@ -154,12 +151,9 @@
     public static List<InfrastructureValue> getValues(final River river, final double kmLo, final double kmHi, final AttributeKey riverside,
             final Set<String> groupTypes) {
         final Session session = SessionHolder.HOLDER.get();
-        final Query query = session.createQuery("FROM InfrastructureValue"
-                + " WHERE (infrastructure.river=:river)"
-                + " AND (station BETWEEN :kmLo - 0.0001 AND :kmHi + 0.0001)"
-                + getRiversideClause(riverside, "", "attr_id")
-                + getGroupTypeClause(groupTypes, "")
-                + " ORDER BY station, attribute.id");
+        final Query query = session
+                .createQuery("FROM InfrastructureValue" + " WHERE (infrastructure.river=:river)" + " AND (station BETWEEN :kmLo - 0.0001 AND :kmHi + 0.0001)"
+                        + getRiversideClause(riverside, "", "attr_id") + getGroupTypeClause(groupTypes, "") + " ORDER BY station, attribute.id");
         query.setParameter("river", river);
         query.setParameter("kmLo", new Double(kmLo));
         query.setParameter("kmHi", new Double(kmHi));
@@ -177,8 +171,8 @@
         String clause = " AND (";
         String sep = "";
         for (final String groupType : groupTypes) {
-            clause += sep + "(" + tableprefix + "infrastructure.group.name='" + groupType.split("\t")[0] + "'"
-                    + " AND " + tableprefix + "infrastructure.type.name='" + groupType.split("\t")[1] + "')";
+            clause += sep + "(" + tableprefix + "infrastructure.group.name='" + groupType.split("\t")[0] + "'" + " AND " + tableprefix
+                    + "infrastructure.type.name='" + groupType.split("\t")[1] + "')";
             sep = " OR ";
         }
         if (sep.length() >= 1)
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/FloodInfrastructurePanel.java	Thu Oct 10 17:33:56 2019 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/FloodInfrastructurePanel.java	Fri Oct 11 18:30:36 2019 +0200
@@ -21,8 +21,9 @@
 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.InfrastructureServerClientXChange;
+import org.dive4elements.river.client.shared.model.InfrastructureServerClientXChange.Element;
 import org.dive4elements.river.client.shared.model.User;
-import org.dive4elements.river.client.shared.model.VegetationZoneServerClientXChange;
 
 import com.google.gwt.core.client.GWT;
 import com.smartgwt.client.types.ListGridFieldType;
@@ -32,13 +33,9 @@
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.events.ClickEvent;
 import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.ColorItem;
 import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.grid.events.CellSavedEvent;
-import com.smartgwt.client.widgets.grid.events.CellSavedHandler;
 import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
 import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
 import com.smartgwt.client.widgets.layout.HLayout;
@@ -54,16 +51,19 @@
     private static final long serialVersionUID = 1L;
 
     private static final String datakey = "flood_infrastructure";
-    final protected List<ListGridRecord> records = new ArrayList<ListGridRecord>();
     private ListGrid elements = new ListGrid();
 
     private final User m_user;
 
+    private final InfrastructureServerClientXChange xchangeHelper = new InfrastructureServerClientXChange();
+
+    private Button submit;
+
     public FloodInfrastructurePanel(final User user) {
         this.m_user = user;
     }
 
-    protected final ListGrid createTable(final Layout root, final DataList data, final String width, final boolean editable) {
+    protected final ListGrid createTable(final Layout root, final DataList data, final String width) {
 
         final Label title = new Label(data.get(0).getDescription());
         title.setHeight("35px");
@@ -76,43 +76,33 @@
         this.elements.setSortField("to");
         this.elements.setCanResizeFields(false);
 
-        this.elements.setCanEdit(editable);
-
-        final ListGridField internalNumber = new ListGridField("number", "number"); // valid only if no data is to be added
-        internalNumber.setCanSort(false);
-        internalNumber.setHidden(true);
+        this.elements.setCanEdit(false);
 
-        final ListGridField infrstrField = new ListGridField("infrstr", "Infrastruktur BWaStr");// this.MSG.uinfo_vegetation_zones_label());
-        infrstrField.setType(ListGridFieldType.TEXT);
-        infrstrField.setWidth("*"); // 245
-        infrstrField.setCanSort(false);
-        infrstrField.setCanDragResize(true);
-        infrstrField.setCanEdit(true); // neue Anforderung - doch nicht? ???
+        final ListGridField groupIdField = new ListGridField("group_id", "groupId");
+        groupIdField.setHidden(true);
 
-        final ListGridField fromField = new ListGridField("type", "Typ/Bezeichnung"); // VegZonePanelHelper.createIntTableField("from",
-        // this.MSG.uinfo_vegetation_zones_from(), true,
-        // getNormalizer(), getValidator()
-        // );
-        fromField.addCellSavedHandler(new CellSavedHandler() {
-            @Override
-            public void onCellSaved(final CellSavedEvent event) {
-                // updateValidationMsgLabel();
-            }
-        });
+        final ListGridField groupField = createField("group_label", "Infrastruktur BWaStr");// this.MSG.uinfo_vegetation_zones_label());
 
-        fromField.setCanEdit(false);
+        final ListGridField typeIdField = new ListGridField("type_id", "typeId");
+        typeIdField.setHidden(true);
+
+        final ListGridField typeField = createField("type_label", "Typ/Bezeichnung");// this.MSG.uinfo_vegetation_zones_label());
 
         final ListGridField removeField = PanelHelper.createRemoveField(this.elements, GWT.getHostPageBaseURL() + this.MSG.removeFeature());
         this.elements.addRecordClickHandler(new RecordClickHandler() { // adding another custom record-Remove-Handler which is not included in the
-            // Panelhelper TODO: MERGE WITH SupraRegionalPanel!!
             @Override
             public void onRecordClick(final RecordClickEvent event) {
                 if (event.getField().getName().equals(removeField.getName())) {
-                    // updateValidationMsgLabel();
+                    final ListGridRecord r = event.getRecord();
+                    final Element infrastr = new Element(r.getAttribute("group_id"), r.getAttribute("group_label"), r.getAttribute("type_id"),
+                            r.getAttribute("type_label"));
+                    FloodInfrastructurePanel.this.xchangeHelper.removeObject(infrastr);
+
+                    validateInput();
                 }
             }
         });
-        this.elements.setFields(infrstrField, fromField, removeField);
+        this.elements.setFields(groupIdField, groupField, typeIdField, typeField, removeField);
 
         root.setWidth(width);
         root.addMember(title);
@@ -120,35 +110,54 @@
         root.addMember(PanelHelper.getSpacer(3));
         root.addMember(PanelHelper.getSpacer(3));
         return this.elements;
+    }
 
+    private ListGridField createField(final String id, final String label) {
+        final ListGridField field = new ListGridField(id, label);// this.MSG.uinfo_vegetation_zones_label());
+        field.setType(ListGridFieldType.TEXT);
+        field.setWidth("*"); // 245
+        field.setCanSort(false);
+        field.setCanDragResize(true);
+        field.setCanEdit(false);
+        return field;
     }
 
     @Override
     public final VLayout create(final DataList data) {
         final VLayout layout = new VLayout();
 
+        final List<Data> items = data.getAll();
+        final Data str = getData(items, datakey);
+        final DataItem[] strItems = str.getItems();
+        if (strItems.length > 0)
+            this.xchangeHelper.parseAndAdd(strItems[0].getStringValue());
+
         final Canvas helper = createHelper(data);
         if (helper != null)
             this.helperContainer.addMember(helper);
 
-        final Canvas submit = getNextButton();
+        this.submit = (Button) getNextButton();
 
         final VLayout root = new VLayout();
         root.setWidth(450);
         createWidget(root, data);
 
         layout.addMember(root);
-        layout.addMember(submit);
-
-        // updateValidationMsgLabel();// init Text
+        layout.addMember(this.submit);
 
         return layout;
     }
 
-    protected Canvas createHelper(final DataList dataList) {
+    private void validateInput() {
+        if (this.xchangeHelper.getItems().size() > 0)
+            this.submit.enable();
+        else
+            this.submit.disable();
+    }
 
-        final DatacageWidgetData data = new DatacageWidgetData(this.artifact, this.m_user, "uinfo.inundation_duration.vegZoneSelect", "load-system:true",
-                false);
+    private Canvas createHelper(final DataList dataList) {
+
+        final DatacageWidgetData data = new DatacageWidgetData(this.artifact, this.m_user, "sinfo_floodduration_infrastructures", "load-system:true", false);
 
         final DatacageWidget datacage = new DatacageWidget(data);
 
@@ -170,81 +179,54 @@
     private void handlePlusClicked(final DatacageWidget datacage) {
         final List<TreeNode> selection = datacage.getPlainSelection();
         if (selection == null || selection.isEmpty()) {
-            SC.say("VegetationzonesTablePanel.this.MSG.warning()");
+            SC.say(FloodInfrastructurePanel.this.MSG.warning());
             return;
         }
 
-        final TreeNode selectedNode = selection.get(0);
+        for (final TreeNode selectedNode : selection) {
+            final String groupId = selectedNode.getAttribute("group_id"); // node-names from meta-data.xml
+            final String groupLabel = selectedNode.getAttribute("group_label");
+            final String typeId = selectedNode.getAttribute("type_id");
+            final String typeLabel = selectedNode.getAttribute("type_label");
 
-        /*
-         * the encoded veg-zones is either in 'data' or 'ids'. We need both, because we have the cases of stadnard vegzones and
-         * user-defined vegzones.
-         */
-        final String dataAttribute = selectedNode.getAttribute("data");
-        final String idsAttribute = selectedNode.getAttribute("ids");
-        final String vegZoneData = (dataAttribute == null || dataAttribute.trim().length() == 0) ? idsAttribute : dataAttribute;
+            if (isEmpty(groupId) || isEmpty(groupLabel) || isEmpty(typeId) || isEmpty(typeLabel))
+                continue;
 
-        // for (final ListGridRecord r : this.elements.getRecords()) {
-        // this.elements.removeData(r);
-        // }
-        // final List<VegetationZoneServerClientXChange> rows = VegetationZoneServerClientXChange.parse(data);
-        // for (final VegetationZoneServerClientXChange row : rows) {
-        // this.elements.addData(createEntry(row));
-        // }
+            final InfrastructureServerClientXChange.Element infrastr = new InfrastructureServerClientXChange.Element(groupId, groupLabel, typeId, typeLabel);
+            if (this.xchangeHelper.containsObject(infrastr))
+                continue;
 
+            this.xchangeHelper.addObject(infrastr);
+
+            this.elements.addData(createEntry(infrastr));
+        }
+        validateInput();
     }
 
-    public final ListGridRecord createEntry(final VegetationZoneServerClientXChange row) {
-
-        final String vegzone = row.getZoneName();
-        final Integer from = row.getMin_day_overflow();
-        final Integer to = row.getMax_day_overflow();
-        final String colorStr = row.getHexColor();
+    private boolean isEmpty(final String test) {
+        if (test == null)
+            return true;
+        if (test.trim().equals(""))
+            return true;
+        return false;
+    }
 
-        if (vegzone == null)
-            return null;
-
+    public final ListGridRecord createEntry(final InfrastructureServerClientXChange.Element row) {
         final ListGridRecord r = new ListGridRecord();
-        r.setAttribute("vegzone", vegzone);
-        r.setAttribute("from", from);
-        r.setAttribute("to", to);
-        r.setAttribute("color", colorStr);
-        r.setAttribute("number", this.records.size());
-        this.records.add(r);
+        r.setAttribute("group_id", row.getGroupId());
+        r.setAttribute("group_label", row.getGroupLabel());
+        r.setAttribute("type_id", row.getTypeId());
+        r.setAttribute("type_label", row.getTypeLabel());
         return r;
-
     }
 
     public void createWidget(final Layout root, final DataList data) {
 
-        this.elements = createTable(root, data, "420", true);
-
-        // this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), "*");
-        // this.vegzone.setColSpan(4);
-        // this.start = PanelHelper.createIntegerItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(),
-        // "*");
-        // this.end = PanelHelper.createIntegerItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), "*");
-        final VLayout fields = new VLayout();
-
-        final ColorItem colorPicker = new ColorItem();
-        colorPicker.setTitle(this.MSG.uinfo_vegetation_zone_color());
+        this.elements = createTable(root, data, "420");
 
-        colorPicker.setShowTitle(true);
-        colorPicker.setShowValueIconOnly(false);
-        colorPicker.setShowPickerIcon(true);
-        colorPicker.setColSpan(2);
-        colorPicker.setWidth(110);
-
-        final Button add = new Button(this.MSG.add_date()); // TODO: make key more generic or change to more specific
-
-        final DynamicForm form1 = new DynamicForm();
-
-        form1.setNumCols(5); // für Layout untereinander muss 2 eingestellt werden
-        // form1.setFields(this.vegzone, this.start, this.end, colorPicker);
-
-        fields.addMember(form1);
-        root.addMember(fields);
-        root.addMember(PanelHelper.getSpacer(10));
+        for (final Element item : this.xchangeHelper.getItems())
+            this.elements.addData(createEntry(item));
+        validateInput();
     }
 
     @Override
@@ -261,8 +243,18 @@
         final Data str = getData(items, datakey);
         final DataItem[] strItems = str.getItems();
 
-        // for (final VegetationZoneServerClientXChange entry : entries) {
-        final Label dateLabel = new Label("zone  (   asfd  - asdf )");
+        final List<Element> items1 = InfrastructureServerClientXChange.parse(strItems[0].getStringValue());
+
+        final StringBuilder builder = new StringBuilder();
+
+        for (final Element infrastr : items1) {
+            builder.append(infrastr.getGroupLabel()).append(" - ").append(infrastr.getTypeLabel()).append("; ");
+        }
+        if (builder.length() > 1)
+            builder.deleteCharAt(builder.length() - 2);
+        else
+            builder.append(" - keine Auswahl - (will never appear because the workflow is being disabled when the table is empty) ");
+        final Label dateLabel = new Label(builder.toString());
         dateLabel.setHeight("20px");
         vLayout.addMember(dateLabel);
 
@@ -280,10 +272,12 @@
 
         final ListGridRecord[] lgr = this.elements.getRecords();
         if (lgr.length == 0) {
-            // return new Data[0]; // TODO: Klären, ob Vegetationszonen-Auswahl Pflicht ist, ob es ein Fallback geben soll usw.
         }
+        final String dataStr = this.xchangeHelper.parseListToDataString();
 
-        final DataItem item = new DefaultDataItem(datakey, null, "VegetationZoneServerClientXChange.parseListToDataString(getZones(lgr))"); // DATA-key
+        final DataItem item = new DefaultDataItem(datakey, null,
+                dataStr.equals("") ? "Non-Empty Value -> createOld would be called (not necessary, because workflow is disabled when table is empty)"
+                        : dataStr);
         data.add(new DefaultData(datakey, null, null, new DataItem[] { item }));
         return data.toArray(new Data[data.size()]);
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/InfrastructureServerClientXChange.java	Fri Oct 11 18:30:36 2019 +0200
@@ -0,0 +1,137 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * 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.shared.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+public class InfrastructureServerClientXChange {
+
+    // IMMER ABGLEICHEN MIT InfrastructureServerClientXChange.class IM SERVER
+
+    private static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR";
+
+    private static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR";
+
+    private final List<Element> m_objects = new ArrayList<Element>();
+
+    public static class Element {
+
+        private final String m_groupId;
+        private final String m_groupLabel;
+        private final String m_typeId;
+        private final String m_typeLabel;
+
+        public Element(final String groupId, final String groupLabel, final String typeId, final String typeLabel) {
+            this.m_groupId = groupId;
+            this.m_groupLabel = groupLabel;
+            this.m_typeId = typeId;
+            this.m_typeLabel = typeLabel;
+        }
+
+        @Override
+        public boolean equals(final Object o) {
+            if (o == this)
+                return true;
+
+            if (!(o instanceof Element))
+                return false;
+
+            final Element compare = (Element) o;
+
+            return this.toKey().equals(compare.toKey());
+        }
+
+        @Override
+        public int hashCode() {
+            return toKey().hashCode();
+        }
+
+        private String toKey() {
+            return "" + this.m_groupId + '#' + this.m_typeId;
+        }
+
+        public String getGroupId() {
+            return this.m_groupId;
+        }
+
+        public String getTypeLabel() {
+            return this.m_typeLabel;
+        }
+
+        public Object getTypeId() {
+            return this.m_typeId;
+        }
+
+        public Object getGroupLabel() {
+            return this.m_groupLabel;
+        }
+    }
+
+    public void parseAndAdd(final String raw) {
+        this.m_objects.addAll(parse(raw));
+    }
+
+    public static List<Element> parse(final String raw) {
+        final List<Element> objects = new ArrayList<Element>();
+        if (raw.contains(TABLE_ROW_SEPARATOR)) {
+            final String[] rows = raw.split(TABLE_ROW_SEPARATOR);
+            for (final String row : rows) {
+                if (row.contains(TABLE_CELL_SEPARATOR)) {
+                    final String[] result = row.split(TABLE_CELL_SEPARATOR);
+                    objects.add(new Element(result[0], result[1], result[2], result[3]));
+                }
+            }
+        }
+        return objects;
+    }
+
+    public boolean containsObject(final Element infrastr) {
+        return this.m_objects.contains(infrastr);
+    }
+
+    public InfrastructureServerClientXChange() {
+    }
+
+    public final String parseListToDataString() {
+
+        // java.util.Collections.sort(list);
+        final StringBuilder builder = new StringBuilder();
+        for (final Element object : this.m_objects) {
+            builder.append(object.getGroupId());
+            builder.append(TABLE_CELL_SEPARATOR);
+            builder.append(object.getGroupLabel());
+            builder.append(TABLE_CELL_SEPARATOR);
+            builder.append(object.getTypeId());
+            builder.append(TABLE_CELL_SEPARATOR);
+            builder.append(object.getTypeLabel());
+            builder.append(TABLE_ROW_SEPARATOR);
+        }
+        return builder.toString();
+
+    }
+
+    public void addObject(final Element infrastr) {
+        this.m_objects.add(infrastr);
+    }
+
+    public void removeObject(final Element infrastr) {
+        this.m_objects.remove(infrastr);
+    }
+
+    public List<Element> getItems() {
+        return this.m_objects; // doof, dass es jetzt doch öffentlich ist :-(
+    }
+
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org