annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverSelect.java @ 3769:728ecd2afa20

Implemented bed quality calculation in minfo module. flys-artifacts/trunk@5474 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 14 Sep 2012 14:20:42 +0000
parents 7b14d00bca8a
children 8e66293c5369
rev   line source
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
3 import java.util.List;
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
4
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
7 import org.w3c.dom.Element;
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import org.w3c.dom.Node;
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 304
diff changeset
10 import de.intevation.artifacts.Artifact;
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.CallContext;
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
13 import de.intevation.artifacts.common.utils.XMLUtils;
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
14
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
15 import de.intevation.artifactdatabase.ProtocolUtils;
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
16 import de.intevation.artifactdatabase.data.StateData;
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
132
8be4a837f20a Added support for the flys backend and an example how to use it.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 126
diff changeset
18 import de.intevation.flys.model.River;
8be4a837f20a Added support for the flys backend and an example how to use it.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 126
diff changeset
19
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: 424
diff changeset
20 import de.intevation.flys.artifacts.FLYSArtifact;
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
21 import de.intevation.flys.artifacts.model.RiverFactory;
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
22 import de.intevation.flys.artifacts.resources.Resources;
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
23
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 /**
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 */
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
28 public class RiverSelect extends DefaultState {
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 /** The logger used in this class. */
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 private static Logger logger = Logger.getLogger(RiverSelect.class);
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
324
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
33 /** Error message that is thrown if no river was found based on a given
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
34 * name.*/
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
35 public static final String ERROR_NO_SUCH_RIVER =
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
36 "error_feed_no_such_river";
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
37
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
38 /** Error message that is thrown if no river was found based on a given
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
39 * name.*/
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
40 public static final String ERROR_NO_RIVER_SELECTED =
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
41 "error_feed_no_river_selected";
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
42
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
43
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 /**
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 * The default constructor that initializes an empty State object.
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 */
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 public RiverSelect() {
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 }
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 /**
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 * Initialize the state based on the state node in the configuration.
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 *
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 * @param config The state configuration node.
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 */
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 public void setup(Node config) {
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 super.setup(config);
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 }
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
61 protected Element createData(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
62 XMLUtils.ElementCreator cr,
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 304
diff changeset
63 Artifact artifact,
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
64 StateData data,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
65 CallContext context)
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 {
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
67 Element select = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
68 cr, "select",
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
69 new String[] { "uiprovider" },
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
70 new String[] { "select_with_map" });
304
992afc0299cd Bugfix: Repaired the dynamic UI part of the RiverSelect state in DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
71 cr.addAttr(select, "name", data.getName(), true);
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
72
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
73 Element label = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
74 cr, "label", null, null);
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
75
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
76 Element choices = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
77 cr, "choices", null, null);
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
78
304
992afc0299cd Bugfix: Repaired the dynamic UI part of the RiverSelect state in DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
79 select.appendChild(label);
992afc0299cd Bugfix: Repaired the dynamic UI part of the RiverSelect state in DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
80
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
81 label.setTextContent(Resources.getMsg(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
82 context.getMeta(),
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
83 getID(),
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
84 getID()));
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
85
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
86 return select;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
87 }
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
88
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
89
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 624
diff changeset
90 @Override
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
91 protected Element[] createItems(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
92 XMLUtils.ElementCreator cr,
313
89bd0417418f The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 304
diff changeset
93 Artifact artifact,
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
94 String name,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
95 CallContext context)
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
96 {
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
97 List<River> rivers = RiverFactory.getRivers();
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
98 Element[] items = new Element[rivers.size()];
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
99
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
100 int idx = 0;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
101 for (River river: rivers) {
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
102 items[idx++] = createRiverItem(cr, river);
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
103 }
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
104
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
105 return items;
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
106 }
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
107
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
108
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
109 /**
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
110 * This method creates a node that represents a river item. This node
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
111 * contains the label and the value that describe the river.
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
112 *
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
113 * @param cr The ElementCreator.
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
114 * @param river The river.
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
115 *
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
116 * @return the element that contains the information about the river.
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
117 */
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
118 protected Element createRiverItem(XMLUtils.ElementCreator cr, River river) {
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
119 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
120 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
121 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
122
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
123 label.setTextContent(river.getName());
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
124 value.setTextContent(river.getName());
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
125
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
126 item.appendChild(label);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
127 item.appendChild(value);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
128
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
129 return item;
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 }
324
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
131
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
132
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
133 @Override
1050
eccf966fb677 State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 660
diff changeset
134 public boolean validate(Artifact artifact)
324
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
135 throws IllegalArgumentException
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
136 {
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
137 logger.debug("RiverSelect.validate");
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
138
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: 424
diff changeset
139 FLYSArtifact flys = (FLYSArtifact) artifact;
324
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
140
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: 424
diff changeset
141 StateData dRiver = getData(flys, "river");
324
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
142
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
143 if (dRiver == null || dRiver.getValue() == null) {
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
144 throw new IllegalArgumentException(ERROR_NO_RIVER_SELECTED);
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
145 }
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
146
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
147 River river = RiverFactory.getRiver((String) dRiver.getValue());
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
148
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
149 if (river == null) {
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
150 throw new IllegalArgumentException(ERROR_NO_SUCH_RIVER);
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
151 }
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
152
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
153 return true;
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
154 }
424
82bd39f27569 ISSUE-37 The river state wants to be rendered using a river_panel UI provider.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
155
82bd39f27569 ISSUE-37 The river state wants to be rendered using a river_panel UI provider.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
156
82bd39f27569 ISSUE-37 The river state wants to be rendered using a river_panel UI provider.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
157 @Override
82bd39f27569 ISSUE-37 The river state wants to be rendered using a river_panel UI provider.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
158 protected String getUIProvider() {
82bd39f27569 ISSUE-37 The river state wants to be rendered using a river_panel UI provider.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
159 return "river_panel";
82bd39f27569 ISSUE-37 The river state wants to be rendered using a river_panel UI provider.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 343
diff changeset
160 }
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 }
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org