# HG changeset patch # User Sascha L. Teichmann # Date 1324391796 0 # Node ID d13011e53022cb3091ff9e8a136795e89bf9ff30 # Parent 7a7b0f0cb653667e682635f1a1707dae8579a9e9 Make DIPS check more verbose flys-aft/trunk@3496 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 7a7b0f0cb653 -r d13011e53022 flys-aft/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/db/SymbolicStatement.java: diff -r 7a7b0f0cb653 -r d13011e53022 flys-aft/src/main/java/de/intevation/aft/DIPSGauge.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 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 getDatums() { return datums; } + + public String getName() { + return name; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 7a7b0f0cb653 -r d13011e53022 flys-aft/src/main/java/de/intevation/aft/River.java --- 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 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;