comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java @ 624:929137ee8154

ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact. flys-artifacts/trunk@1982 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 23 May 2011 15:11:55 +0000
parents c21fb8de54f8
children a9af60c84dca
comparison
equal deleted inserted replaced
623:aa64fe4df8ab 624:929137ee8154
1 package de.intevation.flys.artifacts.states; 1 package de.intevation.flys.artifacts.states;
2
3 import java.util.Map;
4 2
5 import gnu.trove.TDoubleArrayList; 3 import gnu.trove.TDoubleArrayList;
6 4
7 import org.apache.log4j.Logger; 5 import org.apache.log4j.Logger;
8 6
201 public boolean validate(Artifact artifact, CallContext context) 199 public boolean validate(Artifact artifact, CallContext context)
202 throws IllegalArgumentException 200 throws IllegalArgumentException
203 { 201 {
204 logger.debug("WQSelect.validate"); 202 logger.debug("WQSelect.validate");
205 203
206 Map<String, StateData> data = getData(); 204 FLYSArtifact flys = (FLYSArtifact) artifact;
207 205
208 String selectionMode = (String) data.get(WQ_SELECTION).getValue(); 206 StateData data = getData(flys, WQ_SELECTION);
207 String selectionMode = data != null ? (String) data.getValue() : null;
209 208
210 if (selectionMode == null || selectionMode.equals("single")) { 209 if (selectionMode == null || selectionMode.equals("single")) {
211 return validateSingle(artifact, context); 210 return validateSingle(artifact, context);
212 } 211 }
213 else { 212 else {
219 protected boolean validateSingle(Artifact artifact, CallContext context) 218 protected boolean validateSingle(Artifact artifact, CallContext context)
220 throws IllegalArgumentException 219 throws IllegalArgumentException
221 { 220 {
222 logger.debug("WQSelect.validateSingle"); 221 logger.debug("WQSelect.validateSingle");
223 222
224 String tmp = (String) data.get(WQ_SINGLE).getValue(); 223 FLYSArtifact flys = (FLYSArtifact) artifact;
224 StateData data = getData(flys, WQ_SINGLE);
225
226 String tmp = data != null ? (String) data.getValue() : null;
225 227
226 if (tmp == null || tmp.length() == 0) { 228 if (tmp == null || tmp.length() == 0) {
227 throw new IllegalArgumentException("error_empty_state"); 229 throw new IllegalArgumentException("error_empty_state");
228 } 230 }
229 231
239 } 241 }
240 } 242 }
241 243
242 all.sort(); 244 all.sort();
243 245
244 String mode = (String) data.get(WQ_MODE).getValue(); 246 StateData dMode = getData(flys, WQ_MODE);
247 String mode = dMode != null ? (String) data.getValue() : null;
248
245 logger.debug("WQ Mode: " + mode); 249 logger.debug("WQ Mode: " + mode);
246 250
247 double[] minmax = null; 251 double[] minmax = null;
248 252
249 if (mode != null && mode.trim().toLowerCase().equals("w")) { 253 if (mode != null && mode.trim().toLowerCase().equals("w")) {

http://dive4elements.wald.intevation.org