Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java @ 444:932a5e3c7fa1
ISSUE-72 Repaired broken XPath expression in MainValuesService to extract start and end kilometer.
flys-artifacts/trunk@1936 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 17 May 2011 11:53:02 +0000 |
parents | c21fb8de54f8 |
children | 929137ee8154 |
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 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.Collection; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.Map; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Element; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.Node; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
306
35301cc3b875
Modified the states' describe() method - related to the last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
142
diff
changeset
|
12 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
|
13 import de.intevation.artifacts.ArtifactNamespaceContext; |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 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
|
15 import de.intevation.artifacts.CallMeta; |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.common.utils.XMLUtils; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifactdatabase.ProtocolUtils; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.artifactdatabase.data.StateData; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.artifactdatabase.state.AbstractState; |
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.flys.artifacts.resources.Resources; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 /** |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 * @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
|
28 */ |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 public abstract class DefaultState extends AbstractState { |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 /** The logger that is used in this class.*/ |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 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
|
33 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
134
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
35 public Element describeStatic( |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
36 Document document, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
37 Node root, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
38 CallContext context, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
39 String uuid) |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
40 { |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
41 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
42 document, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
43 ArtifactNamespaceContext.NAMESPACE_URI, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
44 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
45 |
142
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
46 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
|
47 |
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
48 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
|
49 Element ui = ProtocolUtils.createArtNode( |
134
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
54 Map<String, StateData> theData = getData(); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
55 if (theData == null) { |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
56 return ui; |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
57 } |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
58 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
59 Collection<StateData> dataItems = theData.values(); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
60 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
61 for (StateData data: dataItems) { |
142
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
62 String name = data.getName(); |
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
63 String value = (String) data.getValue(); |
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
64 |
379
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
65 if (value == null) { |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
66 continue; |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
67 } |
c21fb8de54f8
Enabled the FLYSArtifact to handle an array of inserted WQ values (without given ranges).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
322
diff
changeset
|
68 |
142
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
69 logger.debug("Append element '" + name + "' (" + value + ")"); |
134
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
70 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
71 Element dataElement = creator.create("data"); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
72 creator.addAttr(dataElement, "name", name, true); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
73 creator.addAttr(dataElement, "type", data.getType(), true); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
74 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
75 Element itemElement = creator.create("item"); |
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 creator.addAttr(itemElement, "value", value, true); |
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
77 creator.addAttr( |
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
78 itemElement, |
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
79 "label", |
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
80 Resources.getMsg(meta, value, value), |
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
81 true); |
134
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
82 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
83 dataElement.appendChild(itemElement); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
84 ui.appendChild(dataElement); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
85 } |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
86 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
87 return ui; |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
88 } |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
89 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
90 |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 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
|
92 Artifact artifact, |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 Document document, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 Node root, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 CallContext context, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 String uuid) |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 { |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 document, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 ArtifactNamespaceContext.NAMESPACE_URI, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 |
135
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
103 Element ui = null; |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
104 String uiprovider = getUIProvider(); |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
105 if (uiprovider != null) { |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
106 ui = ProtocolUtils.createArtNode( |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
107 creator, "dynamic", |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
108 new String[] { "uiprovider" }, |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
109 new String[] { uiprovider }); |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
110 } |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
111 else { |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
112 ui = ProtocolUtils.createArtNode(creator, "dynamic", null, null); |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
113 } |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 Map<String, StateData> theData = getData(); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 if (theData == null) { |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 return ui; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 } |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 Collection<StateData> dataItems = theData.values(); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 for (StateData data: dataItems) { |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 String name = data.getName(); |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
306
diff
changeset
|
124 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
|
125 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 Element choices = ProtocolUtils.createArtNode( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 creator, "choices", null, null); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 select.appendChild(choices); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 ui.appendChild(select); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
306
diff
changeset
|
132 Element[] items = createItems(creator, artifact, name, context); |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 for (Element item: items) { |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 choices.appendChild(item); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 } |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 } |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 return ui; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 } |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 /** |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 * 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
|
144 * items. |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 * |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 * @param cr The ElementCreator. |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 * @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
|
148 * |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 * @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
|
150 */ |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 protected Element createData( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 XMLUtils.ElementCreator cr, |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
306
diff
changeset
|
153 Artifact artifact, |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 StateData data, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 CallContext context) |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 { |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 Element select = ProtocolUtils.createArtNode( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 cr, "select", null, null); |
129
b06cd117b565
Appended a missing node to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
128
diff
changeset
|
159 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
|
160 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 Element label = ProtocolUtils.createArtNode( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 cr, "label", null, null); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 |
129
b06cd117b565
Appended a missing node to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
128
diff
changeset
|
164 select.appendChild(label); |
b06cd117b565
Appended a missing node to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
128
diff
changeset
|
165 |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 label.setTextContent(Resources.getMsg( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 context.getMeta(), |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 getID(), |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 getID())); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 return select; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 } |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 /** |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 * 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
|
177 * 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
|
178 * |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 * @param cr The ElementCreator. |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 * @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
|
181 * |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 * @return a list of items. |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 */ |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 protected abstract Element[] createItems( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 XMLUtils.ElementCreator cr, |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
306
diff
changeset
|
186 Artifact artifact, |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 String name, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 CallContext context); |
135
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
189 |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
190 |
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
|
191 /** |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
192 * 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
|
193 * 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
|
194 * |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
195 * @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
|
196 * @param context The CallContext object. |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
197 * |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
198 * @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
|
199 */ |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
200 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
|
201 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
|
202 { |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
203 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
|
204 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
205 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
206 |
135
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
207 protected String getUIProvider() { |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
208 return null; |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
209 } |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
210 } |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
211 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |