annotate flys-aft/src/main/java/de/intevation/aft/River.java @ 4099:006e99437fb9

Store the W/Q differences o existing discharge tables to FLYS database. flys-aft/trunk@3621 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 08 Jan 2012 09:25:36 +0000
parents 9215253ad0be
children 981de0b77c6b
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
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
3 import java.util.List;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
4 import java.util.ArrayList;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
5 import java.util.HashMap;
4078
0944cdd2ee90 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4077
diff changeset
6 import java.util.Map;
0944cdd2ee90 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4077
diff changeset
7
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
8 import java.sql.ResultSet;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 import java.sql.SQLException;
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
10 import java.sql.Types;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import org.apache.log4j.Logger;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 import de.intevation.db.ConnectedStatements;
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
15 import de.intevation.db.SymbolicStatement;
4075
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 class River
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 extends IdPair
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 private static Logger log = Logger.getLogger(River.class);
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 protected String 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 public River() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 public River(int id1, int id2, String name) {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 super(id1, id2);
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 this.name = name;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 public String getName() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 return name;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
4078
0944cdd2ee90 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4077
diff changeset
36
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
37 public boolean sync(SyncContext context) throws SQLException {
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 log.info("sync river: " + this);
4077
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
39
4084
9178beeb7b05 Moved DIPS gauge number -> DIPS gauge index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
40 Map<Long, DIPSGauge> dipsGauges = context.getDIPSGauges();
4081
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
41
4077
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
42 ConnectedStatements flysStatements = context.getFlysStatements();
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
43 ConnectedStatements aftStatements = context.getAftStatements();
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
44
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
45 ResultSet messstellenRs = aftStatements
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
46 .getStatement("select.messstelle")
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
47 .clearParameters()
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
48 .setInt("GEWAESSER_NR", id2).executeQuery();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
49
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
50 String riverName = getName();
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
51
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
52 Map<Long, DIPSGauge> aftDIPSGauges = new HashMap<Long, DIPSGauge>();
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
53
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
54 while (messstellenRs.next()) {
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
55 String name = messstellenRs.getString("NAME");
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
56 String num = messstellenRs.getString("MESSSTELLE_NR");
4084
9178beeb7b05 Moved DIPS gauge number -> DIPS gauge index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
57 Long number = SyncContext.numberToLong(num);
4081
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
58 if (number == null) {
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
59 log.warn("Invalid MESSSTELLE_NR for MESSSTELLE '"+name+"'");
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
60 continue;
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
61 }
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
62 DIPSGauge dipsGauge = dipsGauges.get(number);
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
63 if (dipsGauge == null) {
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
64 log.warn(
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
65 "MESSSTELLE '" + name + "' not found in DIPS. " +
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
66 "Gauge number used for lookup: " + number);
4081
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
67 continue;
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
68 }
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
69 String gaugeRiver = dipsGauge.getRiverName();
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
70 if (!gaugeRiver.equalsIgnoreCase(riverName)) {
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
71 log.warn(
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
72 "MESSSTELLE '" + name +
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
73 "' is assigned to river '" + gaugeRiver +
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
74 "'. Needs to be on '" + riverName + "'.");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
75 continue;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
76 }
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
77 dipsGauge.setAftName(name);
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
78 dipsGauge.setOfficialNumber(number);
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
79 aftDIPSGauges.put(number, dipsGauge);
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
80 }
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
81
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
82 messstellenRs.close();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
83
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
84 List<DIPSGauge> updateGauges = new ArrayList<DIPSGauge>();
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
85
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
86 ResultSet gaugesRs = flysStatements
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
87 .getStatement("select.gauges")
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
88 .clearParameters()
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
89 .setInt("river_id", id1).executeQuery();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
90
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
91 while (gaugesRs.next()) {
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
92 int gaugeId = gaugesRs.getInt("id");
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
93 String name = gaugesRs.getString("name");
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
94 long number = gaugesRs.getLong("official_number");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
95 if (gaugesRs.wasNull()) {
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
96 log.warn("FLYS: Gauge '" + name +
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
97 "' has no official number. Ignored.");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
98 continue;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
99 }
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
100 Long key = Long.valueOf(number);
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
101 DIPSGauge aftDIPSGauge = aftDIPSGauges.remove(key);
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
102 if (aftDIPSGauge == null) {
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
103 log.warn("FLYS: Gauge '" + name + "' number " + number +
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
104 " is not found in AFT/DIPS.");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
105 continue;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
106 }
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
107 aftDIPSGauge.setFlysId(gaugeId);
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
108 log.info("Gauge '" + name +
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
109 "' found in FLYS, AFT and DIPS. -> Update");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
110 updateGauges.add(aftDIPSGauge);
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
111 }
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
112 gaugesRs.close();
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
113
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
114 boolean modified = createGauges(context, aftDIPSGauges);
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
115
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
116 modified |= updateGauges(context, updateGauges);
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
117
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
118 return modified;
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
119 }
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
120
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
121 protected boolean updateGauges(
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
122 SyncContext context,
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
123 List<DIPSGauge> gauges
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
124 )
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
125 throws SQLException
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
126 {
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
127 boolean modified = false;
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
128
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
129 for (DIPSGauge gauge: gauges) {
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
130 modified |= updateGauge(context, gauge);
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
131 }
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
132
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
133 return modified;
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
134 }
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
135
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
136 protected boolean updateGauge(
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
137 SyncContext context,
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
138 DIPSGauge gauge
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
139 )
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
140 throws SQLException
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
141 {
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
142 // We need to load all discharge tables from both database
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
143 // of the gauge and do some pairing based on their descriptions.
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
144
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
145 boolean modified = false;
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
146
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
147 List<DischargeTable> flysDTs =
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
148 DischargeTable.loadFlysDischargeTables(
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
149 context, gauge.getFlysId());
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
150
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
151 List<DischargeTable> aftDTs =
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
152 DischargeTable.loadAftDischargeTables(
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
153 context, gauge.getOfficialNumber());
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
154
4098
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
155 Map<String, DischargeTable> desc2FlysDT =
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
156 new HashMap<String, DischargeTable>();
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
157
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
158 for (DischargeTable dt: flysDTs) {
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
159 String description = dt.getDescription();
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
160 if (description == null) {
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
161 log.warn("FLYS: discharge table " + dt.getId()
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
162 + " has no description. Ignored.");
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
163 continue;
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
164 }
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
165 desc2FlysDT.put(description, dt);
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
166 }
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
167
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
168 List<DischargeTable> createDTs = new ArrayList<DischargeTable>();
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
169
4099
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
170 for (DischargeTable aftDT: aftDTs) {
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
171 String description = aftDT.getDescription();
4098
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
172 DischargeTable flysDT = desc2FlysDT.remove(description);
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
173 if (flysDT != null) {
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
174 // Found in AFT and FLYS.
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
175 log.info("FLYS: Discharge table '" + description
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
176 + "' found in AFT and FLYS. -> update");
4099
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
177 // Create the W/Q diff.
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
178 modified |= writeWQChanges(context, flysDT, aftDT);
4098
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
179 }
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
180 else {
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
181 log.info("FLYS: Discharge table '" + description
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
182 + "' not found in FLYS. -> create");
4099
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
183 createDTs.add(aftDT);
4098
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
184 }
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
185 }
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
186
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
187 for (String description: desc2FlysDT.keySet()) {
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
188 log.info("FLYS: Discharge table '" + description
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
189 + "' found in FLYS but not in AFT. -> ignore");
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
190 }
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
191
9215253ad0be Do the FLYS/AFT description pairing of discharge tables in case a gauge needs updates.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
192 // TODO: Create the new discharge tables.
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
193
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
194 return modified;
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
195 }
4079
42094f01afa6 Added model for DIPS gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4078
diff changeset
196
4099
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
197 protected boolean writeWQChanges(
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
198 SyncContext context,
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
199 DischargeTable flysDT,
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
200 DischargeTable aftDT
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
201 )
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
202 throws SQLException
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
203 {
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
204 flysDT.loadFlysValues(context);
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
205 aftDT.loadAftValues(context);
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
206 WQDiff diff = new WQDiff(flysDT.getValues(), aftDT.getValues());
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
207 if (diff.hasChanges()) {
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
208 diff.writeChanges(context, flysDT.getId());
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
209 return true;
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
210 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
211 return false;
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
212 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
213
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
214 protected boolean createGauges(
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
215 SyncContext context,
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
216 Map<Long, DIPSGauge> gauges
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
217 )
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
218 throws SQLException
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
219 {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
220 ConnectedStatements flysStatements = context.getFlysStatements();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
221
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
222 SymbolicStatement.Instance nextId =
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
223 flysStatements.getStatement("next.gauge.id");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
224
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
225 SymbolicStatement.Instance insertStmnt =
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
226 flysStatements.getStatement("insert.gauge");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
227
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
228 boolean modified = false;
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
229
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
230 for (Map.Entry<Long, DIPSGauge> entry: gauges.entrySet()) {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
231 Long officialNumber = entry.getKey();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
232 DIPSGauge gauge = entry.getValue();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
233
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
234 log.info("Gauge '" + gauge.getAftName() +
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
235 "' not in FLYS but in AFT/DIPS. -> Create");
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
236
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
237 if (!gauge.hasDatums()) {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
238 log.warn("FLYS: Gauge '" +
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
239 gauge.getAftName() + "' has no datum. Ignored.");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
240 continue;
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
241 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
242
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
243 ResultSet rs = null;
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
244 flysStatements.beginTransaction();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
245 try {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
246 (rs = nextId.executeQuery()).next();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
247 int gaugeId = rs.getInt("gauge_id");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
248 rs.close(); rs = null;
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
249
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
250 insertStmnt
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
251 .clearParameters()
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
252 .setInt("id", gaugeId)
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
253 .setString("name", gauge.getAftName())
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
254 .setInt("river_id", id1)
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
255 .setDouble("station", gauge.getStation())
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
256 .setDouble("aeo", gauge.getAeo())
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
257 .setDouble("official_number", officialNumber)
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
258 .setDouble("datum", gauge.getLatestDatum().getValue());
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
259
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
260 insertStmnt.execute();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
261
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
262 log.info("FLYS: Created gauge '" + gauge.getAftName() +
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
263 "' with id " + gaugeId + ".");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
264
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
265 gauge.setFlysId(gaugeId);
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
266 createDischargeTables(context, officialNumber, gauge);
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
267 flysStatements.commitTransaction();
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
268 modified = true;
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
269 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
270 catch (SQLException sqle) {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
271 flysStatements.rollbackTransaction();
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
272 log.error(sqle, sqle);
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
273 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
274 finally {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
275 if (rs != null) {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
276 rs.close();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
277 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
278 }
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
279 }
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
280
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
281 return modified;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
282 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
283
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
284 protected void createDischargeTables(
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
285 SyncContext context,
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
286 Long officialNumber,
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
287 DIPSGauge gauge
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
288 )
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
289 throws SQLException
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
290 {
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
291 log.info("create discharge tables");
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
292
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
293 // Load the discharge tables from AFT.
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
294 List<DischargeTable> dts = loadAftDischargeTables(
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
295 context, officialNumber, gauge);
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
296
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
297 // Persist the time intervals.
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
298 persistFlysTimeIntervals(context, dts);
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
299
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
300 // Persist the discharge tables
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
301 int [] flysDTIds = persistFlysDischargeTables(context, dts);
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
302
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
303 // Copy over the W/Q values
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
304 copyWQsFromAftToFlys(context, dts, flysDTIds);
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
305 }
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
306
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
307 protected List<DischargeTable> loadAftDischargeTables(
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
308 SyncContext context,
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
309 Long officialNumber,
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
310 DIPSGauge gauge
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
311 )
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
312 throws SQLException
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
313 {
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
314 return DischargeTable.loadAftDischargeTables(
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
315 context, officialNumber, gauge.getFlysId());
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
316 }
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
317
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
318 protected void persistFlysTimeIntervals(
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
319 SyncContext context,
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
320 List<DischargeTable> dts
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
321 )
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
322 throws SQLException
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
323 {
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
324 for (DischargeTable dt: dts) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
325 TimeInterval timeInterval = dt.getTimeInterval();
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
326 if (timeInterval != null) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
327 dt.setTimeInterval(
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
328 context.fetchOrCreateFLYSTimeInterval(timeInterval));
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
329 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
330 }
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
331 }
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
332
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
333 protected int [] persistFlysDischargeTables(
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
334 SyncContext context,
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
335 List<DischargeTable> dts
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
336 )
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
337 throws SQLException
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
338 {
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
339 boolean debug = log.isDebugEnabled();
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
340
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
341 int [] flysDTIds = new int[dts.size()];
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
342
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
343 ResultSet rs = null;
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
344 try {
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
345 ConnectedStatements flysStatements =
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
346 context.getFlysStatements();
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
347
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
348 SymbolicStatement.Instance nextId =
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
349 flysStatements.getStatement("next.discharge.id");
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
350
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
351 SymbolicStatement.Instance insertDT =
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
352 flysStatements.getStatement("insert.dischargetable");
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
353
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
354 for (int i = 0; i < flysDTIds.length; ++i) {
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
355 rs = nextId.executeQuery();
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
356 rs.next();
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
357 int id = rs.getInt("discharge_table_id");
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
358 flysDTIds[i] = id;
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
359 rs.close(); rs = null;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
360
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
361 DischargeTable dt = dts.get(i);
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
362 insertDT.clearParameters()
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
363 .setInt("id", id)
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
364 .setInt("gauge_id", dt.getGaugeId())
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
365 .setString("description", dt.getDescription());
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
366
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
367 TimeInterval timeInterval = dt.getTimeInterval();
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
368 if (timeInterval != null) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
369 insertDT.setInt("time_interval_id", timeInterval.getId());
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
370 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
371 else {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
372 insertDT.setNull("time_interval_id", Types.INTEGER);
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
373 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
374
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
375 insertDT.execute();
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
376 if (debug) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
377 log.debug("FLYS: Created discharge table id: " + id);
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
378 }
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
379 }
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
380 }
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
381 finally {
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
382 if (rs != null) {
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
383 rs.close();
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
384 rs = null;
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
385 }
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
386 }
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
387
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
388 return flysDTIds;
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
389 }
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
390
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
391 protected void copyWQsFromAftToFlys(
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
392 SyncContext context,
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
393 List<DischargeTable> dts,
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
394 int [] flysDTIds
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
395 )
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
396 throws SQLException
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
397 {
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
398 for (int i = 0; i < flysDTIds.length; ++i) {
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
399 DischargeTable dt = dts.get(i);
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
400 dt.loadAftValues(context);
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
401 dt.storeFlysValues(context, flysDTIds[i]);
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
402 dt.clearValues(); // To save memory.
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
403 }
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
404 }
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
405
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
406 public String toString() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
407 return "[River: name=" + name + ", " + super.toString() + "]";
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
408 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
409
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
410 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
411 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org