annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java @ 624:929137ee8154

ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact. flys-artifacts/trunk@1982 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 23 May 2011 15:11:55 +0000
parents c21fb8de54f8
children 833290f16f09
rev   line source
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import org.apache.log4j.Logger;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.w3c.dom.Element;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
7 import de.intevation.artifacts.Artifact;
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import de.intevation.artifacts.CallContext;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.common.utils.XMLUtils;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.artifactdatabase.ProtocolUtils;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.artifactdatabase.data.StateData;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
15 import de.intevation.flys.model.River;
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
16
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
17 import de.intevation.flys.artifacts.FLYSArtifact;
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
18 import de.intevation.flys.artifacts.model.RiverFactory;
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.artifacts.resources.Resources;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 /**
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 */
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
24 public class LocationDistanceSelect extends RangeState {
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 /** The logger used in this class.*/
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 private static Logger logger = Logger.getLogger(LocationDistanceSelect.class);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 /** The default step width.*/
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 public static final String DEFAULT_STEP = "100";
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
33 /** The name of the 'from' field. */
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
34 public static final String FROM = "ld_from";
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
35
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
36 /** The name of the 'to' field. */
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
37 public static final String TO = "ld_to";
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
38
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
39 /** The name of the 'step' field. */
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
40 public static final String STEP = "ld_step";
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
41
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 /**
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 * The default constructor that initializes an empty State object.
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 */
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 public LocationDistanceSelect() {
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 }
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 protected Element createData(
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 XMLUtils.ElementCreator cr,
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
50 Artifact artifact,
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 StateData data,
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 CallContext context)
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 {
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 Element select = ProtocolUtils.createArtNode(
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 cr, "select", null, null);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 cr.addAttr(select, "name", data.getName(), true);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 Element label = ProtocolUtils.createArtNode(
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 cr, "label", null, null);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 Element choices = ProtocolUtils.createArtNode(
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 cr, "choices", null, null);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 label.setTextContent(Resources.getMsg(
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 context.getMeta(),
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 data.getName(),
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 data.getName()));
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 select.appendChild(label);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 return select;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 }
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 protected Element[] createItems(
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 XMLUtils.ElementCreator cr,
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
78 Artifact artifact,
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 String name,
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 CallContext context)
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 {
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
82 double[] minmax = getMinMaxDistance(artifact);
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
83
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
84 double minVal = Double.MIN_VALUE;
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
85 double maxVal = Double.MAX_VALUE;
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
86
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
87 if (minmax != null) {
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
88 minVal = minmax[0];
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
89 maxVal = minmax[1];
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
90 }
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
91 else {
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
92 logger.warn("Could not read min/max distance values!");
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
93 }
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 if (name.equals("ld_from")) {
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
96 Element min = createItem(
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
97 cr,
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
98 new String[] {"min", new Double(minVal).toString()});
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
99
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 return new Element[] { min };
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 }
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 else if (name.equals("ld_to")) {
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
103 Element max = createItem(
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
104 cr,
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
105 new String[] {"max", new Double(maxVal).toString()});
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
106
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 return new Element[] { max };
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 }
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 else {
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 Element step = createItem(cr, new String[] {"step", DEFAULT_STEP});
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 return new Element[] { step };
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 }
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 }
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 String[] arr = (String[]) obj;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 label.setTextContent(arr[0]);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 value.setTextContent(arr[1]);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 item.appendChild(label);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 item.appendChild(value);
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 return item;
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 }
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 protected String getUIProvider() {
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 return "location_distance_panel";
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 }
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
137
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
138
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
139 protected double[] getMinMaxDistance(Artifact artifact) {
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
140 FLYSArtifact flysArtifact = (FLYSArtifact) artifact;
624
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
141 StateData data = getData(flysArtifact, "river");
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
142
624
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
143 String name = data != null ? (String) data.getValue() : "";
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
144
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
145 logger.debug("Search for the min/max distances of '" + name + "'");
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
146
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
147 River river = RiverFactory.getRiver(name);
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
148
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
149 return river != null ? river.determineMinMaxDistance() : null;
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
150 }
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
151
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
152
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
153 @Override
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
154 public boolean validate(Artifact artifact, CallContext context)
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
155 throws IllegalArgumentException
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
156 {
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
157 logger.debug("LocationDistanceSelect.validate");
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
158
624
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
159 FLYSArtifact flys = (FLYSArtifact) artifact;
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
160
624
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
161 StateData dFrom = getData(flys, FROM);
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
162 StateData dTo = getData(flys, TO);
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
163 StateData dStep = getData(flys, STEP);
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
164
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
165 String fromStr = dFrom != null ? (String) dFrom.getValue() : null;
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
166 String toStr = dTo != null ? (String) dTo.getValue() : null;
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 379
diff changeset
167 String stepStr = dStep != null ? (String) dStep.getValue() : null;
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
168
352
ed3325a0232a Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 322
diff changeset
169 if (fromStr == null || toStr == null || stepStr == null) {
ed3325a0232a Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 322
diff changeset
170 throw new IllegalArgumentException("error_empty_state");
ed3325a0232a Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 322
diff changeset
171 }
ed3325a0232a Throw an illegal argument exception in LocationDistanceSelect.validate() and WQSelect.validate() if no data has been inserted so far.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 322
diff changeset
172
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
173 try {
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
174 double from = Double.parseDouble(fromStr);
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
175 double to = Double.parseDouble(toStr);
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
176 double step = Double.parseDouble(stepStr);
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
177
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
178 double[] minmaxDist = getMinMaxDistance(artifact);
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
179
379
c21fb8de54f8 Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 352
diff changeset
180 return validateBounds(minmaxDist[0], minmaxDist[1], from, to, step);
322
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
181 }
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
182 catch (NumberFormatException nfe) {
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
183 throw new IllegalArgumentException("error_feed_number_format");
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
184 }
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
185 }
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186 }
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org