comparison 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
comparison
equal deleted inserted replaced
4104:cdcf98245e36 4105:309d4ca09816
168 .getStatement("select.gauge.discharge.tables") 168 .getStatement("select.gauge.discharge.tables")
169 .clearParameters() 169 .clearParameters()
170 .setInt("gauge_id", gaugeId) 170 .setInt("gauge_id", gaugeId)
171 .executeQuery(); 171 .executeQuery();
172 172
173 while (rs.next()) { 173 OUTER: while (rs.next()) {
174 int id = rs.getInt("id"); 174 int id = rs.getInt("id");
175 String description = rs.getString("description"); 175 String description = rs.getString("description");
176 Date startTime = rs.getDate("start_time"); 176 if (description == null) {
177 Date stopTime = rs.getDate("stop_time"); 177 description = "";
178 }
179 for (DischargeTable dt: dts) {
180 if (dt.getDescription().equals(description)) {
181 log.warn("FLYS: Found discharge table '" +
182 description + "' with same description. -> ignore");
183 continue OUTER;
184 }
185 }
186 Date startTime = rs.getDate("start_time");
187 Date stopTime = rs.getDate("stop_time");
178 TimeInterval ti = startTime == null 188 TimeInterval ti = startTime == null
179 ? null 189 ? null
180 : new TimeInterval(startTime, stopTime); 190 : new TimeInterval(startTime, stopTime);
191
181 DischargeTable dt = new DischargeTable( 192 DischargeTable dt = new DischargeTable(
182 id, gaugeId, ti, description); 193 id, gaugeId, ti, description);
183 dts.add(dt); 194 dts.add(dt);
184 } 195 }
185 rs.close(); 196 rs.close();
210 .getStatement("select.abflusstafel") 221 .getStatement("select.abflusstafel")
211 .clearParameters() 222 .clearParameters()
212 .setString("number", "%" + officialNumber) 223 .setString("number", "%" + officialNumber)
213 .executeQuery(); 224 .executeQuery();
214 225
215 while (rs.next()) { 226 OUTER: while (rs.next()) {
216 int dtId = rs.getInt("ABFLUSSTAFEL_NR"); 227 int dtId = rs.getInt("ABFLUSSTAFEL_NR");
217 Date from = rs.getDate("GUELTIG_VON"); 228 Date from = rs.getDate("GUELTIG_VON");
218 Date to = rs.getDate("GUELTIG_BIS"); 229 Date to = rs.getDate("GUELTIG_BIS");
219 230
220 if (from != null && to != null && from.compareTo(to) > 0) { 231 if (from != null && to != null && from.compareTo(to) > 0) {
228 String description = rs.getString("ABFLUSSTAFEL_BEZ"); 239 String description = rs.getString("ABFLUSSTAFEL_BEZ");
229 if (description == null) { 240 if (description == null) {
230 description = String.valueOf(officialNumber); 241 description = String.valueOf(officialNumber);
231 } 242 }
232 243
244 for (DischargeTable dt: dts) {
245 if (dt.getDescription().equals(description)) {
246 log.warn("AFT: Found discharge table '" +
247 description + "' with same description. -> ignore.");
248 continue OUTER;
249 }
250 }
251
233 double datumValue = rs.getDouble("PEGELNULLPUNKT"); 252 double datumValue = rs.getDouble("PEGELNULLPUNKT");
234 Double datum = rs.wasNull() ? null : datumValue; 253 Double datum = rs.wasNull() ? null : datumValue;
235 254
236 TimeInterval timeInterval = from == null 255 TimeInterval timeInterval = from == null
237 ? null 256 ? null

http://dive4elements.wald.intevation.org