annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java @ 417:e54053bc0e70

Implemented the input validation of WQ in the adapted WQ panel. flys-artifacts/trunk@1882 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 10 May 2011 15:28:30 +0000
parents 34de11dcf355
children 929137ee8154
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;
417
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
5 import java.util.Map;
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
6
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 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
8
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 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
10
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 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
12 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
13
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 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
15 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
16
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 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
18
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 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
20 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
21 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
22 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
23
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 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
25 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
26 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
27
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 * @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
31 */
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 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
33
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 /** 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
35 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
36
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
401
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
38 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
39
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
40 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
41
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
42
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
43 /**
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
44 * 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
45 * 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
46 * (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
47 * 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
48 * 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
49 *
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
50 * @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
51 * @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
52 * @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
53 * @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
54 *
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
55 * @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
56 * 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
57 */
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
58 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
59 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
60 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
61 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
62 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
63 {
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 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
65
401
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
66 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
67 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
68 }
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
69 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
70 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
71 }
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
72 else {
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
73 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
74 return null;
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
75 }
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
76 }
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
77
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
78
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
79 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
80 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
81 Artifact artifact,
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
82 String name,
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
83 CallContext context)
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
84 {
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
85 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
86
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
87 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
88 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
89
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
90 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
91 }
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
92
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
93
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
94 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
95 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
96 Artifact artifact,
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
97 String name,
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
98 CallContext context)
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
99 {
34de11dcf355 Small bugfix in the adapted WQ state and further i18n strings.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 399
diff changeset
100 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
101
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
102 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
103
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
104 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
105 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
106
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
107 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
108
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
109 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
110 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
111 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
112 }
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
113
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
114 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
115
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
116 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
117
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
118 for (Gauge gauge: 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
119 Range range = gauge.getRange();
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
120 double lower = range.getA().doubleValue();
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 double upper = range.getB().doubleValue();
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 from = dist[0] < lower ? lower : dist[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
124 double to = dist[1] > upper ? upper : dist[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
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 String key = Double.toString(from) + ";" + Double.toString(to);
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 elements[idx++] = createItem(cr, new String[] {key, ""});
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 }
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
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 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
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
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
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
135 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
136 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
137 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
138 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
139
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
140 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
141
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
142 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
143 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
144
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
145 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
146 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
147
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
148 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
149 }
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
150
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
151
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
152 @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
153 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
154 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
155 }
417
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
156
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
157
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
158 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
159 throws IllegalArgumentException
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
160 {
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
161 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
162
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
163 Map<String, StateData> data = getData();
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
164
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
165 String mode = (String) data.get(FIELD_WQ_MODE).getValue();
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
166
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
167 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
168 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
169 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
170 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
171 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
172 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
173 else {
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
174 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
175 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
176 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
177
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
178
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
179 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
180 throws IllegalArgumentException
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
181 {
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
182 logger.debug("WQAdapted.validateW");
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
183
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
184 RangeWithValues[] rwvs = extractInput(getData("wq_values"));
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
185 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
186
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
187 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
188 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
189 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
190 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
191
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
192 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
193 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
194 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
195 }
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 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
198
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
199 return true;
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
200 }
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
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
203 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
204 throws IllegalArgumentException
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
205 {
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
206 logger.debug("WQAdapted.validateQ");
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
207
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
208 RangeWithValues[] rwvs = extractInput(getData("wq_values"));
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
209 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
210 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
211 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
212
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
213 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
214 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
215 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
216 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
217
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
218 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
219 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
220 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
221 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
222 }
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
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
225 return true;
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
226 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
227
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
228
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
229 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
230 throws IllegalArgumentException
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
231 {
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
232 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
233 ? 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
234 : null;
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
235
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
236 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
237 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
238 return true;
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
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
241 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
242 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
243 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
244 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
245 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
246 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
247
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
248 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
249 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
250 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
251 "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
252 }
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
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
255 return true;
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
256 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
257
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
258
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
259 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
260 throws IllegalArgumentException
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
261 {
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
262 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
263 ? gauge.determineMinMaxW()
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
264 : null;
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
265
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
266 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
267 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
268 return true;
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
269 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
270
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
271 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
272 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
273 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
274 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
275 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
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 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
279 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
280 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
281 "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
282 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
283 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
284
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
285 return true;
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
286 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
287
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
288
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
289 protected RangeWithValues[] extractInput(StateData data) {
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
290 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
291 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
292
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
293 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
294
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
295 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
296 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
297
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
298 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
299 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
300
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
301 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
302
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
303 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
304 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
305
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
306 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
307 try {
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
308 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
309 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
310 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
311 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
312 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
313 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
314
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
315 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
316 }
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
317
e54053bc0e70 Implemented the input validation of WQ in the adapted WQ panel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 401
diff changeset
318 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
319 }
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
320 }
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
321 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org