annotate flys-aft/src/main/java/de/intevation/aft/Rivers.java @ 4766:655e86f025c1

run_hydr_morph.sh: Add SKIP_DA50 and SKIP_W80 flags.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 04 Jan 2013 11:16:50 +0100
parents a310aceb2e51
children f939e1e6cfa4
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
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
23 public boolean sync(SyncContext context) throws SQLException {
4077
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
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
30 Map<String, River> flysRivers = new HashMap<String, River>();
4075
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
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
33 .getStatement("select.rivers").executeQuery();
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
34
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
35 try {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
36 while (flysRs.next()) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
37 int id = flysRs.getInt("id");
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
38 String name = flysRs.getString("name");
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
39 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
40 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
41 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
42 }
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
43 }
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
44 finally {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
45 flysRs.close();
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
46 }
4075
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 List<River> commonRivers = new ArrayList<River>();
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
49
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
50 ResultSet aftRs = aftStatements
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
51 .getStatement("select.gewaesser").executeQuery();
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
52
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
53 try {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
54 while (aftRs.next()) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
55 String name = aftRs.getString("NAME");
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
56 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
57 if (river != null) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
58 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
59 river.setId2(id2);
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
60 commonRivers.add(river);
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
61 }
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
62 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
63 }
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
64 finally {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
65 aftRs.close();
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4094
diff changeset
66 }
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
67
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
68
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
69 boolean modified = false;
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
70
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
71 for (River river: commonRivers) {
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
72 modified |= river.sync(context);
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4073
diff changeset
73 }
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
74
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
75 return modified;
4073
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 }
2c70fae83d0c start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org