annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/MinMaxState.java @ 6693:88bb0c794833

issue1391: Enable GaugeDischarge artifact to directly load a table by its ID This allows us to use the GaugeDischargeArtifact for any discharge tables that we have in our database. The name of the created facet is taken from the ids string as is also usual in the WMS artifacts.
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 29 Jul 2013 12:19:57 +0200
parents af13ceeba52a
children e4606eae8ea5
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
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
13 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
14
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
15 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
16 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
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
18 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
19 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
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2235
diff changeset
21 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
22
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
23 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
24
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 /**
2235
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2205
diff changeset
27 * State that holds minimun and maximum (for validation).
ee5310134463 Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2205
diff changeset
28 *
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
29 * @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
30 */
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 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
32
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
33 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
34
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
35 @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
36 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
37 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
38 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
39 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
40 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
41 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
42 ) {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
43 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
44
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 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
46 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
47 "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
48 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
49
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
50 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
51
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
52 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
53 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
54 "min",
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
55 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
56 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
57
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 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
59 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
60 "max",
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
61 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
62 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
63
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 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
65 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
66 }
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
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
69 /**
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
70 * @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
71 * @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
72 * @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
73 * @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
74 *
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
75 * @return
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
76 */
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
77 @Override
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
78 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
79 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
80 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
81 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
82 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
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 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
85 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
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 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
88 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
89 }
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 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
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
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 * 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
98 * <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
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 * @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
101 *
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
102 * @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
103 */
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
104 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
105 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
106 }
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 /**
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
110 * 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
111 * 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
112 * 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
113 * 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
114 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
115 * @param artifact The D4EArtifact.
2202
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
116 * @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
117 *
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
118 * @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
119 * 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
120 */
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
121 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
122 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
123 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
124
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
125 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
126 }
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
127 else {
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
128 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
129 }
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
130 }
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 * 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
135 * [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 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
138 * @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
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[] 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
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 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
145
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
146 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
147 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
148 return null;
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 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
152
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2202
diff changeset
153 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
154 }
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
155
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 /**
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
158 * 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
159 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
160 * @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
161 * @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
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 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
164 */
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
165 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
166 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
167
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
168 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
169 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
170
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
171 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
172 }
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
173
d1660809daab Added default values for min and max items prepared by MinMaxState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2190
diff changeset
174
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
175 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
176
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
177 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
178
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
179 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
180 }
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
181 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org