Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java @ 1050:eccf966fb677
State engine: Removed CallContext from state validation.
flys-artifacts/trunk@2512 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 19 Aug 2011 14:10:18 +0000 |
parents | 610d0e0f4f85 |
children | 61c051e53f9b |
comparison
equal
deleted
inserted
replaced
1049:433559e25b50 | 1050:eccf966fb677 |
---|---|
198 return new double[] { minQ, maxQ }; | 198 return new double[] { minQ, maxQ }; |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 @Override | 202 @Override |
203 public boolean validate(Artifact artifact, CallContext context) | 203 public boolean validate(Artifact artifact) |
204 throws IllegalArgumentException | 204 throws IllegalArgumentException |
205 { | 205 { |
206 logger.debug("WQSelect.validate"); | 206 logger.debug("WQSelect.validate"); |
207 | 207 |
208 FLYSArtifact flys = (FLYSArtifact) artifact; | 208 FLYSArtifact flys = (FLYSArtifact) artifact; |
209 | 209 |
210 StateData data = getData(flys, WQ_SELECTION); | 210 StateData data = getData(flys, WQ_SELECTION); |
211 String selectionMode = data != null ? (String) data.getValue() : null; | 211 String selectionMode = data != null ? (String) data.getValue() : null; |
212 | 212 |
213 if (selectionMode == null || selectionMode.equals("single")) { | 213 if (selectionMode == null || selectionMode.equals("single")) { |
214 return validateSingle(artifact, context); | 214 return validateSingle(artifact); |
215 } | 215 } |
216 else { | 216 else { |
217 return validateRange(artifact, context); | 217 return validateRange(artifact); |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 | 221 |
222 protected boolean validateBounds( | 222 protected boolean validateBounds( |
239 | 239 |
240 return true; | 240 return true; |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 protected boolean validateSingle(Artifact artifact, CallContext context) | 244 protected boolean validateSingle(Artifact artifact) |
245 throws IllegalArgumentException | 245 throws IllegalArgumentException |
246 { | 246 { |
247 logger.debug("WQSelect.validateSingle"); | 247 logger.debug("WQSelect.validateSingle"); |
248 | 248 |
249 FLYSArtifact flys = (FLYSArtifact) artifact; | 249 FLYSArtifact flys = (FLYSArtifact) artifact; |
291 | 291 |
292 return validateBounds(minmax[0], minmax[1], min, max, 0d); | 292 return validateBounds(minmax[0], minmax[1], min, max, 0d); |
293 } | 293 } |
294 | 294 |
295 | 295 |
296 protected boolean validateRange(Artifact artifact, CallContext context) | 296 protected boolean validateRange(Artifact artifact) |
297 throws IllegalArgumentException | 297 throws IllegalArgumentException |
298 { | 298 { |
299 logger.debug("WQSelect.validateRange"); | 299 logger.debug("WQSelect.validateRange"); |
300 FLYSArtifact flys = (FLYSArtifact) artifact; | 300 FLYSArtifact flys = (FLYSArtifact) artifact; |
301 | 301 |
323 double from = Double.parseDouble(fromStr); | 323 double from = Double.parseDouble(fromStr); |
324 double to = Double.parseDouble(toStr); | 324 double to = Double.parseDouble(toStr); |
325 double step = Double.parseDouble(stepStr); | 325 double step = Double.parseDouble(stepStr); |
326 | 326 |
327 if (mode != null && mode.trim().toLowerCase().equals("w")) { | 327 if (mode != null && mode.trim().toLowerCase().equals("w")) { |
328 return validateW(artifact, context, from, to, step); | 328 return validateW(artifact, from, to, step); |
329 } | 329 } |
330 else if (mode != null && mode.trim().toLowerCase().equals("q")) { | 330 else if (mode != null && mode.trim().toLowerCase().equals("q")) { |
331 return validateQ(artifact, context, from, to, step); | 331 return validateQ(artifact, from, to, step); |
332 } | 332 } |
333 else { | 333 else { |
334 throw new IllegalArgumentException( | 334 throw new IllegalArgumentException( |
335 "error_feed_invalid_wq_mode"); | 335 "error_feed_invalid_wq_mode"); |
336 } | 336 } |
343 | 343 |
344 /** | 344 /** |
345 * Validates the inserted W values. | 345 * Validates the inserted W values. |
346 * | 346 * |
347 * @param artifact The owner artifact. | 347 * @param artifact The owner artifact. |
348 * @param context The CallContext | |
349 * @param from The lower value of the W range. | 348 * @param from The lower value of the W range. |
350 * @param to The upper value of the W range. | 349 * @param to The upper value of the W range. |
351 * @param step The step width. | 350 * @param step The step width. |
352 * | 351 * |
353 * @return true, if everything was fine, otherwise an exception is thrown. | 352 * @return true, if everything was fine, otherwise an exception is thrown. |
354 */ | 353 */ |
355 protected boolean validateW( | 354 protected boolean validateW( |
356 Artifact artifact, | 355 Artifact artifact, |
357 CallContext context, | |
358 double from, | 356 double from, |
359 double to, | 357 double to, |
360 double step) | 358 double step) |
361 throws IllegalArgumentException | 359 throws IllegalArgumentException |
362 { | 360 { |
370 | 368 |
371 /** | 369 /** |
372 * Validates the inserted Q values. | 370 * Validates the inserted Q values. |
373 * | 371 * |
374 * @param artifact The owner artifact. | 372 * @param artifact The owner artifact. |
375 * @param context The CallContext | |
376 * @param from The lower value of the Q range. | 373 * @param from The lower value of the Q range. |
377 * @param to The upper value of the Q range. | 374 * @param to The upper value of the Q range. |
378 * @param step The step width. | 375 * @param step The step width. |
379 * | 376 * |
380 * @return true, if everything was fine, otherwise an exception is thrown. | 377 * @return true, if everything was fine, otherwise an exception is thrown. |
381 */ | 378 */ |
382 protected boolean validateQ( | 379 protected boolean validateQ( |
383 Artifact artifact, | 380 Artifact artifact, |
384 CallContext context, | |
385 double from, | 381 double from, |
386 double to, | 382 double to, |
387 double step) | 383 double step) |
388 throws IllegalArgumentException | 384 throws IllegalArgumentException |
389 { | 385 { |