Mercurial > dive4elements > river
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 | 1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 | |
11 package org.dive4elements.river.artifacts.uinfo.inundationduration; | |
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 | 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 | 19 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; |
20 import org.dive4elements.river.artifacts.uinfo.UinfoCalcMode; | |
21 | |
22 /** | |
23 * Access to the flow depth calculation type specific SInfo artifact data. | |
24 * REMARK: this class is NOT intended to be hold in the results (or anywhere else), in order to avoid a permanent | |
25 * reference to the artifact instance. | |
26 * Hence we do NOT cache any data. | |
27 * | |
28 * @author Gernot Belger | |
29 */ | |
30 final class InundationDurationAccess extends RangeAccess { | |
31 | |
32 // IMMER ABGLEICHEN MIT SuperVegZonesTablePanel.TABLE_CELL_SEPARATOR | |
33 public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR"; | |
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 | 37 |
38 // Fields from state: | |
39 // | |
40 // calculation_mode (String) | |
41 // ld_from, ld_to | |
42 // ye_select (String; state.uinfo.totalepoch oder state.uinfo.year) | |
43 // singleyear (String) | |
44 // totalepoch (String; TODO: minmax totalEpoch herausfinden und setzen (nicht hier.. aber trotzdem die Erinnerung hier)) | |
45 // use_scenario boolean (danach kommt kein radioBtn, sondern sedimentheight-Eingabe) | |
46 // sedimentheight String | |
47 // | |
48 // vegzones (String) TODO: MIT VegetationzonesAccess zusammenlegen | |
49 | |
50 public InundationDurationAccess(final UINFOArtifact uinfo) { | |
51 super(uinfo); | |
52 /* assert calculation mode */ | |
53 final UinfoCalcMode calculationMode = uinfo.getCalculationMode(); | |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
54 this.helper = new EpochYearAccessHelper(uinfo); |
9069 | 55 assert (calculationMode == UinfoCalcMode.uinfo_inundation_duration); |
56 } | |
57 | |
58 public Double getSedimentHeight() { | |
59 if (super.getBoolean("use_scenario")) { | |
60 return super.getDouble("sedimentheight"); // TODO: INPUT Valdiation (nicht hier, sondern im Panel. Erinnerung) | |
61 } | |
62 return null; | |
63 } | |
64 | |
65 public Integer getYear() { | |
66 final int[] years = this.helper.getYears("state.uinfo.year", "singleyear"); | |
67 if (years != null) { | |
68 return years[0]; | |
69 } | |
70 return null; | |
71 } | |
72 | |
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 | 77 } |
78 return null; | |
79 } | |
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 | 84 } |
85 | |
86 } |