Mercurial > dive4elements > river
annotate flys-aft/src/main/java/de/intevation/aft/Rivers.java @ 4075:dbd0b3b1b8b8
Sync each river.
flys-aft/trunk@3419 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 14 Dec 2011 17:53:15 +0000 |
parents | 2c70fae83d0c |
children | 97de7a552b79 |
rev | line source |
---|---|
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.aft; |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
3 import java.util.Map; |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
4 import java.util.HashMap; |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
5 import java.util.List; |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
6 import java.util.ArrayList; |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
7 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
8 |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import java.sql.SQLException; |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
10 import java.sql.ResultSet; |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
12 import de.intevation.db.ConnectedStatements; |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
13 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
14 import org.apache.log4j.Logger; |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 public class Rivers |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 { |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
18 private static Logger log = Logger.getLogger(Rivers.class); |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
20 public Rivers() { |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 } |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
23 public void sync( |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
24 ConnectedStatements aftStatements, |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
25 ConnectedStatements flysStatements |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
26 ) |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
27 throws SQLException |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
28 { |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
29 log.info("sync: rivers"); |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
31 Map<String, Integer> flysRivers = new HashMap<String, Integer>(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
32 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
33 ResultSet flysRs = flysStatements |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
34 .getStatement("select.river").executeQuery(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
35 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
36 while (flysRs.next()) { |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
37 Integer id = flysRs.getInt("id"); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
38 String name = flysRs.getString("name").toLowerCase(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
39 flysRivers.put(name, id); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
40 } |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
41 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
42 flysRs.close(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
43 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
44 List<River> commonRivers = new ArrayList<River>(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
45 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
46 ResultSet aftRs = aftStatements |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
47 .getStatement("select.gewaesser").executeQuery(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
48 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
49 while (aftRs.next()) { |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
50 String name = aftRs.getString("NAME"); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
51 Integer id1 = flysRivers.get(name.toLowerCase()); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
52 if (id1 != null) { |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
53 int id2 = aftRs.getInt("GEWAESSER_NR"); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
54 River river = new River(id1, id2, name); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
55 System.err.println(river); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
56 commonRivers.add(river); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
57 } |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
58 } |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
59 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
60 aftRs.close(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
61 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
62 for (River river: commonRivers) { |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
63 river.sync(aftStatements, flysStatements); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
64 } |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 } |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |