[PATCH] fix-analysis distance range bugfix
Wald Commits
scm-commit at wald.intevation.org
Mon May 28 18:18:28 CEST 2018
# HG changeset patch
# User gernotbelger
# Date 1527524301 -7200
# Node ID 21e65960a9e35fa057b496645ac21560876e7194
# Parent 2c6aba003112f95723eab6eb394815de4ddedbda
fix-analysis distance range bugfix
diff -r 2c6aba003112 -r 21e65960a9e3 artifacts/src/main/java/org/dive4elements/river/artifacts/states/RangeState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/RangeState.java Mon May 28 16:39:56 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/RangeState.java Mon May 28 18:18:21 2018 +0200
@@ -8,45 +8,33 @@
package org.dive4elements.river.artifacts.states;
+import org.apache.log4j.Logger;
import org.dive4elements.artifacts.Artifact;
-
import org.dive4elements.river.artifacts.D4EArtifact;
-
import org.dive4elements.river.artifacts.access.RangeAccess;
-import org.apache.log4j.Logger;
-
-
/**
* State in which km range is set.
+ *
* @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
*/
public abstract class RangeState extends DefaultState {
/** The log that is used in this class. */
- private Logger log = Logger.getLogger(RangeState.class);
-
+ private final Logger log = Logger.getLogger(RangeState.class);
public RangeState() {
}
protected abstract double[] getMinMax(Artifact artifact);
-
- protected boolean validateBounds(
- double fromValid, double toValid,
- double from, double to)
- throws IllegalArgumentException
- {
- if (from < fromValid) {
- log.error(
- "Invalid 'from'. " + from + " is smaller than " + fromValid);
+ protected boolean validateBounds(final double fromValid, final double toValid, final double from, final double to) throws IllegalArgumentException {
+ if (from < fromValid || from > toValid) {
+ this.log.error("Invalid 'from'. " + from + " is smaller than " + fromValid);
// error message used in client to resolve i18n
throw new IllegalArgumentException("error_feed_from_out_of_range");
- }
- else if (to > toValid) {
- log.error(
- "Invalid 'to'. " + to + " is bigger than " + toValid);
+ } else if (to > toValid || to < fromValid) {
+ this.log.error("Invalid 'to'. " + to + " is bigger than " + toValid);
// error message used in client to resolve i18n
throw new IllegalArgumentException("error_feed_to_out_of_range");
}
@@ -54,50 +42,48 @@
return true;
}
-
/**
* Validates a given range with a given valid range.
*
- * @param fromValid Valid lower value of the range.
- * @param toValid Valid upper value of the range.
- * @param from The lower value.
- * @param to The upper value.
- * @param step The step width.
+ * @param fromValid
+ * Valid lower value of the range.
+ * @param toValid
+ * Valid upper value of the range.
+ * @param from
+ * The lower value.
+ * @param to
+ * The upper value.
+ * @param step
+ * The step width.
*
* @return true, if everything was fine, otherwise an exception is thrown.
*/
- protected boolean validateBounds(
- double fromValid, double toValid,
- double from, double to, double step)
- throws IllegalArgumentException
- {
- log.debug("RangeState.validateRange");
+ protected boolean validateBounds(final double fromValid, final double toValid, final double from, final double to, final double step)
+ throws IllegalArgumentException {
+ this.log.debug("RangeState.validateRange");
// XXX The step width is not validated at the moment!
return validateBounds(fromValid, toValid, from, to);
}
-
@Override
- public boolean validate(Artifact artifact)
- throws IllegalArgumentException
- {
- D4EArtifact flys = (D4EArtifact) artifact;
+ public boolean validate(final Artifact artifact) throws IllegalArgumentException {
+ final D4EArtifact flys = (D4EArtifact) artifact;
try {
- RangeAccess rangeAccess = new RangeAccess(flys);
- double from = rangeAccess.getFrom();
- double to = rangeAccess.getTo();
- double step = rangeAccess.getStep();
+ final RangeAccess rangeAccess = new RangeAccess(flys);
+ final double from = rangeAccess.getFrom();
+ final double to = rangeAccess.getTo();
+ final double step = rangeAccess.getStep();
- double[] minmax = getMinMax(flys);
+ final double[] minmax = getMinMax(flys);
return validateBounds(minmax[0], minmax[1], from, to, step);
}
- catch (NumberFormatException nfe) {
+ catch (final NumberFormatException nfe) {
throw new IllegalArgumentException("error_invalid_double_value");
}
- catch (NullPointerException npe) {
+ catch (final NullPointerException npe) {
throw new IllegalArgumentException("error_empty_state");
}
}
diff -r 2c6aba003112 -r 21e65960a9e3 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon May 28 16:39:56 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon May 28 18:18:21 2018 +0200
@@ -358,8 +358,8 @@
error_no_sedimentloadinfo_data = No Sedimentload data for the current parameters.
error_feed_no_data = No input data found.
-error_feed_from_out_of_range = The lower value is bigger than the upper value.
-error_feed_to_out_of_range = The upper value is out or the valid range.
+error_feed_from_out_of_range = The start value is out of the valid range.
+error_feed_to_out_of_range = The end value is out of the valid range.
error_feed_from_bigger_to = The lower value is bigger than the upper value.
error_feed_invalid_wq_mode = Invalid WQ-Mode selected.
error_feed_number_format_float = The inserted value is no floating point number.
diff -r 2c6aba003112 -r 21e65960a9e3 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon May 28 16:39:56 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon May 28 18:18:21 2018 +0200
@@ -358,8 +358,8 @@
error_no_sedimentloadinfo_data = F\u00fcr die gew\u00e4te Parametrisierung liegen keine Daten vor.
error_feed_no_data = Keine Eingabedaten gefunden.
-error_feed_from_out_of_range = Der untere Wert liegt au\u00dferhalb des g\u00fcltigen Wertebereiches.
-error_feed_to_out_of_range = Der obere Wert liegt au\u00dferhalb des g\u00fcltigen Wertebereiches.
+error_feed_from_out_of_range = Der Start-Wert liegt au\u00dferhalb des g\u00fcltigen Wertebereiches.
+error_feed_to_out_of_range = Der End-Wert liegt au\u00dferhalb des g\u00fcltigen Wertebereiches.
error_feed_from_bigger_to = Der untere Wert ist gr\u00f6\u00dfer als der obere Wert.
error_feed_invalid_wq_mode = Ung\u00fcltiger Modus f\u00fcr die WQ-Eingabe gew\u00e4hlt.
error_feed_number_format_float = Der eingegebene Wert ist keine Flie\u00dfkommazahl.
More information about the Dive4Elements-commits
mailing list