changeset 4082:d13011e53022

Make DIPS check more verbose flys-aft/trunk@3496 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 20 Dec 2011 14:36:36 +0000
parents 7a7b0f0cb653
children 44dc38ca8492
files flys-aft/ChangeLog flys-aft/src/main/java/de/intevation/aft/DIPSGauge.java flys-aft/src/main/java/de/intevation/aft/River.java
diffstat 3 files changed, 35 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/flys-aft/ChangeLog	Fri Dec 16 19:25:31 2011 +0000
+++ b/flys-aft/ChangeLog	Tue Dec 20 14:36:36 2011 +0000
@@ -1,3 +1,9 @@
+2011-12-20	Sascha L. Teichmann	<sascha.teichmann@inteavtion.de>
+
+	* src/main/java/de/intevation/aft/River.java,
+	  src/main/java/de/intevation/aft/DIPSGauge.java: Make DIPS check
+	  more verbose.
+
 2011-12-16	Sascha L. Teichmann	<sascha.teichmann@inteavtion.de>
 
 	* src/main/java/de/intevation/db/SymbolicStatement.java:
--- a/flys-aft/src/main/java/de/intevation/aft/DIPSGauge.java	Fri Dec 16 19:25:31 2011 +0000
+++ b/flys-aft/src/main/java/de/intevation/aft/DIPSGauge.java	Tue Dec 20 14:36:36 2011 +0000
@@ -65,15 +65,20 @@
 
     protected double aeo;
 
+    protected String name;
+
     protected List<Datum> datums;
 
     public DIPSGauge() {
     }
 
     public DIPSGauge(Element element) {
+
+        name = element.getAttribute("NAME");
+
         String aeoString = element.getAttribute("EINZUGSGEBIET_AEO");
         if (aeoString.length() == 0) {
-            log.warn("WARN: setting AEO to zero");
+            log.warn("DIPS: Setting AEO of gauge '" + name + "' to zero.");
             aeoString = "0";
         }
         aeo = Double.parseDouble(aeoString);
@@ -91,5 +96,9 @@
     public List<Datum> getDatums() {
         return datums;
     }
+
+    public String getName() {
+        return name;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-aft/src/main/java/de/intevation/aft/River.java	Fri Dec 16 19:25:31 2011 +0000
+++ b/flys-aft/src/main/java/de/intevation/aft/River.java	Tue Dec 20 14:36:36 2011 +0000
@@ -14,16 +14,11 @@
 
 import de.intevation.db.ConnectedStatements;
 
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 public class River
 extends      IdPair
 {
     private static Logger log = Logger.getLogger(River.class);
 
-    public static final Pattern NUMBER = Pattern.compile("0*([0-9]+)");
-
     protected String name;
 
     public River() {
@@ -39,10 +34,12 @@
     }
 
     public static Long numberToLong(String s) {
-        Matcher m = NUMBER.matcher(s);
-        if (!m.matches()) return null;
-        String ns = m.group(1);
-        return Long.valueOf(ns.length() == 0 ? "0": ns);
+        try {
+            return Long.valueOf(s.trim());
+        }
+        catch (NumberFormatException nfe) {
+        }
+        return null;
     }
 
     public static Map<Long, DIPSGauge> indexByNumber(Document document) {
@@ -50,9 +47,20 @@
         NodeList nodes = document.getElementsByTagName("PEGELSTATION");
         for (int i = nodes.getLength()-1; i >= 0; --i) {
             Element element = (Element)nodes.item(i);
-            Long number = numberToLong(element.getAttribute("NUMMER"));
+            String numberString = element.getAttribute("NUMMER");
+            Long number = numberToLong(numberString);
             if (number != null) {
-                map.put(number, new DIPSGauge(element));
+                DIPSGauge newG = new DIPSGauge(element);
+                DIPSGauge oldG = map.put(number, newG);
+                if (oldG != null) {
+                    log.warn("DIPS: '" + newG.getName() +
+                        "' collides with '" + oldG.getName() + 
+                        "' on gauge number " + number + ".");
+                }
+            }
+            else {
+                log.warn("DIPS: gauge '" + element.getAttribute("NAME") +
+                    "' has invalid gauge number '" + numberString + "'");
             }
         }
         return map;

http://dive4elements.wald.intevation.org