changeset 4088:52cde7fe742a

Fetch discharge table infos from AFT. flys-aft/trunk@3573 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 03 Jan 2012 11:36:07 +0000 (2012-01-03)
parents aad1886ea226
children 859b4781554a
files flys-aft/ChangeLog flys-aft/src/main/java/de/intevation/aft/River.java flys-aft/src/main/resources/sql/aft-common.properties
diffstat 3 files changed, 60 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-aft/ChangeLog	Mon Jan 02 17:45:25 2012 +0000
+++ b/flys-aft/ChangeLog	Tue Jan 03 11:36:07 2012 +0000
@@ -1,3 +1,11 @@
+2012-01-03	Sascha L. Teichmann	<sascha.teichmann@inteavtion.de>
+
+	* src/main/java/de/intevation/aft/River.java: Fetch discharge table
+	  infos from AFT.
+
+	* src/main/resources/sql/aft-common.properties: Added statement to fetch
+	  infos from ABFLUSSTAFEL.
+
 2012-01-02	Sascha L. Teichmann	<sascha.teichmann@inteavtion.de>
 
 	* src/main/resources/sql/flys-common.properties: Added statements
--- a/flys-aft/src/main/java/de/intevation/aft/River.java	Mon Jan 02 17:45:25 2012 +0000
+++ b/flys-aft/src/main/java/de/intevation/aft/River.java	Tue Jan 03 11:36:07 2012 +0000
@@ -4,6 +4,7 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Date;
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -163,6 +164,9 @@
                 log.info("FLYS: Created gauge '" + gauge.getAftName() + 
                     "' with id " + gaugeId + ".");
 
+                gauge.setFlysId(gaugeId);
+                createDischargeTables(context, officialNumber, gauge);
+
                 flysStatements.commitTransaction();
             }
             catch (SQLException sqle) {
@@ -177,6 +181,50 @@
         }
     }
 
+    protected void createDischargeTables(
+        SyncContext context,
+        Long        officialNumber,
+        DIPSGauge   gauge
+    )
+    throws SQLException
+    {
+        log.info("create discharge tables");
+
+        boolean debug = log.isDebugEnabled();
+
+        ConnectedStatements flysStatements = context.getFlysStatements();
+        ConnectedStatements aftStatements  = context.getAftStatements();
+
+        ResultSet rs = null;
+        try {
+            rs = aftStatements.getStatement("select.abflusstafel")
+                .clearParameters()
+                .setString("number", "%" + officialNumber).
+                executeQuery();
+
+            while (rs.next()) {
+                int dtId  = rs.getInt("ABFLUSSTAFEL_NR");
+                Date from = rs.getDate("GUELTIG_VON");
+                Date to   = rs.getDate("GUELTIG_BIS");
+
+                double datumValue = rs.getDouble("PEGELNULLPUNKT");
+                Double datum = rs.wasNull() ? null : datumValue;
+
+                if (debug) {
+                    log.debug("id:         " + dtId);
+                    log.debug("valid from: " + from);
+                    log.debug("valid to:   " + to);
+                    log.debug("datum:      " + datum);
+                }
+            }
+        }
+        finally {
+            if (rs != null) {
+                rs.close();
+            }
+        }
+    }
+
     public String toString() {
         return "[River: name=" + name + ", " + super.toString() + "]";
     }
--- a/flys-aft/src/main/resources/sql/aft-common.properties	Mon Jan 02 17:45:25 2012 +0000
+++ b/flys-aft/src/main/resources/sql/aft-common.properties	Tue Jan 03 11:36:07 2012 +0000
@@ -1,3 +1,7 @@
 select.gewaesser = SELECT GEWAESSER_NR, NAME FROM SL_GEWAESSER
 select.messstelle = SELECT NAME, MESSSTELLE_NR FROM MESSSTELLE WHERE GEWAESSER_NR = :GEWAESSER_NR
+select.abflusstafel = SELECT ABFLUSSTAFEL_NR, \
+                             strftime('%s', GUELTIG_VON) * 1000 AS GUELTIG_VON, \
+                             strftime('%s', GUELTIG_BIS) * 1000 AS GUELTIG_BIS, \
+                             PEGELNULLPUNKT FROM ABFLUSSTAFEL WHERE MESSSTELLE_NR LIKE :number
 

http://dive4elements.wald.intevation.org