Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelSelectState.java @ 8456:572c102b1819
Improve error handling.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 29 Oct 2014 19:52:06 +0100 |
parents | e4606eae8ea5 |
children | 5e38e2924c07 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
9 package org.dive4elements.river.artifacts.states; |
1172
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
11 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
|
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 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
|
14 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
15 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
16 import org.dive4elements.artifacts.CallContext; |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
17 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
18 import org.dive4elements.artifactdatabase.data.DefaultStateData; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
19 import org.dive4elements.artifactdatabase.data.StateData; |
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
|
20 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
21 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
22 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
23 import org.dive4elements.river.artifacts.D4EArtifact; |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
24 import org.dive4elements.river.artifacts.StaticWKmsArtifact; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
25 import org.dive4elements.river.artifacts.model.CalculationResult; |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
26 import org.dive4elements.river.artifacts.model.WKms; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
27 import org.dive4elements.river.artifacts.model.extreme.ExtremeResult; |
7636
003502ea4854
issue1020: Handle FixRealizingResult for UESK waterlevel-selection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7571
diff
changeset
|
28 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5415
diff
changeset
|
29 import org.dive4elements.river.artifacts.resources.Resources; |
5865
73da40528cf2
River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
30 import org.dive4elements.river.utils.RiverUtils; |
8186
a1ceacf15d3a
Removed NASTY package clash. We had too org.dive4elements.river.util packages.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7660
diff
changeset
|
31 import org.dive4elements.river.backend.utils.StringUtil; |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
32 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
33 |
1172
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 /** |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 * @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
|
36 */ |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 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
|
38 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
39 private static final Logger log = |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
40 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
|
41 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
42 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
|
43 |
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
|
44 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
|
45 |
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
|
46 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
|
47 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
48 |
1172
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 @Override |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 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
|
51 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
|
52 } |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
53 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
54 |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
55 /** |
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
56 * @param flys ignored |
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
57 * @param cc ignrored |
7657
84573d5935be
Improved logging.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7638
diff
changeset
|
58 * @param stateData ignored |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
59 */ |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
60 @Override |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
61 public StateData transform( |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
62 D4EArtifact flys, |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
63 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
|
64 StateData stateData, |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
65 String name, |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
66 String val |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
67 ) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
68 if (!isValueValid(val)) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
69 log.error("The given input string is not valid: '" + val + "'"); |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
70 return null; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
71 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
72 |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
73 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
|
74 } |
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 @Override |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
78 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
|
79 throws IllegalArgumentException |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
80 { |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
81 D4EArtifact flys = (D4EArtifact) artifact; |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
82 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
83 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
|
84 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
85 if (data == null) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
86 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
|
87 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
88 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
89 return true; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
90 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
91 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
92 |
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
|
93 @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
|
94 protected Element createStaticData( |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
95 D4EArtifact 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 ) { |
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 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
|
103 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
|
104 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
|
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 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
|
107 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
|
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 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
|
110 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
|
111 |
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
|
112 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
|
113 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
|
114 |
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 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
|
116 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
|
117 |
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 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
|
119 } |
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 |
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 |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
122 /** |
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
123 * Get name to display for selected watelerlevel (for example "Q=123") |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2205
diff
changeset
|
124 * from the CalculationResult. |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
125 */ |
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
|
126 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
|
127 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
|
128 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
129 D4EArtifact artifact = RiverUtils.getArtifact(parts[0], cc); |
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
|
130 |
7571
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
131 Object rawData = artifact.compute( |
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
|
132 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
|
133 null, |
7571
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
134 //WINFO_WSP_STATE_ID, |
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
135 artifact.getCurrentStateId(), |
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
|
136 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
|
137 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
|
138 |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
139 WKms[] wkms = null; |
5415
5bac3e75f59c
WaterlevelSelectState: Avoid npe with extreme results.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4433
diff
changeset
|
140 |
7571
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
141 // TODO issue1020: Fetch cases in which only WKms or |
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
142 // other weird stuff arrives. |
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
143 if (rawData instanceof CalculationResult) { |
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
144 CalculationResult calcResult = (CalculationResult) rawData; |
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
145 if (calcResult.getData() instanceof ExtremeResult) { |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
146 wkms = ((ExtremeResult) calcResult.getData()).getWQKms(); |
7571
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
147 } |
7636
003502ea4854
issue1020: Handle FixRealizingResult for UESK waterlevel-selection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7571
diff
changeset
|
148 else if (calcResult.getData() instanceof FixRealizingResult) { |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
149 wkms = ((FixRealizingResult) calcResult.getData()).getWQKms(); |
7636
003502ea4854
issue1020: Handle FixRealizingResult for UESK waterlevel-selection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7571
diff
changeset
|
150 } |
7571
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
151 else { |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
152 wkms = (WKms[]) calcResult.getData(); |
7571
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
153 } |
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
154 } |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
155 else if (rawData instanceof WKms) { |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
156 wkms = new WKms[] {(WKms) rawData}; |
7571
f89ad512f426
issue1020: In WaterlevelSelectState create label more differentiated at
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6016
diff
changeset
|
157 } |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
158 else if (rawData instanceof WKms[]) { |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
159 wkms = (WKms[]) rawData; |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
160 } |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
161 else if (artifact instanceof StaticWKmsArtifact) { |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
162 wkms = new WKms[] {((StaticWKmsArtifact) artifact).getWKms(0)}; |
5415
5bac3e75f59c
WaterlevelSelectState: Avoid npe with extreme results.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4433
diff
changeset
|
163 } |
5bac3e75f59c
WaterlevelSelectState: Avoid npe with extreme results.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4433
diff
changeset
|
164 else { |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
165 if (rawData == null) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
166 log.error("Do not know how to handle null data " + |
7657
84573d5935be
Improved logging.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7638
diff
changeset
|
167 "from artifact class " + artifact.getClass()); |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
168 } |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
169 else { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
170 log.error("Do not know how to handle " + rawData.getClass()); |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
171 } |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
172 |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
173 wkms = null; |
7660 | 174 } |
175 if (wkms == null || wkms.length == 0) { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
176 log.error("No data for label generation."); |
7657
84573d5935be
Improved logging.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7638
diff
changeset
|
177 // This is critical, will fail without much grace later further down |
84573d5935be
Improved logging.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7638
diff
changeset
|
178 // the road. |
84573d5935be
Improved logging.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7638
diff
changeset
|
179 return new String[] {""}; |
5415
5bac3e75f59c
WaterlevelSelectState: Avoid npe with extreme results.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4433
diff
changeset
|
180 } |
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
|
181 |
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
|
182 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
|
183 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
|
184 idx = Integer.parseInt(parts[2]); |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
185 if (wkms[idx] == null) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
186 log.error("null label for " + value + " (" + parts[2] + ")"); |
7638
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
187 return new String[] {""}; |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
188 } |
21adafca6441
issue1020: Avoid some traps, use WKms and handle data from StaticArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7636
diff
changeset
|
189 String name = wkms[idx].getName(); |
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
|
190 |
6016
d24d29d9efa7
issue1320: Handle exception.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
191 return new String[] { StringUtil.wWrap(name) }; |
d24d29d9efa7
issue1320: Handle exception.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
192 } |
d24d29d9efa7
issue1320: Handle exception.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
193 catch (NumberFormatException nfe) { /* do nothing */ |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
194 log.error("Cannot get label for " + value + " (" + parts[2] + ")"); |
6016
d24d29d9efa7
issue1320: Handle exception.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
195 return new String[] {""}; |
d24d29d9efa7
issue1320: Handle exception.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
196 } |
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
|
197 } |
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
|
198 |
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
|
199 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
200 /** |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
201 * 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
|
202 * 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
|
203 * |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
204 * @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
|
205 * |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
206 * @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
|
207 * false. |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
208 */ |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
209 public static boolean isValueValid(String value) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
210 log.debug("Validate string: '" + value + "'"); |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
211 |
1655
d251e5929860
Extracted StringUtil.unbracket from WaterlevelSelectState.strip .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1187
diff
changeset
|
212 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
|
213 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
214 log.debug("Validate substring: '" + value + "'"); |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
215 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
216 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
|
217 return false; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
218 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
219 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
220 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
|
221 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
222 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
|
223 return false; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
224 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
225 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
226 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
|
227 return false; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
228 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
229 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
230 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
|
231 return false; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
232 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
233 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
234 try { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
235 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
|
236 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
237 catch (NumberFormatException nfe) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8186
diff
changeset
|
238 log.error("Index is not a valid integer!", nfe); |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
239 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
240 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
241 return true; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1172
diff
changeset
|
242 } |
1172
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
243 } |
23eb122c8ec1
Prepared the winfo artifact for floodmap calculations (now selectable in the UI).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
244 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |