changeset 4076:039413d7e394

Load gauges from both dbs. flys-aft/trunk@3436 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 16 Dec 2011 11:26:12 +0000
parents dbd0b3b1b8b8
children 97de7a552b79
files flys-aft/ChangeLog flys-aft/src/main/java/de/intevation/aft/River.java flys-aft/src/main/java/de/intevation/db/SymbolicStatement.java flys-aft/src/main/resources/sql/aft-common.properties flys-aft/src/main/resources/sql/flys-common.properties
diffstat 5 files changed, 57 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-aft/ChangeLog	Wed Dec 14 17:53:15 2011 +0000
+++ b/flys-aft/ChangeLog	Fri Dec 16 11:26:12 2011 +0000
@@ -1,3 +1,15 @@
+2011-12-16	Sascha L. Teichmann	<sascha.teichmann@inteavtion.de>
+
+	* src/main/java/de/intevation/db/SymbolicStatement.java:
+	  Made the setX() methods cascadable.
+
+	* src/main/java/de/intevation/aft/River.java: Fetches
+	  the gauges from the database.
+
+	* src/main/resources/sql/aft-common.properties,
+	  src/main/resources/sql/flys-common.properties: Added gauges
+	  statements.
+
 2011-12-14	Sascha L. Teichmann	<sascha.teichmann@inteavtion.de>
 
 	* src/main/java/de/intevation/db/SymbolicStatement.java:
--- a/flys-aft/src/main/java/de/intevation/aft/River.java	Wed Dec 14 17:53:15 2011 +0000
+++ b/flys-aft/src/main/java/de/intevation/aft/River.java	Fri Dec 16 11:26:12 2011 +0000
@@ -1,5 +1,6 @@
 package de.intevation.aft;
 
+import java.sql.ResultSet;
 import java.sql.SQLException;
 
 import org.apache.log4j.Logger;
@@ -32,6 +33,31 @@
     throws SQLException
     {
         log.info("sync river: " + this);
+        ResultSet messstellenRs = aftStatements
+            .getStatement("select.messstelle")
+            .clearParameters()
+            .setInt("GEWAESSER_NR", id2).executeQuery();
+
+        while (messstellenRs.next()) {
+            String name = messstellenRs.getString("NAME");
+            String num  = messstellenRs.getString("MESSSTELLE_NR");
+            System.err.println(name + ": " + num);
+        }
+
+        messstellenRs.close();
+
+        ResultSet gaugesRs = flysStatements
+            .getStatement("select.gauges")
+            .clearParameters()
+            .setInt("river_id", id1).executeQuery();
+
+        while (gaugesRs.next()) {
+            int gaugeId = gaugesRs.getInt("id");
+            String name = gaugesRs.getString("name");
+            System.err.println(name + ": " + gaugeId);
+        }
+
+        gaugesRs.close();
     }
 
     public String toString() {
--- a/flys-aft/src/main/java/de/intevation/db/SymbolicStatement.java	Wed Dec 14 17:53:15 2011 +0000
+++ b/flys-aft/src/main/java/de/intevation/db/SymbolicStatement.java	Fri Dec 16 11:26:12 2011 +0000
@@ -45,7 +45,7 @@
             }
         }
 
-        public void setInt(String key, int value)
+        public Instance setInt(String key, int value)
         throws SQLException 
         {
             List<Integer> pos = positions.get(key.toLowerCase());
@@ -54,9 +54,11 @@
                     stmnt.setInt(p, value);
                 }
             }
+
+            return this;
         }
 
-        public void setString(String key, String value)
+        public Instance setString(String key, String value)
         throws SQLException 
         {
             List<Integer> pos = positions.get(key.toLowerCase());
@@ -65,9 +67,10 @@
                     stmnt.setString(p, value);
                 }
             }
+            return this;
         }
 
-        public void setObject(String key, Object value)
+        public Instance setObject(String key, Object value)
         throws SQLException 
         {
             List<Integer> pos = positions.get(key.toLowerCase());
@@ -76,9 +79,10 @@
                     stmnt.setObject(p, value);
                 }
             }
+            return this;
         }
 
-        public void setTimestamp(String key, Timestamp value)
+        public Instance setTimestamp(String key, Timestamp value)
         throws SQLException 
         {
             List<Integer> pos = positions.get(key.toLowerCase());
@@ -87,9 +91,10 @@
                     stmnt.setTimestamp(p, value);
                 }
             }
+            return this;
         }
 
-        public void setDouble(String key, int value)
+        public Instance setDouble(String key, int value)
         throws SQLException 
         {
             List<Integer> pos = positions.get(key.toLowerCase());
@@ -98,9 +103,10 @@
                     stmnt.setDouble(p, value);
                 }
             }
+            return this;
         }
 
-        public void setNull(String key, int sqlType)
+        public Instance setNull(String key, int sqlType)
         throws SQLException 
         {
             List<Integer> pos = positions.get(key.toLowerCase());
@@ -109,16 +115,19 @@
                     stmnt.setNull(p, sqlType);
                 }
             }
+            return this;
         }
 
-        public void set(Map<String, Object> map) throws SQLException {
+        public Instance set(Map<String, Object> map) throws SQLException {
             for (Map.Entry<String, Object> entry: map.entrySet()) {
                 setObject(entry.getKey(), entry.getValue());
             }
+            return this;
         }
 
-        public void clearParameters() throws SQLException {
+        public Instance clearParameters() throws SQLException {
             stmnt.clearParameters();
+            return this;
         }
 
         public boolean execute() throws SQLException {
--- a/flys-aft/src/main/resources/sql/aft-common.properties	Wed Dec 14 17:53:15 2011 +0000
+++ b/flys-aft/src/main/resources/sql/aft-common.properties	Fri Dec 16 11:26:12 2011 +0000
@@ -1,2 +1,3 @@
 select.gewaesser = SELECT GEWAESSER_NR, NAME FROM SL_GEWAESSER
+select.messstelle = SELECT NAME, MESSSTELLE_NR FROM MESSSTELLE WHERE GEWAESSER_NR = :GEWAESSER_NR
 
--- a/flys-aft/src/main/resources/sql/flys-common.properties	Wed Dec 14 17:53:15 2011 +0000
+++ b/flys-aft/src/main/resources/sql/flys-common.properties	Fri Dec 16 11:26:12 2011 +0000
@@ -1,1 +1,2 @@
 select.river = SELECT id, name FROM rivers 
+select.gauges = SELECT id, name FROM gauges WHERE river_id = :river_id

http://dive4elements.wald.intevation.org