changeset 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 b6a18d706cbe
files flys-aft/ChangeLog flys-aft/src/main/java/de/intevation/aft/River.java flys-aft/src/main/java/de/intevation/db/SymbolicStatement.java
diffstat 3 files changed, 32 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-aft/ChangeLog	Sun Jan 08 09:25:36 2012 +0000
+++ b/flys-aft/ChangeLog	Sun Jan 08 11:33:44 2012 +0000
@@ -1,3 +1,14 @@
+2012-01-07	Sascha L. Teichmann	<sascha.teichmann@inteavtion.de>
+
+	* src/main/java/de/intevation/db/SymbolicStatement.java:
+	  Added setLong() method. Used when setting the official number
+	  of a gauge.
+
+	* src/main/java/de/intevation/aft/River.java: Store the new
+	  discharge tables in FLYS  when gauges exist in both 
+	  FLYS and AFT and there are discharge tables that are only in AFT.
+	  Store official number as long.
+
 2012-01-07	Sascha L. Teichmann	<sascha.teichmann@inteavtion.de>
 
 	* src/main/java/de/intevation/aft/River.java: Store
--- a/flys-aft/src/main/java/de/intevation/aft/River.java	Sun Jan 08 09:25:36 2012 +0000
+++ b/flys-aft/src/main/java/de/intevation/aft/River.java	Sun Jan 08 11:33:44 2012 +0000
@@ -189,7 +189,11 @@
                 + "' found in FLYS but not in AFT. -> ignore");
         }
 
-        // TODO: Create the new discharge tables.
+        // Create the new discharge tables.
+        for (DischargeTable aftDT: createDTs) {
+            createDischargeTables(context, gauge);
+            modified = true;
+        }
 
         return modified;
     }
@@ -254,7 +258,7 @@
                     .setInt("river_id", id1)
                     .setDouble("station", gauge.getStation())
                     .setDouble("aeo", gauge.getAeo())
-                    .setDouble("official_number", officialNumber)
+                    .setLong("official_number", officialNumber)
                     .setDouble("datum", gauge.getLatestDatum().getValue());
 
                 insertStmnt.execute();
@@ -263,7 +267,7 @@
                     "' with id " + gaugeId + ".");
 
                 gauge.setFlysId(gaugeId);
-                createDischargeTables(context, officialNumber, gauge);
+                createDischargeTables(context, gauge);
                 flysStatements.commitTransaction();
                 modified = true;
             }
@@ -283,7 +287,6 @@
 
     protected void createDischargeTables(
         SyncContext context,
-        Long        officialNumber,
         DIPSGauge   gauge
     )
     throws SQLException
@@ -292,7 +295,7 @@
 
         // Load the discharge tables from AFT.
         List<DischargeTable> dts = loadAftDischargeTables(
-            context, officialNumber, gauge);
+            context, gauge);
 
         // Persist the time intervals.
         persistFlysTimeIntervals(context, dts);
@@ -306,13 +309,12 @@
 
     protected List<DischargeTable> loadAftDischargeTables(
         SyncContext context,
-        Long        officialNumber,
         DIPSGauge   gauge
     )
     throws SQLException
     {
         return DischargeTable.loadAftDischargeTables(
-            context, officialNumber, gauge.getFlysId());
+            context, gauge.getOfficialNumber(), gauge.getFlysId());
     }
 
     protected void persistFlysTimeIntervals(
--- a/flys-aft/src/main/java/de/intevation/db/SymbolicStatement.java	Sun Jan 08 09:25:36 2012 +0000
+++ b/flys-aft/src/main/java/de/intevation/db/SymbolicStatement.java	Sun Jan 08 11:33:44 2012 +0000
@@ -106,6 +106,18 @@
             return this;
         }
 
+        public Instance setLong(String key, long value)
+        throws SQLException 
+        {
+            List<Integer> pos = positions.get(key.toLowerCase());
+            if (pos != null) {
+                for (Integer p: pos) {
+                    stmnt.setLong(p, value);
+                }
+            }
+            return this;
+        }
+
         public Instance setNull(String key, int sqlType)
         throws SQLException 
         {

http://dive4elements.wald.intevation.org