annotate flys-aft/src/main/java/de/intevation/aft/Rivers.java @ 5333:623e5c9f91ef

Various i18n issues from flys/issue1180 .
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 19 Mar 2013 10:24:03 +0100
parents f939e1e6cfa4
children
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
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
3 import de.intevation.db.ConnectedStatements;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
4
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
5 import java.sql.ResultSet;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
6 import java.sql.SQLException;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
7
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
8 import java.util.ArrayList;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
9 import java.util.HashMap;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
10 import java.util.List;
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
11 import java.util.Map;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
12
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
13 import org.apache.log4j.Logger;
4073
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 public class Rivers
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 {
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
17 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
18
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
19 public Rivers() {
4073
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 }
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
22 public boolean sync(SyncContext context) throws SQLException {
4077
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
23
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
24 log.info("sync: rivers");
4073
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25
4077
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
26 ConnectedStatements flysStatements = context.getFlysStatements();
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
27 ConnectedStatements aftStatements = context.getAftStatements();
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
28
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
29 Map<String, River> flysRivers = new HashMap<String, River>();
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
30
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
31 ResultSet flysRs = flysStatements
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
32 .getStatement("select.rivers").executeQuery();
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
33
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
34 try {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
35 while (flysRs.next()) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
36 int id = flysRs.getInt("id");
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
37 String name = flysRs.getString("name");
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
38 double from = flysRs.getDouble("min_km");
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
39 double to = flysRs.getDouble("max_km");
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
40 flysRivers.put(name.toLowerCase(), new River(id, name, from, to));
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
41 }
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
42 }
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
43 finally {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
44 flysRs.close();
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
45 }
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
46
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
47 List<River> commonRivers = new ArrayList<River>();
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 ResultSet aftRs = aftStatements
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
50 .getStatement("select.gewaesser").executeQuery();
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
51
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
52 try {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
53 while (aftRs.next()) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
54 String name = aftRs.getString("NAME");
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
55 River river = flysRivers.get(name.toLowerCase());
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
56 if (river != null) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
57 int id2 = aftRs.getInt("GEWAESSER_NR");
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
58 river.setId2(id2);
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
59 commonRivers.add(river);
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
60 }
4075
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 }
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
63 finally {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
64 aftRs.close();
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
65 }
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
66
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
67
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
68 boolean modified = false;
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
69
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
70 for (River river: commonRivers) {
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
71 modified |= river.sync(context);
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
72 }
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
73
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
74 return modified;
4073
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 }
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 }
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org