diff artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/BUNDUArtifact.java @ 9071:a561b882436d

create module bundu (Betrieb & Unterhaltung) incl. original Fixierungsanalyse+Ausgelagerte Wasserspiegellage
author gernotbelger
date Wed, 16 May 2018 11:08:56 +0200
parents
children 02739b8c010d
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/BUNDUArtifact.java	Wed May 16 11:08:56 2018 +0200
@@ -0,0 +1,81 @@
+/* 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.bundu;
+
+import org.apache.commons.lang.StringUtils;
+import org.dive4elements.artifactdatabase.state.FacetActivity;
+import org.dive4elements.river.artifacts.D4EArtifact;
+
+/**
+ * The default BUNDU artifact.
+ *
+ * @author Gernot Belger
+ */
+public class BUNDUArtifact extends D4EArtifact {
+
+    private static final long serialVersionUID = 1L;
+
+    /** 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 = "bundu";
+
+    private static final String FIELD_RIVER = "river";
+
+    private static final String FIELD_MODE = "calculation_mode";
+
+    static {
+        // Active/deactivate facets.
+        // BEWARE: we can only define one activity for "sinfo", so we use the artifact
+        // as place for this
+        FacetActivity.Registry.getInstance().register(ARTIFACT_NAME, (artifact, facet, output) -> null);
+    }
+
+    /**
+     * Default constructor, because it's serializable.
+     */
+    public BUNDUArtifact() {
+    }
+
+    /**
+     * Returns the name of the concrete artifact.
+     *
+     * @return the name of the concrete artifact.
+     */
+    @Override
+    public String getName() {
+        return ARTIFACT_NAME;
+    }
+
+    public BunduCalcMode getCalculationMode() {
+
+        final String calc = getDataAsString(FIELD_MODE);
+        if (calc == null) {
+            throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE);
+        }
+
+        try {
+            return BunduCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase());
+        }
+        catch (final Exception e) {
+            throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e);
+        }
+    }
+
+    public String getRiver() {
+        return getDataAsString(FIELD_RIVER);
+    }
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org