Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java @ 9391:2da486c7c05f
salix historical sounding workflow changed
author | gernotbelger |
---|---|
date | Thu, 09 Aug 2018 17:25:13 +0200 |
parents | f575ff573cbb |
children | ba3ad54edbae |
comparison
equal
deleted
inserted
replaced
9390:f575ff573cbb | 9391:2da486c7c05f |
---|---|
24 import org.dive4elements.river.model.River; | 24 import org.dive4elements.river.model.River; |
25 import org.dive4elements.river.utils.Formatter; | 25 import org.dive4elements.river.utils.Formatter; |
26 import org.dive4elements.river.utils.RiverUtils; | 26 import org.dive4elements.river.utils.RiverUtils; |
27 import org.w3c.dom.Element; | 27 import org.w3c.dom.Element; |
28 | 28 |
29 public class SoundingsSelect extends DefaultState { | 29 public abstract class SoundingsSelect extends DefaultState { |
30 | 30 |
31 public static final String SOUNDINGS = "soundings"; | 31 private static final String SOUNDINGS = "soundings"; |
32 | 32 |
33 public static final String PREFIX_SINGLE = "single-"; | 33 public static final String PREFIX_SINGLE = "single-"; |
34 | 34 |
35 /** Private log. */ | 35 /** Private log. */ |
36 private static final Logger log = Logger.getLogger(SoundingsSelect.class); | 36 private static final Logger log = Logger.getLogger(SoundingsSelect.class); |
37 | 37 |
38 @Override | 38 @Override |
39 public String getUIProvider() { | 39 protected final void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, |
40 return "parameter-matrix-sounding"; | 40 final Element select) { |
41 } | |
42 | |
43 @Override | |
44 protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) { | |
45 try { | 41 try { |
46 creator.addAttr(select, "type", "multiattribute", true); | 42 creator.addAttr(select, "type", "multiattribute", true); |
47 | 43 |
48 appendMeta(creator, select); | 44 appendMeta(creator, select); |
49 | 45 |
71 | 67 |
72 select.appendChild(meta); | 68 select.appendChild(meta); |
73 | 69 |
74 } | 70 } |
75 | 71 |
76 protected KVP<String, String>[] getOptions(final Artifact artifact, final String parameterName, final CallContext context, final ElementCreator creator, | 72 private KVP<String, String>[] getOptions(final Artifact artifact, final String parameterName, final CallContext context, final ElementCreator creator, |
77 final Element select) throws IllegalArgumentException { | 73 final Element select) throws IllegalArgumentException { |
78 log.debug("Get options for parameter: '" + parameterName + "'"); | 74 log.debug("Get options for parameter: '" + parameterName + "'"); |
79 | 75 |
80 if (!testParameterName(parameterName)) { | 76 if (!testParameterName(parameterName)) { |
81 throw new IllegalArgumentException("Invalid parameter for state: '" + parameterName + "'"); | 77 throw new IllegalArgumentException("Invalid parameter for state: '" + parameterName + "'"); |
92 | 88 |
93 final List<KVP<String, String>> kvp = Collections.<KVP<String, String>>emptyList(); | 89 final List<KVP<String, String>> kvp = Collections.<KVP<String, String>>emptyList(); |
94 return kvp.toArray(new KVP[kvp.size()]); | 90 return kvp.toArray(new KVP[kvp.size()]); |
95 } | 91 } |
96 | 92 |
97 protected void appendSingles(final River river, final double kmLo, final double kmHi, final ElementCreator creator, final Element select, | 93 private void appendSingles(final River river, final double kmLo, final double kmHi, final ElementCreator creator, final Element select, |
98 final CallContext context) { | 94 final CallContext context) { |
99 final List<BedHeight> singles = BedHeight.getBedHeights(river, kmLo, kmHi); | 95 final List<BedHeight> singles = BedHeight.getBedHeights(river, kmLo, kmHi); |
100 | 96 |
101 if (singles != null) { | 97 if (singles != null) { |
102 final int size = singles.size(); | 98 final int size = singles.size(); |
125 log.debug(XMLUtils.toString(select)); | 121 log.debug(XMLUtils.toString(select)); |
126 } | 122 } |
127 } | 123 } |
128 | 124 |
129 @Override | 125 @Override |
130 protected Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value, | 126 protected final Element createStaticData(final D4EArtifact flys, final ElementCreator creator, final CallContext cc, final String name, final String value, |
131 final String type) { | 127 final String type) { |
132 final Element data = creator.create("data"); | 128 final Element data = creator.create("data"); |
133 creator.addAttr(data, "name", name, true); | 129 creator.addAttr(data, "name", name, true); |
134 creator.addAttr(data, "type", type, true); | 130 creator.addAttr(data, "type", type, true); |
135 creator.addAttr(data, "label", Resources.getMsg(cc.getMeta(), name, name), true); | 131 creator.addAttr(data, "label", Resources.getMsg(cc.getMeta(), name, name), true); |
145 } | 141 } |
146 | 142 |
147 return data; | 143 return data; |
148 } | 144 } |
149 | 145 |
150 protected String getLabelFor(final CallContext cc, final String parameterName, final String value) throws IllegalArgumentException { | 146 private String getLabelFor(final CallContext cc, final String parameterName, final String value) throws IllegalArgumentException { |
151 if (!testParameterName(parameterName)) { | 147 if (!testParameterName(parameterName)) { |
152 throw new IllegalArgumentException("Invalid parameter for state: '" + parameterName + "'"); | 148 throw new IllegalArgumentException("Invalid parameter for state: '" + parameterName + "'"); |
153 } | 149 } |
154 | 150 |
155 if (value.indexOf(PREFIX_SINGLE) >= 0) { | 151 if (value.indexOf(PREFIX_SINGLE) >= 0) { |
156 return getLabelForSingle(cc, value); | 152 return getLabelForSingle(cc, value); |
157 } | 153 } |
158 return value; | 154 return value; |
159 } | 155 } |
160 | 156 |
161 protected String getLabelForSingle(final CallContext cc, final String value) { | 157 private String getLabelForSingle(final CallContext cc, final String value) { |
162 final String id = value.replace(PREFIX_SINGLE, ""); | 158 final String id = value.replace(PREFIX_SINGLE, ""); |
163 try { | 159 try { |
164 final BedHeight s = BedHeight.getBedHeightById(Integer.parseInt(id)); | 160 final BedHeight s = BedHeight.getBedHeightById(Integer.parseInt(id)); |
165 | 161 |
166 if (s != null) { | 162 if (s != null) { |
184 * The name of a parameter. | 180 * The name of a parameter. |
185 * | 181 * |
186 * @return true, if parameterName is one of <i>MAIN_CHANNEL</i> or | 182 * @return true, if parameterName is one of <i>MAIN_CHANNEL</i> or |
187 * <i>TOTAL_CHANNEL</i>. Otherwise false. | 183 * <i>TOTAL_CHANNEL</i>. Otherwise false. |
188 */ | 184 */ |
189 protected boolean testParameterName(final String parameterName) { | 185 private boolean testParameterName(final String parameterName) { |
190 if (parameterName == null || parameterName.length() == 0) { | 186 if (parameterName == null || parameterName.length() == 0) { |
191 return false; | 187 return false; |
192 } else if (parameterName.equals(SOUNDINGS)) { | 188 } else if (parameterName.equals(SOUNDINGS)) { |
193 return true; | 189 return true; |
194 } else { | 190 } else { |