Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstWQFixing.java Thu Jul 19 17:54:10 2018 +0200 @@ -0,0 +1,53 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ +package org.dive4elements.river.artifacts.bundu.bezugswst; + +import org.apache.log4j.Logger; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.model.RangeWithValues; +import org.dive4elements.river.artifacts.states.WQAdapted; + +/** + * State to input W/Q data for fixings + * + * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a> + */ +public class BunduWstWQFixing extends WQAdapted { + + /** The log used in this state. */ + private static Logger log = Logger.getLogger(BunduWstWQFixing.class); + + /** Simple sanity check if values are positive numbers **/ + @Override + public boolean validate(final Artifact artifact) throws IllegalArgumentException { + log.debug("BunduWstWQFixing.validate"); + + final RangeWithValues[] rwvs = extractInput(getData((D4EArtifact) artifact, "wq_values")); + + if (rwvs == null) { + throw new IllegalArgumentException("error_missing_wq_data"); + } + + for (final RangeWithValues rwv : rwvs) { + final double[] values = rwv.getValues(); + for (final double val : values) { + if (val <= 0) { + throw new IllegalArgumentException("error_validate_positive"); + } + } + } + + return true; + } + + @Override + protected String getUIProvider() { + return "bundu_wst_wq_panel"; + } +}