annotate artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationAccess.java @ 9155:9b4f5e61c02e

Changed to list of DateRange, added methods in DateRange to support year ranges
author mschaefer
date Tue, 19 Jun 2018 14:15:32 +0200
parents 611a523fc42f
children 2f5052835b76
rev   line source
9069
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
2 * Software engineering by
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
5 *
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
9 */
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
10
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
11 package org.dive4elements.river.artifacts.uinfo.inundationduration;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
12
9155
9b4f5e61c02e Changed to list of DateRange, added methods in DateRange to support year ranges
mschaefer
parents: 9070
diff changeset
13 import java.util.List;
9b4f5e61c02e Changed to list of DateRange, added methods in DateRange to support year ranges
mschaefer
parents: 9070
diff changeset
14
9b4f5e61c02e Changed to list of DateRange, added methods in DateRange to support year ranges
mschaefer
parents: 9070
diff changeset
15 import org.dive4elements.artifacts.common.utils.DateUtils;
9069
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
16 import org.dive4elements.river.artifacts.access.RangeAccess;
9070
611a523fc42f VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents: 9069
diff changeset
17 import org.dive4elements.river.artifacts.common.EpochYearAccessHelper;
9155
9b4f5e61c02e Changed to list of DateRange, added methods in DateRange to support year ranges
mschaefer
parents: 9070
diff changeset
18 import org.dive4elements.river.artifacts.model.DateRange;
9069
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
19 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
20 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
21
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
22 /**
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
23 * Access to the flow depth calculation type specific SInfo artifact data.
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
24 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
25 * reference to the artifact instance.
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
26 * Hence we do NOT cache any data.
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
27 *
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
28 * @author Gernot Belger
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
29 */
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
30 final class InundationDurationAccess extends RangeAccess {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
31
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
32 // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
33 public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR";
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
34 public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR";
9070
611a523fc42f VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents: 9069
diff changeset
35
611a523fc42f VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents: 9069
diff changeset
36 private final EpochYearAccessHelper helper;
9069
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
37
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
38 // Fields from state:
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
39 //
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
40 // calculation_mode (String)
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
41 // ld_from, ld_to
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
42 // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year)
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
43 // singleyear (String)
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
44 // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier))
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
45 // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe)
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
46 // sedimentheight String
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
47 //
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
48 // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
49
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
50 public InundationDurationAccess(final UINFOArtifact uinfo) {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
51 super(uinfo);
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
52 /* assert calculation mode */
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
53 final UinfoCalcMode calculationMode = uinfo.getCalculationMode();
9070
611a523fc42f VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents: 9069
diff changeset
54 this.helper = new EpochYearAccessHelper(uinfo);
9069
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
55 assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration);
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
56 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
57
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
58 public Double getSedimentHeight() {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
59 if (super.getBoolean("use_scenario")) {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
60 return super.getDouble("sedimentheight"); // TODO: INPUT Valdiation (nicht hier, sondern im Panel. Erinnerung)
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
61 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
62 return null;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
63 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
64
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
65 public Integer getYear() {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
66 final int[] years = this.helper.getYears("state.uinfo.year", "singleyear");
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
67 if (years != null) {
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
68 return years[0];
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
69 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
70 return null;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
71 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
72
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
73 public int[] getTotalEpoch() {
9155
9b4f5e61c02e Changed to list of DateRange, added methods in DateRange to support year ranges
mschaefer
parents: 9070
diff changeset
74 final List<DateRange> epochs = this.helper.getEpochs("state.uinfo.totalepoch", "totalepoch");
9b4f5e61c02e Changed to list of DateRange, added methods in DateRange to support year ranges
mschaefer
parents: 9070
diff changeset
75 if (!epochs.isEmpty()) {
9b4f5e61c02e Changed to list of DateRange, added methods in DateRange to support year ranges
mschaefer
parents: 9070
diff changeset
76 return new int[] { DateUtils.getYearFromDate(epochs.get(0).getFrom()), DateUtils.getYearFromDate(epochs.get(0).getTo()) };
9069
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
77 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
78 return null;
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
79 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
80
9070
611a523fc42f VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents: 9069
diff changeset
81 public String getVegZones() {
611a523fc42f VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents: 9069
diff changeset
82 // MIT VegetationzonesAccess zusammenlegen (eine Zeile sparen...)
611a523fc42f VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents: 9069
diff changeset
83 return super.getString("vegzones");
9069
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
84 }
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
85
1ffd38826175 access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
diff changeset
86 }

http://dive4elements.wald.intevation.org