Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstWQFixing.java @ 9276:3141f0e7314e
clone for bundu.ws.wq
author | gernotbelger |
---|---|
date | Thu, 19 Jul 2018 17:54:10 +0200 |
parents | |
children | 2323d005f9a5 |
comparison
equal
deleted
inserted
replaced
9275:ff9372d0cc1c | 9276:3141f0e7314e |
---|---|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 package org.dive4elements.river.artifacts.bundu.bezugswst; | |
9 | |
10 import org.apache.log4j.Logger; | |
11 import org.dive4elements.artifacts.Artifact; | |
12 import org.dive4elements.river.artifacts.D4EArtifact; | |
13 import org.dive4elements.river.artifacts.model.RangeWithValues; | |
14 import org.dive4elements.river.artifacts.states.WQAdapted; | |
15 | |
16 /** | |
17 * State to input W/Q data for fixings | |
18 * | |
19 * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a> | |
20 */ | |
21 public class BunduWstWQFixing extends WQAdapted { | |
22 | |
23 /** The log used in this state. */ | |
24 private static Logger log = Logger.getLogger(BunduWstWQFixing.class); | |
25 | |
26 /** Simple sanity check if values are positive numbers **/ | |
27 @Override | |
28 public boolean validate(final Artifact artifact) throws IllegalArgumentException { | |
29 log.debug("BunduWstWQFixing.validate"); | |
30 | |
31 final RangeWithValues[] rwvs = extractInput(getData((D4EArtifact) artifact, "wq_values")); | |
32 | |
33 if (rwvs == null) { | |
34 throw new IllegalArgumentException("error_missing_wq_data"); | |
35 } | |
36 | |
37 for (final RangeWithValues rwv : rwvs) { | |
38 final double[] values = rwv.getValues(); | |
39 for (final double val : values) { | |
40 if (val <= 0) { | |
41 throw new IllegalArgumentException("error_validate_positive"); | |
42 } | |
43 } | |
44 } | |
45 | |
46 return true; | |
47 } | |
48 | |
49 @Override | |
50 protected String getUIProvider() { | |
51 return "bundu_wst_wq_panel"; | |
52 } | |
53 } |