Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java @ 674:d5f9ba1d055f
Added calculation base class to collect the problems during the calculations. Adjusted calculation 4 to use the mechanism.
flys-artifacts/trunk@2098 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 10 Jun 2011 09:19:27 +0000 |
parents | 23fced04ffdb |
children | 06689035024c |
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; |
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.apache.log4j.Logger; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.Document; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import org.w3c.dom.Element; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import org.w3c.dom.Node; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
306
35301cc3b875
Modified the states' describe() method - related to the last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
142
diff
changeset
|
14 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
|
15 import de.intevation.artifacts.ArtifactNamespaceContext; |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 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
|
17 import de.intevation.artifacts.CallMeta; |
126
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.artifacts.common.utils.XMLUtils; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.artifactdatabase.ProtocolUtils; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.artifactdatabase.data.StateData; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.artifactdatabase.state.AbstractState; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
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
|
25 import de.intevation.flys.artifacts.FLYSArtifact; |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 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
|
27 |
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 /** |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 * @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
|
31 */ |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 public abstract class DefaultState extends AbstractState { |
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 /** 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
|
35 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
|
36 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
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
|
38 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
|
39 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
|
40 } |
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
|
41 |
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
|
42 |
134
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
43 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
|
44 Artifact artifact, |
134
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
45 Document document, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
46 Node root, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
47 CallContext context, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
48 String uuid) |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
49 { |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
50 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
|
51 document, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
52 ArtifactNamespaceContext.NAMESPACE_URI, |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
53 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
54 |
142
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
55 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
|
56 |
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
57 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
|
58 Element ui = ProtocolUtils.createArtNode( |
134
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
63 Map<String, StateData> theData = getData(); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
64 if (theData == null) { |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
65 return ui; |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
66 } |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
67 |
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
|
68 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
|
69 FLYSArtifact flys = (FLYSArtifact) artifact; |
134
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
70 |
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
|
71 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
|
72 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
|
73 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
|
74 |
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
|
75 String value = data != null ? (String) data.getValue() : null; |
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 |
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
|
77 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
|
78 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
|
79 } |
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
|
80 |
142
b43671a551d1
Append human readable strings of the selected values to the DESCRIBE output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
81 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
|
82 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
83 Element dataElement = creator.create("data"); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
84 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
|
85 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
|
86 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
87 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
|
88 creator.addAttr(itemElement, "value", value, true); |
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
|
89 |
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
|
90 String attrValue = ""; |
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
|
91 try { |
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
|
92 // XXX A better way to format the output would be to use the |
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
|
93 // 'type' value if the data objects. |
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
|
94 double doubleVal = Double.valueOf(value); |
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
|
95 Locale l = Resources.getLocale(meta); |
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
|
96 NumberFormat nf = NumberFormat.getInstance(l); |
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
|
97 |
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
|
98 attrValue = nf.format(doubleVal); |
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
|
99 } |
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
|
100 catch (NumberFormatException nfe) { |
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
|
101 attrValue = Resources.getMsg(meta, value, value); |
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
|
102 } |
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
|
103 |
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
|
104 creator.addAttr(itemElement, "label", attrValue, true); |
134
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
105 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
106 dataElement.appendChild(itemElement); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
107 ui.appendChild(dataElement); |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
108 } |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
109 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
110 return ui; |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
111 } |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
112 |
f3dfa188d8b2
Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
129
diff
changeset
|
113 |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 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
|
115 Artifact artifact, |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 Document document, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 Node root, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 CallContext context, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 String uuid) |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 { |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 document, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 ArtifactNamespaceContext.NAMESPACE_URI, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 |
135
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
126 Element ui = null; |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
127 String uiprovider = getUIProvider(); |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
128 if (uiprovider != null) { |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
129 ui = ProtocolUtils.createArtNode( |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
130 creator, "dynamic", |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
131 new String[] { "uiprovider" }, |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
132 new String[] { uiprovider }); |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
133 } |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
134 else { |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
135 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
|
136 } |
126
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 Map<String, StateData> theData = getData(); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 if (theData == null) { |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 return ui; |
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 |
624
929137ee8154
ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
379
diff
changeset
|
143 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
|
144 FLYSArtifact flys = (FLYSArtifact) artifact; |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 |
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
|
146 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
|
147 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
|
148 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
|
149 |
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
|
150 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
|
151 |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
306
diff
changeset
|
152 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
|
153 |
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
|
154 String defValue = (String) data.getValue(); |
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
|
155 String defDesc = null; |
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
|
156 |
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
|
157 if (defValue != null && defValue.length() > 0) { |
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
|
158 defDesc = Resources.getMsg( |
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
|
159 context.getMeta(), |
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
|
160 defValue, |
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
|
161 defValue); |
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
|
162 } |
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
|
163 |
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
|
164 if (defValue != null && defDesc != null) { |
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
|
165 creator.addAttr(select, "defaultValue", defValue, true); |
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
|
166 creator.addAttr(select, "defaultLabel", defDesc, true); |
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
|
167 } |
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
|
168 |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 Element choices = ProtocolUtils.createArtNode( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 creator, "choices", null, null); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 select.appendChild(choices); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 ui.appendChild(select); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
306
diff
changeset
|
175 Element[] items = createItems(creator, artifact, name, context); |
635
acf3b49ec31f
Take the flow direction into account.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
630
diff
changeset
|
176 if (items != null) { |
acf3b49ec31f
Take the flow direction into account.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
630
diff
changeset
|
177 for (Element item: items) { |
acf3b49ec31f
Take the flow direction into account.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
630
diff
changeset
|
178 choices.appendChild(item); |
acf3b49ec31f
Take the flow direction into account.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
630
diff
changeset
|
179 } |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 } |
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 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 return ui; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 } |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 /** |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 * 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
|
189 * items. |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 * |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 * @param cr The ElementCreator. |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 * @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
|
193 * |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 * @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
|
195 */ |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 protected Element createData( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 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
|
198 Artifact artifact, |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
199 StateData data, |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
200 CallContext context) |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
201 { |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 Element select = ProtocolUtils.createArtNode( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
203 cr, "select", null, null); |
129
b06cd117b565
Appended a missing node to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
128
diff
changeset
|
204 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
|
205 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
206 Element label = ProtocolUtils.createArtNode( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
207 cr, "label", null, null); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
208 |
129
b06cd117b565
Appended a missing node to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
128
diff
changeset
|
209 select.appendChild(label); |
b06cd117b565
Appended a missing node to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
128
diff
changeset
|
210 |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
211 label.setTextContent(Resources.getMsg( |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
212 context.getMeta(), |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
213 getID(), |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
214 getID())); |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
215 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
216 return select; |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
217 } |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
219 |
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 * 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
|
222 * 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
|
223 * |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
224 * @param cr The ElementCreator. |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
225 * @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
|
226 * |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
227 * @return a list of items. |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
228 */ |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
635
diff
changeset
|
229 protected Element[] createItems( |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
230 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
|
231 Artifact artifact, |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
232 String name, |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
635
diff
changeset
|
233 CallContext context |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
635
diff
changeset
|
234 ) { |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
635
diff
changeset
|
235 return null; |
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
635
diff
changeset
|
236 } |
135
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
237 |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
238 |
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
|
239 /** |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
240 * 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
|
241 * 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
|
242 * |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
243 * @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
|
244 * @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
|
245 * |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
246 * @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
|
247 */ |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
248 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
|
249 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
|
250 { |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
251 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
|
252 } |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
253 |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
254 |
135
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
255 protected String getUIProvider() { |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
256 return null; |
2d6e02787d00
Added a method to retrieve the UIProvider for a state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
134
diff
changeset
|
257 } |
126
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
258 } |
b18aebd1342f
Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
259 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |