Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java @ 2040:cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
flys-artifacts/trunk@3526 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 22 Dec 2011 12:52:12 +0000 |
parents | 355495661a1c |
children | 522826b41ffa |
rev | line source |
---|---|
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
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:
1691
diff
changeset
|
3 import java.text.NumberFormat; |
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:
1691
diff
changeset
|
4 |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
5 import gnu.trove.TDoubleArrayList; |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
6 |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.apache.log4j.Logger; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Element; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
137
diff
changeset
|
11 import de.intevation.artifacts.Artifact; |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.CallContext; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.common.utils.XMLUtils; |
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:
1691
diff
changeset
|
15 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifactdatabase.ProtocolUtils; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifactdatabase.data.StateData; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
20 import de.intevation.flys.model.Gauge; |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
21 import de.intevation.flys.model.River; |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
22 import de.intevation.flys.model.Wst; |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
23 |
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:
1691
diff
changeset
|
24 import de.intevation.flys.artifacts.FLYSArtifact; |
1055
61c051e53f9b
Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1050
diff
changeset
|
25 import de.intevation.flys.artifacts.WINFOArtifact; |
61c051e53f9b
Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1050
diff
changeset
|
26 |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
27 import de.intevation.flys.artifacts.model.WstFactory; |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.flys.artifacts.resources.Resources; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
1103
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1055
diff
changeset
|
30 import de.intevation.flys.utils.FLYSUtils; |
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1055
diff
changeset
|
31 |
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1055
diff
changeset
|
32 |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 /** |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 */ |
921
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
36 public class WQSelect extends DefaultState { |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
1691
17648043429f
Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1103
diff
changeset
|
38 /** The logger used in this class. */ |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 private static Logger logger = Logger.getLogger(WQSelect.class); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
1691
17648043429f
Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1103
diff
changeset
|
42 /** The default step width for Qs. */ |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 public static final String DEFAULT_STEP_Q = "50"; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
1691
17648043429f
Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1103
diff
changeset
|
45 /** The default step width for Qs. */ |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 public static final String DEFAULT_STEP_W = "30"; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
48 /** The name of the 'mode' field. */ |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
49 public static final String WQ_MODE = "wq_mode"; |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
50 |
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:
1691
diff
changeset
|
51 /** Them name fo the 'free' field. */ |
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:
1691
diff
changeset
|
52 public static final String WQ_FREE = "wq_free"; |
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:
1691
diff
changeset
|
53 |
1691
17648043429f
Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1103
diff
changeset
|
54 /** The name of the 'selection' field. */ |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
55 public static final String WQ_SELECTION = "wq_selection"; |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
56 |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
57 /** The name of the 'from' field. */ |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
58 public static final String WQ_FROM = "wq_from"; |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
59 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
60 /** The name of the 'to' field. */ |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
61 public static final String WQ_TO = "wq_to"; |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
62 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
63 /** The name of the 'step' field. */ |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
64 public static final String WQ_STEP = "wq_step"; |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
65 |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
66 /** The name of the 'single' field. */ |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
67 public static final String WQ_SINGLE = "wq_single"; |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
68 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
69 |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 /** |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 * The default constructor that initializes an empty State object. |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 */ |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 public WQSelect() { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 |
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:
1691
diff
changeset
|
76 |
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:
1691
diff
changeset
|
77 @Override |
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:
1691
diff
changeset
|
78 protected Element createStaticData( |
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:
1691
diff
changeset
|
79 FLYSArtifact flys, |
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:
1691
diff
changeset
|
80 ElementCreator creator, |
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:
1691
diff
changeset
|
81 CallContext cc, |
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:
1691
diff
changeset
|
82 String name, |
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:
1691
diff
changeset
|
83 String value, |
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:
1691
diff
changeset
|
84 String type |
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:
1691
diff
changeset
|
85 ) { |
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:
1691
diff
changeset
|
86 if (!name.equals(WQ_SINGLE)) { |
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:
1691
diff
changeset
|
87 return super.createStaticData(flys, creator, cc, name, value, type); |
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:
1691
diff
changeset
|
88 } |
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:
1691
diff
changeset
|
89 |
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:
1691
diff
changeset
|
90 String mode = flys.getDataAsString(WQ_MODE); |
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:
1691
diff
changeset
|
91 String free = flys.getDataAsString(WQ_FREE); |
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:
1691
diff
changeset
|
92 |
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:
1691
diff
changeset
|
93 WINFOArtifact winfo = (WINFOArtifact) flys; |
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:
1691
diff
changeset
|
94 |
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:
1691
diff
changeset
|
95 Element dataElement = creator.create("data"); |
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:
1691
diff
changeset
|
96 creator.addAttr(dataElement, "name", name, true); |
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:
1691
diff
changeset
|
97 creator.addAttr(dataElement, "type", type, true); |
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:
1691
diff
changeset
|
98 |
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:
1691
diff
changeset
|
99 Element itemElement = creator.create("item"); |
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:
1691
diff
changeset
|
100 creator.addAttr(itemElement, "value", value, true); |
2025
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
101 |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
102 String label = ""; |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
103 |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
104 if (mode == null || mode.equals("W") || Boolean.valueOf(free)) { |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
105 label = getLabel(winfo, cc, value); |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
106 } |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
107 else { |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
108 label = getSpecialLabel(winfo, cc, value); |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
109 } |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
110 |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
111 creator.addAttr(itemElement, "label", label, true); |
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:
1691
diff
changeset
|
112 |
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:
1691
diff
changeset
|
113 dataElement.appendChild(itemElement); |
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:
1691
diff
changeset
|
114 |
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:
1691
diff
changeset
|
115 return dataElement; |
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:
1691
diff
changeset
|
116 } |
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:
1691
diff
changeset
|
117 |
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:
1691
diff
changeset
|
118 |
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:
1691
diff
changeset
|
119 protected static String getLabel( |
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:
1691
diff
changeset
|
120 WINFOArtifact winfo, |
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:
1691
diff
changeset
|
121 CallContext cc, |
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:
1691
diff
changeset
|
122 String raw |
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:
1691
diff
changeset
|
123 ) { |
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:
1691
diff
changeset
|
124 String[] values = raw.split(" "); |
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:
1691
diff
changeset
|
125 String label = null; |
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:
1691
diff
changeset
|
126 |
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:
1691
diff
changeset
|
127 NumberFormat nf = NumberFormat.getInstance( |
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:
1691
diff
changeset
|
128 Resources.getLocale(cc.getMeta())); |
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:
1691
diff
changeset
|
129 |
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:
1691
diff
changeset
|
130 for (String value: values) { |
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:
1691
diff
changeset
|
131 try { |
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:
1691
diff
changeset
|
132 double v = Double.valueOf(value.trim()); |
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:
1691
diff
changeset
|
133 |
2025
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
134 String formatted = nf.format(v); |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
135 |
2030
355495661a1c
Changed the seperator character between Ws and Qs in the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2025
diff
changeset
|
136 label = label != null ? label + ";" + formatted : formatted; |
2025
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
137 } |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
138 catch (NumberFormatException nfe) { |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
139 // do nothing here |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
140 } |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
141 } |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
142 |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
143 return label; |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
144 } |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
145 |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
146 |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
147 protected static String getSpecialLabel( |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
148 WINFOArtifact winfo, |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
149 CallContext cc, |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
150 String raw |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
151 ) { |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
152 String[] values = raw.split(" "); |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
153 String label = null; |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
154 |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
155 NumberFormat nf = NumberFormat.getInstance( |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
156 Resources.getLocale(cc.getMeta())); |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
157 |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
158 for (String value: values) { |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
159 try { |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
160 double v = Double.valueOf(value.trim()); |
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
161 |
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:
1691
diff
changeset
|
162 String tmp = nf.format(v); |
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:
1691
diff
changeset
|
163 String mv = FLYSUtils.getNamedMainValue(winfo.getGauge(),v); |
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:
1691
diff
changeset
|
164 |
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:
1691
diff
changeset
|
165 if (mv != null && mv.length() > 0) { |
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:
1691
diff
changeset
|
166 String add = mv + ": " + tmp; |
2025
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
167 logger.debug("Add main value: '" + mv + "'"); |
2030
355495661a1c
Changed the seperator character between Ws and Qs in the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2025
diff
changeset
|
168 label = label != null ? label + ";" + add : add; |
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:
1691
diff
changeset
|
169 } |
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:
1691
diff
changeset
|
170 else { |
2025
6762f54b23b1
Bugfix: format all Ws and Qs in WQSelect State.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1743
diff
changeset
|
171 logger.debug("Add non main value: '" + tmp + "'"); |
2030
355495661a1c
Changed the seperator character between Ws and Qs in the Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2025
diff
changeset
|
172 label = label != null ? label + ";" + tmp : tmp; |
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:
1691
diff
changeset
|
173 } |
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:
1691
diff
changeset
|
174 } |
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:
1691
diff
changeset
|
175 catch (NumberFormatException nfe) { |
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:
1691
diff
changeset
|
176 // do nothing here |
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:
1691
diff
changeset
|
177 } |
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:
1691
diff
changeset
|
178 } |
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:
1691
diff
changeset
|
179 |
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:
1691
diff
changeset
|
180 return label; |
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:
1691
diff
changeset
|
181 } |
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:
1691
diff
changeset
|
182 |
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:
1691
diff
changeset
|
183 |
1691
17648043429f
Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1103
diff
changeset
|
184 @Override |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 protected Element createData( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 XMLUtils.ElementCreator cr, |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
137
diff
changeset
|
187 Artifact artifact, |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 StateData data, |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 CallContext context) |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 Element select = ProtocolUtils.createArtNode( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 cr, "select", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 cr.addAttr(select, "name", data.getName(), true); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 Element label = ProtocolUtils.createArtNode( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 cr, "label", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
199 Element choices = ProtocolUtils.createArtNode( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
200 cr, "choices", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
201 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 label.setTextContent(Resources.getMsg( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
203 context.getMeta(), |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
204 data.getName(), |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
205 data.getName())); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
206 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
207 select.appendChild(label); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
208 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 return select; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
210 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
211 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
212 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
631
diff
changeset
|
213 @Override |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
214 protected Element[] createItems( |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
215 XMLUtils.ElementCreator cr, |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
137
diff
changeset
|
216 Artifact artifact, |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
217 String name, |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 CallContext context) |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
219 { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
220 // TODO Insert correct min/max values! |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
221 double[] minmaxW = determineMinMaxW(artifact); |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
222 double[] minmaxQ = determineMinMaxQ(artifact); |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
223 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
224 if (name.equals("wq_from")) { |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
225 Element minW = createItem( |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
226 cr, new String[] {"minW", new Double(minmaxW[0]).toString()}); |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
227 Element minQ = createItem( |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
228 cr, new String[] {"minQ", new Double(minmaxQ[0]).toString()}); |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
229 return new Element[] { minW, minQ }; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
230 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
231 else if (name.equals("wq_to")) { |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
232 Element maxW = createItem( |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
233 cr, new String[] {"maxW", new Double(minmaxW[1]).toString()}); |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
234 Element maxQ = createItem( |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
235 cr, new String[] {"maxQ", new Double(minmaxQ[1]).toString()}); |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
236 return new Element[] { maxW, maxQ }; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
237 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
238 else { |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
631
diff
changeset
|
239 Element stepW = createItem( |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
631
diff
changeset
|
240 cr, new String[] {"stepW", DEFAULT_STEP_W}); |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
631
diff
changeset
|
241 Element stepQ = createItem( |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
631
diff
changeset
|
242 cr, new String[] {"stepQ", DEFAULT_STEP_Q}); |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
243 return new Element[] { stepW, stepQ }; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
244 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
245 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
246 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
247 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
248 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
249 Element item = ProtocolUtils.createArtNode(cr, "item", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
250 Element label = ProtocolUtils.createArtNode(cr, "label", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
251 Element value = ProtocolUtils.createArtNode(cr, "value", null, null); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
252 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
253 String[] arr = (String[]) obj; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
254 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
255 label.setTextContent(arr[0]); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
256 value.setTextContent(arr[1]); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
257 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
258 item.appendChild(label); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
259 item.appendChild(value); |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
260 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
261 return item; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
262 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
263 |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
264 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
631
diff
changeset
|
265 @Override |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
266 protected String getUIProvider() { |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
267 return "wq_panel"; |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
268 } |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
269 |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
270 |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
271 /** |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
272 * Determines the min and max W value for the current gauge. If no min and |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
273 * max values could be determined, this method will return |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
274 * [Double.MIN_VALUE, Double.MAX_VALUE]. |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
275 * |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
276 * @param artifact The FLYSArtifact. |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
277 * |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
278 * @return the min and max W values for the current gauge. |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
279 */ |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
280 protected double[] determineMinMaxW(Artifact artifact) { |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
281 logger.debug("WQSelect.determineCurrentGauge"); |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
282 |
1055
61c051e53f9b
Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1050
diff
changeset
|
283 Gauge gauge = ((WINFOArtifact) artifact).getGauge(); |
320
a8e7c351bdf1
The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
319
diff
changeset
|
284 double[] minmaxW = gauge != null ? gauge.determineMinMaxW() : null; |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
285 |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
286 double minW = minmaxW != null ? minmaxW[0] : Double.MIN_VALUE; |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
287 double maxW = minmaxW != null ? minmaxW[1] : Double.MAX_VALUE; |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
288 |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
289 return new double[] { minW, maxW }; |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
290 } |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
291 |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
292 |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
293 /** |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
294 * Determines the min and max Q value for the current gauge. If no min and |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
295 * max values could be determined, this method will return |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
296 * [Double.MIN_VALUE, Double.MAX_VALUE]. |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
297 * |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
298 * @param artifact The FLYSArtifact. |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
299 * |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
300 * @return the min and max Q values for the current gauge. |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
301 */ |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
302 protected double[] determineMinMaxQ(Artifact artifact) { |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
303 logger.debug("WQSelect.determineMinMaxQ"); |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
304 |
1055
61c051e53f9b
Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1050
diff
changeset
|
305 WINFOArtifact flysArtifact = (WINFOArtifact) artifact; |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
306 |
1103
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1055
diff
changeset
|
307 River river = FLYSUtils.getRiver(flysArtifact); |
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1055
diff
changeset
|
308 Gauge gauge = flysArtifact.getGauge(); |
e0243627ba62
Use FLYSUtils.getRiver instead of WINFOArtifact.getRiver.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1055
diff
changeset
|
309 Wst wst = WstFactory.getWst(river); |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
310 |
320
a8e7c351bdf1
The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
319
diff
changeset
|
311 double[] minmaxQ = gauge != null |
a8e7c351bdf1
The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
319
diff
changeset
|
312 ? wst.determineMinMaxQ(gauge.getRange()) |
a8e7c351bdf1
The getGauge() method of the FLYSArtifact returns the first gauge based on the given stationing now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
319
diff
changeset
|
313 : null; |
319
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
314 |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
315 double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE; |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
316 double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE; |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
317 |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
318 return new double[] { minQ, maxQ }; |
d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
319 } |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
320 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
321 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
322 @Override |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
921
diff
changeset
|
323 public boolean validate(Artifact artifact) |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
324 throws IllegalArgumentException |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
325 { |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
326 logger.debug("WQSelect.validate"); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
327 |
1055
61c051e53f9b
Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1050
diff
changeset
|
328 WINFOArtifact flys = (WINFOArtifact) artifact; |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
329 |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
330 StateData data = getData(flys, WQ_SELECTION); |
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
331 String selectionMode = data != null ? (String) data.getValue() : null; |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
332 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
333 if (selectionMode == null || selectionMode.equals("single")) { |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
921
diff
changeset
|
334 return validateSingle(artifact); |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
335 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
336 else { |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
921
diff
changeset
|
337 return validateRange(artifact); |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
338 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
339 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
340 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
341 |
921
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
342 protected boolean validateBounds( |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
343 double fromValid, double toValid, |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
344 double from, double to, double step) |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
345 throws IllegalArgumentException |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
346 { |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
347 logger.debug("RangeState.validateRange"); |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
348 |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
349 if (from < fromValid) { |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
350 logger.error( |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
351 "Invalid 'from'. " + from + " is smaller than " + fromValid); |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
352 throw new IllegalArgumentException("error_feed_from_out_of_range"); |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
353 } |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
354 else if (to > toValid) { |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
355 logger.error( |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
356 "Invalid 'to'. " + to + " is bigger than " + toValid); |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
357 throw new IllegalArgumentException("error_feed_to_out_of_range"); |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
358 } |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
359 |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
360 return true; |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
361 } |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
362 |
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
660
diff
changeset
|
363 |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
921
diff
changeset
|
364 protected boolean validateSingle(Artifact artifact) |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
365 throws IllegalArgumentException |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
366 { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
367 logger.debug("WQSelect.validateSingle"); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
368 |
1055
61c051e53f9b
Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1050
diff
changeset
|
369 WINFOArtifact flys = (WINFOArtifact) artifact; |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
370 StateData data = getData(flys, WQ_SINGLE); |
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
371 |
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
372 String tmp = data != null ? (String) data.getValue() : null; |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
373 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
374 if (tmp == null || tmp.length() == 0) { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
375 throw new IllegalArgumentException("error_empty_state"); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
376 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
377 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
378 String[] strValues = tmp.split(" "); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
379 TDoubleArrayList all = new TDoubleArrayList(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
380 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
381 for (String strValue: strValues) { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
382 try { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
383 all.add(Double.parseDouble(strValue)); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
384 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
385 catch (NumberFormatException nfe) { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
386 logger.warn(nfe, nfe); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
387 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
388 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
389 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
390 all.sort(); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
391 |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
392 StateData dMode = getData(flys, WQ_MODE); |
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
393 String mode = dMode != null ? (String) data.getValue() : null; |
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
394 |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
395 logger.debug("WQ Mode: " + mode); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
396 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
397 double[] minmax = null; |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
398 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
399 if (mode != null && mode.trim().toLowerCase().equals("w")) { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
400 minmax = determineMinMaxW(artifact); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
401 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
402 else { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
403 minmax = determineMinMaxQ(artifact); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
404 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
405 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
406 double min = all.get(0); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
407 double max = all.get(all.size()-1); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
408 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
409 logger.debug("Inserted min value = " + min); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
410 logger.debug("Inserted max value = " + max); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
411 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
412 return validateBounds(minmax[0], minmax[1], min, max, 0d); |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
413 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
414 |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
415 |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
921
diff
changeset
|
416 protected boolean validateRange(Artifact artifact) |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
417 throws IllegalArgumentException |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
418 { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
419 logger.debug("WQSelect.validateRange"); |
1055
61c051e53f9b
Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1050
diff
changeset
|
420 WINFOArtifact flys = (WINFOArtifact) artifact; |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
421 |
631
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
422 StateData data = flys.getData(WQ_MODE); |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
423 String mode = data != null ? (String) data.getValue() : null; |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
424 logger.debug("WQ Mode: " + mode); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
425 |
631
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
426 if (mode == null || mode.length() == 0) { |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
427 throw new IllegalArgumentException("error_feed_invalid_wq_mode"); |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
428 } |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
429 |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
430 StateData dFrom = flys.getData(WQ_FROM); |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
431 StateData dTo = flys.getData(WQ_TO); |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
432 StateData dStep = flys.getData(WQ_STEP); |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
433 |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
434 String fromStr = dFrom != null ? (String) dFrom.getValue() : null; |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
435 String toStr = dTo != null ? (String) dTo.getValue() : null; |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
436 String stepStr = dStep != null ? (String) dStep.getValue() : null; |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
437 |
352
ed3325a0232a
Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
438 if (fromStr == null || toStr == null || stepStr == null) { |
ed3325a0232a
Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
439 throw new IllegalArgumentException("error_empty_state"); |
ed3325a0232a
Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
440 } |
ed3325a0232a
Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
441 |
631
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
442 try { |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
443 double from = Double.parseDouble(fromStr); |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
444 double to = Double.parseDouble(toStr); |
a9af60c84dca
Small bugfixes in the WQ selection state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
445 double step = Double.parseDouble(stepStr); |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
446 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
447 if (mode != null && mode.trim().toLowerCase().equals("w")) { |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
921
diff
changeset
|
448 return validateW(artifact, from, to, step); |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
449 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
450 else if (mode != null && mode.trim().toLowerCase().equals("q")) { |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
921
diff
changeset
|
451 return validateQ(artifact, from, to, step); |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
452 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
453 else { |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
631
diff
changeset
|
454 throw new IllegalArgumentException( |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
631
diff
changeset
|
455 "error_feed_invalid_wq_mode"); |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
456 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
457 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
458 catch (NumberFormatException nfe) { |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
459 throw new IllegalArgumentException("error_feed_number_format"); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
460 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
461 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
462 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
463 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
464 /** |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
465 * Validates the inserted W values. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
466 * |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
467 * @param artifact The owner artifact. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
468 * @param from The lower value of the W range. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
469 * @param to The upper value of the W range. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
470 * @param step The step width. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
471 * |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
472 * @return true, if everything was fine, otherwise an exception is thrown. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
473 */ |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
474 protected boolean validateW( |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
475 Artifact artifact, |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
476 double from, |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
477 double to, |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
478 double step) |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
479 throws IllegalArgumentException |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
480 { |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
481 logger.debug("WQSelect.validateW"); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
482 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
483 double[] minmaxW = determineMinMaxW(artifact); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
484 |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
485 return validateBounds(minmaxW[0], minmaxW[1], from, to, step); |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
486 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
487 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
488 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
489 /** |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
490 * Validates the inserted Q values. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
491 * |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
492 * @param artifact The owner artifact. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
493 * @param from The lower value of the Q range. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
494 * @param to The upper value of the Q range. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
495 * @param step The step width. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
496 * |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
497 * @return true, if everything was fine, otherwise an exception is thrown. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
498 */ |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
499 protected boolean validateQ( |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
500 Artifact artifact, |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
501 double from, |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
502 double to, |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
503 double step) |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
504 throws IllegalArgumentException |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
505 { |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
506 logger.debug("WQSelect.validateQ"); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
507 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
508 double[] minmaxQ = determineMinMaxQ(artifact); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
509 |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
352
diff
changeset
|
510 return validateBounds(minmaxQ[0], minmaxQ[1], from, to, step); |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
320
diff
changeset
|
511 } |
137
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
512 } |
7f839b81cdde
Added a new state for the W/Q input in the WINFO parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
513 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |