Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelSelectState.java @ 2560:0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
flys-artifacts/trunk@4086 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 17 Feb 2012 14:16:50 +0000 |
parents | a22e0cb6eace |
children | 5642a83420f2 |
rev | line source |
---|---|
1172
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
3 import org.apache.log4j.Logger; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
4 |
1180
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
5 import org.w3c.dom.Element; |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
6 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
7 import de.intevation.artifacts.Artifact; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
8 import de.intevation.artifacts.CallContext; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
9 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
10 import de.intevation.artifactdatabase.data.DefaultStateData; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
11 import de.intevation.artifactdatabase.data.StateData; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
12 |
1180
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
13 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
14 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
15 import de.intevation.flys.artifacts.FLYSArtifact; |
1180
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
16 import de.intevation.flys.artifacts.model.CalculationResult; |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
17 import de.intevation.flys.artifacts.model.WQKms; |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
18 import de.intevation.flys.artifacts.resources.Resources; |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
19 import de.intevation.flys.utils.FLYSUtils; |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
20 import de.intevation.flys.utils.StringUtil; |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
21 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
22 |
1172
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 /** |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 */ |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 public class WaterlevelSelectState extends DefaultState { |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
28 private static final Logger logger = |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
29 Logger.getLogger(WaterlevelSelectState.class); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
30 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
31 public static final String SPLIT_CHAR = ";"; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
32 |
1180
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
33 public static final String WINFO_WSP_STATE_ID = "state.winfo.waterlevel"; |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
34 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
35 public static final String I18N_STATIC_KEY = "wsp.selected.string"; |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
36 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
37 |
1172
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 @Override |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 protected String getUIProvider() { |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 return "wsp_datacage_panel"; |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 } |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
42 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
43 |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
44 /** |
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
45 * @param flys ignored |
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
46 * @param cc ignrored |
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
47 */ |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
48 @Override |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
49 public StateData transform( |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
50 FLYSArtifact flys, |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
51 CallContext cc, |
2205
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
52 StateData stateData, |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
53 String name, |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
54 String val |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
55 ) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
56 if (!isValueValid(val)) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
57 logger.error("The given input string is not valid: '" + val + "'"); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
58 return null; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
59 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
60 |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
61 return new DefaultStateData(name, null, null, StringUtil.unbracket(val)); |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
62 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
63 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
64 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
65 @Override |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
66 public boolean validate(Artifact artifact) |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
67 throws IllegalArgumentException |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
68 { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
69 FLYSArtifact flys = (FLYSArtifact) artifact; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
70 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
71 StateData data = flys.getData("wsp"); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
72 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
73 if (data == null) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
74 throw new IllegalArgumentException("WSP is empty"); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
75 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
76 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
77 return true; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
78 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
79 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
80 |
1180
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
81 @Override |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
82 protected Element createStaticData( |
1743
8a2cbf947395
Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1660
diff
changeset
|
83 FLYSArtifact flys, |
1180
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
84 ElementCreator creator, |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
85 CallContext cc, |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
86 String name, |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
87 String value, |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
88 String type |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
89 ) { |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
90 Element dataElement = creator.create("data"); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
91 creator.addAttr(dataElement, "name", name, true); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
92 creator.addAttr(dataElement, "type", type, true); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
93 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
94 Element itemElement = creator.create("item"); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
95 creator.addAttr(itemElement, "value", value, true); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
96 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
97 String[] labels = getLabels(cc, value); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
98 Object[] obj = new Object[] { labels[0] }; |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
99 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
100 String attrValue = Resources.getMsg( |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
101 cc.getMeta(), I18N_STATIC_KEY, I18N_STATIC_KEY, obj); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
102 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
103 creator.addAttr(itemElement, "label", attrValue, true); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
104 dataElement.appendChild(itemElement); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
105 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
106 return dataElement; |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
107 } |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
108 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
109 |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
110 /** |
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
111 * Get name to display for selected watelerlevel (for example "Q=123") |
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
112 * from the CalculationResult. |
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
113 */ |
1180
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
114 public static String[] getLabels(CallContext cc, String value) { |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
115 String[] parts = value.split(SPLIT_CHAR); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
116 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
117 FLYSArtifact artifact = FLYSUtils.getArtifact(parts[0], cc); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
118 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
119 CalculationResult rawData = (CalculationResult) artifact.compute( |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
120 cc, |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
121 null, |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
122 WINFO_WSP_STATE_ID, |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
123 ComputeType.ADVANCE, |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
124 false); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
125 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
126 WQKms[] wqkms = (WQKms[]) rawData.getData(); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
127 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
128 int idx = -1; |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
129 try { |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
130 idx = Integer.parseInt(parts[2]); |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
131 } |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
132 catch (NumberFormatException nfe) { /* do nothing */ } |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
133 |
1657
91d038c7aae5
Bugfix: #328 Improved datacage configuration and labels for selected waterlevels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1655
diff
changeset
|
134 String name = wqkms[idx].getName(); |
91d038c7aae5
Bugfix: #328 Improved datacage configuration and labels for selected waterlevels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1655
diff
changeset
|
135 |
1660
804c58c56422
Extracted/use StringUtil.wWrap .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1657
diff
changeset
|
136 return new String[] { StringUtil.wWrap(name) }; |
1180
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
137 } |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
138 |
1aba1a75beb2
Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
139 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
140 /** |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
141 * Validates the given String. A valid string for this state requires the |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
142 * format: "UUID;FACETNAME;FACETINDEX". |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
143 * |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
144 * @param value The string value requires validation. |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
145 * |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
146 * @return true, if the string applies the specified format, otherwise |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
147 * false. |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
148 */ |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
149 public static boolean isValueValid(String value) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
150 logger.debug("Validate string: '" + value + "'"); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
151 |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
152 value = StringUtil.unbracket(value); |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
153 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
154 logger.debug("Validate substring: '" + value + "'"); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
155 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
156 if (value == null || value.length() == 0) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
157 return false; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
158 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
159 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
160 String[] parts = value.split(SPLIT_CHAR); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
161 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
162 if (parts == null || parts.length < 3) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
163 return false; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
164 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
165 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
166 if (parts[0] == null || parts[0].length() == 0) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
167 return false; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
168 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
169 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
170 if (parts[1] == null || parts[1].length() == 0) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
171 return false; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
172 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
173 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
174 try { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
175 Integer.parseInt(parts[2]); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
176 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
177 catch (NumberFormatException nfe) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
178 logger.error("Index is not a valid integer!", nfe); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
179 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
180 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
181 return true; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
182 } |
1172
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 } |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |