# HG changeset patch # User Sascha L. Teichmann # Date 1326131884 0 # Node ID 309d4ca09816fea57b97c606018e1810d6155e75 # Parent cdcf98245e36d9ebe452d79a43408a19618dd536 Prevent redundant and ever growing discharge table lists in FLYS db. flys-aft/trunk@3637 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r cdcf98245e36 -r 309d4ca09816 flys-aft/ChangeLog --- a/flys-aft/ChangeLog Mon Jan 09 17:40:46 2012 +0000 +++ b/flys-aft/ChangeLog Mon Jan 09 17:58:04 2012 +0000 @@ -1,3 +1,10 @@ +2012-01-09 Sascha L. Teichmann + + * src/main/java/de/intevation/aft/DischargeTable.java: Write + warning if there are discharge tables with same descriptions + in FLYS or AFT and ignore the redundant ones. This led + to an ever growing FLYS database. + 2012-01-09 Sascha L. Teichmann * src/main/java/de/intevation/aft/Sync.java: Log if modifications diff -r cdcf98245e36 -r 309d4ca09816 flys-aft/src/main/java/de/intevation/aft/DischargeTable.java --- a/flys-aft/src/main/java/de/intevation/aft/DischargeTable.java Mon Jan 09 17:40:46 2012 +0000 +++ b/flys-aft/src/main/java/de/intevation/aft/DischargeTable.java Mon Jan 09 17:58:04 2012 +0000 @@ -170,14 +170,25 @@ .setInt("gauge_id", gaugeId) .executeQuery(); - while (rs.next()) { + OUTER: while (rs.next()) { int id = rs.getInt("id"); String description = rs.getString("description"); - Date startTime = rs.getDate("start_time"); - Date stopTime = rs.getDate("stop_time"); + if (description == null) { + description = ""; + } + for (DischargeTable dt: dts) { + if (dt.getDescription().equals(description)) { + log.warn("FLYS: Found discharge table '" + + description + "' with same description. -> ignore"); + continue OUTER; + } + } + Date startTime = rs.getDate("start_time"); + Date stopTime = rs.getDate("stop_time"); TimeInterval ti = startTime == null ? null : new TimeInterval(startTime, stopTime); + DischargeTable dt = new DischargeTable( id, gaugeId, ti, description); dts.add(dt); @@ -212,7 +223,7 @@ .setString("number", "%" + officialNumber) .executeQuery(); - while (rs.next()) { + OUTER: while (rs.next()) { int dtId = rs.getInt("ABFLUSSTAFEL_NR"); Date from = rs.getDate("GUELTIG_VON"); Date to = rs.getDate("GUELTIG_BIS"); @@ -230,6 +241,14 @@ description = String.valueOf(officialNumber); } + for (DischargeTable dt: dts) { + if (dt.getDescription().equals(description)) { + log.warn("AFT: Found discharge table '" + + description + "' with same description. -> ignore."); + continue OUTER; + } + } + double datumValue = rs.getDouble("PEGELNULLPUNKT"); Double datum = rs.wasNull() ? null : datumValue;