Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceGaugeState.java @ 4034:46c1210be26b
Set translated data descriptions
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Thu, 04 Oct 2012 16:26:48 +0200 |
parents | a38f43f626f5 |
children | 8e66293c5369 |
rev | line source |
---|---|
2191
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.Element; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.Artifact; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.CallContext; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.CallMeta; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.common.utils.XMLUtils; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.model.Gauge; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.flys.model.River; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.flys.artifacts.FLYSArtifact; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.flys.utils.FLYSUtils; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 /** |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 */ |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 public class ReferenceGaugeState extends DefaultState { |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 private static final Logger logger = |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 Logger.getLogger(ReferenceGaugeState.class); |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
2207
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
31 public static final String DATA_NAME = "reference_gauge"; |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
32 |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
33 |
2191
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 @Override |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 protected Element[] createItems( |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 XMLUtils.ElementCreator cr, |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 Artifact artifact, |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 String name, |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 CallContext context) |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 { |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 CallMeta meta = context.getMeta(); |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 River river = FLYSUtils.getRiver((FLYSArtifact) artifact); |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 List<Gauge> gauges = river.getGauges(); |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 int num = gauges != null ? gauges.size() : 0; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 Element[] opts = new Element[num]; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 for (int i = 0; i < num; i++ ) { |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 Gauge g = gauges.get(i); |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 String gaugeName = g.getName(); |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 long officialNumber = g.getOfficialNumber(); |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 opts[i] = createItem( |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 cr, new String[] { gaugeName, String.valueOf(officialNumber) }); |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 } |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 return opts; |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 } |
2207
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
62 |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
63 |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
64 @Override |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
65 protected String getLabelFor( |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
66 CallContext cc, |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
67 String name, |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
68 String value, |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
69 String type |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
70 ) { |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
71 if (name.equals(DATA_NAME)) { |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
72 try { |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
73 long number = Long.valueOf(value); |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
74 Gauge gauge = Gauge.getGaugeByOfficialNumber(number); |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
75 |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
76 if (gauge != null) { |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
77 return gauge.getName(); |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
78 } |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
79 } |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
80 catch (NumberFormatException nfe) { |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
81 // do nothing |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
82 } |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
83 } |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
84 |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
85 return super.getLabelFor(cc, name, value, type); |
a38f43f626f5
Display the name of the reference gauge in the static ui of 'historical discharge curves' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2191
diff
changeset
|
86 } |
2191
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 } |
f28844a57fed
Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |