annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java @ 1078:048517d67215

Changed state spawning mechanism of MainValuesArtifact. flys-artifacts/trunk@2575 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 25 Aug 2011 10:38:45 +0000
parents 13784581ab0c
children fb5a7ff9feb8
rev   line source
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import org.apache.log4j.Logger;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.w3c.dom.Element;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import de.intevation.artifacts.Artifact;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import de.intevation.artifacts.CallContext;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import de.intevation.artifacts.CallMeta;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.common.utils.XMLUtils;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.artifactdatabase.ProtocolUtils;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
15 import de.intevation.flys.artifacts.FLYSArtifact;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import de.intevation.flys.artifacts.resources.Resources;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 /**
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 */
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 public class ScenarioSelect extends DefaultState {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 /** The logger that is used in this class.*/
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 private static Logger logger = Logger.getLogger(ScenarioSelect.class);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
27 public static final String FIELD_MODE = "scenario";
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
28 public static final String FIELD_BARRIERS = "uesk.barriers";
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 public static final String SCENARIO_CURRENT = "scenario.current";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 public static final String SCENARIO_POTENTIEL = "scenario.potentiel";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 public static final String SCENARIO_SCENRAIO = "scenario.scenario";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 public static final String[] SCENARIOS = {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 SCENARIO_CURRENT,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 SCENARIO_POTENTIEL,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 SCENARIO_SCENRAIO };
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
40
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
41 @Override
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
42 protected String getUIProvider() {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
43 return "map_digitize";
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
44 }
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
45
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
46
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 @Override
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 protected Element[] createItems(
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 XMLUtils.ElementCreator cr,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 Artifact artifact,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 String name,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 CallContext context)
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 {
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
54 CallMeta meta = context.getMeta();
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
56 if (name.equals(FIELD_MODE)) {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
57 Element[] scenarios = new Element[SCENARIOS.length];
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
58
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
59 int i = 0;
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
60
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
61 for (String scenario: SCENARIOS) {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
62 scenarios[i++] = createItem(
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
63 cr, new String[] {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
64 Resources.getMsg(meta, scenario, scenario),
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
65 scenario
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
66 });
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
67 }
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
68
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
69 return scenarios;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 }
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
71 else {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
72 FLYSArtifact flys = (FLYSArtifact) artifact;
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
73 String data = flys.getDataAsString(name);
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
75 return new Element[] { createItem(
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
76 cr,
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
77 new String[] {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
78 Resources.getMsg(meta, name, name),
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
79 data
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
80 }
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
81 )};
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
82 }
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 String[] arr = (String[]) obj;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 label.setTextContent(arr[0]);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 value.setTextContent(arr[1]);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 item.appendChild(label);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 item.appendChild(value);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 return item;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org