Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java @ 3727:b81f328da582
Removed code duplication.
flys-artifacts/trunk@5399 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 08 Sep 2012 12:58:58 +0000 |
parents | c91e7db0fd4b |
children | 5d0419882382 |
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, |
3722
c91e7db0fd4b
Set data for characteristic diameter for use in parameter matrix UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3452
diff
changeset
|
42 String parameterName, |
c91e7db0fd4b
Set data for characteristic diameter for use in parameter matrix UI.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3452
diff
changeset
|
43 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
|
44 ) |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 throws IllegalArgumentException |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 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
|
48 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 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
|
50 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
|
51 "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
|
52 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
54 River river = FLYSUtils.getRiver((FLYSArtifact) artifact); |
2716
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
55 double lo = ((FLYSArtifact) artifact).getDataAsDouble("ld_from"); |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
56 double hi = ((FLYSArtifact) artifact).getDataAsDouble("ld_to"); |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
57 |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
58 double kmLo = Math.min(lo, hi); |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
59 double kmHi = Math.max(lo, hi); |
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
61 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
|
62 |
2716
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
63 appendSingles(river, kmLo, kmHi, kvp); |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
64 appendEpochs(river, kmLo, kmHi, kvp); |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
65 |
3452
200e70f31f6f
Removed some superfluous casts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3087
diff
changeset
|
66 return kvp.toArray(new KVP[kvp.size()]); |
2712
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 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
69 |
2716
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
70 protected void appendSingles( |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
71 River river, |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
72 double kmLo, |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
73 double kmHi, |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
74 List<KVP<String, String>> kvp |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
75 ) { |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
76 List<BedHeightSingle> singles = |
2716
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
77 BedHeightSingle.getBedHeightSingles(river, kmLo, kmHi); |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
78 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
79 if (singles != null) { |
3087
4a76da133144
Removed repeated x.size() calls from for loops.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
80 for (int i = 0, S = singles.size(); i < S; i++) { |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
81 BedHeightSingle s = singles.get(i); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
82 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
83 String id = PREFIX_SINGLE + s.getId(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
84 String value = s.getDescription(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
85 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
86 kvp.add(new KVP(id, value)); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
87 } |
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 } |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
89 } |
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
91 |
2716
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
92 protected void appendEpochs( |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
93 River river, |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
94 double kmLo, |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
95 double kmHi, |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
96 List<KVP<String, String>> kvp |
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
97 ) { |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
98 List<BedHeightEpoch> epochs = |
2716
150dcdefeb7d
Only offer soundings that fit to the current km range in MINFO bed height workflow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2712
diff
changeset
|
99 BedHeightEpoch.getBedHeightEpochs(river, kmLo, kmHi); |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
100 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
101 if (epochs != null) { |
3087
4a76da133144
Removed repeated x.size() calls from for loops.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
102 for (int i = 0, E = epochs.size(); i < E; i++) { |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
103 BedHeightEpoch e = epochs.get(i); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
104 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
105 String id = PREFIX_EPOCH + e.getId(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
106 String value = e.getDescription(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
107 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
108 kvp.add(new KVP(id, value)); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
109 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
110 } |
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 @Override |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 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
|
116 CallContext cc, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 String parameterName, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 String value |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 ) throws IllegalArgumentException |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 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
|
122 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
|
123 "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
|
124 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
126 if (value.indexOf(PREFIX_SINGLE) >= 0) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
127 return getLabelForSingle(cc, value); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
128 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
129 else if (value.indexOf(PREFIX_EPOCH) >= 0) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
130 return getLabelForEpoch(cc, value); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
131 } |
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 return value; |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
134 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
135 |
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 protected String getLabelForSingle(CallContext cc, String value) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
138 String id = value.replace(PREFIX_SINGLE, ""); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
139 try { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
140 BedHeightSingle s = BedHeightSingle.getBedHeightSingleById( |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
141 Integer.parseInt(id)); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
142 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
143 if (s != null) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
144 return s.getDescription(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
145 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
146 else { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
147 return "no value for '" + id + "'"; |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
148 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
149 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
150 catch (NumberFormatException nfe) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
151 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
|
152 } |
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 return "n.A."; |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
155 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
156 |
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 protected String getLabelForEpoch(CallContext cc, String value) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
159 String id = value.replace(PREFIX_EPOCH, ""); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
160 try { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
161 BedHeightEpoch e = BedHeightEpoch.getBedHeightEpochById( |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
162 Integer.parseInt(id)); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
163 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
164 if (e != null) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
165 return e.getDescription(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
166 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
167 else { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
168 return "no value for '" + id + "'"; |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
169 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
170 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
171 catch (NumberFormatException nfe) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
172 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
|
173 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
174 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
175 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
|
176 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 |
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 /** |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 * 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
|
181 * state. |
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 * @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
|
184 * |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 * @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
|
186 * <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
|
187 */ |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 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
|
189 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
|
190 return false; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 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
|
193 return true; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 else { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 return false; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
199 } |
3083
4bd3d8bbb60c
Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2716
diff
changeset
|
200 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |