[PATCH 2 of 4] uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
Wald Commits
scm-commit at wald.intevation.org
Tue Jun 26 20:16:15 CEST 2018
# HG changeset patch
# User gernotbelger
# Date 1530035315 -7200
# Node ID 2f5052835b761168024b26f141d2026e5d980b2b
# Parent 37db8c4c44b748372b4f3bd3252038a4f21c9f12
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/doc/conf/artifacts/uinfo.xml
--- a/artifacts/doc/conf/artifacts/uinfo.xml Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/doc/conf/artifacts/uinfo.xml Tue Jun 26 19:48:35 2018 +0200
@@ -148,7 +148,7 @@
</state>
- <state id="state.uinfo.load.year" description="state.uinfo.load.year" state="org.dive4elements.river.artifacts.states.LoadSingleYearSelectState" helpText="help.state.uinfo.load.year">
+ <state id="state.uinfo.load.year" description="state.uinfo.load.year" state="org.dive4elements.river.artifacts.uinfo.inundationduration.LoadSingleYearSelectState" helpText="help.state.uinfo.load.year">
<data name="singleyear" type="String" />
</state>
@@ -201,6 +201,31 @@
<state id="state.uinfo.inundation_duration" description="state.uinfo.inundation_duration" state="org.dive4elements.river.artifacts.uinfo.inundationduration.InundationDurationState" helpText="help.state.uinfo.inundation_duration">
<outputmodes>
+ <outputmode name="map" description="output.uesk.map.description" type="map">
+ <facets>
+ <facet name="floodmap.wsplgen" />
+ <facet name="floodmap.barriers" />
+ <facet name="floodmap.riveraxis" />
+ <facet name="floodmap.wmsbackground" />
+ <facet name="floodmap.kms" />
+ <facet name="floodmap.qps" />
+ <facet name="floodmap.hws_lines" />
+ <facet name="floodmap.hws_points" />
+ <facet name="floodmap.hydr_boundaries" />
+ <facet name="floodmap.hydr_boundaries_poly" />
+ <facet name="floodmap.catchment" />
+ <facet name="floodmap.floodplain" />
+ <facet name="floodmap.floodmarks" />
+ <facet name="floodmap.lines" />
+ <facet name="floodmap.buildings" />
+ <facet name="floodmap.fixpoints" />
+ <facet name="floodmap.floodmaps" />
+ <facet name="floodmap.gauge_location" />
+ <facet name="floodmap.externalwms" />
+ <facet name="floodmap.jetties" />
+ </facets>
+ </outputmode>
+
<!-- FIXME: i01n name in FLYSConstants -->
<outputmode name="uinfo_inundation_duration_export" description="output.uinfo_inundation_duration_export" mime-type="text/plain" type="export">
<facets>
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/doc/conf/uinfo_uedauern_aue_Beispielfluss.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/doc/conf/uinfo_uedauern_aue_Beispielfluss.properties Tue Jun 26 19:48:35 2018 +0200
@@ -0,0 +1,6 @@
+jahre=1995,1996,1997
+url=htps://geoportal.bafg.de/wms/${jahr}
+
+mittel_url=htps://geoportal.bafg.de/wms/${jahr}
+mittel_start=8888
+mittel_ende=2000
\ No newline at end of file
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/doc/conf/uinfo_uedauern_aue_Elbe.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/doc/conf/uinfo_uedauern_aue_Elbe.properties Tue Jun 26 19:48:35 2018 +0200
@@ -0,0 +1,6 @@
+jahre=1995,1996,1997
+url=htps://geoportal.bafg.de/wms/${jahr}
+
+mittel_url=htps://geoportal.bafg.de/wms/${jahr}
+mittel_start=1998
+mittel_ende=2000
\ No newline at end of file
diff -r 37db8c4c44b7 -r 2f5052835b76 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 Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java Tue Jun 26 19:48:35 2018 +0200
@@ -8,9 +8,10 @@
package org.dive4elements.river.artifacts.bundu.bezugswst;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.LinkedHashMap;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.river.artifacts.states.RadioSelect;
/**
@@ -19,16 +20,12 @@
public class FixationChoice extends RadioSelect {
private static final long serialVersionUID = 1L;
- public FixationChoice() {
- super();
+ @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);
+ entries.put("state.bundu.fix.manual", null);
+ return entries;
}
- @Override
- protected List<String> makeEntries() {
- final List<String> entries = new ArrayList<>();
- entries.add("state.bundu.fix.auto");
- entries.add("state.bundu.fix.manual");
- return entries;
-
- }
}
\ No newline at end of file
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/common/EpochYearAccessHelper.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/EpochYearAccessHelper.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/EpochYearAccessHelper.java Tue Jun 26 19:48:35 2018 +0200
@@ -43,9 +43,7 @@
/** [year1, years2,..] if its about years. */
public int[] getYears(final String yearSelectedValue, final String yearKey) {
int[] years = null;
- // if (years != null) {
- // return years;
- // }
+
if (getYearEpoch().equals(yearSelectedValue)) {
final TIntArrayList ints = new TIntArrayList();
final String yearsData = getString(yearKey);
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/YearChoice.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/YearChoice.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/collision/YearChoice.java Tue Jun 26 19:48:35 2018 +0200
@@ -8,9 +8,10 @@
package org.dive4elements.river.artifacts.sinfo.collision;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.LinkedHashMap;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.river.artifacts.states.RadioSelect;
/**
@@ -24,10 +25,10 @@
}
@Override
- protected List<String> makeEntries() {
- final List<String> entries = new ArrayList<>();
- entries.add("state.sinfo.year");
- entries.add("state.sinfo.epoch");
+ protected LinkedHashMap<String, String> makeEntries(final CallMeta meta, final Artifact artifact) {
+ final LinkedHashMap<String, String> entries = new LinkedHashMap<>();
+ entries.put("state.sinfo.year", null);
+ entries.put("state.sinfo.epoch", null);
return entries;
}
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/RiversideRadioChoice.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/RiversideRadioChoice.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/RiversideRadioChoice.java Tue Jun 26 19:48:35 2018 +0200
@@ -8,9 +8,10 @@
package org.dive4elements.river.artifacts.sinfo.flood_duration;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.LinkedHashMap;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.river.artifacts.states.RadioSelect;
/**
@@ -24,13 +25,11 @@
}
@Override
- protected List<String> makeEntries() {
- final List<String> entries = new ArrayList<>();
- entries.add("state.sinfo.riverside.left");
- entries.add("state.sinfo.riverside.right");
- entries.add("state.sinfo.riverside.both");
+ protected LinkedHashMap<String, String> makeEntries(final CallMeta meta, final Artifact artifact) {
+ final LinkedHashMap<String, String> entries = new LinkedHashMap<>();
+ entries.put("state.sinfo.riverside.left", null);
+ entries.put("state.sinfo.riverside.right", null);
+ entries.put("state.sinfo.riverside.both", null);
return entries;
-
}
-
}
\ No newline at end of file
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/DefaultBedHeights.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/DefaultBedHeights.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/DefaultBedHeights.java Tue Jun 26 19:48:35 2018 +0200
@@ -9,11 +9,6 @@
*/
package org.dive4elements.river.artifacts.sinfo.tkhstate;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -84,13 +79,9 @@
}
private static Collection<String> loadBedHeightDefaultsForRiver(final River river, final Calculation problems) {
- final File configDir = Config.getConfigDirectory();
- final File configFile = new File(configDir, CONFIG_FILE);
- final Properties properties = new Properties();
- try (final InputStreamReader reader = new InputStreamReader(Files.newInputStream(configFile.toPath()), StandardCharsets.ISO_8859_1)) {
- properties.load(reader);
-
+ try {
+ final Properties properties = Config.loadProperties(CONFIG_FILE);
final String value = properties.getProperty(river.getName());
final String[] split = StringUtils.split(StringUtils.trim(value), ',');
if (ArrayUtils.isEmpty(split)) {
@@ -100,7 +91,9 @@
return Arrays.asList(split);
}
- catch (final IOException e) {
+ catch (
+
+ final Exception e) {
e.printStackTrace();
problems.addProblem("sinfo.bedheightsfinder.configfile.loaderror", CONFIG_FILE, e.getMessage());
return Collections.emptyList();
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/states/RadioSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/RadioSelect.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/RadioSelect.java Tue Jun 26 19:48:35 2018 +0200
@@ -9,7 +9,8 @@
*/
package org.dive4elements.river.artifacts.states;
-import java.util.List;
+import java.util.LinkedHashMap;
+import java.util.Map;
import org.dive4elements.artifacts.Artifact;
import org.dive4elements.artifacts.CallContext;
@@ -25,14 +26,14 @@
public abstract class RadioSelect extends DefaultState {
private static final long serialVersionUID = 1L;
- private final List<String> entries;
public RadioSelect() {
- super();
- this.entries = makeEntries();
+
}
- protected abstract List<String> makeEntries();
+ protected abstract LinkedHashMap<String, String> makeEntries(CallMeta meta, Artifact artifact); // AUSNAHMSWEISE EXPLIZITER TYP, damit gewährleistet ist,
+ // dass die Reihenfolge
+ // nicht verrutscht
@Override
protected final String getUIProvider() {
@@ -42,13 +43,26 @@
@Override
protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) {
final CallMeta meta = context.getMeta();
- final Element[] elements = new Element[this.entries.size()];
+ final Map<String, String> entries = makeEntries(meta, artifact);
+
+ final Element[] elements = new Element[entries.size()];
int i = 0;
- for (final String item : this.entries) {
- elements[i] = createItem(ec, new String[] { Resources.getMsg(meta, item, item), item });
+ for (final String key : entries.keySet()) {
+ final String label = entries.get(key);
+ final String labelToSet = label != null ? label : Resources.getMsg(meta, key);
+ elements[i] = createItem(ec, new String[] { labelToSet, key });
i++;
}
return elements;
}
-}
+ @Override
+ protected String getLabelFor(final CallContext cc, final String name, final String value, final String type) {
+ // könnte nicht davon ausgegangen werden, dass die entries immer zuerst in createItems erzeugt werden und da quasi
+ // "lazy" initialisiert werden?
+ final Map<String, String> entries = makeEntries(cc.getMeta(), null);
+
+ final String valueToSet = entries.get(value) != null ? entries.get(value) : value;
+ return super.getLabelFor(cc, name, valueToSet, type);
+ }
+}
\ No newline at end of file
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/CalculationSelectUinfo.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/CalculationSelectUinfo.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/CalculationSelectUinfo.java Tue Jun 26 19:48:35 2018 +0200
@@ -19,6 +19,7 @@
import org.dive4elements.artifacts.common.utils.XMLUtils;
import org.dive4elements.river.artifacts.resources.Resources;
import org.dive4elements.river.artifacts.states.DefaultState;
+import org.dive4elements.river.artifacts.uinfo.inundationduration.UedauernPropertiesHelper;
import org.w3c.dom.Element;
/**
@@ -54,8 +55,17 @@
log.debug("CalculationSelect.validate");
final UINFOArtifact uinfo = (UINFOArtifact) artifact;
+ final String calcDebug = uinfo.getCalculationMode().toString();
+ if (calcDebug.equals("uinfo_inundation_duration")) {
+
+ final String river = uinfo.getRiver();
+ if (!UedauernPropertiesHelper.fileExistsForRiver(river)) {
+ throw new IllegalArgumentException("error_river_inundationdur_file_not_found");
+ }
+ }
+
/* throws an exception if calculation mode is invalid */
- uinfo.getCalculationMode();
+
return true;
}
}
\ No newline at end of file
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java Tue Jun 26 19:48:35 2018 +0200
@@ -10,12 +10,8 @@
package org.dive4elements.river.artifacts.uinfo.inundationduration;
-import java.util.List;
-
-import org.dive4elements.artifacts.common.utils.DateUtils;
import org.dive4elements.river.artifacts.access.RangeAccess;
import org.dive4elements.river.artifacts.common.EpochYearAccessHelper;
-import org.dive4elements.river.artifacts.model.DateRange;
import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode;
@@ -70,12 +66,16 @@
return null;
}
- public int[] getTotalEpoch() {
- final List<DateRange> epochs = this.helper.getEpochs("state.uinfo.totalepoch", "totalepoch");
- if (!epochs.isEmpty()) {
- return new int[] { DateUtils.getYearFromDate(epochs.get(0).getFrom()), DateUtils.getYearFromDate(epochs.get(0).getTo()) };
+ // TODO: eigentlich nur die WMS-Url des gewählten dingens (jahr, oder epoche)
+ public String getWMSUrl() {
+
+ final UedauernPropertiesHelper helper = UedauernPropertiesHelper.getInstance(getRiverName());
+ if (this.getYear() != null) {
+ return helper.urlFromYear(this.getYear());
+ } else {
+ return helper.getMittelUrl(); // nur 2 cases...
}
- return null;
+
}
public String getVegZones() {
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationCalculation.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationCalculation.java Tue Jun 26 19:48:35 2018 +0200
@@ -52,7 +52,7 @@
final River river = indurax.getRiver();
final RiverInfo riverInfo = new RiverInfo(river);
final DoubleRange calcRange = indurax.getRange();
- final int[] totalEpoch = indurax.getTotalEpoch();
+ final String url = indurax.getWMSUrl();
final Integer year = indurax.getYear(); // null bei year -> Integer.. evtl ungünstig.. evtl. anders lösen
final DoubleRange range = indurax.getRange();
final Double sedimentHeight = indurax.getSedimentHeight();
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationState.java Tue Jun 26 19:48:35 2018 +0200
@@ -15,6 +15,7 @@
import org.dive4elements.artifacts.CallContext;
import org.dive4elements.river.artifacts.ChartArtifact;
import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.MapArtifact.MapState;
import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult;
import org.dive4elements.river.artifacts.model.Calculation;
import org.dive4elements.river.artifacts.model.CalculationResult;
@@ -22,13 +23,12 @@
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.states.DefaultState;
import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
/**
* @author Domenico Nardi Tironi
*/
-public class InundationDurationState extends DefaultState {
+public class InundationDurationState extends MapState {
/// ** The log that is used in this state. */
// private static Logger log = Logger.getLogger(FlowDepthState.class);
@@ -60,6 +60,10 @@
facets.add(new EmptyFacet());
return null;
}
+
+ if (facets != null)
+ super.computeAdvance(artifact, hash, context, facets, old);
+
return compute((UINFOArtifact) artifact, context, hash, facets, old);
}
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/LoadSingleYearSelectState.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/LoadSingleYearSelectState.java Tue Jun 26 19:48:35 2018 +0200
@@ -0,0 +1,84 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.artifacts.uinfo.inundationduration;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.artifactdatabase.data.StateData;
+import org.dive4elements.artifactdatabase.state.Facet;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.states.AddTableDataHelper;
+import org.dive4elements.river.artifacts.states.DefaultState;
+import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
+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);
+
+ private InundationDurationAccess access;
+
+ /**
+ * 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";
+ }
+
+ @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 Map<String, StateData> data = super.getData();
+ final UedauernPropertiesHelper properties = UedauernPropertiesHelper.getInstance(this.access.getRiverName());
+
+ for (final String year : properties.getEinzeljahre()) {
+ final Map<String, String> row = new HashMap<>();
+ row.put("year", year);
+ helper.addRow(row);
+
+ }
+ helper.submitMapToXml();
+ }
+ }
+ catch (final IllegalArgumentException iae) {
+ iae.printStackTrace();
+ }
+ }
+
+ @Override
+ public Object computeInit(final D4EArtifact artifact, final String hash, final Object context, final CallMeta meta, final List<Facet> facets) {
+ if (artifact instanceof UINFOArtifact) {
+ this.access = new InundationDurationAccess((UINFOArtifact) artifact);
+ }
+ return super.computeInit(artifact, hash, context, meta, facets);
+ }
+
+}
\ No newline at end of file
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/UedauernPropertiesHelper.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/UedauernPropertiesHelper.java Tue Jun 26 19:48:35 2018 +0200
@@ -0,0 +1,122 @@
+/** 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.inundationduration;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.lang.text.StrSubstitutor;
+import org.dive4elements.artifacts.CallMeta;
+import org.dive4elements.artifacts.common.utils.Config;
+import org.dive4elements.river.artifacts.resources.Resources;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+public class UedauernPropertiesHelper {
+
+ private static UedauernPropertiesHelper instance;
+ private final String CONFIG_FILE;
+ private final String rivername;
+ private Integer[] mittelStartEnde = null;
+ private String[] einzeljahre = null;
+ private String mittelUrl = null;
+ private Properties properties = null;
+
+ public UedauernPropertiesHelper(final String rivername) {
+ this.rivername = rivername;
+ this.CONFIG_FILE = makeFileName(rivername);
+ }
+
+ public static synchronized UedauernPropertiesHelper getInstance(final String rivername) {
+ if (UedauernPropertiesHelper.instance == null || !UedauernPropertiesHelper.instance.getRivername().equals(rivername)) {
+
+ UedauernPropertiesHelper.instance = new UedauernPropertiesHelper(rivername);
+ }
+ return UedauernPropertiesHelper.instance;
+ }
+
+ private String getRivername() {
+ return this.rivername;
+ }
+
+ private static final String makeFileName(final String river) {
+ return "uinfo_uedauern_aue_" + river + ".properties";
+ }
+
+ public LinkedHashMap<String, String> getExtraLayers(final CallMeta meta) {
+ final LinkedHashMap<String, String> entries = new LinkedHashMap<>();
+
+ final Integer[] totalEpoch = getMittelStartEnd();
+ final Object[] args = new Object[] { String.valueOf(totalEpoch[0]), String.valueOf(totalEpoch[1]) };
+
+ // final ResourceBundle rb = ResourceBundle.getBundle("Name");
+ entries.put("state.uinfo.totalepoch", Resources.getMsg(meta, "state.uinfo.totalepoch", args)); //
+ // String.valueOf: avoid formatting
+ // (3.333,00
+
+ return entries;
+ }
+
+ private Properties getProperties() {
+ if (this.properties == null) {
+ this.properties = Config.loadProperties(this.CONFIG_FILE);
+ }
+ return this.properties;
+ }
+
+ private final Integer[] getMittelStartEnd() {
+ if (this.mittelStartEnde == null) {
+ final Integer mittel_start = Integer.valueOf(getProperties().get("mittel_start").toString());
+ final Integer mittel_ende = Integer.valueOf(getProperties().get("mittel_ende").toString());
+ this.mittelStartEnde = new Integer[] { mittel_start, mittel_ende }; // lazy
+
+ }
+ return this.mittelStartEnde;
+ }
+
+ public String[] getEinzeljahre() {
+ if (this.einzeljahre == null) { // lazy
+ final Object years = getProperties().get("jahre");
+ if (years != null) {
+ this.einzeljahre = years.toString().split(",");
+ }
+ }
+ return this.einzeljahre;
+ }
+
+ public final String getMittelUrl() {
+ if (this.mittelUrl == null) { // lazy
+ this.mittelUrl = getProperties().get("mittel_url").toString();
+ }
+ return this.mittelUrl;
+ }
+
+ public final String urlFromYear(final int year) {
+ // besser kein lazy-loading, da der user nochmal zurück gehen und das Jahr ändern könnte...
+ final String templateUrl = getProperties().get("url").toString();
+ final Map<String, String> tokens = new HashMap<>();
+ tokens.put("jahr", String.valueOf(year));
+ final StrSubstitutor subst = new StrSubstitutor(tokens);
+ final String yearUrl = subst.replace(templateUrl);
+ return yearUrl;
+ }
+
+ public static boolean fileExistsForRiver(final String river) {
+ final Properties properties = Config.loadProperties(makeFileName(river));
+ if (properties.size() == 0) {
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/YearChoice.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/YearChoice.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/YearChoice.java Tue Jun 26 19:48:35 2018 +0200
@@ -8,26 +8,33 @@
package org.dive4elements.river.artifacts.uinfo.inundationduration;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.LinkedHashMap;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.river.artifacts.states.RadioSelect;
+import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
/**
* @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
*/
public class YearChoice extends RadioSelect {
private static final long serialVersionUID = 1L;
-
- public YearChoice() {
- super();
- }
+ private InundationDurationAccess access = null;
@Override
- protected List<String> makeEntries() {
- final List<String> entries = new ArrayList<>();
- entries.add("state.uinfo.year");
- entries.add("state.uinfo.totalepoch");
+ protected LinkedHashMap<String, String> makeEntries(final CallMeta meta, final Artifact artifact) {
+ // in helper-klasse; dann hier label lazy loaden
+ final LinkedHashMap<String, String> entries = new LinkedHashMap<>();
+ if (artifact != null && artifact instanceof UINFOArtifact) {
+ this.access = new InundationDurationAccess((UINFOArtifact) artifact);
+ }
+ if (this.access != null) {
+ final UedauernPropertiesHelper helper = UedauernPropertiesHelper.getInstance(this.access.getRiverName());
+ final LinkedHashMap<String, String> extras = helper.getExtraLayers(meta);
+ entries.put("state.uinfo.year", null);
+ entries.putAll(extras);
+ }
return entries;
}
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/ScenarioTypeState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/ScenarioTypeState.java Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/ScenarioTypeState.java Tue Jun 26 19:48:35 2018 +0200
@@ -1,9 +1,10 @@
package org.dive4elements.river.artifacts.uinfo.salix;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.LinkedHashMap;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallMeta;
import org.dive4elements.river.artifacts.states.RadioSelect;
/**
@@ -17,11 +18,11 @@
}
@Override
- protected List<String> makeEntries() {
- final List<String> entries = new ArrayList<>();
- entries.add("scenarioType.option1");
- entries.add("scenarioType.option2");
- entries.add("scenarioType.option3");
+ protected LinkedHashMap<String, String> makeEntries(final CallMeta meta, final Artifact artifact) {
+ final LinkedHashMap<String, String> entries = new LinkedHashMap<>();
+ entries.put("scenarioType.option1", null);
+ entries.put("scenarioType.option2", null);
+ entries.put("scenarioType.option3", null);
return entries;
}
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties Tue Jun 26 19:48:35 2018 +0200
@@ -83,7 +83,7 @@
state.uinfo.load.epoch=Epoch
state.uinfo.year=Year
state.uinfo.epoch=Epoch
-state.uinfo.totalepoch=Total Epoch
+state.uinfo.totalepoch=Langj\u00e4hriges Mittel ({0} - {1})
state.sinfo.year_epoch = Year/Epoch
state.sinfo.load.year= Year(s)
diff -r 37db8c4c44b7 -r 2f5052835b76 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties Tue Jun 26 16:17:30 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties Tue Jun 26 19:48:35 2018 +0200
@@ -83,7 +83,7 @@
state.uinfo.load.epoch=Epoche
state.uinfo.year=Einzeljahr
state.uinfo.epoch=Epoche
-state.uinfo.totalepoch=Langj\u00e4hriges Mittel
+state.uinfo.totalepoch=Langj\u00e4hriges Mittel ({0} - {1})
state.sinfo.year_epoch = Jahr/Epoche
state.sinfo.load.year= Jahr(e)
diff -r 37db8c4c44b7 -r 2f5052835b76 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 Tue Jun 26 16:17:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Tue Jun 26 19:48:35 2018 +0200
@@ -1536,4 +1536,6 @@
String export_csv_title();
String waterlevel_ground_state();
+
+ String error_river_inundationdur_file_not_found();
}
\ No newline at end of file
diff -r 37db8c4c44b7 -r 2f5052835b76 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 Tue Jun 26 16:17:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Tue Jun 26 19:48:35 2018 +0200
@@ -324,6 +324,7 @@
ele_window_save_error = Error while saving elevations.
ele_window_geometry_error = The geometry is not supported:
+error_river_inundationdur_file_not_found = F\u00fcr das gew\u00e4hlte Gew\u00e4sser liegen keine Daten vor oder die "uinfo_uedauern_aue_Gew\u00e4sser.properties"-Datei wurde nicht gefunden.
unexpected_exception = There occured an unexpected exception
error_years_wrong = The second year needs to be bigger than the first year.
error_read_minmax_values = Error while reading min/max values for the location input.
diff -r 37db8c4c44b7 -r 2f5052835b76 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 Tue Jun 26 16:17:30 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Tue Jun 26 19:48:35 2018 +0200
@@ -324,6 +324,7 @@
ele_window_save_error = Fehler beim Speichern der H\u00f6hen.
ele_window_geometry_error = Die Geometrie wird nicht unterst\u00fctzt:
+error_river_inundationdur_file_not_found = F\u00fcr das gew\u00e4hlte Gew\u00e4sser liegen keine Daten vor oder die "uinfo_uedauern_aue_Gew\u00e4sser.properties"-Datei wurde nicht gefunden.
unexpected_exception = Ein unerwarteter Fehler ist aufgetreten
error_years_wrong = Das zweite Jahr muss gr\u00f6\u00dfer als das erste sein.
error_read_minmax_values = Fehler beim Lesen der min/max Werte. Es kann keine Validierung der eingegebenen Strecke durchgef\u00fchrt werden.
More information about the Dive4Elements-commits
mailing list