aheinecke@6060: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde aheinecke@6060: * Software engineering by Intevation GmbH aheinecke@6060: * aheinecke@6060: * This file is Free Software under the GNU AGPL (>=v3) aheinecke@6060: * and comes with ABSOLUTELY NO WARRANTY! Check out the aheinecke@6060: * documentation coming with Dive4Elements River for details. aheinecke@6060: */ aheinecke@6060: package org.dive4elements.river.artifacts.states; aheinecke@6060: aheinecke@6060: import org.dive4elements.artifacts.Artifact; aheinecke@6062: import org.dive4elements.river.artifacts.D4EArtifact; aheinecke@6062: import org.dive4elements.river.artifacts.model.RangeWithValues; aheinecke@6060: aheinecke@6060: import org.apache.log4j.Logger; aheinecke@6060: aheinecke@6060: /** aheinecke@6060: * State to input W/Q data for fixings aheinecke@6060: * @author Andre Heinecke aheinecke@6060: */ aheinecke@6060: public class WQFixing extends WQAdapted { aheinecke@6060: teichmann@8202: /** The log used in this state.*/ teichmann@8202: private static Logger log = Logger.getLogger(WQFixing.class); aheinecke@6060: aheinecke@6062: /** Simple sanity check if values are positive numbers **/ aheinecke@6060: @Override aheinecke@6060: public boolean validate(Artifact artifact) aheinecke@6060: throws IllegalArgumentException aheinecke@6060: { teichmann@8202: log.debug("WQFixing.validate"); aheinecke@6062: tom@8856: RangeWithValues[] rwvs = extractInput( tom@8856: getData((D4EArtifact) artifact, "wq_values")); aheinecke@6062: aheinecke@6062: if (rwvs == null) { aheinecke@6062: throw new IllegalArgumentException("error_missing_wq_data"); aheinecke@6062: } aheinecke@6062: aheinecke@6062: for (RangeWithValues rwv: rwvs) { aheinecke@6062: double[] values = rwv.getValues(); aheinecke@6062: for (double val: values) { aheinecke@6062: if (val <= 0) { tom@8856: throw new IllegalArgumentException( tom@8856: "error_validate_positive"); aheinecke@6062: } aheinecke@6062: } aheinecke@6062: } aheinecke@6062: aheinecke@6060: return true; aheinecke@6060: } aheinecke@6060: aheinecke@6060: @Override aheinecke@6060: protected String getUIProvider() { aheinecke@6060: return "wq_panel_adapted_fixing"; aheinecke@6060: } aheinecke@6060: }