diff flys-aft/src/main/java/de/intevation/aft/River.java @ 4094:b20b710aa86f

Bubble up modifications up to main(). flys-aft/trunk@3605 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 05 Jan 2012 18:58:49 +0000
parents 7bddd4601707
children 83c72bc07591
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/River.java	Thu Jan 05 17:46:18 2012 +0000
+++ b/flys-aft/src/main/java/de/intevation/aft/River.java	Thu Jan 05 18:58:49 2012 +0000
@@ -35,7 +35,7 @@
     }
 
 
-    public void sync(SyncContext context) throws SQLException {
+    public boolean sync(SyncContext context) throws SQLException {
         log.info("sync river: " + this);
 
         Map<Long, DIPSGauge> dipsGauges = context.getDIPSGauges();
@@ -81,7 +81,6 @@
 
         messstellenRs.close();
 
-
         List<DIPSGauge> updateGauges = new ArrayList<DIPSGauge>();
 
         ResultSet gaugesRs = flysStatements
@@ -110,13 +109,14 @@
                 "' found in FLYS, AFT and DIPS. -> Update");
             updateGauges.add(aftDIPSGauge);
         }
+        gaugesRs.close();
 
-        createGauges(context, aftDIPSGauges);
+        boolean modified = createGauges(context, aftDIPSGauges);
 
-        gaugesRs.close();
+        return modified;
     }
 
-    protected void createGauges(
+    protected boolean createGauges(
         SyncContext          context,
         Map<Long, DIPSGauge> gauges
     )
@@ -130,6 +130,8 @@
         SymbolicStatement.Instance insertStmnt =
             flysStatements.getStatement("insert.gauge");
 
+        boolean modified = false;
+
         for (Map.Entry<Long, DIPSGauge> entry: gauges.entrySet()) {
             Long      officialNumber = entry.getKey();
             DIPSGauge gauge          = entry.getValue();
@@ -167,12 +169,12 @@
 
                 gauge.setFlysId(gaugeId);
                 createDischargeTables(context, officialNumber, gauge);
-
                 flysStatements.commitTransaction();
+                modified = true;
             }
             catch (SQLException sqle) {
                 flysStatements.rollbackTransaction();
-                throw sqle;
+                log.error(sqle, sqle);
             }
             finally {
                 if (rs != null) {
@@ -180,6 +182,8 @@
                 }
             }
         }
+
+        return modified;
     }
 
     protected void createDischargeTables(

http://dive4elements.wald.intevation.org