annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/RiverSelect.java @ 6693:88bb0c794833

issue1391: Enable GaugeDischarge artifact to directly load a table by its ID This allows us to use the GaugeDischargeArtifact for any discharge tables that we have in our database. The name of the created facet is taken from the ids string as is also usual in the WMS artifacts.
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 29 Jul 2013 12:19:57 +0200
parents af13ceeba52a
children 9aa0bd26ce7f
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
9 package org.dive4elements.river.artifacts.states;
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
10
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
11 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
12
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
13 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
14
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
15 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
16 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
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
18 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
19 import org.dive4elements.artifacts.CallContext;
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
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
21 import org.dive4elements.artifacts.common.utils.XMLUtils;
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
22
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
23 import org.dive4elements.artifactdatabase.ProtocolUtils;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
24 import org.dive4elements.artifactdatabase.data.StateData;
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
25
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
26 import org.dive4elements.river.model.River;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
27
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
28 import org.dive4elements.river.artifacts.D4EArtifact;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
29 import org.dive4elements.river.artifacts.model.RiverFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4049
diff changeset
30 import org.dive4elements.river.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
31
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
32
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
33 /**
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
34 * @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
35 */
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
36 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
37
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
38 /** 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
39 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
40
324
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
41 /** 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
42 * name.*/
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
43 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
44 "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
45
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
46 /** 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
47 * name.*/
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
48 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
49 "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
50
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
51
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
52 /**
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 * 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
54 */
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 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
56 }
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
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 * 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
61 *
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
62 * @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
63 */
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
64 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
65 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
66 }
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
67
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
68
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
69 protected Element createData(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
70 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
71 Artifact artifact,
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
72 StateData data,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
73 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
74 {
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
75 Element select = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
76 cr, "select",
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
77 new String[] { "uiprovider" },
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
78 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
79 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
80
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
81 Element label = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
82 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
83
4049
8e66293c5369 Removed dead code
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3650
diff changeset
84
8e66293c5369 Removed dead code
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3650
diff changeset
85 // XXX: DEAD CODE
8e66293c5369 Removed dead code
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3650
diff changeset
86 /*
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
87 Element choices = ProtocolUtils.createArtNode(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
88 cr, "choices", null, null);
4049
8e66293c5369 Removed dead code
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3650
diff changeset
89 */
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
90
304
992afc0299cd Bugfix: Repaired the dynamic UI part of the RiverSelect state in DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 132
diff changeset
91 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
92
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
93 label.setTextContent(Resources.getMsg(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
94 context.getMeta(),
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
95 getID(),
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
96 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
97
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
98 return select;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
99 }
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
100
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
101
660
627be3ca1ab6 code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 624
diff changeset
102 @Override
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
103 protected Element[] createItems(
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
104 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
105 Artifact artifact,
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
106 String name,
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
107 CallContext context)
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
108 {
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
109 List<River> rivers = RiverFactory.getRivers();
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
110 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
111
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
112 int idx = 0;
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
113 for (River river: rivers) {
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
114 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
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
126
b18aebd1342f Added an abstract base class DefaultState for States.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 116
diff changeset
117 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
118 }
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
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
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 /**
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 * 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
123 * 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
124 *
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 * @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
126 * @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
127 *
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 * @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
129 */
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
130 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
131 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
132 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
133 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
134
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
135 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
136 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
137
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
138 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
139 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
140
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
141 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
142 }
324
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
143
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
144
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
145 @Override
1050
eccf966fb677 State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 660
diff changeset
146 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
147 throws IllegalArgumentException
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 logger.debug("RiverSelect.validate");
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
150
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
151 D4EArtifact flys = (D4EArtifact) artifact;
324
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
152
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
153 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
154
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
155 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
156 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
157 }
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
158
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
159 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
160
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
161 if (river == null) {
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
162 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
163 }
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
164
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
165 return true;
cd9e397cc2a8 The inserted river is validated in the feed operation().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 313
diff changeset
166 }
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
167
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
168
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
169 @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
170 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
171 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
172 }
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
173 }
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
174 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org