Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MinMaxState.java @ 5550:220d12a41bfa
merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 04 Apr 2013 10:56:26 +0200 |
parents | ee5310134463 |
children |
rev | line source |
---|---|
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
|
1 package de.intevation.flys.artifacts.states; |
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
|
2 |
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
|
3 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
|
4 |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
5 import org.apache.log4j.Logger; |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
6 |
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
|
7 import de.intevation.artifacts.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
|
8 import de.intevation.artifacts.CallContext; |
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
|
9 |
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 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
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 de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
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 |
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
|
13 import de.intevation.artifactdatabase.ProtocolUtils; |
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
|
14 |
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
|
15 import de.intevation.flys.artifacts.FLYSArtifact; |
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
|
16 |
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
|
17 |
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 /** |
2235
ee5310134463
Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2205
diff
changeset
|
19 * State that holds minimun and maximum (for validation). |
ee5310134463
Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2205
diff
changeset
|
20 * |
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 * @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
|
22 */ |
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 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
|
24 |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
25 private static final Logger logger = Logger.getLogger(MinMaxState.class); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
26 |
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
|
27 @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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 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
|
34 ) { |
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
|
35 FLYSArtifact flys = (FLYSArtifact) 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
|
36 |
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 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
|
38 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
|
39 "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
|
40 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
|
41 |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
42 String[] defMinMax = getDefaults(artifact, name); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
43 |
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
|
44 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
|
45 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
|
46 "min", |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
47 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
|
48 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
|
49 |
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 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
|
51 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
|
52 "max", |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
53 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
|
54 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
|
55 |
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
|
56 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
|
57 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
|
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 |
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 |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
61 /** |
2205
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
62 * @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
|
63 * @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
|
64 * @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
|
65 * @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
|
66 * |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
67 * @return |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
68 */ |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
69 @Override |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
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 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
|
77 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
|
78 |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
79 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
|
80 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
|
81 } |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
82 } |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
83 |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
84 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
|
85 } |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
86 |
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 /** |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
89 * 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
|
90 * <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
|
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 * @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
|
93 * |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
94 * @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
|
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 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
|
97 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
|
98 } |
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
99 |
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 /** |
2202
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
102 * This method returns the default values for min and max. If the static |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
103 * field DefaultState.USE_DEFAULTS is set, the minimum and maximum inserted |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
104 * by the user is returned as string. Otherwise, the absolute minimum and |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
105 * maximum are returned. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
106 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
107 * @param artifact The FLYSArtifact. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
108 * @param name The name of the parameter. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
109 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
110 * @return a string array [min,max] that contains the minimum and maximum |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
111 * values for the parameter <i>name</i>. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
112 */ |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
113 protected String[] getDefaults(Artifact artifact, String name) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
114 if (DefaultState.USE_DEFAULTS) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
115 String[] tmp = getMinMaxByParameter(artifact, name); |
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 tmp != null ? tmp : getMinMaxDefaults(artifact, name); |
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 else { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
120 return getMinMaxDefaults(artifact, name); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
121 } |
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 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
124 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
125 /** |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
126 * 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
|
127 * [min,max]. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
128 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
129 * @param artifact The FLYSArtifact that stores the parameter. |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
130 * @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
|
131 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
132 * @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
|
133 */ |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
134 protected String[] getMinMaxByParameter(Artifact artifact, String name) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
135 FLYSArtifact flys = (FLYSArtifact) artifact; |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
136 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
|
137 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
138 if (rawValue == null) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
139 logger.debug("No value for '" + rawValue + "' existing."); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
140 return null; |
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 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
143 logger.debug("Raw value for '" + name + "' = " + rawValue); |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
144 |
2205
a22e0cb6eace
Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2202
diff
changeset
|
145 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
|
146 } |
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 |
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 * 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
|
151 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
152 * @param artifact The FLYSArtifact (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
|
153 * @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
|
154 * |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
155 * @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
|
156 */ |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
157 protected String[] getMinMaxDefaults(Artifact artifact, String name) { |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
158 FLYSArtifact flys = (FLYSArtifact) artifact; |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
159 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
160 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
|
161 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
|
162 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
163 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
|
164 } |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
165 |
d1660809daab
Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2190
diff
changeset
|
166 |
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
|
167 protected abstract Object getLower(FLYSArtifact flys); |
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
|
168 |
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
|
169 protected abstract Object getUpper(FLYSArtifact flys); |
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
|
170 |
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
|
171 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
|
172 } |
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
|
173 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |