annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/MinMaxState.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
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: 2235
diff changeset
9 package org.dive4elements.river.artifacts.states;
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.w3c.dom.Element;
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8618
diff changeset
13 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8618
diff changeset
14 import org.apache.logging.log4j.LogManager;
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
15
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
16 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
17 import org.dive4elements.artifacts.CallContext;
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
19 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
20 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
22 import org.dive4elements.artifactdatabase.ProtocolUtils;
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
24 import org.dive4elements.river.artifacts.D4EArtifact;
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 /**
2235
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2205
diff changeset
28 * State that holds minimun and maximum (for validation).
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2205
diff changeset
29 *
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 */
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 public abstract class MinMaxState extends DefaultState {
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8618
diff changeset
34 private static final Logger log = LogManager.getLogger(MinMaxState.class);
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
35
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 @Override
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 protected void appendItems(
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 Artifact artifact,
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 ElementCreator creator,
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 String name,
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 CallContext context,
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 Element select
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 ) {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
44 D4EArtifact flys = (D4EArtifact) artifact;
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 select.setAttributeNS(
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 ArtifactNamespaceContext.NAMESPACE_URI,
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 "art:type",
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 getType());
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
8618
42fc26e463db Remove another obsolete check for an unused (and removed) config value
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
51 String[] defMinMax = getMinMaxDefaults(artifact, name);
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
52
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 Element min = ProtocolUtils.createArtNode(
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 creator,
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 "min",
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
56 new String[] { "value", "default" },
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
57 new String[] { String.valueOf(getLower(flys)), defMinMax[0] });
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 Element max = ProtocolUtils.createArtNode(
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 creator,
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 "max",
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
62 new String[] { "value", "default" },
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
63 new String[] { String.valueOf(getUpper(flys)), defMinMax[1] });
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 select.appendChild(min);
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 select.appendChild(max);
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 }
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
70 /**
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
71 * @param cc
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
72 * @param name
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
73 * @param value
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
74 * @param type
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
75 *
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
76 * @return
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
77 */
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
78 @Override
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
79 protected String getLabelFor(
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
80 CallContext cc,
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
81 String name,
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
82 String value,
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
83 String type
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
84 ) {
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
85 if (type.indexOf("range") > 0) {
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
86 String[] minmax = extractRangeAsString(value);
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
87
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
88 if (minmax != null) {
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
89 return minmax[0] + " - " + minmax[1];
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
90 }
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
91 }
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
92
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
93 return super.getLabelFor(cc, name, value, type);
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
94 }
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
95
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
96
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
97 /**
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
98 * Returns a string array with [min,max] from <i>rawValue</i>.
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
99 * <i>rawValue</i> should be a string like "1999;2001".
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
100 *
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
101 * @param rawValue A string with min and max separated by a ';'.
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
102 *
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
103 * @return the min and max as string array ([min,max]).
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
104 */
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
105 protected String[] extractRangeAsString(String rawValue) {
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
106 return rawValue.split(";");
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
107 }
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
108
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
109
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
110 /**
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
111 * Returns a string array with minimum and maximum inserted by the user as
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
112 * [min,max].
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
113 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
114 * @param artifact The D4EArtifact that stores the parameter.
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
115 * @param name The name of the parameter for raw min/max value string.
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
116 *
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
117 * @return a string array [min,max].
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
118 */
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
119 protected String[] getMinMaxByParameter(Artifact artifact, String name) {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
120 D4EArtifact flys = (D4EArtifact) artifact;
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
121 String rawValue = flys.getDataAsString(name);
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
122
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
123 if (rawValue == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
124 log.debug("No value for '" + rawValue + "' existing.");
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
125 return null;
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
126 }
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
127
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
128 log.debug("Raw value for '" + name + "' = " + rawValue);
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
129
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
130 return extractRangeAsString(rawValue);
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
131 }
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
132
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
133
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
134 /**
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
135 * Returns a string array with absolute minimum and maximum as [min,max].
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
136 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
137 * @param artifact The D4EArtifact (not used in this implementation).
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
138 * @param name The parameter name (not used in this implementation).
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
139 *
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
140 * @return a string array [min,max].
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
141 */
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
142 protected String[] getMinMaxDefaults(Artifact artifact, String name) {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
143 D4EArtifact flys = (D4EArtifact) artifact;
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
144
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
145 Object lower = getLower(flys);
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
146 Object upper = getUpper(flys);
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
147
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
148 return new String[] { String.valueOf(lower), String.valueOf(upper) };
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
149 }
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
150
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
151
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
152 protected abstract Object getLower(D4EArtifact flys);
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
154 protected abstract Object getUpper(D4EArtifact flys);
2190
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 protected abstract String getType();
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 }
2792d2617be9 Introduced an abstract MinMaxState and a concrete class IntRangeState to add min/max value pairs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org