Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MultiStringArrayState.java @ 4287:82c1e911dd71
Add start and end time of an observation on a measurement station
Add start and end time of an observation on a measurement station to the
MeasurementStation classes.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 29 Oct 2012 09:54:31 +0100 |
parents | 33bfc01410fb |
children |
rev | line source |
---|---|
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Element; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.Artifact; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.CallContext; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.common.model.KVP; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.artifacts.FLYSArtifact; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.flys.artifacts.resources.Resources; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 /** |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 * |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 */ |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public abstract class MultiStringArrayState extends DefaultState { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 private static final Logger logger = |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 Logger.getLogger(MultiStringArrayState.class); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 @Override |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 protected void appendItems( |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 Artifact artifact, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 ElementCreator creator, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 String name, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 CallContext context, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 Element select |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 ) { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 try { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 creator.addAttr(select, "type", "options", true); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
3649
33bfc01410fb
Merged revisions 5375,5379,5382 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
38 for (KVP kvp: getOptions(artifact, name, context)) { |
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 Element item = creator.create("item"); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 creator.addAttr(item, "label", kvp.getValue().toString(), true); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 creator.addAttr(item, "value", kvp.getKey().toString(), true); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 select.appendChild(item); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 catch (IllegalArgumentException iae) { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 logger.warn("Illegal argument", iae); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 @Override |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 protected Element createStaticData( |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 FLYSArtifact flys, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 ElementCreator creator, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 CallContext cc, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 String name, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 String value, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 String type |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 ) { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 Element data = creator.create("data"); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 creator.addAttr(data, "name", name, true); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 creator.addAttr(data, "type", type, true); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 creator.addAttr(data, "label", |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 Resources.getMsg(cc.getMeta(), name, name), true); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 String[] values = value.split(";"); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 for (String val: values) { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 Element item = creator.create("item"); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 creator.addAttr(item, "value", val, true); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 creator.addAttr(item, "label", getLabelFor(cc, name, val), true); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 data.appendChild(item); |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 return data; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 protected abstract KVP<String, String>[] getOptions( |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 Artifact artifact, |
3649
33bfc01410fb
Merged revisions 5375,5379,5382 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
83 String parameterName, |
33bfc01410fb
Merged revisions 5375,5379,5382 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3083
diff
changeset
|
84 CallContext context |
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 ) |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 throws IllegalArgumentException; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 protected abstract String getLabelFor( |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 CallContext cc, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 String parameterName, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 String value |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 ) |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 throws IllegalArgumentException; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 } |
3083
4bd3d8bbb60c
Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2709
diff
changeset
|
96 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |