changeset 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
files flys-aft/ChangeLog flys-aft/src/main/java/de/intevation/aft/DischargeTable.java flys-aft/src/main/java/de/intevation/aft/River.java
diffstat 3 files changed, 41 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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	<sascha.teichmann@inteavtion.de>
+
+	* 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	<sascha.teichmann@inteavtion.de>
 
 	* src/main/java/de/intevation/aft/River.java: Do the pairing
--- 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<WQ> getValues() {
+        return values;
+    }
+
+    public void setValues(List<WQ> values) {
+        this.values = values;
+    }
+
+
+
     protected void loadValues(SymbolicStatement.Instance query) 
     throws SQLException
     {
--- 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

http://dive4elements.wald.intevation.org