comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeState.java @ 2191:f28844a57fed

Added states (work is not finished yet) for the 'historical discharge curve' calculation. flys-artifacts/trunk@3801 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 27 Jan 2012 13:26:04 +0000
parents
children 66408cdca36f
comparison
equal deleted inserted replaced
2190:2792d2617be9 2191:f28844a57fed
1 package de.intevation.flys.artifacts.states;
2
3 import org.apache.log4j.Logger;
4
5 import org.w3c.dom.Element;
6
7 import de.intevation.artifacts.Artifact;
8 import de.intevation.artifacts.ArtifactNamespaceContext;
9 import de.intevation.artifacts.CallContext;
10 import de.intevation.artifacts.CallMeta;
11
12 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
13
14 import de.intevation.flys.artifacts.resources.Resources;
15
16
17 /**
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
19 */
20 public class HistoricalDischargeState extends DefaultState {
21
22 private static final Logger logger =
23 Logger.getLogger(HistoricalDischargeState.class);
24
25
26 public static final String DATA_MODE = "historical_mode";
27 public static final String DATA_VALUES = "historical_values";
28 public static final int DATA_MODE_W = 0;
29 public static final int DATA_MODE_Q = 1;
30
31
32 @Override
33 protected String getUIProvider() {
34 return "wq_simple_array";
35 }
36
37 protected void appendItems(
38 Artifact artifact,
39 ElementCreator creator,
40 String name,
41 CallContext context,
42 Element select
43 ) {
44 if (name != null && name.equals(DATA_VALUES)) {
45 select.setAttributeNS(
46 ArtifactNamespaceContext.NAMESPACE_URI,
47 "art:type",
48 "intarray");
49 }
50 else if (name != null && name.equals(DATA_MODE)) {
51 select.setAttributeNS(
52 ArtifactNamespaceContext.NAMESPACE_URI,
53 "art:type",
54 "intoptions");
55 }
56
57 super.appendItems(artifact, creator, name, context, select);
58 }
59
60
61 @Override
62 protected Element[] createItems(
63 ElementCreator creator,
64 Artifact artifact,
65 String name,
66 CallContext context
67 ) {
68 logger.debug("createItems()");
69
70 if (name != null && name.equals(DATA_MODE)) {
71 return createModeItem(creator, artifact, name, context);
72 }
73 else if (name != null && name.equals(DATA_VALUES)) {
74 return createValuesItem(creator, artifact, name, context);
75 }
76
77 logger.warn("Tried to create item for invalid data: " + name);
78
79 return new Element[0];
80 }
81
82
83 protected Element[] createModeItem(
84 ElementCreator creator,
85 Artifact artifact,
86 String name,
87 CallContext context
88 ) {
89 logger.debug("createModeItem()");
90
91 CallMeta meta = context.getMeta();
92
93 Element modeW = createItem(
94 creator,
95 new String[] {
96 Resources.getMsg(meta, "historical.mode.w","historical.mode.w"),
97 String.valueOf(DATA_MODE_W) } );
98
99 Element modeQ = createItem(
100 creator,
101 new String[] {
102 Resources.getMsg(meta, "historical.mode.q","historical.mode.q"),
103 String.valueOf(DATA_MODE_Q) } );
104
105 return new Element[] { modeW, modeQ };
106 }
107
108
109 protected Element[] createValuesItem(
110 ElementCreator creator,
111 Artifact artifact,
112 String name,
113 CallContext context
114 ) {
115 logger.debug("createValuesItem()");
116
117 Element valuesW = createItem(
118 creator, new String[] { "ws", "" } );
119
120 Element valuesQ = createItem(
121 creator, new String[] { "qs", "" } );
122
123 return new Element[] { valuesW, valuesQ };
124 }
125 }
126 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org