[PATCH] Predefined artifact for standard vegetation zones

Wald Commits scm-commit at wald.intevation.org
Fri Sep 28 13:44:13 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1538135052 -7200
# Node ID 8b7bf26b878206a3d1c79739ffa3b7e4a353d137
# Parent  3f230fe8eb196086d918fbf1ba2b6f440c6335cf
Predefined artifact for standard vegetation zones.
Some minor adaptions.

diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/doc/conf/meta-data.xml
--- a/artifacts/doc/conf/meta-data.xml	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Fri Sep 28 13:44:12 2018 +0200
@@ -256,7 +256,7 @@
                     <dc:call-macro name="cross_sections" />
                     <dc:call-macro name="basedata_5_flood-protections" />
                     <dc:call-macro name="hyks" />
-                    <dc:call-macro name="predefined_vegetation_zones_cs" />
+                    <dc:call-macro name="predefined_vegetation_zones" />
                   </dc:when>
                   <dc:comment> Duration curve </dc:comment>
                   <dc:when test="$out = 'duration_curve'">
@@ -341,8 +341,7 @@
                     <dc:call-macro name="longitudinal-section-prototype" />
                   </dc:when>
                   <dc:when test="$out = 'uinfo.inundation_duration.vegzoneselect'">
-                    <dc:variable name="vegzonedata" expr="dc:defaultvegetationzone($river)"></dc:variable>
-                    <defaultVegetationZone factory="dummy" target_out="{$out}" data="{$vegzonedata}"></defaultVegetationZone>
+                    <dc:call-macro name="predefined_vegetation_zones" />
                   </dc:when>
                   <dc:when test="$out = 'bundu_wspl_longitudinal_section'">
                     <dc:call-macro name="longitudinal-section-prototype" />
@@ -1331,14 +1330,15 @@
       </hyks>
     </dc:macro>
 
- <!-- Default Vegetation Zones -->
-    <dc:macro name="predefined_vegetation_zones_cs">
-      <U-INFO>
-        <vegetation_zones> 
-          <dc:variable name="vegzonedata" expr="dc:defaultvegetationzone($river)"></dc:variable>
-            <defaultVegetationZone factory="dummy" target_out="{$out}" data="{$vegzonedata}"/>         
+    <!-- Default Vegetation Zones -->
+    <dc:macro name="predefined_vegetation_zones">
+      <uinfo>
+        <vegetation_zones>
+          <dc:variable name="vegzonedata" expr="dc:defaultvegetationzone($river)"/>
+
+          <defaultVegetationZone factory="predefined_vegetation_zonesf" target_out="{$out}" ids="{$vegzonedata}"/>         
         </vegetation_zones>
-      </U-INFO>
+      </uinfo>
     </dc:macro>
 
     <!-- wst-data -->
@@ -3779,10 +3779,7 @@
           <vegetation_zones>
             <dc:for-each>
               <dc:variable name="vegzonedata" expr="dc:data_from_artifact($a_gid,'vegzones')" />
-              <dc:variable name="vegzonedatalabel" expr="dc:get('ld_from')" />
-              <dc:variable name="label_temp" type="string" expr="dc:coalesce($collection_name, dc:toString($collection_gid))" />
-              <dc:variable name="fromkm" type="number" expr="dc:fromValue(dc:get('ld_mode'), dc:get('ld_locations'), dc:get('ld_from'))" />
-              <dc:variable name="tokm" type="number" expr="dc:fromValue(dc:get('ld_mode'), dc:get('ld_locations'), dc:get('ld_to'))" />
+              <dc:variable name="label_temp" type="string" expr="concat(dc:get('ld_f'), ' km - ', dc:get('ld_t'), ' km')" />
 
               <dc:element name="${facet_name}">
                 <dc:attribute name="factory" value="uinfo" />
@@ -3793,8 +3790,6 @@
                 <dc:attribute name="ids" value="${facet_num}" />
                 <!-- veg zones string as attribute -->
                 <dc:attribute name="data" value="${vegzonedata}" />
-                <dc:attribute name="from_km" value="${fromkm}" />
-                <dc:attribute name="to_km" value="${tokm}" /> 
               </dc:element>
             </dc:for-each>
           </vegetation_zones>
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/model/river/MainWstValuesCalculator.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/river/MainWstValuesCalculator.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/river/MainWstValuesCalculator.java	Fri Sep 28 13:44:12 2018 +0200
@@ -31,10 +31,11 @@
 
     private final Map<String, MainValueQPosition> positions;
 
-    private static class MainValueQPosition {
+    static class MainValueQPosition {
 
-        private final Map<Gauge, QPosition> gaugePositions = new HashMap<>();
-        private QPosition refGaugePositions = null;
+        public final Map<Gauge, QPosition> gaugePositions = new HashMap<>();
+
+        public QPosition refGaugePositions = null;
     }
 
     public static MainWstValuesCalculator forRiver(final CallContext context, final River river, final DoubleRange calcRange, final String... mainValueNames) {
@@ -93,7 +94,7 @@
 
     public boolean hasPosition(final String mainValueName) {
 
-        final MainValueQPosition position = this.positions.get(mainValueName);
+        final MainValueQPosition position = this.positions.get(mainValueName.toUpperCase());
         if (position == null)
             throw new IllegalArgumentException();
 
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedchannel/PredefinedChannelArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedchannel/PredefinedChannelArtifact.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/predefinedchannel/PredefinedChannelArtifact.java	Fri Sep 28 13:44:12 2018 +0200
@@ -33,10 +33,11 @@
  * Display of a river channel data series loaded from database
  *
  * @author Matthias Schäfer
- *
  */
 public class PredefinedChannelArtifact extends AbstractStaticStateArtifact implements FacetTypes {
 
+    private static final long serialVersionUID = 1L;
+
     /** The log for this class. */
     private static Logger log = Logger.getLogger(PredefinedChannelArtifact.class);
 
@@ -48,7 +49,7 @@
         FacetActivity.Registry.getInstance().register(NAME, FacetActivity.INACTIVE);
     }
 
-    public static final String STATIC_STATE_NAME = "state.predefined_channel.static";
+    private static final String STATIC_STATE_NAME = "state.predefined_channel.static";
 
     /**
      * Trivial Constructor.
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/UINFOArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/UINFOArtifact.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/UINFOArtifact.java	Fri Sep 28 13:44:12 2018 +0200
@@ -47,6 +47,8 @@
 
     private static final String FIELD_MODE = "calculation_mode";
 
+    public static final String FIELD_VEGZONES = "vegzones";
+
     static {
         // Active/deactivate facets.
         // BEWARE: we can only define one activity for "uinfo", so we use the artifact
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/PredefinedVegetationZonesArtifact.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/PredefinedVegetationZonesArtifact.java	Fri Sep 28 13:44:12 2018 +0200
@@ -0,0 +1,117 @@
+/** 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.uinfo.salix;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.artifactdatabase.state.DefaultOutput;
+import org.dive4elements.artifactdatabase.state.Facet;
+import org.dive4elements.artifactdatabase.state.FacetActivity;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.ArtifactFactory;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.artifacts.common.utils.XMLUtils;
+import org.dive4elements.river.artifacts.AbstractStaticStateArtifact;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.artifacts.states.StaticState;
+import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
+import org.dive4elements.river.artifacts.uinfo.vegetationzones.VegetationZonesCrossSectionProcessor;
+import org.w3c.dom.Document;
+
+/**
+ * Display of vegetation zones loaded from database
+ *
+ * @author Gernot Belger
+ *
+ */
+public class PredefinedVegetationZonesArtifact extends AbstractStaticStateArtifact implements FacetTypes {
+
+    private static final long serialVersionUID = 1L;
+
+    /** Artifact name. */
+    private static final String NAME = "predefined_vegetation_zones";
+
+    private static final String DEFAULT_VEGZONES_DESCRIPTION = "uinfo_facet_vegetation_default_zones_cross_section.description";
+
+    private static final String STATIC_STATE_NAME = "state.predefined_vegetation_zones.static";
+
+    static {
+        // TODO: Move to configuration.
+        FacetActivity.Registry.getInstance().register(NAME, FacetActivity.INACTIVE);
+    }
+
+    /** The log for this class. */
+    private static Logger log = Logger.getLogger(PredefinedVegetationZonesArtifact.class);
+
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+    @Override
+    protected void initStaticState() {
+
+        final StaticState state = new StaticState(STATIC_STATE_NAME);
+        final DefaultOutput output = new DefaultOutput("general", "general", "image/png", "chart");
+
+        final List<Facet> facets = getFacets(STATIC_STATE_NAME);
+        output.addFacets(facets);
+        state.addOutput(output);
+
+        setStaticState(state);
+    }
+
+    /**
+     * Gets called from factory, to set things up.
+     */
+    @Override
+    public void setup(final String identifier, final ArtifactFactory factory, final Object context, final CallMeta callMeta, final Document data,
+            final List<Class> loadFacets) {
+
+        if (log.isDebugEnabled())
+            log.debug(XMLUtils.toString(data));
+
+        final String vegZoneData = getDatacageIDValue(data);
+
+        createFacets(callMeta, vegZoneData);
+
+        super.setup(identifier, factory, context, callMeta, data, loadFacets);
+    }
+
+    private void createFacets(final CallMeta callMeta, final String vegZoneData) {
+        if (vegZoneData == null)
+            return;
+
+        addStringData(UINFOArtifact.FIELD_VEGZONES, vegZoneData);
+
+        final String seriesName = Resources.getMsg(callMeta, DEFAULT_VEGZONES_DESCRIPTION);
+
+        final List<Facet> facets = new ArrayList<>(1);
+        facets.add(VegetationZonesCrossSectionProcessor.createVegetationZonesCrossSectionFacet(seriesName));
+        addFacets(STATIC_STATE_NAME, facets);
+    }
+
+    @Override
+    protected void initialize(final Artifact artifact, final Object context, final CallMeta meta) {
+        // do not clone facets, etc. from master artifact
+
+        log.debug("initialize");
+        importData((D4EArtifact) artifact, "river");
+        importData((D4EArtifact) artifact, "ld_from");
+        importData((D4EArtifact) artifact, "ld_to");
+
+        log.debug("ld_from " + getDataAsString("ld_from"));
+        log.debug("ld_to " + getDataAsString("ld_to"));
+    }
+}
\ No newline at end of file
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineAccess.java	Fri Sep 28 13:44:12 2018 +0200
@@ -127,5 +127,4 @@
         }
         return null;
     }
-
 }
\ No newline at end of file
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java	Fri Sep 28 13:44:12 2018 +0200
@@ -10,7 +10,6 @@
 package org.dive4elements.river.artifacts.uinfo.salix;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Map.Entry;
 import java.util.NavigableMap;
@@ -43,16 +42,13 @@
     private static final String MAIN_VALUE_HQ5 = "HQ5";
 
     private static final double SALIX_DISTANCE = 2.31;
-    private final List<ResultRow> rows = new ArrayList<>();
 
     private final RiverInfoProvider riverInfoProvider;
 
-
     public SalixLineCalculator(final RiverInfoProvider riverInfoProvider) {
         this.riverInfoProvider = riverInfoProvider;
     }
 
-
     /**
      * Calculate the salix line result rows
      */
@@ -65,17 +61,30 @@
         final WINFOArtifact winfo = new WinfoArtifactWrapper(uinfo);
         winfo.addStringData("ld_mode", "distance");
         winfo.addStringData("ld_step", "100");
-        for (final double station : new ComputationRangeAccess(winfo).getKms()) {
-            this.rows.add(createRow(mainWstValues, station, rangeScenarios));
+
+        final List<ResultRow> rows = new ArrayList<>();
+        for (final double station : new ComputationRangeAccess(winfo).getKms())
+            rows.add(createRow(mainWstValues, station, rangeScenarios));
+
+        final SalixLineCalculationResult result = createResult(scenarioType, scenarioLabels, rangeString, additionalString, rows);
+        results.addResult(result, problems);
+    }
+
+    private SalixLineCalculationResult createResult(final ScenarioType scenarioType, final String[] scenarioLabels, final String rangeString,
+            final String additionalString, final List<ResultRow> rows) {
+
+        switch (scenarioType) {
+        case REGIONAL:
+            return new SalixLineCalculationRegionalResult("Salix-regional", scenarioLabels, rangeString, additionalString, rows);
+
+        case SUPRAREGIONAL:
+            return new SalixLineCalculationSupraRegionalResult("Salix-supra", scenarioLabels, rangeString, additionalString, rows);
+
+        case HISTORICAL:
+            return new SalixLineCalculationHistoricalResult("Salix-hist", scenarioLabels, rangeString, additionalString, rows);
+        default:
+            return new SalixLineCalculationResult("Salix-simple", rows);
         }
-        if (scenarioType == ScenarioType.REGIONAL)
-            results.addResult(new SalixLineCalculationRegionalResult("Salix-regional", scenarioLabels, rangeString, additionalString, this.rows), problems);
-        else if (scenarioType == ScenarioType.SUPRAREGIONAL)
-            results.addResult(new SalixLineCalculationSupraRegionalResult("Salix-supra", scenarioLabels, rangeString, additionalString, this.rows), problems);
-        else if (scenarioType == ScenarioType.HISTORICAL)
-            results.addResult(new SalixLineCalculationHistoricalResult("Salix-hist", scenarioLabels, rangeString, additionalString, this.rows), problems);
-        else
-            results.addResult(new SalixLineCalculationResult("Salix-simple", this.rows), problems);
     }
 
     private MainWstValuesCalculator fetchGaugeMainValuePositions2(final Calculation problems) {
@@ -169,14 +178,27 @@
         return noScen;
     }
 
-    /**
-     * Searches the row of a station in a result rows collection
-     */
-    private ResultRow searchStation(final double station, final Collection<ResultRow> rows) {
-        for (final ResultRow row : rows) {
-            if (row.getDoubleValue(GeneralResultType.station) > station + 0.0001)
-                return row;
-        }
-        return null;
-    }
-}
+    // /**
+    // * Find and return a height (iota, w main value) of a station in a previously calculated result
+    // */
+    // public double fetchStationHeight(final double station, final AbstractResultType resultType,
+    // final SalixLineCalculationResult result) {
+    //
+    // // Search the station in the previously calculated result rows
+    // final ResultRow stationRow = searchStation(station, result.getRows());
+    // if (stationRow != null)
+    // return stationRow.getDoubleValue(resultType);
+    // return Double.NaN;
+    // }
+
+    // /**
+    // * Searches the row of a station in a result rows collection
+    // */
+    // private ResultRow searchStation(final double station, final Collection<ResultRow> rows) {
+    // for (final ResultRow row : rows) {
+    // if (row.getDoubleValue(GeneralResultType.station) > station + 0.0001)
+    // return row;
+    // }
+    // return null;
+    // }
+}
\ No newline at end of file
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java	Fri Sep 28 13:44:12 2018 +0200
@@ -62,7 +62,9 @@
             rows.add(row2);
         }
 
-        final VegetationZonesCalculationResult result = new VegetationZonesCalculationResult("Ergebnis 1", rows);
+        final String label = String.format("%.3f - %.3f", calcRange.getMinimumDouble(), calcRange.getMaximumDouble());
+
+        final VegetationZonesCalculationResult result = new VegetationZonesCalculationResult(label, rows);
 
         results.addResult(result, problems);
 
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCrossSectionFacet.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCrossSectionFacet.java	Fri Sep 28 13:44:12 2018 +0200
@@ -0,0 +1,63 @@
+/** 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.uinfo.vegetationzones;
+
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.model.BlackboardDataFacet;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.exports.CrossSectionGenerator;
+
+/**
+ * @author Gernot Belger
+ *
+ */
+public final class VegetationZonesCrossSectionFacet extends BlackboardDataFacet implements FacetTypes {
+
+    private static final long serialVersionUID = 1L;
+
+    public VegetationZonesCrossSectionFacet(final String name, final String description) {
+        super(0, name, description);
+
+        this.metaData.put("X", CrossSectionGenerator.I18N_XAXIS_LABEL);
+        this.metaData.put("Y", CrossSectionGenerator.I18N_YAXIS_LABEL);
+    }
+
+    /**
+     * Returns the data this facet requires.
+     *
+     * @param artifact
+     *            the owner artifact.
+     * @param context
+     *            the CallContext (ignored).
+     *
+     * @return
+     *         the data as PredefinedChannelQueryCalculationResult
+     */
+    @Override
+    public Object getData(final Artifact artifact, final CallContext context) {
+
+        final VegetationzonesAccess vAccess = new VegetationzonesAccess((D4EArtifact) artifact);
+        return VegetationZoneServerClientXChange.parse(vAccess.getVegZones());
+    }
+
+    /**
+     * Create a deep copy of this Facet.
+     *
+     * @return a deep copy.
+     */
+    @Override
+    public VegetationZonesCrossSectionFacet deepCopy() {
+        final VegetationZonesCrossSectionFacet copy = new VegetationZonesCrossSectionFacet(this.name, this.description);
+        copy.set(this);
+        return copy;
+    }
+}
\ No newline at end of file
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCrossSectionProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCrossSectionProcessor.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCrossSectionProcessor.java	Fri Sep 28 13:44:12 2018 +0200
@@ -19,11 +19,10 @@
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
 import org.dive4elements.artifacts.DataProvider;
-import org.dive4elements.river.artifacts.common.AbstractCalculationResult;
+import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.common.AbstractProcessor;
 import org.dive4elements.river.artifacts.model.CrossSectionFacetUtils;
 import org.dive4elements.river.artifacts.model.river.MainWstValuesCalculator;
-import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
 import org.dive4elements.river.exports.CrossSectionGenerator;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.jfree.StripedAreaDataset;
@@ -42,7 +41,6 @@
 
     public static final String FACET_VEGETATION_ZONES_CROSS_SECTION = "uinfo_facet_vegetation_zones_cross_section";
 
-    private static final String FACET_VEGETATION_ZONES_CROSS_SECTION_DESCRIPTION = "uinfo_facet_vegetation_zones_cross_section.description";
 
     private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>();
 
@@ -50,10 +48,9 @@
         HANDLED_FACET_TYPES.add(FACET_VEGETATION_ZONES_CROSS_SECTION);
     }
 
-    public static Facet createVegetationZonesCrossSectionFacet(final CallContext context, final String hash, final String id,
-            final AbstractCalculationResult result, final int index) {
-        return AbstractProcessor.createFacet(context, hash, id, result, index, CrossSectionGenerator.I18N_XAXIS_LABEL, FACET_VEGETATION_ZONES_CROSS_SECTION,
-                FACET_VEGETATION_ZONES_CROSS_SECTION_DESCRIPTION);
+    public static Facet createVegetationZonesCrossSectionFacet(final String description) {
+
+        return new VegetationZonesCrossSectionFacet(FACET_VEGETATION_ZONES_CROSS_SECTION, description);
     }
 
     public static void generateSeries(final CrossSectionGenerator generator, final ArtifactAndFacet bundle, final CallContext context,
@@ -70,7 +67,7 @@
             final StripedAreaDataset dataset = new StripedAreaDataset(theme);
 
             final Artifact artifact = bundle.getArtifact();
-            final VegetationzonesAccess vAccess = new VegetationzonesAccess((UINFOArtifact) artifact);
+            final VegetationzonesAccess vAccess = new VegetationzonesAccess((D4EArtifact) artifact);
             final River river = vAccess.getRiver();
             final List<VegetationZoneServerClientXChange> zones = VegetationZoneServerClientXChange.parse(vAccess.getVegZones());
 
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesState.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesState.java	Fri Sep 28 13:44:12 2018 +0200
@@ -21,6 +21,7 @@
 import org.dive4elements.river.artifacts.model.EmptyFacet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.ReportFacet;
+import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.states.DefaultState;
 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
 
@@ -34,6 +35,8 @@
 
     private static final long serialVersionUID = 1L;
 
+    private static final String FACET_VEGETATION_ZONES_CROSS_SECTION_DESCRIPTION = "uinfo_facet_vegetation_zones_cross_section.description";
+
     /**
      * From this state can only be continued trivially.
      */
@@ -80,7 +83,10 @@
 
         if (!resultList.isEmpty()) {
 
-            facets.add(VegetationZonesCrossSectionProcessor.createVegetationZonesCrossSectionFacet(context, hash, this.id, resultList.get(0), 0));
+            final String label = resultList.get(0).getLabel();
+            final String facetDescription = Resources.getMsg(context.getMeta(), FACET_VEGETATION_ZONES_CROSS_SECTION_DESCRIPTION, new Object[] { label });
+
+            facets.add(VegetationZonesCrossSectionProcessor.createVegetationZonesCrossSectionFacet(facetDescription));
 
             final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id);
             final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id);
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationzonesAccess.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationzonesAccess.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationzonesAccess.java	Fri Sep 28 13:44:12 2018 +0200
@@ -10,10 +10,9 @@
 
 package org.dive4elements.river.artifacts.uinfo.vegetationzones;
 
+import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.access.RangeAccess;
-import org.dive4elements.river.artifacts.common.EpochYearAccessHelper;
 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
-import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode;
 
 /**
  * Access to the flow depth calculation type specific SInfo artifact data.
@@ -25,24 +24,16 @@
  */
 final class VegetationzonesAccess extends RangeAccess {
 
-    private final EpochYearAccessHelper helper;
-
     // Fields from state:
     // calculation_mode (String)
     // ld_from, ld_to,ld_step
     // vegzones (String)
 
-    public VegetationzonesAccess(final UINFOArtifact uinfo) {
+    public VegetationzonesAccess(final D4EArtifact uinfo) {
         super(uinfo);
-
-        /* assert calculation mode */
-        final UinfoCalcMode calculationMode = uinfo.getCalculationMode();
-        this.helper = new EpochYearAccessHelper(uinfo);
-        assert (calculationMode == UinfoCalcMode.uinfo_vegetation_zones);
     }
 
     public String getVegZones() {
-        return super.getString("vegzones");
+        return super.getString(UINFOArtifact.FIELD_VEGZONES);
     }
-
 }
\ No newline at end of file
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Fri Sep 28 13:44:12 2018 +0200
@@ -1193,7 +1193,8 @@
 uinfo_facet_salix_scenario = Iota Scenario, {0}
 uinfo_facet_salix_scenario.filtered.description = Iota Scenario, {0}
 uinfo_facet_salix_scenario.raw.description = Iota Scenario, {0} (raw data)
-uinfo_facet_vegetation_zones_cross_section.description = Vegetation Zones
+uinfo_facet_vegetation_zones_cross_section.description = Vegetation Zones ({0})
+uinfo_facet_vegetation_default_zones_cross_section.description = Standard Vegetation Zones
 uinfo_salix_scenario_deltaw = \u0394MW={0}
 uinfo_salix_scenario_supraregional = supraregional
 uinfo_salix_scenario_historical = historical
diff -r 3f230fe8eb19 -r 8b7bf26b8782 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Fri Sep 28 10:16:12 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Fri Sep 28 13:44:12 2018 +0200
@@ -1193,7 +1193,8 @@
 uinfo_facet_salix_scenario = Iota Szenario, {0}
 uinfo_facet_salix_scenario.filtered.description = Iota Szenario, {0}
 uinfo_facet_salix_scenario.raw.description = Iota Szenario, {0} (Rohdaten)
-uinfo_facet_vegetation_zones_cross_section.description = Vegetationszonen
+uinfo_facet_vegetation_zones_cross_section.description = Vegetationszonen ({0})
+uinfo_facet_vegetation_default_zones_cross_section.description = Standardvegetationszonen
 uinfo_salix_scenario_deltaw = \u0394MW={0}
 uinfo_salix_scenario_supraregional = \u00fcberregional
 uinfo_salix_scenario_historical = historisch
diff -r 3f230fe8eb19 -r 8b7bf26b8782 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	Fri Sep 28 10:16:12 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Fri Sep 28 13:44:12 2018 +0200
@@ -831,7 +831,7 @@
 uinfo_salix_line_export = Iota Export
 uinfo_vegetation_zones_export = Vegetation Zones Export
 uinfo_vegetation_zones_report = Vegetation  Zones Report
-defaultVegetationZone = Default Vegetation Zone
+defaultVegetationZone = Standard Vegetation Zones
 
 vegetation_zones = Vegetation Zones
 uinfo_vegetation_zone_overlap = Ranges are overlapping.
diff -r 3f230fe8eb19 -r 8b7bf26b8782 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	Fri Sep 28 10:16:12 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Fri Sep 28 13:44:12 2018 +0200
@@ -831,7 +831,7 @@
 uinfo_salix_line_export = Iota Export
 uinfo_vegetation_zones_export = Vegetationszonen Export
 uinfo_vegetation_zones_report = Vegetationszonen Bericht
-defaultVegetationZone = Standardvegetationszone
+defaultVegetationZone = Standardvegetationszonen
 
 vegetation_zones = Vegetationszonen
 uinfo_vegetation_zone_overlap = Bereiche \u00fcberlappen.
diff -r 3f230fe8eb19 -r 8b7bf26b8782 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java	Fri Sep 28 10:16:12 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java	Fri Sep 28 13:44:12 2018 +0200
@@ -12,7 +12,6 @@
 
 import org.dive4elements.river.client.client.ui.DatacageWidget;
 import org.dive4elements.river.client.client.ui.DatacageWidgetData;
-import org.dive4elements.river.client.shared.model.ArtifactDescription;
 import org.dive4elements.river.client.shared.model.DataList;
 import org.dive4elements.river.client.shared.model.User;
 
@@ -29,7 +28,7 @@
 
     private static final long serialVersionUID = 1L;
 
-    private final static Double DELTA = 0.0000001;
+    // private final static Double DELTA = 0.0000001;
 
     private final User user;
 
@@ -39,7 +38,7 @@
     // private final Double vegZoneTo = null;
     // private final Label kmOverlapLabel = new Label();
 
-    // TODO: in der LV steht, dass eine Warnung herausgegeben werden soll, wenn der kmBereich der ausgewählten
+    // REMARK:: in der LV steht, dass eine Warnung herausgegeben werden soll, wenn der kmBereich der ausgewählten
     // Vegetationszone NICHT überlappt.
     // Derzeit werden durch den XPathQuery (siehe meta-data.xml usw) solche Vegetationszonen ohnehin gefiltert (nicht
     // angezeigt) - so wie es bisher überall standard ist, sodass
@@ -64,7 +63,6 @@
         final DatacageWidgetData data = new DatacageWidgetData(this.artifact, this.user, "uinfo.inundation_duration.vegZoneSelect", "load-system:true", false);
 
         final DatacageWidget datacage = new DatacageWidget(data);
-        final ArtifactDescription artifact = this.artifact.getArtifactDescription();
 
         // for (final DataList item : artifact.getOldData()) {
         // if (item.getState().equals("state.uinfo.inundationduration.distance_only")) {
@@ -86,24 +84,7 @@
         plusBtn.addClickHandler(new ClickHandler() {
             @Override
             public void onClick(final ClickEvent event) {
-                final List<TreeNode> selection = datacage.getPlainSelection();
-                if (selection == null || selection.isEmpty()) {
-                    SC.say(VegetationzonesTablePanel.this.MSG.warning());
-                    return;
-                }
-                final String data = selection.get(0).getAttribute("data");
-                // final String vegZoneFromStr = selection.get(0).getAttribute("from_km");
-                // final String vegZoneToStr = selection.get(0).getAttribute("to_km");
-                // if (vegZoneFromStr != null && vegZoneToStr != null) {
-                // VegetationzonesTablePanel.this.vegZoneFrom = Double.valueOf(vegZoneFromStr);
-                // VegetationzonesTablePanel.this.vegZoneTo = Double.valueOf(vegZoneToStr);
-                // } else {
-                // VegetationzonesTablePanel.this.vegZoneFrom = null;
-                // VegetationzonesTablePanel.this.vegZoneTo = null;
-                // }
-                createTableFromDataStr(data);
-                updateValidationMsgLabel();
-                // updateKmOverlapValidationLabel();
+                handlePlusClicked(datacage);
             }
         });
 
@@ -114,6 +95,37 @@
         return helperLayout;
     }
 
+    protected void handlePlusClicked(final DatacageWidget datacage) {
+        final List<TreeNode> selection = datacage.getPlainSelection();
+        if (selection == null || selection.isEmpty()) {
+            SC.say(VegetationzonesTablePanel.this.MSG.warning());
+            return;
+        }
+
+        final TreeNode selectedNode = selection.get(0);
+
+        /*
+         * 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;
+
+        // final String vegZoneFromStr = selection.get(0).getAttribute("from_km");
+        // final String vegZoneToStr = selection.get(0).getAttribute("to_km");
+        // if (vegZoneFromStr != null && vegZoneToStr != null) {
+        // VegetationzonesTablePanel.this.vegZoneFrom = Double.valueOf(vegZoneFromStr);
+        // VegetationzonesTablePanel.this.vegZoneTo = Double.valueOf(vegZoneToStr);
+        // } else {
+        // VegetationzonesTablePanel.this.vegZoneFrom = null;
+        // VegetationzonesTablePanel.this.vegZoneTo = null;
+        // }
+        createTableFromDataStr(vegZoneData);
+        updateValidationMsgLabel();
+        // updateKmOverlapValidationLabel();
+    }
+
     // private void updateKmOverlapValidationLabel() {
     // this.kmOverlapLabel.setText("MÖP");
     // if (this.vegZoneFrom != null && this.vegZoneTo != null) { // standardvegetationstabelle prüfung deaktiviert, da keine
@@ -126,4 +138,4 @@
     // }
     // }
     // }
-}
+}
\ No newline at end of file
diff -r 3f230fe8eb19 -r 8b7bf26b8782 gwt-client/src/main/webapp/WEB-INF/web.xml
--- a/gwt-client/src/main/webapp/WEB-INF/web.xml	Fri Sep 28 10:16:12 2018 +0200
+++ b/gwt-client/src/main/webapp/WEB-INF/web.xml	Fri Sep 28 13:44:12 2018 +0200
@@ -208,7 +208,7 @@
     <servlet-name>dynamicMainvalues</servlet-name>
     <servlet-class>org.dive4elements.river.client.server.DynamicMainValuesServiceImpl</servlet-class>
   </servlet>
-  
+
   <servlet>
     <servlet-name>dynamicMainvaluesTimeRangeDetermination</servlet-name>
     <servlet-class>org.dive4elements.river.client.server.DynamicMainValuesTimeRangeDeterminationServiceImpl</servlet-class>


More information about the Dive4Elements-commits mailing list