Mercurial > dive4elements > river
annotate flys-aft/src/main/java/de/intevation/aft/Rivers.java @ 4083:44dc38ca8492
Added an optional XSL transformation to fix the raw DIPS files.
flys-aft/trunk@3513 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 21 Dec 2011 14:56:29 +0000 |
parents | 97de7a552b79 |
children | b20b710aa86f |
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 |
4077
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
23 public void sync(SyncContext context) throws SQLException { |
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
24 |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
25 log.info("sync: rivers"); |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
4077
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
27 ConnectedStatements flysStatements = context.getFlysStatements(); |
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
28 ConnectedStatements aftStatements = context.getAftStatements(); |
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
29 |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
30 Map<String, Integer> flysRivers = new HashMap<String, Integer>(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
31 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
32 ResultSet flysRs = flysStatements |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
33 .getStatement("select.river").executeQuery(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
34 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
35 while (flysRs.next()) { |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
36 Integer id = flysRs.getInt("id"); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
37 String name = flysRs.getString("name").toLowerCase(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
38 flysRivers.put(name, id); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
39 } |
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 flysRs.close(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
42 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
43 List<River> commonRivers = new ArrayList<River>(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
44 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
45 ResultSet aftRs = aftStatements |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
46 .getStatement("select.gewaesser").executeQuery(); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
47 |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
48 while (aftRs.next()) { |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
49 String name = aftRs.getString("NAME"); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
50 Integer id1 = flysRivers.get(name.toLowerCase()); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
51 if (id1 != null) { |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
52 int id2 = aftRs.getInt("GEWAESSER_NR"); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
53 River river = new River(id1, id2, name); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
54 commonRivers.add(river); |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
55 } |
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
56 } |
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 aftRs.close(); |
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 for (River river: commonRivers) { |
4077
97de7a552b79
Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4075
diff
changeset
|
61 river.sync(context); |
4075
dbd0b3b1b8b8
Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4073
diff
changeset
|
62 } |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 } |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |