annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java @ 2715:250a370c377d

Added chart generator for middle bed height charts. flys-artifacts/trunk@4441 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 18 May 2012 11:58:38 +0000
parents ed612b85fb6d
children 150dcdefeb7d
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
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
3 import java.util.ArrayList;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
4 import java.util.List;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
5
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 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
7
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.Artifact;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 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
10
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
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
13 import de.intevation.flys.model.BedHeightEpoch;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
14 import de.intevation.flys.model.BedHeightSingle;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
15 import de.intevation.flys.model.River;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
16
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
17 import de.intevation.flys.artifacts.FLYSArtifact;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
18 import de.intevation.flys.utils.FLYSUtils;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
19
2709
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 class SoundingsSelect extends MultiStringArrayState {
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 public static final String SOUNDINGS = "soundings";
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
25 public static final String PREFIX_SINGLE = "single-";
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
26
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
27 public static final String PREFIX_EPOCH = "epoch-";
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
28
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 private static final Logger logger = Logger.getLogger(SoundingsSelect.class);
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 @Override
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 public String getUIProvider() {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 return "parameter-matrix";
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 @Override
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 protected 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
41 Artifact artifact,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 String parameterName
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 )
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 throws IllegalArgumentException
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 logger.debug("Get options for parameter: '" + parameterName + "'");
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 if (!testParameterName(parameterName)) {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 throw new IllegalArgumentException(
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 "Invalid parameter for state: '" + parameterName + "'");
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
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
53 River river = FLYSUtils.getRiver((FLYSArtifact) artifact);
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
55 List<KVP<String, String>> kvp = new ArrayList<KVP<String, String>>();
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
57 appendSingles(river, kvp);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
58 appendEpochs(river, kvp);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
59
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
60 return (KVP<String,String>[]) kvp.toArray(new KVP[kvp.size()]);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
61 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
62
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
63
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
64 protected void appendSingles(River river, List<KVP<String, String>> kvp) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
65 List<BedHeightSingle> singles =
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
66 BedHeightSingle.getBedHeightSingles(river);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
67
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
68 if (singles != null) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
69 for (int i = 0; i < singles.size(); i++) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
70 BedHeightSingle s = singles.get(i);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
71
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
72 String id = PREFIX_SINGLE + s.getId();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
73 String value = s.getDescription();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
74
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
75 kvp.add(new KVP(id, value));
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
76 }
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 }
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
78 }
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
80
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
81 protected void appendEpochs(River river, List<KVP<String, String>> kvp) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
82 List<BedHeightEpoch> epochs =
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
83 BedHeightEpoch.getBedHeightEpochs(river);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
84
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
85 if (epochs != null) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
86 for (int i = 0; i < epochs.size(); i++) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
87 BedHeightEpoch e = epochs.get(i);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
88
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
89 String id = PREFIX_EPOCH + e.getId();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
90 String value = e.getDescription();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
91
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
92 kvp.add(new KVP(id, value));
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
93 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
94 }
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 @Override
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 protected String getLabelFor(
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 CallContext cc,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 String parameterName,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 String value
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 ) throws IllegalArgumentException
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 if (!testParameterName(parameterName)) {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 throw new IllegalArgumentException(
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 "Invalid parameter for state: '" + parameterName + "'");
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
110 if (value.indexOf(PREFIX_SINGLE) >= 0) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
111 return getLabelForSingle(cc, value);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
112 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
113 else if (value.indexOf(PREFIX_EPOCH) >= 0) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
114 return getLabelForEpoch(cc, value);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
115 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
116
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
117 return value;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
118 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
119
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
120
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
121 protected String getLabelForSingle(CallContext cc, String value) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
122 String id = value.replace(PREFIX_SINGLE, "");
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
123 try {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
124 BedHeightSingle s = BedHeightSingle.getBedHeightSingleById(
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
125 Integer.parseInt(id));
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
126
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
127 if (s != null) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
128 return s.getDescription();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
129 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
130 else {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
131 return "no value for '" + id + "'";
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
132 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
133 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
134 catch (NumberFormatException nfe) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
135 logger.warn("Could not parse id from string '" + id + "'", nfe);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
136 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
137
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
138 return "n.A.";
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
139 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
140
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
141
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
142 protected String getLabelForEpoch(CallContext cc, String value) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
143 String id = value.replace(PREFIX_EPOCH, "");
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
144 try {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
145 BedHeightEpoch e = BedHeightEpoch.getBedHeightEpochById(
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
146 Integer.parseInt(id));
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
147
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
148 if (e != null) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
149 return e.getDescription();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
150 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
151 else {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
152 return "no value for '" + id + "'";
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
153 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
154 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
155 catch (NumberFormatException nfe) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
156 logger.warn("Could not parse id from string '" + id + "'", nfe);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
157 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
158
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
159 return "n.A.";
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 /**
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 * This method might be used to test, if a parameter name is handled by this
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 * state.
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 *
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 * @param parameterName The name of a parameter.
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 *
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 * @return true, if parameterName is one of <i>MAIN_CHANNEL</i> or
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 * <i>TOTAL_CHANNEL</i>. Otherwise false.
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171 */
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 protected boolean testParameterName(String parameterName) {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 if (parameterName == null || parameterName.length() == 0) {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 return false;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 else if (parameterName.equals(SOUNDINGS)) {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 return true;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 else {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180 return false;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183 }

http://dive4elements.wald.intevation.org