Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java @ 8854:7bbfb24e6eec
SINFO - first prototype of BArt Fließtiefen
author | gernotbelger |
---|---|
date | Thu, 18 Jan 2018 18:34:41 +0100 |
parents | |
children | 20b85ea3b524 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java Thu Jan 18 18:34:41 2018 +0100 @@ -0,0 +1,73 @@ +/* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * 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.sinfo; + +import org.apache.commons.lang.StringUtils; +import org.dive4elements.river.artifacts.D4EArtifact; + +/** + * The default MINFO artifact. + * + * @author Gernot Belger + */ +public class SINFOArtifact +extends D4EArtifact +{ + /** Error message that is thrown if no mode has been chosen. */ + private static final String ERROR_NO_CALCULATION_MODE = + "error_feed_no_calculation_mode"; + + /** Error message that is thrown if an invalid calculation mode has been + * chosen. */ + private static final String ERROR_INVALID_CALCULATION_MODE = + "error_feed_invalid_calculation_mode"; + + + /** The name of the artifact. */ + private static final String ARTIFACT_NAME = "sinfo"; + + private static final String FIELD_FIVER = "river"; + + private static final String FIELD_MODE = "calculation_mode"; + + /** + * Default constructor, because it's serializable. + */ + public SINFOArtifact() { + } + + /** + * Returns the name of the concrete artifact. + * + * @return the name of the concrete artifact. + */ + @Override + public String getName() { + return ARTIFACT_NAME; + } + + public SinfoCalcMode getCalculationMode() { + + final String calc = getDataAsString(FIELD_MODE); + if (calc == null) { + throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); + } + + try { + return SinfoCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase()); + } catch (Exception e) { + throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e); + } + } + + public String getRiver() { + return getDataAsString(FIELD_FIVER); + } +} \ No newline at end of file