annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceGaugeState.java @ 4418:e0a355d0c771

FixationArtifact: In doc, mention where the FacetActivity is registered.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 06 Nov 2012 09:04:07 +0100
parents eaf83d4ae6b1
children e8a4d2fd25cc
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
4174
eaf83d4ae6b1 Sorted gauges for reference gauge selection in historical discharge calculation based on their name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4049
diff changeset
3 import java.util.Collections;
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 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
5
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 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
7
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 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
9 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
10
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.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
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.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
14 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
15
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.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
17 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
18
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
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 * @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
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 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
24
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
25 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
26
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
27
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 @Override
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 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
30 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
31 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
32 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
33 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
34 {
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 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
36 List<Gauge> gauges = river.getGauges();
4174
eaf83d4ae6b1 Sorted gauges for reference gauge selection in historical discharge calculation based on their name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4049
diff changeset
37 Collections.sort(gauges);
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 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
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 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
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 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
44 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
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 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
47 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
48
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 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
50 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
51 }
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 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
54 }
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
55
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
56
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
57 @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
58 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
59 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
60 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
61 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
62 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
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 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
65 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
66 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
67 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
68
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 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
70 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
71 }
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 }
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 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
74 // 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
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 }
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
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 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
79 }
2191
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 }
f28844a57fed Added states (work is not finished yet) for the 'historical discharge curve' calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org