annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java @ 5865:73da40528cf2

River artifacts: Renamed FLYSUtils to RiverUtils.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 15:09:31 +0200
parents 4897a58c8746
children 59ff03ff48f1
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3931
diff changeset
9 package org.dive4elements.river.artifacts.states;
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
11 import java.util.ArrayList;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
12 import java.util.List;
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
13
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 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
15
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3931
diff changeset
16 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3931
diff changeset
17 import org.dive4elements.artifacts.CallContext;
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3931
diff changeset
19 import org.dive4elements.artifacts.common.model.KVP;
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3931
diff changeset
21 import org.dive4elements.river.model.BedHeightEpoch;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3931
diff changeset
22 import org.dive4elements.river.model.BedHeightSingle;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3931
diff changeset
23 import org.dive4elements.river.model.River;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3931
diff changeset
24
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3931
diff changeset
25 import org.dive4elements.river.artifacts.FLYSArtifact;
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
26 import org.dive4elements.river.utils.RiverUtils;
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
27
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 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
30
3931
c79b98085096 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
31 public static final String SOUNDINGS = "soundings";
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
33 public static final String PREFIX_SINGLE = "single-";
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
34
3931
c79b98085096 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
35 public static final String PREFIX_EPOCH = "epoch-";
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
36
3931
c79b98085096 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
37 /** Private logger. */
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 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
39
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 @Override
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 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
43 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
44 }
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
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 @Override
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 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
49 Artifact artifact,
3649
33bfc01410fb Merged revisions 5375,5379,5382 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3452
diff changeset
50 String parameterName,
33bfc01410fb Merged revisions 5375,5379,5382 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3452
diff changeset
51 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
52 )
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 throws IllegalArgumentException
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 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
56
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 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
58 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
59 "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
60 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
62 River river = RiverUtils.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
63 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
64 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
65
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
66 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
67 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
68
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
69 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
70
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
71 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
72 appendEpochs(river, kmLo, kmHi, kvp);
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
73
3452
200e70f31f6f Removed some superfluous casts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3087
diff changeset
74 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
75 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
76
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
77
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
78 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
79 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
80 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
81 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
82 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
83 ) {
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
84 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
85 BedHeightSingle.getBedHeightSingles(river, kmLo, kmHi);
3785
a5f65e8983be Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3782
diff changeset
86
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
87 if (singles != null) {
3782
5d0419882382 Added missing translation of minfo state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3649
diff changeset
88 int size = singles.size();
3785
a5f65e8983be Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3782
diff changeset
89
3782
5d0419882382 Added missing translation of minfo state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3649
diff changeset
90 logger.debug("Found " + size + " singles.");
3785
a5f65e8983be Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3782
diff changeset
91
3782
5d0419882382 Added missing translation of minfo state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3649
diff changeset
92 for (int i = 0; i < size; i++) {
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
93 BedHeightSingle s = singles.get(i);
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
94
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
95 String id = PREFIX_SINGLE + s.getId();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
96 String value = s.getDescription();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
97
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
98 kvp.add(new KVP(id, value));
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
99 }
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 }
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
101 }
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
103
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
104 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
105 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
106 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
107 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
108 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
109 ) {
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
110 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
111 BedHeightEpoch.getBedHeightEpochs(river, kmLo, kmHi);
2712
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 if (epochs != null) {
3782
5d0419882382 Added missing translation of minfo state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3649
diff changeset
114 int size = epochs.size();
3785
a5f65e8983be Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3782
diff changeset
115
3782
5d0419882382 Added missing translation of minfo state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3649
diff changeset
116 logger.debug("Found " + size + " epochs.");
3785
a5f65e8983be Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3782
diff changeset
117
3782
5d0419882382 Added missing translation of minfo state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3649
diff changeset
118 for (int i = 0; i < size; i++) {
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
119 BedHeightEpoch e = epochs.get(i);
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 String id = PREFIX_EPOCH + e.getId();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
122 String value = e.getDescription();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
123
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
124 kvp.add(new KVP(id, value));
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
125 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
126 }
2709
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 @Override
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 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
132 CallContext cc,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 String parameterName,
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 String value
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 ) throws IllegalArgumentException
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 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
138 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
139 "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
140 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141
2712
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
142 if (value.indexOf(PREFIX_SINGLE) >= 0) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
143 return getLabelForSingle(cc, value);
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 if (value.indexOf(PREFIX_EPOCH) >= 0) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
146 return getLabelForEpoch(cc, value);
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 return value;
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
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 protected String getLabelForSingle(CallContext cc, String value) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
154 String id = value.replace(PREFIX_SINGLE, "");
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
155 try {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
156 BedHeightSingle s = BedHeightSingle.getBedHeightSingleById(
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
157 Integer.parseInt(id));
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 if (s != null) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
160 return s.getDescription();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
161 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
162 else {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
163 return "no value for '" + id + "'";
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
164 }
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 catch (NumberFormatException nfe) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
167 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
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 return "n.A.";
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
171 }
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 protected String getLabelForEpoch(CallContext cc, String value) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
175 String id = value.replace(PREFIX_EPOCH, "");
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
176 try {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
177 BedHeightEpoch e = BedHeightEpoch.getBedHeightEpochById(
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
178 Integer.parseInt(id));
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
179
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
180 if (e != null) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
181 return e.getDescription();
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
182 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
183 else {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
184 return "no value for '" + id + "'";
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
185 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
186 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
187 catch (NumberFormatException nfe) {
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
188 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
189 }
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
190
ed612b85fb6d Implemented SoundingsSelect.getOptions() and SoundingsSelect.getLabelFor().
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2709
diff changeset
191 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
192 }
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
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 /**
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 * 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
197 * state.
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 * @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
200 *
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 * @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
202 * <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
203 */
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 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
205 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
206 return false;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 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
209 return true;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 else {
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 return false;
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214 }
cd6bcca17de6 Added states and improved transition model for MINFO middle bed height calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 }
3083
4bd3d8bbb60c Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2716
diff changeset
216 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org