annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java @ 2205:a22e0cb6eace

Format the timerange (static ui) inserted in the 'historical discharge curves' calculation. flys-artifacts/trunk@3829 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 30 Jan 2012 13:29:07 +0000
parents 19518116a49a
children 4cd0eb2ebb3b
rev   line source
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
669
23fced04ffdb #103 PART 1: The numbers which are written into the static DESCRIBE part are i18n formatted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
3 import java.text.NumberFormat;
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
4 import java.util.Iterator;
669
23fced04ffdb #103 PART 1: The numbers which are written into the static DESCRIBE part are i18n formatted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 660
diff changeset
5 import java.util.Locale;
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import java.util.Map;
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
7 import java.util.List;
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import org.apache.log4j.Logger;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.w3c.dom.Document;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import org.w3c.dom.Element;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.w3c.dom.Node;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
306
35301cc3b875 Modified the states' describe() method - related to the last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 142
diff changeset
15 import de.intevation.artifacts.Artifact;
142
b43671a551d1 Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
16 import de.intevation.artifacts.ArtifactNamespaceContext;
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import de.intevation.artifacts.CallContext;
142
b43671a551d1 Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
18 import de.intevation.artifacts.CallMeta;
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import de.intevation.artifacts.common.utils.XMLUtils;
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
21 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import de.intevation.artifactdatabase.ProtocolUtils;
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
24
1176
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
25 import de.intevation.artifactdatabase.data.DefaultStateData;
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import de.intevation.artifactdatabase.data.StateData;
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
27
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 import de.intevation.artifactdatabase.state.AbstractState;
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
29 import de.intevation.artifactdatabase.state.Facet;
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
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
31 import de.intevation.flys.artifacts.FLYSArtifact;
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
32
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 import de.intevation.flys.artifacts.resources.Resources;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 /**
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 */
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 public abstract class DefaultState extends AbstractState {
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
1029
3f3988bb6284 Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 958
diff changeset
41 /** The logger that is used in this class. */
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 private static Logger logger = Logger.getLogger(DefaultState.class);
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
2015
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
44
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
45 /** Determines, if the DESCRIBE document should contain default values or
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
46 * not. */
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
47 public static final boolean USE_DEFAULTS =
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
48 Boolean.getBoolean("flys.use.default.values");
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
49
1768
41ba2276d785 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1743
diff changeset
50 /** The three possible compute types. */
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
51 public static enum ComputeType {
942
796c54058dc4 Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 941
diff changeset
52 FEED, ADVANCE, INIT
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
53 }
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
1768
41ba2276d785 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1743
diff changeset
55
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
56 protected StateData getData(FLYSArtifact artifact, String name) {
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
57 return artifact.getData(name);
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
58 }
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
59
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
60
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1050
diff changeset
61 /**
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1050
diff changeset
62 * Append to a node and return xml description relevant for gui.
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1050
diff changeset
63 */
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
64 public Element describeStatic(
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
65 Artifact artifact,
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
66 Document document,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
67 Node root,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
68 CallContext context,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
69 String uuid)
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
70 {
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
71 ElementCreator creator = new ElementCreator(
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
72 document,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
73 ArtifactNamespaceContext.NAMESPACE_URI,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
74 ArtifactNamespaceContext.NAMESPACE_PREFIX);
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
75
142
b43671a551d1 Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
76 CallMeta meta = context.getMeta();
b43671a551d1 Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
77
b43671a551d1 Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 136
diff changeset
78 String label = Resources.getMsg(meta, getID(), getID());
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 135
diff changeset
79 Element ui = ProtocolUtils.createArtNode(
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
80 creator, "state",
136
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 135
diff changeset
81 new String[] { "name", "uiprovider", "label" },
2e510c998adb New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 135
diff changeset
82 new String[] { getID(), getUIProvider(), label });
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
83
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
84 Map<String, StateData> theData = getData();
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
85 if (theData == null) {
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
86 return ui;
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
87 }
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
88
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
89 Iterator<String> iter = theData.keySet().iterator();
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
90 FLYSArtifact flys = (FLYSArtifact) artifact;
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
91
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
92 while (iter.hasNext()) {
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
93 String name = iter.next();
1180
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
94 appendStaticData(flys, context, creator, ui, name);
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
95 }
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
96
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
97 return ui;
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
98 }
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
99
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 129
diff changeset
100
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
101 protected void appendStaticData(
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
102 FLYSArtifact flys,
1180
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
103 CallContext context,
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
104 ElementCreator cr,
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
105 Element ui,
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
106 String name
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
107 ) {
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
108 StateData data = getData(flys, name);
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
109 String value = (data != null) ? (String) data.getValue() : null;
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
110
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
111 if (value == null) {
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
112 return;
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
113 }
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
114
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
115 String type = data.getType();
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
116
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
117 logger.debug(
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
118 "Append element " + type + "'" +
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
119 name + "' (" + value + ")");
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
120
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
121 Element e = createStaticData(flys, cr, context, name, value, type);
1180
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
122
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
123 ui.appendChild(e);
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
124
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
125 }
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
126
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
127
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
128 /**
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
129 * Creates a <i>data</i> element used in the static part of the DESCRIBE
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
130 * document.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
131 *
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
132 * @param creator The ElementCreator that is used to build new Elements.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
133 * @param meta The CallMeta object used for i18n.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
134 * @param name The name of the data item.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
135 * @param value The value as string.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
136 *
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
137 * @return an Element.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
138 */
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
139 protected Element createStaticData(
1743
8a2cbf947395 Prepared the DESCRIBE document of a WINFO Artifact so that named main values for Qs are displayed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1691
diff changeset
140 FLYSArtifact flys,
1180
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
141 ElementCreator creator,
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
142 CallContext cc,
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
143 String name,
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
144 String value,
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
145 String type
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
146 ) {
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
147 Element dataElement = creator.create("data");
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
148 creator.addAttr(dataElement, "name", name, true);
1180
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
149 creator.addAttr(dataElement, "type", type, true);
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
150
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
151 Element itemElement = creator.create("item");
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
152 creator.addAttr(itemElement, "value", value, true);
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
153
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
154 creator.addAttr(
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
155 itemElement,
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
156 "label",
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
157 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: 2189
diff changeset
158 true);
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
159
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
160 dataElement.appendChild(itemElement);
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
161
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
162 return dataElement;
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
163 }
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
164
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
165
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
166 /**
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
167 * @param cc
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
168 * @param name
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
169 * @param value
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
170 * @param type
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
171 *
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
172 * @return
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
173 */
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
174 protected String getLabelFor(
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
175 CallContext cc,
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
176 String name,
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
177 String value,
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
178 String type
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
179 ) {
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
180 CallMeta meta = cc.getMeta();
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
181
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
182 try {
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
183 // XXX A better way to format the output would be to use the
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
184 // 'type' value of the data objects.
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
185 double doubleVal = Double.valueOf(value);
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
186 Locale l = Resources.getLocale(meta);
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
187 NumberFormat nf = NumberFormat.getInstance(l);
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
188
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
189 return nf.format(doubleVal);
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
190 }
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
191 catch (NumberFormatException nfe) {
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
192 return Resources.getMsg(meta, value, value);
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
193 }
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
194 }
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
195
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
196
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 public Element describe(
306
35301cc3b875 Modified the states' describe() method - related to the last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 142
diff changeset
198 Artifact artifact,
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 Document document,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 Node root,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 CallContext context,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 String uuid)
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 {
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
204 ElementCreator creator = new ElementCreator(
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 document,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 ArtifactNamespaceContext.NAMESPACE_URI,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 ArtifactNamespaceContext.NAMESPACE_PREFIX);
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208
135
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
209 Element ui = null;
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
210 String uiprovider = getUIProvider();
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
211 if (uiprovider != null) {
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1050
diff changeset
212 ui = ProtocolUtils.createArtNode(
135
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
213 creator, "dynamic",
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
214 new String[] { "uiprovider" },
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
215 new String[] { uiprovider });
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
216 }
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
217 else {
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1050
diff changeset
218 ui = ProtocolUtils.createArtNode(creator, "dynamic", null, null);
135
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
219 }
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221 Map<String, StateData> theData = getData();
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 if (theData == null) {
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223 return ui;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 }
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225
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
226 Iterator<String> iter = theData.keySet().iterator();
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
227 FLYSArtifact flys = (FLYSArtifact) artifact;
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228
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
229 while (iter.hasNext()) {
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
230 String name = iter.next();
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
231 StateData data = getData(flys, name);
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
232
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
233 data = data != null ? data : getData(name);
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
234
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
235 Element select = createData(creator, artifact, data, context);
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236
2015
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
237 if (USE_DEFAULTS) {
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
238 String defValue = (String) data.getValue();
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
239 String defDesc = null;
630
40d3039f85ac ISSUE-40 (part I/II) Write values that the user had former selected / inserted into DESCRIBE document to preselect such data in the UI.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
240
2015
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
241 if (defValue != null && defValue.length() > 0) {
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
242 defDesc = Resources.getMsg(
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
243 context.getMeta(),
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
244 defValue,
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
245 defValue);
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
246 }
630
40d3039f85ac ISSUE-40 (part I/II) Write values that the user had former selected / inserted into DESCRIBE document to preselect such data in the UI.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
247
2015
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
248 if (defValue != null && defDesc != null) {
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
249 creator.addAttr(select, "defaultValue", defValue, true);
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
250 creator.addAttr(select, "defaultLabel", defDesc, true);
61667c3a0003 Disabled default values in Artifact's DESCRIBE document - added a system property to re-enable those default values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1768
diff changeset
251 }
630
40d3039f85ac ISSUE-40 (part I/II) Write values that the user had former selected / inserted into DESCRIBE document to preselect such data in the UI.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
252 }
40d3039f85ac ISSUE-40 (part I/II) Write values that the user had former selected / inserted into DESCRIBE document to preselect such data in the UI.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 624
diff changeset
253
2189
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
254 appendItems(artifact, creator, name, context, select);
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255 ui.appendChild(select);
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256 }
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258 return ui;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259 }
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 /**
2189
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
263 * @param artifact
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
264 * @param creator
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
265 * @param name
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
266 * @param context
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
267 * @param select
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
268 */
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
269 protected void appendItems(
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
270 Artifact artifact,
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
271 ElementCreator creator,
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
272 String name,
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
273 CallContext context,
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
274 Element select
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
275 ) {
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
276 Element choices = ProtocolUtils.createArtNode(
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
277 creator, "choices", null, null);
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
278
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
279 select.appendChild(choices);
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
280
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
281 Element[] items = createItems(creator, artifact, name, context);
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
282 if (items != null) {
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
283 for (Element item: items) {
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
284 choices.appendChild(item);
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
285 }
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
286 }
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
287 }
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
288
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
289
19518116a49a Refactored some code in DefaultState to better override the base class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2015
diff changeset
290 /**
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291 * This method creates the root node that contains the list of selectable
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292 * items.
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293 *
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294 * @param cr The ElementCreator.
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
295 * @param name The name of the amount of data.
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
296 *
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
297 * @return the root node of the item list.
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298 */
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
299 protected Element createData(
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
300 ElementCreator cr,
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
301 Artifact artifact,
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
302 StateData data,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
303 CallContext context)
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
304 {
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
305 Element select = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
306 cr, "select", null, null);
129
b06cd117b565 Appended a missing node to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
307 cr.addAttr(select, "name", data.getName(), true);
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
308
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
309 Element label = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
310 cr, "label", null, null);
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
311
129
b06cd117b565 Appended a missing node to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
312 select.appendChild(label);
b06cd117b565 Appended a missing node to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
313
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
314 label.setTextContent(Resources.getMsg(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
315 context.getMeta(),
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
316 getID(),
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
317 getID()));
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
318
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
319 return select;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
320 }
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
321
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
322
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
323 /**
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
324 * This method creates a list of items. These items represent the amount of
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
325 * input data that is possible for this state.
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
326 *
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
327 * @param cr The ElementCreator.
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
328 * @param name The name of the amount of data.
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
329 *
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
330 * @return a list of items.
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
331 */
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 635
diff changeset
332 protected Element[] createItems(
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1136
diff changeset
333 ElementCreator cr,
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
334 Artifact artifact,
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
335 String name,
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 635
diff changeset
336 CallContext context
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 635
diff changeset
337 ) {
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 635
diff changeset
338 return null;
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 635
diff changeset
339 }
135
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
340
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
341
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
342 /**
1180
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
343 * This method is used to create an <i>item</i> Element that contains two
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
344 * further elements <i>label</i> and <i>value</i>. The label and value
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
345 * elements both have text nodes.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
346 *
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
347 * @param cr The ElementCreator used to build new Elements.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
348 * @param obj This implementation awaits a String array with [0] = label and
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
349 * [1] = value.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
350 *
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
351 * @return an Element.
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
352 */
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
353 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
354 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
355 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
356 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
357
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
358 String[] arr = (String[]) obj;
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
359
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
360 label.setTextContent(arr[0]);
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
361 value.setTextContent(arr[1]);
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
362
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
363 item.appendChild(label);
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
364 item.appendChild(value);
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
365
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
366 return item;
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
367 }
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
368
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
369
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1176
diff changeset
370 /**
1176
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
371 * This method transform a given value into a StateData object.
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
372 *
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
373 * @param flys The FLYSArtifact.
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
374 * @param name The name of the data object.
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
375 * @param val The value of the data object.
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
376 *
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
377 * @return a StateData object with <i>name</i> and <i>val</i>ue.
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
378 */
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
379 public StateData transform(
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
380 FLYSArtifact flys,
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
381 CallContext cc,
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
382 StateData stateData,
1176
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
383 String name,
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
384 String val
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
385 ) {
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
386 logger.debug("Transform data ('" + name + "','" + val + "')");
2205
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
387
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
388 stateData.setValue(val);
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
389
a22e0cb6eace Format the timerange (static ui) inserted in the 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2189
diff changeset
390 return stateData;
1176
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
391 }
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
392
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
393
28154920e0b3 Introduced the possibility for States to transform/modify input before the data is added to FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
394 /**
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
395 * This method validates the inserted data and returns true, if everything
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
396 * was correct, otherwise an exception is thrown.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
397 *
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
398 * @param artifact A reference to the owner 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
399 *
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
400 * @return true, if everything was fine.
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
401 */
1050
eccf966fb677 State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1029
diff changeset
402 public boolean validate(Artifact 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
403 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
404 {
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
405 return true;
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
406 }
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
407
448d0dc64357 The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
408
1691
17648043429f Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1180
diff changeset
409 /**
17648043429f Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1180
diff changeset
410 * Returns which UIProvider shall be used to aid user input.
17648043429f Cosmetics, docs, annotations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1180
diff changeset
411 */
135
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
412 protected String getUIProvider() {
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
413 return null;
2d6e02787d00 Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
414 }
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 669
diff changeset
415
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1050
diff changeset
416
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
417 public Object computeAdvance(
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
418 FLYSArtifact artifact,
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
419 String hash,
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
420 CallContext context,
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
421 List<Facet> facets,
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
422 Object old
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
423 ) {
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
424 return null;
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
425 }
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 669
diff changeset
426
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1050
diff changeset
427
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
428 public Object computeFeed(
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
429 FLYSArtifact artifact,
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
430 String hash,
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
431 CallContext context,
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 697
diff changeset
432 List<Facet> facets,
697
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
433 Object old
b972eba2ed8a Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 687
diff changeset
434 ) {
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 669
diff changeset
435 return null;
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 669
diff changeset
436 }
941
1b509e4cf99b Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
437
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1050
diff changeset
438
941
1b509e4cf99b Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
439 public Object computeInit(
1b509e4cf99b Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
440 FLYSArtifact artifact,
1b509e4cf99b Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
441 String hash,
958
ae198bef4ba0 Added configurations for river WMSe (currently for Saar, Mosel, Elbe).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 942
diff changeset
442 Object context,
941
1b509e4cf99b Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
443 CallMeta meta,
1b509e4cf99b Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
444 List<Facet> facets)
1b509e4cf99b Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
445 {
1b509e4cf99b Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
446 return null;
1b509e4cf99b Added a computeInit() method to intialize data/facets after creating new artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 742
diff changeset
447 }
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
448 }
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
449 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org