Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SoundingsSelect.java @ 3201:1c00ed73ccf4
FixA: Fixed da/dQ for exp function but the fitting still does not work.
flys-artifacts/trunk@4818 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 27 Jun 2012 16:41:02 +0000 |
parents | 4a76da133144 |
children | 200e70f31f6f |
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); |
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
|
54 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
|
55 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
|
56 |
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 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
|
58 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
|
59 |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
60 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
|
61 |
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
|
62 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
|
63 appendEpochs(river, kmLo, kmHi, kvp); |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
64 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
65 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
|
66 } |
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 |
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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 ) { |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
75 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
|
76 BedHeightSingle.getBedHeightSingles(river, kmLo, kmHi); |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
77 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
78 if (singles != null) { |
3087
4a76da133144
Removed repeated x.size() calls from for loops.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
79 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
|
80 BedHeightSingle s = singles.get(i); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
81 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
82 String id = PREFIX_SINGLE + s.getId(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
83 String value = s.getDescription(); |
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 kvp.add(new KVP(id, value)); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
86 } |
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 } |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
88 } |
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
90 |
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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 ) { |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
97 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
|
98 BedHeightEpoch.getBedHeightEpochs(river, kmLo, kmHi); |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
99 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
100 if (epochs != null) { |
3087
4a76da133144
Removed repeated x.size() calls from for loops.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
101 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
|
102 BedHeightEpoch e = epochs.get(i); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
103 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
104 String id = PREFIX_EPOCH + e.getId(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
105 String value = e.getDescription(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
106 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
107 kvp.add(new KVP(id, value)); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
108 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
109 } |
2709
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 } |
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 @Override |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 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
|
115 CallContext cc, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 String parameterName, |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 String value |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 ) throws IllegalArgumentException |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 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
|
121 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
|
122 "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
|
123 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 |
2712
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
125 if (value.indexOf(PREFIX_SINGLE) >= 0) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
126 return getLabelForSingle(cc, value); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
127 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
128 else if (value.indexOf(PREFIX_EPOCH) >= 0) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
129 return getLabelForEpoch(cc, value); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
130 } |
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 return value; |
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 |
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 protected String getLabelForSingle(CallContext cc, String value) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
137 String id = value.replace(PREFIX_SINGLE, ""); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
138 try { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
139 BedHeightSingle s = BedHeightSingle.getBedHeightSingleById( |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
140 Integer.parseInt(id)); |
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 if (s != null) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
143 return s.getDescription(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
144 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
145 else { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
146 return "no value for '" + 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 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
149 catch (NumberFormatException nfe) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
150 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
|
151 } |
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 return "n.A."; |
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 |
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 protected String getLabelForEpoch(CallContext cc, String value) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
158 String id = value.replace(PREFIX_EPOCH, ""); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
159 try { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
160 BedHeightEpoch e = BedHeightEpoch.getBedHeightEpochById( |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
161 Integer.parseInt(id)); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
162 |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
163 if (e != null) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
164 return e.getDescription(); |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
165 } |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
166 else { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
167 return "no value for '" + id + "'"; |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
168 } |
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 catch (NumberFormatException nfe) { |
ed612b85fb6d
Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2709
diff
changeset
|
171 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
|
172 } |
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 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
|
175 } |
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 * 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
|
180 * state. |
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 * @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
|
183 * |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 * @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
|
185 * <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
|
186 */ |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 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
|
188 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
|
189 return false; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 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
|
192 return true; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 } |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 else { |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 return false; |
cd6bcca17de6
Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 } |
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 } |
3083
4bd3d8bbb60c
Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2716
diff
changeset
|
199 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |