comparison flys-aft/src/main/java/de/intevation/aft/River.java @ 4100:981de0b77c6b

If gauges exist in FLYS and AFT store the discharge tables in FLYS that are only in AFT. flys-aft/trunk@3622 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 08 Jan 2012 11:33:44 +0000
parents 006e99437fb9
children e8967ee1cb05
comparison
equal deleted inserted replaced
4099:006e99437fb9 4100:981de0b77c6b
187 for (String description: desc2FlysDT.keySet()) { 187 for (String description: desc2FlysDT.keySet()) {
188 log.info("FLYS: Discharge table '" + description 188 log.info("FLYS: Discharge table '" + description
189 + "' found in FLYS but not in AFT. -> ignore"); 189 + "' found in FLYS but not in AFT. -> ignore");
190 } 190 }
191 191
192 // TODO: Create the new discharge tables. 192 // Create the new discharge tables.
193 for (DischargeTable aftDT: createDTs) {
194 createDischargeTables(context, gauge);
195 modified = true;
196 }
193 197
194 return modified; 198 return modified;
195 } 199 }
196 200
197 protected boolean writeWQChanges( 201 protected boolean writeWQChanges(
252 .setInt("id", gaugeId) 256 .setInt("id", gaugeId)
253 .setString("name", gauge.getAftName()) 257 .setString("name", gauge.getAftName())
254 .setInt("river_id", id1) 258 .setInt("river_id", id1)
255 .setDouble("station", gauge.getStation()) 259 .setDouble("station", gauge.getStation())
256 .setDouble("aeo", gauge.getAeo()) 260 .setDouble("aeo", gauge.getAeo())
257 .setDouble("official_number", officialNumber) 261 .setLong("official_number", officialNumber)
258 .setDouble("datum", gauge.getLatestDatum().getValue()); 262 .setDouble("datum", gauge.getLatestDatum().getValue());
259 263
260 insertStmnt.execute(); 264 insertStmnt.execute();
261 265
262 log.info("FLYS: Created gauge '" + gauge.getAftName() + 266 log.info("FLYS: Created gauge '" + gauge.getAftName() +
263 "' with id " + gaugeId + "."); 267 "' with id " + gaugeId + ".");
264 268
265 gauge.setFlysId(gaugeId); 269 gauge.setFlysId(gaugeId);
266 createDischargeTables(context, officialNumber, gauge); 270 createDischargeTables(context, gauge);
267 flysStatements.commitTransaction(); 271 flysStatements.commitTransaction();
268 modified = true; 272 modified = true;
269 } 273 }
270 catch (SQLException sqle) { 274 catch (SQLException sqle) {
271 flysStatements.rollbackTransaction(); 275 flysStatements.rollbackTransaction();
281 return modified; 285 return modified;
282 } 286 }
283 287
284 protected void createDischargeTables( 288 protected void createDischargeTables(
285 SyncContext context, 289 SyncContext context,
286 Long officialNumber,
287 DIPSGauge gauge 290 DIPSGauge gauge
288 ) 291 )
289 throws SQLException 292 throws SQLException
290 { 293 {
291 log.info("create discharge tables"); 294 log.info("create discharge tables");
292 295
293 // Load the discharge tables from AFT. 296 // Load the discharge tables from AFT.
294 List<DischargeTable> dts = loadAftDischargeTables( 297 List<DischargeTable> dts = loadAftDischargeTables(
295 context, officialNumber, gauge); 298 context, gauge);
296 299
297 // Persist the time intervals. 300 // Persist the time intervals.
298 persistFlysTimeIntervals(context, dts); 301 persistFlysTimeIntervals(context, dts);
299 302
300 // Persist the discharge tables 303 // Persist the discharge tables
304 copyWQsFromAftToFlys(context, dts, flysDTIds); 307 copyWQsFromAftToFlys(context, dts, flysDTIds);
305 } 308 }
306 309
307 protected List<DischargeTable> loadAftDischargeTables( 310 protected List<DischargeTable> loadAftDischargeTables(
308 SyncContext context, 311 SyncContext context,
309 Long officialNumber,
310 DIPSGauge gauge 312 DIPSGauge gauge
311 ) 313 )
312 throws SQLException 314 throws SQLException
313 { 315 {
314 return DischargeTable.loadAftDischargeTables( 316 return DischargeTable.loadAftDischargeTables(
315 context, officialNumber, gauge.getFlysId()); 317 context, gauge.getOfficialNumber(), gauge.getFlysId());
316 } 318 }
317 319
318 protected void persistFlysTimeIntervals( 320 protected void persistFlysTimeIntervals(
319 SyncContext context, 321 SyncContext context,
320 List<DischargeTable> dts 322 List<DischargeTable> dts

http://dive4elements.wald.intevation.org