changeset 9761:c088f7a5797d 3.2.x

Reduce code duplication RiverUtils.getValueFromWQ(wq) was equivalent to wq.getRawValue().
author Tom Gottfried <tom@intevation.de>
date Thu, 10 Nov 2022 18:16:25 +0100
parents 9bbb29142ddb
children d5d250ad3c78
files artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java
diffstat 2 files changed, 1 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Thu Nov 10 15:42:16 2022 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Thu Nov 10 18:16:25 2022 +0100
@@ -638,7 +638,7 @@
                     winfo, wqkms.getRawValue());
                 // For 'W am Pegel' s
                 if (colDesc == null) {
-                    Double value = RiverUtils.getValueFromWQ(wqkms);
+                    Double value = wqkms.getRawValue();
                     colDesc = (value != null) ?
                         Formatter.getWaterlevelW(context).format(value) : null;
                 }
--- a/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java	Thu Nov 10 15:42:16 2022 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/RiverUtils.java	Thu Nov 10 18:16:25 2022 +0100
@@ -20,7 +20,6 @@
 import org.dive4elements.river.artifacts.model.LocationProvider;
 import org.dive4elements.river.artifacts.model.RiverFactory;
 import org.dive4elements.river.artifacts.model.WKms;
-import org.dive4elements.river.artifacts.model.WQ;
 import org.dive4elements.river.artifacts.states.WDifferencesState;
 import org.dive4elements.river.artifacts.states.WaterlevelSelectState;
 import org.dive4elements.river.backend.SessionFactoryProvider;
@@ -38,8 +37,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import javax.xml.xpath.XPathConstants;
 
@@ -82,9 +79,6 @@
      */
     public static enum WQ_INPUT { ADAPTED, SINGLE, RANGE, NONE };
 
-    public static final Pattern NUMBERS_PATTERN =
-        Pattern.compile("\\D*(\\d++.\\d*)\\D*");
-
     public static final String XPATH_FLOODMAP_RIVER_PROJECTION =
         "/artifact-database/floodmap/river[@name=$name]/srid/@value";
 
@@ -448,29 +442,6 @@
     }
 
 
-    public static Double getValueFromWQ(WQ wq) {
-        if (wq == null) {
-            return null;
-        }
-
-        Matcher m = NUMBERS_PATTERN.matcher(wq.getName());
-
-        if (m.matches()) {
-            log.debug("Found a number.");
-
-            String raw = m.group(1);
-
-            try {
-                return Double.valueOf(raw);
-            }
-            catch (NumberFormatException nfe) {
-            }
-        }
-
-        return null;
-    }
-
-
     /** Creates human-readable name for a wsp (waterlevel/longitudinal section).
      * @param name will be split at '='s.
      */

http://dive4elements.wald.intevation.org