# HG changeset patch # User Sascha L. Teichmann # Date 1326014736 0 # Node ID 006e99437fb96f3f3ab0b7b0c8740de0d010f7a3 # Parent 9215253ad0be34e797a2214316665b2c78c65ea6 Store the W/Q differences o existing discharge tables to FLYS database. flys-aft/trunk@3621 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 9215253ad0be -r 006e99437fb9 flys-aft/ChangeLog --- a/flys-aft/ChangeLog Fri Jan 06 18:54:00 2012 +0000 +++ b/flys-aft/ChangeLog Sun Jan 08 09:25:36 2012 +0000 @@ -1,3 +1,12 @@ +2012-01-07 Sascha L. Teichmann + + * src/main/java/de/intevation/aft/River.java: Store + the W/Q differences of existing discharge tables + to the FLYS database. + + * src/main/java/de/intevation/aft/DischargeTable.java: Added + getter/setter for W/Q values. + 2012-01-06 Sascha L. Teichmann * src/main/java/de/intevation/aft/River.java: Do the pairing diff -r 9215253ad0be -r 006e99437fb9 flys-aft/src/main/java/de/intevation/aft/DischargeTable.java --- a/flys-aft/src/main/java/de/intevation/aft/DischargeTable.java Fri Jan 06 18:54:00 2012 +0000 +++ b/flys-aft/src/main/java/de/intevation/aft/DischargeTable.java Sun Jan 08 09:25:36 2012 +0000 @@ -78,6 +78,16 @@ values.clear(); } + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } + + + protected void loadValues(SymbolicStatement.Instance query) throws SQLException { diff -r 9215253ad0be -r 006e99437fb9 flys-aft/src/main/java/de/intevation/aft/River.java --- 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 createDTs = new ArrayList(); - 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 gauges