annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelGroundDifferences.java @ 8202:e4606eae8ea5

sed src/**/*.java 's/logger/log/g'
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 12:58:17 +0200
parents 714fda61b006
children 2323d005f9a5 0a5239a1e46e
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4865
diff changeset
9 package org.dive4elements.river.artifacts.states;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.w3c.dom.Element;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
15 import org.dive4elements.river.artifacts.D4EArtifact;
4865
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
16
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4865
diff changeset
17 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4865
diff changeset
18 import org.dive4elements.artifacts.CallContext;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4865
diff changeset
20 import org.dive4elements.artifacts.common.utils.XMLUtils;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4865
diff changeset
22 import org.dive4elements.artifactdatabase.data.StateData;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4865
diff changeset
23 import org.dive4elements.artifactdatabase.ProtocolUtils;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 /**
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 */
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 public class WaterlevelGroundDifferences extends RangeState {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 public static final String LOWER_FIELD = "diff_from";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 public static final String UPPER_FIELD = "diff_to";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 public static final String DIFF_FIELD = "diff_diff";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public static final double DEFAULT_STEP = 0d;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7736
diff changeset
38 private static Logger log =
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 Logger.getLogger(WaterlevelGroundDifferences.class);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 protected String getLowerField() {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 return LOWER_FIELD;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 protected String getUpperField() {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 return UPPER_FIELD;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 protected String getStepField() {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 return DIFF_FIELD;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 @Override
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 protected double[] getMinMax(Artifact artifact) {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 return new double[] { -Double.MAX_VALUE, Double.MAX_VALUE };
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 @Override
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 protected String getUIProvider() {
928
e7664917dbdf Changed the desired UI provider for the WaterlevelGroundDifferences state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
65 return "waterlevel_ground_panel";
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 protected double getDefaultStep() {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 return DEFAULT_STEP;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 @Override
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 protected Element[] createItems(
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 XMLUtils.ElementCreator cr,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 Artifact artifact,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 String name,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 CallContext context)
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 double[] minmax = getMinMax(artifact);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 double minVal = Double.MIN_VALUE;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 double maxVal = Double.MAX_VALUE;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 if (minmax != null) {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 minVal = minmax[0];
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 maxVal = minmax[1];
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7736
diff changeset
91 log.warn("Could not read min/max distance values!");
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 if (name.equals(LOWER_FIELD)) {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 Element min = createItem(
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 cr,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 new String[] {"min", new Double(minVal).toString()});
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 return new Element[] { min };
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 else if (name.equals(UPPER_FIELD)) {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 Element max = createItem(
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 cr,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 new String[] {"max", new Double(maxVal).toString()});
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 return new Element[] { max };
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 else {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 Element step = createItem(
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 cr,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 new String[] {"step", String.valueOf(getDefaultStep())});
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 return new Element[] { step };
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 String[] arr = (String[]) obj;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 label.setTextContent(arr[0]);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 value.setTextContent(arr[1]);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 item.appendChild(label);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 item.appendChild(value);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 return item;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 }
4865
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
132
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
133 @Override
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
134 public boolean validate(Artifact artifact)
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
135 throws IllegalArgumentException
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
136 {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
137 D4EArtifact flys = (D4EArtifact) artifact;
4865
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
138
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
139 StateData dFrom = getData(flys, getLowerField());
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
140 StateData dTo = getData(flys, getUpperField());
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
141 StateData dStep = getData(flys, getStepField());
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
142
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
143 String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
144 String toStr = dTo != null ? (String) dTo.getValue() : null;
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
145 String stepStr = dStep != null ? (String) dStep.getValue() : null;
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
146
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
147 if (fromStr == null || toStr == null || stepStr == null) {
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
148 throw new IllegalArgumentException("error_empty_state");
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
149 }
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
150
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
151 try {
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
152 double from = Double.parseDouble(fromStr);
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
153 double to = Double.parseDouble(toStr);
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
154 double step = Double.parseDouble(stepStr);
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
155
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
156 double[] minmax = getMinMax(flys);
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
157
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
158 return validateBounds(minmax[0], minmax[1], from, to, step);
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
159 }
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
160 catch (NumberFormatException nfe) {
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
161 throw new IllegalArgumentException("error_invalid_double_value");
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
162 }
1358d0c8481c RangeState and descendants: Use RangeAccess, resolve direct ld_* usage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 928
diff changeset
163 }
7736
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
164
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
165 @Override
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
166 protected boolean validateBounds(
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
167 double fromValid, double toValid,
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
168 double from, double to
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
169 ) throws IllegalArgumentException {
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
170 if (to < 0d) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7736
diff changeset
171 log.error(
7736
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
172 "Invalid 'to' " + to + " is lesser than zero.");
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
173 throw new IllegalArgumentException("error_feed_from_out_of_range");
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
174 }
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
175 return super.validateBounds(fromValid, toValid, from, to);
714fda61b006 Server side validation for flys/issue1549.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
176 }
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org