Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/RiversideRadioChoice.java @ 9627:f51e23eb036a
zu pos 20
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Mon, 14 Oct 2019 16:27:31 +0200 |
parents | 1a4d2ce77423 |
children |
rev | line source |
---|---|
9050 | 1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9054
95643dffd006
rename grounding->collision; inundation_duration->flood_duration
gernotbelger
parents:
9053
diff
changeset
|
9 package org.dive4elements.river.artifacts.sinfo.flood_duration; |
9050 | 10 |
9627 | 11 import java.util.Collection; |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9054
diff
changeset
|
12 import java.util.LinkedHashMap; |
9053 | 13 |
9627 | 14 import org.dive4elements.artifactdatabase.data.StateData; |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9054
diff
changeset
|
15 import org.dive4elements.artifacts.Artifact; |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9054
diff
changeset
|
16 import org.dive4elements.artifacts.CallMeta; |
9627 | 17 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; |
9053 | 18 import org.dive4elements.river.artifacts.states.RadioSelect; |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
19 import org.dive4elements.river.model.Attribute.AttributeKey; |
9050 | 20 |
21 /** | |
22 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
23 */ | |
9053 | 24 public class RiversideRadioChoice extends RadioSelect { |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
25 |
9050 | 26 private static final long serialVersionUID = 1L; |
27 | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
28 public enum RiversideChoiceKey { |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
29 NONE("", AttributeKey.NONE), // |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
30 LEFT("state.sinfo.riverside.left", AttributeKey.LEFT), // |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
31 RIGHT("state.sinfo.riverside.right", AttributeKey.RIGHT), // |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
32 BOTH("state.sinfo.riverside.both", AttributeKey.UNKNOWN); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
33 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
34 private final String key; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
35 private final AttributeKey attributeKey; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
36 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
37 RiversideChoiceKey(final String key, final AttributeKey attributeKey) { |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
38 this.key = key; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
39 this.attributeKey = attributeKey; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
40 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
41 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
42 public static RiversideChoiceKey fromKey(final String key) { |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
43 for (final RiversideChoiceKey v : values()) { |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
44 if (key.equalsIgnoreCase(v.key)) |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
45 return v; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
46 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
47 return NONE; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
48 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
49 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
50 public String getKey() { |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
51 return this.key; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
52 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
53 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
54 public AttributeKey getAttributeKey() { |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
55 return this.attributeKey; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
56 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
57 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9054
diff
changeset
|
58 |
9053 | 59 @Override |
9178
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9054
diff
changeset
|
60 protected LinkedHashMap<String, String> makeEntries(final CallMeta meta, final Artifact artifact) { |
2f5052835b76
uinfo inundationduration langjähr. Mittel, Uedauern.properties, Meldung
gernotbelger
parents:
9054
diff
changeset
|
61 final LinkedHashMap<String, String> entries = new LinkedHashMap<>(); |
9179 | 62 entries.put(RiversideChoiceKey.LEFT.getKey(), null); |
63 entries.put(RiversideChoiceKey.RIGHT.getKey(), null); | |
64 entries.put(RiversideChoiceKey.BOTH.getKey(), null); | |
9627 | 65 |
66 // remove infrastructures, because the values might be invalid | |
67 if (artifact instanceof SINFOArtifact) | |
68 removeInfrastructures((SINFOArtifact) artifact); | |
69 | |
9053 | 70 return entries; |
71 } | |
9369 | 72 |
9627 | 73 private void removeInfrastructures(final SINFOArtifact artifact) { |
74 final Collection<StateData> test = artifact.getAllData(); | |
75 | |
76 for (final StateData dataItem : test) { | |
77 | |
78 if (dataItem.getName().equals(FloodInfrastructure.getDatakey())) | |
79 dataItem.setValue(null); | |
80 } | |
81 } | |
82 | |
9369 | 83 @Override |
84 protected String getDatakey() { | |
85 return "riverside"; | |
86 } | |
87 | |
88 @Override | |
89 protected String getUIProvider() { | |
90 | |
91 return "riverside_radio_panel"; | |
92 } | |
9050 | 93 } |