Mercurial > dive4elements > river
changeset 4105:309d4ca09816
Prevent redundant and ever growing discharge table lists in FLYS db.
flys-aft/trunk@3637 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 09 Jan 2012 17:58:04 +0000 |
parents | cdcf98245e36 |
children | 9ba12119e662 |
files | flys-aft/ChangeLog flys-aft/src/main/java/de/intevation/aft/DischargeTable.java |
diffstat | 2 files changed, 30 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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 <sascha.teichmann@inteavtion.de> + + * 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 <sascha.teichmann@inteavtion.de> * src/main/java/de/intevation/aft/Sync.java: Log if modifications
--- 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;