Mercurial > dive4elements > river
diff flys-aft/src/main/java/de/intevation/aft/DischargeTable.java @ 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 | 2305731f563c |
children | 06891562e633 |
line wrap: on
line diff
--- 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;