Mercurial > dive4elements > river
diff flys-aft/src/main/java/de/intevation/aft/River.java @ 4099:006e99437fb9
Store the W/Q differences o existing discharge tables to FLYS database.
flys-aft/trunk@3621 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 08 Jan 2012 09:25:36 +0000 |
parents | 9215253ad0be |
children | 981de0b77c6b |
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/River.java Fri Jan 06 18:54:00 2012 +0000 +++ b/flys-aft/src/main/java/de/intevation/aft/River.java Sun Jan 08 09:25:36 2012 +0000 @@ -167,19 +167,20 @@ List<DischargeTable> createDTs = new ArrayList<DischargeTable>(); - for (DischargeTable dt: aftDTs) { - String description = dt.getDescription(); + for (DischargeTable aftDT: aftDTs) { + String description = aftDT.getDescription(); DischargeTable flysDT = desc2FlysDT.remove(description); if (flysDT != null) { // Found in AFT and FLYS. log.info("FLYS: Discharge table '" + description + "' found in AFT and FLYS. -> update"); - // TODO: Create the W/Q diff. + // Create the W/Q diff. + modified |= writeWQChanges(context, flysDT, aftDT); } else { log.info("FLYS: Discharge table '" + description + "' not found in FLYS. -> create"); - createDTs.add(dt); + createDTs.add(aftDT); } } @@ -193,6 +194,23 @@ return modified; } + protected boolean writeWQChanges( + SyncContext context, + DischargeTable flysDT, + DischargeTable aftDT + ) + throws SQLException + { + flysDT.loadFlysValues(context); + aftDT.loadAftValues(context); + WQDiff diff = new WQDiff(flysDT.getValues(), aftDT.getValues()); + if (diff.hasChanges()) { + diff.writeChanges(context, flysDT.getId()); + return true; + } + return false; + } + protected boolean createGauges( SyncContext context, Map<Long, DIPSGauge> gauges