Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduWstWQFixing.java @ 9277:2323d005f9a5
compile error fix
author | gernotbelger |
---|---|
date | Fri, 20 Jul 2018 10:39:02 +0200 |
parents | 3141f0e7314e |
children | 82c67b859aa7 |
line wrap: on
line source
/* 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.artifacts.CallContext; import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.model.RangeWithValues; import org.dive4elements.river.artifacts.states.WQAdapted; import org.w3c.dom.Element; /** * 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); @Override protected String getUIProvider() { return "bundu_wst_wq_panel"; } /** 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; } // adding bezugsjahr and dauer to client @Override protected Element[] createItems(final XMLUtils.ElementCreator ec, final Artifact artifact, final String name, final CallContext context) { final Element[] defaultElements = super.createItems(ec, artifact, name, context); final BunduAccess access = new BunduAccess((D4EArtifact) artifact); final int bezugsjahr = access.getBezugsJahr(); final int qSeriesLength = access.getQSeriesLength(); final String[] keys = new String[] { "ignore_q_series_length", "ignore_bezugsjahr" }; final String[] values = new String[] { String.valueOf(qSeriesLength), String.valueOf(bezugsjahr) }; return FixationChoice.appendElements(ec, defaultElements, keys, values); } }