Mercurial > dive4elements > river
annotate flys-aft/src/main/java/de/intevation/aft/River.java @ 4077:97de7a552b79
Load DIPS XML
flys-aft/trunk@3452 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 16 Dec 2011 16:21:59 +0000 |
parents | 039413d7e394 |
children | 0944cdd2ee90 |
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 |
4077
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4076
diff
changeset
|
29 public void sync(SyncContext context) throws SQLException { |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 log.info("sync river: " + this); |
4077
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4076
diff
changeset
|
31 |
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4076
diff
changeset
|
32 ConnectedStatements flysStatements = context.getFlysStatements(); |
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4076
diff
changeset
|
33 ConnectedStatements aftStatements = context.getAftStatements(); |
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4076
diff
changeset
|
34 |
4076
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
35 ResultSet messstellenRs = aftStatements |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
36 .getStatement("select.messstelle") |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
37 .clearParameters() |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
38 .setInt("GEWAESSER_NR", id2).executeQuery(); |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
39 |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
40 while (messstellenRs.next()) { |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
41 String name = messstellenRs.getString("NAME"); |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
42 String num = messstellenRs.getString("MESSSTELLE_NR"); |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
43 System.err.println(name + ": " + num); |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
44 } |
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 messstellenRs.close(); |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
47 |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
48 ResultSet gaugesRs = flysStatements |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
49 .getStatement("select.gauges") |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
50 .clearParameters() |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
51 .setInt("river_id", id1).executeQuery(); |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
52 |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
53 while (gaugesRs.next()) { |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
54 int gaugeId = gaugesRs.getInt("id"); |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
55 String name = gaugesRs.getString("name"); |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
56 System.err.println(name + ": " + gaugeId); |
039413d7e394
Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
57 } |
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 gaugesRs.close(); |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 } |
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 public String toString() { |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 return "[River: name=" + name + ", " + super.toString() + "]"; |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 } |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |