diff artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/UINFOArtifact.java @ 9036:c265c9fc915c

work on u-info/s-info states
author gernotbelger
date Mon, 30 Apr 2018 18:03:02 +0200
parents fb9430250899
children 13b5b515c61f
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/UINFOArtifact.java	Mon Apr 30 10:13:15 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/UINFOArtifact.java	Mon Apr 30 18:03:02 2018 +0200
@@ -10,78 +10,72 @@
 package org.dive4elements.river.artifacts.uinfo;
 
 import org.apache.commons.lang.StringUtils;
-import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.artifactdatabase.state.FacetActivity;
-import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.river.artifacts.D4EArtifact;
 
 /**
- * The default SINFO artifact.
+ * The default UINFO artifact.
  *
  * @author Gernot Belger
  */
 public class UINFOArtifact 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 = "uinfo";
-
-	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, new FacetActivity() {
-			@Override
-			public Boolean isInitialActive(final Artifact artifact, final Facet facet, final String output) {
-				return null;
-			}
-		});
-	}
+    private static final long serialVersionUID = 1L;
 
-	/**
-	 * Default constructor, because it's serializable.
-	 */
-	public UINFOArtifact() {
-	}
-
-	/**
-	 * Returns the name of the concrete artifact.
-	 *
-	 * @return the name of the concrete artifact.
-	 */
-	@Override
-	public String getName() {
-		return ARTIFACT_NAME;
-	}
+    /** Error message that is thrown if no mode has been chosen. */
+    private static final String ERROR_NO_CALCULATION_MODE = "error_feed_no_calculation_mode";
 
-	public UinfoCalcMode getCalculationMode() {
-
-		final String calc = getDataAsString(FIELD_MODE);
-		if (calc == null) {
-			throw new IllegalArgumentException(ERROR_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";
 
-		try {
-			return UinfoCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase());
-		} catch (final Exception e) {
-			throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e);
-		}
-	}
+    /** The name of the artifact. */
+    private static final String ARTIFACT_NAME = "uinfo";
 
-	public String getRiver() {
-		return getDataAsString(FIELD_RIVER);
-	}
+    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 UINFOArtifact() {
+    }
+
+    /**
+     * Returns the name of the concrete artifact.
+     *
+     * @return the name of the concrete artifact.
+     */
+    @Override
+    public String getName() {
+        return ARTIFACT_NAME;
+    }
+
+    public UinfoCalcMode getCalculationMode() {
+
+        final String calc = getDataAsString(FIELD_MODE);
+        if (calc == null) {
+            throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE);
+        }
+
+        try {
+            return UinfoCalcMode.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