annotate flys-aft/src/main/java/de/intevation/aft/River.java @ 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
rev   line source
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.aft;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
3 import java.sql.ResultSet;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 import java.sql.SQLException;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 import de.intevation.db.ConnectedStatements;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 public class River
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 extends IdPair
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 private static Logger log = Logger.getLogger(River.class);
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 protected String name;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 public River() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public River(int id1, int id2, String name) {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 super(id1, id2);
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 this.name = name;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 public String getName() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 return name;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 public void sync(
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 ConnectedStatements aftStatements,
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 ConnectedStatements flysStatements
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 )
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 throws SQLException
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 log.info("sync river: " + this);
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
36 ResultSet messstellenRs = aftStatements
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
37 .getStatement("select.messstelle")
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
38 .clearParameters()
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
39 .setInt("GEWAESSER_NR", id2).executeQuery();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
40
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
41 while (messstellenRs.next()) {
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
42 String name = messstellenRs.getString("NAME");
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
43 String num = messstellenRs.getString("MESSSTELLE_NR");
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
44 System.err.println(name + ": " + num);
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
45 }
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
46
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
47 messstellenRs.close();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
48
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
49 ResultSet gaugesRs = flysStatements
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
50 .getStatement("select.gauges")
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
51 .clearParameters()
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
52 .setInt("river_id", id1).executeQuery();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
53
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
54 while (gaugesRs.next()) {
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
55 int gaugeId = gaugesRs.getInt("id");
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
56 String name = gaugesRs.getString("name");
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
57 System.err.println(name + ": " + gaugeId);
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
58 }
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
59
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
60 gaugesRs.close();
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 public String toString() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 return "[River: name=" + name + ", " + super.toString() + "]";
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org