Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java @ 666:eb45e05e5c5b
Set the second y axis to axis position 1 (starts at 0).
flys-artifacts/trunk@2079 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 08 Jun 2011 12:35:44 +0000 |
parents | 627be3ca1ab6 |
children | dda282dcc44f |
rev | line source |
---|---|
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
3 import java.util.ArrayList; |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
636
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
5 import java.util.Comparator; |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
6 import java.util.Collections; |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.apache.log4j.Logger; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.Element; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.Artifact; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.CallContext; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifactdatabase.ProtocolUtils; |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
16 import de.intevation.artifactdatabase.data.StateData; |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifacts.common.utils.XMLUtils; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.model.Gauge; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.model.Range; |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
22 import de.intevation.flys.model.River; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
23 import de.intevation.flys.model.Wst; |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.artifacts.FLYSArtifact; |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
26 import de.intevation.flys.artifacts.model.RangeWithValues; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
27 import de.intevation.flys.artifacts.model.WstFactory; |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 /** |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 */ |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public class WQAdapted extends DefaultState { |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 /** The logger used in this state.*/ |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 private static Logger logger = Logger.getLogger(WQAdapted.class); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
401
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
39 public static final String FIELD_WQ_MODE = "wq_mode"; |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
40 |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
41 public static final String FIELD_WQ_VALUES = "wq_values"; |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
42 |
636
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
43 public static final class GaugeOrder implements Comparator<Gauge> { |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
44 private int order; |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
45 |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
46 public GaugeOrder(boolean up) { |
642
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
636
diff
changeset
|
47 order = up ? 1 : -1; |
636
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
48 } |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
49 |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
50 public int compare(Gauge a, Gauge b) { |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
51 return order * a.getRange().getA().compareTo(b.getRange().getA()); |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
52 } |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
53 } // class GaugeOrder |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
54 |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
55 public static final GaugeOrder GAUGE_UP = new GaugeOrder(true); |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
56 public static final GaugeOrder GAUGE_DOWN = new GaugeOrder(false); |
401
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
57 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
58 public WQAdapted() { |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
59 } |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
60 |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 /** |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 * This method creates one element for each gauge of the selected river that |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 * is intersected by the given kilometer range. Each element is a tuple of |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 * (from;to) where <i>from</i> is the lower bounds of the gauge or the lower |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 * kilometer range. <i>to</i> is the upper bounds of the gauge or the upper |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 * kilometer range. |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 * |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 * @param cr The ElementCreator. |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 * @param artifact The FLYS artifact. |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 * @param name The name of the data item. |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 * @param context The CallContext. |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 * |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 * @return a list of elements that consist of tuples of the intersected |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 * gauges of the selected river. |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 */ |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
76 @Override |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 protected Element[] createItems( |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 XMLUtils.ElementCreator cr, |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 Artifact artifact, |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 String name, |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 CallContext context) |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 { |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 logger.debug("WQAdapted.createItems"); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 |
401
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
85 if (name != null && name.equals(FIELD_WQ_MODE)) { |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
86 return createModeItems(cr, artifact, name, context); |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
87 } |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
88 else if (name != null && name.equals(FIELD_WQ_VALUES)) { |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
89 return createValueItems(cr, artifact, name, context); |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
90 } |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
91 else { |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
92 logger.warn("Unknown data object: " + name); |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
93 return null; |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
94 } |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
95 } |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
96 |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
97 |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
98 protected Element[] createModeItems( |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
99 XMLUtils.ElementCreator cr, |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
100 Artifact artifact, |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
101 String name, |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
102 CallContext context) |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
103 { |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
104 logger.debug("WQAdapted.createModeItems"); |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
105 |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
106 Element w = createItem(cr, new String[] { "w", "W" }); |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
107 Element q = createItem(cr, new String[] { "q", "Q" }); |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
108 |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
109 return new Element[] { w, q }; |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
110 } |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
111 |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
112 |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
113 protected Element[] createValueItems( |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
114 XMLUtils.ElementCreator cr, |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
115 Artifact artifact, |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
116 String name, |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
117 CallContext context) |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
118 { |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
119 logger.debug("WQAdapted.createValueItems"); |
34de11dcf355
Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
399
diff
changeset
|
120 |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 FLYSArtifact flysArtifact = (FLYSArtifact) artifact; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 double[] dist = flysArtifact.getDistance(); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 List<Gauge> gauges = flysArtifact.getGauges(); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 int num = gauges != null ? gauges.size() : 0; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 if (num == 0) { |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 logger.warn("Selected distance matches no gauges."); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 return null; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 } |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 Element[] elements = new Element[num]; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 |
636
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
135 double rangeFrom = dist[0]; |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
136 double rangeTo = dist[1]; |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
137 |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 int idx = 0; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 |
636
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
140 if (rangeFrom < rangeTo) { |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
141 Collections.sort(gauges, GAUGE_UP); |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
142 for (Gauge gauge: gauges) { |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
143 Range range = gauge.getRange(); |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
144 double lower = range.getA().doubleValue(); |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
145 double upper = range.getB().doubleValue(); |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 |
636
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
147 double from = lower < rangeFrom ? rangeFrom : lower; |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
148 double to = upper > rangeTo ? rangeTo : upper; |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 |
636
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
150 elements[idx++] = createItem( |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
151 cr, new String[] { from + ";" + to, ""}); |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
152 } |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
153 } |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
154 else { |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
155 Collections.sort(gauges, GAUGE_DOWN); |
642
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
636
diff
changeset
|
156 rangeFrom = dist[1]; |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
636
diff
changeset
|
157 rangeTo = dist[0]; |
636
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
158 for (Gauge gauge: gauges) { |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
159 Range range = gauge.getRange(); |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
160 double lower = range.getA().doubleValue(); |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
161 double upper = range.getB().doubleValue(); |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 |
642
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
636
diff
changeset
|
163 double from = lower < rangeFrom ? rangeFrom : lower; |
2dbbb5be30a1
Re-eanbled the calculation of the backjump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
636
diff
changeset
|
164 double to = upper > rangeTo ? rangeTo : upper; |
636
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
165 |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
166 elements[idx++] = createItem( |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
167 cr, new String[] { to + ";" + from, ""}); |
58276db49b16
Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
624
diff
changeset
|
168 } |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 } |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 return elements; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 } |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) { |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 Element item = ProtocolUtils.createArtNode(cr, "item", null, null); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 Element label = ProtocolUtils.createArtNode(cr, "label", null, null); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 Element value = ProtocolUtils.createArtNode(cr, "value", null, null); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 String[] arr = (String[]) obj; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 label.setTextContent(arr[0]); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 value.setTextContent(arr[1]); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 item.appendChild(label); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 item.appendChild(value); |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 return item; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 } |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 @Override |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 protected String getUIProvider() { |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 return "wq_panel_adapted"; |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 } |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
196 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
197 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
642
diff
changeset
|
198 @Override |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
199 public boolean validate(Artifact artifact, CallContext context) |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
200 throws IllegalArgumentException |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
201 { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
202 logger.debug("WQAdapted.validate"); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
203 |
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:
417
diff
changeset
|
204 FLYSArtifact flys = (FLYSArtifact) artifact; |
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:
417
diff
changeset
|
205 StateData data = getData(flys, FIELD_WQ_MODE); |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
206 |
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:
417
diff
changeset
|
207 String mode = data != null ? (String) data.getValue() : null; |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
208 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
209 if (mode != null && mode.equals("W")) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
210 return validateW(artifact, context); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
211 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
212 else if (mode != null && mode.equals("Q")) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
213 return validateQ(artifact, context); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
214 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
215 else { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
216 throw new IllegalArgumentException("error_feed_no_wq_mode_selected"); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
217 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
218 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
219 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
220 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
221 protected boolean validateW(Artifact artifact, CallContext context) |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
222 throws IllegalArgumentException |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
223 { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
224 logger.debug("WQAdapted.validateW"); |
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:
417
diff
changeset
|
225 FLYSArtifact flys = (FLYSArtifact) artifact; |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
226 |
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:
417
diff
changeset
|
227 RangeWithValues[] rwvs = extractInput(getData(flys, "wq_values")); |
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:
417
diff
changeset
|
228 |
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:
417
diff
changeset
|
229 if (rwvs == 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:
417
diff
changeset
|
230 throw new IllegalArgumentException("error_missing_wq_data"); |
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:
417
diff
changeset
|
231 } |
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:
417
diff
changeset
|
232 |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
233 List<Gauge> gauges = ((FLYSArtifact) artifact).getGauges(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
234 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
235 for (Gauge gauge: gauges) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
236 Range range = gauge.getRange(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
237 double lower = range.getA().doubleValue(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
238 double upper = range.getB().doubleValue(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
239 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
240 for (RangeWithValues rwv: rwvs) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
241 if (lower <= rwv.getLower() && upper >= rwv.getUpper()) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
242 compareWsWithGauge(gauge, rwv.getValues()); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
243 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
244 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
245 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
246 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
247 return true; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
248 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
249 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
250 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
251 protected boolean validateQ(Artifact artifact, CallContext context) |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
252 throws IllegalArgumentException |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
253 { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
254 logger.debug("WQAdapted.validateQ"); |
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:
417
diff
changeset
|
255 FLYSArtifact flys = (FLYSArtifact) artifact; |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
256 |
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:
417
diff
changeset
|
257 RangeWithValues[] rwvs = extractInput(getData(flys, "wq_values")); |
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:
417
diff
changeset
|
258 |
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:
417
diff
changeset
|
259 if (rwvs == 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:
417
diff
changeset
|
260 throw new IllegalArgumentException("error_missing_wq_data"); |
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:
417
diff
changeset
|
261 } |
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:
417
diff
changeset
|
262 |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
263 List<Gauge> gauges = ((FLYSArtifact) artifact).getGauges(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
264 River river = ((FLYSArtifact) artifact).getRiver(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
265 Wst wst = WstFactory.getWst(river); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
266 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
267 for (Gauge gauge: gauges) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
268 Range range = gauge.getRange(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
269 double lower = range.getA().doubleValue(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
270 double upper = range.getB().doubleValue(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
271 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
272 for (RangeWithValues rwv: rwvs) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
273 if (lower <= rwv.getLower() && upper >= rwv.getUpper()) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
274 compareQsWithGauge(wst, gauge, rwv.getValues()); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
275 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
276 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
277 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
278 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
279 return true; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
280 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
281 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
282 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
283 protected boolean compareQsWithGauge(Wst wst, Gauge gauge, double[] qs) |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
284 throws IllegalArgumentException |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
285 { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
286 double[] minmax = gauge != null |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
287 ? wst.determineMinMaxQ(gauge.getRange()) |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
288 : null; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
289 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
290 if (minmax == null) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
291 logger.warn("Could not determine min/max Q of gauge."); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
292 return true; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
293 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
294 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
295 if (logger.isDebugEnabled()) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
296 logger.debug("Validate Qs with:"); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
297 logger.debug("-- Gauge: " + gauge.getName()); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
298 logger.debug("-- Gauge min: " + minmax[0]); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
299 logger.debug("-- Gauge max: " + minmax[1]); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
300 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
301 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
302 for (double q: qs) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
303 if (q < minmax[0] || q > minmax[1]) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
304 throw new IllegalArgumentException( |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
305 "error_feed_q_values_invalid"); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
306 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
307 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
308 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
309 return true; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
310 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
311 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
312 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
313 protected boolean compareWsWithGauge(Gauge gauge, double[] ws) |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
314 throws IllegalArgumentException |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
315 { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
316 double[] minmax = gauge != null |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
317 ? gauge.determineMinMaxW() |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
318 : null; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
319 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
320 if (minmax == null) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
321 logger.warn("Could not determine min/max W of gauge."); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
322 return true; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
323 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
324 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
325 if (logger.isDebugEnabled()) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
326 logger.debug("Validate Ws with:"); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
327 logger.debug("-- Gauge: " + gauge.getName()); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
328 logger.debug("-- Gauge min: " + minmax[0]); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
329 logger.debug("-- Gauge max: " + minmax[1]); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
330 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
331 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
332 for (double w: ws) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
333 if (w < minmax[0] || w > minmax[1]) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
334 throw new IllegalArgumentException( |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
335 "error_feed_w_values_invalid"); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
336 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
337 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
338 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
339 return true; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
340 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
341 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
342 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
343 protected RangeWithValues[] extractInput(StateData data) { |
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:
417
diff
changeset
|
344 if (data == 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:
417
diff
changeset
|
345 return 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:
417
diff
changeset
|
346 } |
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:
417
diff
changeset
|
347 |
417
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
348 String dataString = (String) data.getValue(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
349 String[] ranges = dataString.split(":"); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
350 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
351 List<RangeWithValues> rwv = new ArrayList<RangeWithValues>(); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
352 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
353 for (String range: ranges) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
354 String[] parts = range.split(";"); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
355 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
356 double lower = Double.parseDouble(parts[0]); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
357 double upper = Double.parseDouble(parts[1]); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
358 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
359 String[] values = parts[2].split(","); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
360 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
361 int num = values.length; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
362 double[] res = new double[num]; |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
363 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
364 for (int i = 0; i < num; i++) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
365 try { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
366 res[i] = Double.parseDouble(values[i]); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
367 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
368 catch (NumberFormatException nfe) { |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
369 logger.warn(nfe, nfe); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
370 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
371 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
372 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
373 rwv.add(new RangeWithValues(lower, upper, res)); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
374 } |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
375 |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
376 return (RangeWithValues[]) rwv.toArray(new RangeWithValues[rwv.size()]); |
e54053bc0e70
Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
401
diff
changeset
|
377 } |
399
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
378 } |
53cc794fee07
Improved the transition model and added states to enable the 'discharge longitudinal section' computation - NOTE: the work in this computation has not finished yet.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
379 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |