annotate flys-aft/src/main/java/de/intevation/aft/River.java @ 5822:a7df90f425e2 before-dive4elements-move

Remove obsolete (duplicate) macro and its use.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 25 Apr 2013 08:24:54 +0200
parents 14de791bd8f7
children
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
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4754
diff changeset
3 import de.intevation.db.ConnectedStatements;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4754
diff changeset
4 import de.intevation.db.SymbolicStatement;
4078
0944cdd2ee90 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4077
diff changeset
5
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
6 import java.sql.ResultSet;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import java.sql.SQLException;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4754
diff changeset
9 import java.util.ArrayList;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4754
diff changeset
10 import java.util.HashMap;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4754
diff changeset
11 import java.util.List;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4754
diff changeset
12 import java.util.Map;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4754
diff changeset
14 import org.apache.log4j.Logger;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 public class River
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 extends IdPair
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 private static Logger log = Logger.getLogger(River.class);
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 protected String name;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
23 protected double from;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
24 protected double to;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
25
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 public River() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
29 public River(int id1, String name, double from, double to) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
30 super(id1);
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
31 this.name = name;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
32 this.from = from;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
33 this.to = to;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
34 }
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
35
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public River(int id1, int id2, String name) {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 super(id1, id2);
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 this.name = name;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 public String getName() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 return name;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
4753
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
45 public double getFrom() {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
46 return from;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
47 }
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
48
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
49 public void setFrom(double from) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
50 this.from = from;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
51 }
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
52
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
53 public double getTo() {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
54 return to;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
55 }
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
56
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
57 public void setTo(double to) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
58 this.to = to;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
59 }
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
60
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
61 public boolean inside(double x) {
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
62 return x >= from && x <= to;
a310aceb2e51 Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
63 }
4078
0944cdd2ee90 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4077
diff changeset
64
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
65 public boolean sync(SyncContext context) throws SQLException {
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 log.info("sync river: " + this);
4077
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
67
5188
2b7f44c80857 Stations are now filtered by DiPS not AFT.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4775
diff changeset
68 // Only take relevant gauges into account.
2b7f44c80857 Stations are now filtered by DiPS not AFT.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4775
diff changeset
69 Map<Long, DIPSGauge> dipsGauges = context.getDIPSGauges(name, from, to);
4081
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
70
4077
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
71 ConnectedStatements flysStatements = context.getFlysStatements();
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
72 ConnectedStatements aftStatements = context.getAftStatements();
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
73
4754
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
74 String riverName = getName();
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
75
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
76 Map<Long, DIPSGauge> aftDIPSGauges = new HashMap<Long, DIPSGauge>();
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
77
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
78 ResultSet messstellenRs = aftStatements
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
79 .getStatement("select.messstelle")
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
80 .clearParameters()
4774
9dcc32fc5167 Moved check for calculation range intersection to SQL statement.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
81 .setInt("GEWAESSER_NR", id2)
9dcc32fc5167 Moved check for calculation range intersection to SQL statement.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
82 .executeQuery();
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
83
4754
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
84 try {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
85 while (messstellenRs.next()) {
4774
9dcc32fc5167 Moved check for calculation range intersection to SQL statement.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
86 String name = messstellenRs.getString("NAME");
9dcc32fc5167 Moved check for calculation range intersection to SQL statement.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
87 String num = messstellenRs.getString("MESSSTELLE_NR");
5188
2b7f44c80857 Stations are now filtered by DiPS not AFT.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4775
diff changeset
88 double station = messstellenRs.getDouble("STATIONIERUNG");
2b7f44c80857 Stations are now filtered by DiPS not AFT.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4775
diff changeset
89
5258
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
90 if (!messstellenRs.wasNull() && !inside(station)) {
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
91 log.warn("Station found in AFT but in not range: " + station);
5188
2b7f44c80857 Stations are now filtered by DiPS not AFT.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4775
diff changeset
92 continue;
2b7f44c80857 Stations are now filtered by DiPS not AFT.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4775
diff changeset
93 }
4754
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
94
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
95 Long number = SyncContext.numberToLong(num);
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
96 if (number == null) {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
97 log.warn("AFT: Invalid MESSSTELLE_NR for MESSSTELLE '"+name+"'");
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
98 continue;
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
99 }
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
100 DIPSGauge dipsGauge = dipsGauges.get(number);
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
101 if (dipsGauge == null) {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
102 log.warn(
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
103 "DIPS: MESSSTELLE '" + name + "' not found in DIPS. " +
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
104 "Gauge number used for lookup: " + number);
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
105 continue;
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
106 }
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
107 String gaugeRiver = dipsGauge.getRiverName();
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
108 if (!gaugeRiver.equalsIgnoreCase(riverName)) {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
109 log.warn(
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
110 "DIPS: MESSSTELLE '" + name +
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
111 "' is assigned to river '" + gaugeRiver +
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
112 "'. Needs to be on '" + riverName + "'.");
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
113 continue;
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
114 }
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
115 dipsGauge.setAftName(name);
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
116 dipsGauge.setOfficialNumber(number);
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
117 aftDIPSGauges.put(number, dipsGauge);
4081
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
118 }
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
119 }
4754
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
120 finally {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
121 messstellenRs.close();
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
122 }
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
123
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
124 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
125
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
126 ResultSet gaugesRs = flysStatements
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
127 .getStatement("select.gauges")
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
128 .clearParameters()
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
129 .setInt("river_id", id1).executeQuery();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
130
4754
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
131 try {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
132 while (gaugesRs.next()) {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
133 int gaugeId = gaugesRs.getInt("id");
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
134 String name = gaugesRs.getString("name");
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
135 long number = gaugesRs.getLong("official_number");
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
136 if (gaugesRs.wasNull()) {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
137 log.warn("FLYS: Gauge '" + name +
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
138 "' has no official number. Ignored.");
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
139 continue;
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
140 }
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
141 Long key = Long.valueOf(number);
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
142 DIPSGauge aftDIPSGauge = aftDIPSGauges.remove(key);
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
143 if (aftDIPSGauge == null) {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
144 log.warn("FLYS: Gauge '" + name + "' number " + number +
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
145 " is not found in AFT/DIPS.");
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
146 continue;
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
147 }
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
148 aftDIPSGauge.setFlysId(gaugeId);
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
149 log.info("Gauge '" + name +
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
150 "' found in FLYS, AFT and DIPS. -> Update");
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
151 updateGauges.add(aftDIPSGauge);
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
152 }
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
153 }
4754
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
154 finally {
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
155 gaugesRs.close();
04377ccef10a AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4753
diff changeset
156 }
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
157
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
158 boolean modified = createGauges(context, aftDIPSGauges);
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
159
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
160 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
161
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
162 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
163 }
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
164
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
165 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
166 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
167 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
168 )
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
169 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
170 {
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
171 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
172
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
173 for (DIPSGauge gauge: gauges) {
5616
14de791bd8f7 AFT/DIPS/SGM: Do _not_ update current discharge table from AFT.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5480
diff changeset
174 // XXX: Do dont modify the master AT.
14de791bd8f7 AFT/DIPS/SGM: Do _not_ update current discharge table from AFT.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5480
diff changeset
175 // modified |= updateBfGIdOnMasterDischargeTable(context, gauge);
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
176 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
177 }
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
178
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
179 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
180 }
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
181
5258
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
182 protected boolean updateBfGIdOnMasterDischargeTable(
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
183 SyncContext context,
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
184 DIPSGauge gauge
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
185 ) throws SQLException {
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
186 log.info(
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
187 "FLYS: Updating master discharge table bfg_id for '" +
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
188 gauge.getAftName() + "'");
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
189 ConnectedStatements flysStatements = context.getFlysStatements();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
190
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
191 ResultSet rs = flysStatements
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
192 .getStatement("select.gauge.master.discharge.table")
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
193 .clearParameters()
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
194 .setInt("gauge_id", gauge.getFlysId())
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
195 .executeQuery();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
196
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
197 int flysId;
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
198
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
199 try {
5480
7a68967ca72a AFT/DIPS: Small fixes and workarounds for Oracle DB problems.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5258
diff changeset
200 if (!rs.next()) {
5258
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
201 log.error(
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
202 "FLYS: No master discharge table found for gauge '" +
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
203 gauge.getAftName() + "'");
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
204 return false;
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
205 }
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
206 String bfgId = rs.getString("bfg_id");
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
207 if (!rs.wasNull()) { // already has BFG_ID
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
208 return false;
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
209 }
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
210 flysId = rs.getInt("id");
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
211 } finally {
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
212 rs.close();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
213 }
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
214
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
215 // We need to find out the BFG_ID of the current discharge table
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
216 // for this gauge in AFT.
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
217
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
218 ConnectedStatements aftStatements = context.getAftStatements();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
219
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
220 rs = aftStatements
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
221 .getStatement("select.bfg.id.current")
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
222 .clearParameters()
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
223 .setString("number", "%" + gauge.getOfficialNumber())
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
224 .executeQuery();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
225
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
226 String bfgId = null;
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
227
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
228 try {
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
229 if (rs.next()) {
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
230 bfgId = rs.getString("BFG_ID");
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
231 }
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
232 } finally {
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
233 rs.close();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
234 }
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
235
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
236 if (bfgId == null) {
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
237 log.warn(
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
238 "No BFG_ID found for current discharge table of gauge '" +
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
239 gauge + "'");
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
240 return false;
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
241 }
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
242
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
243 // Set the BFG_ID in FLYS.
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
244 flysStatements.beginTransaction();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
245 try {
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
246 flysStatements
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
247 .getStatement("update.bfg.id.discharge.table")
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
248 .clearParameters()
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
249 .setInt("id", flysId)
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
250 .setString("bfg_id", bfgId)
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
251 .executeUpdate();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
252 flysStatements.commitTransaction();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
253 } catch (SQLException sqle) {
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
254 flysStatements.rollbackTransaction();
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
255 log.error(sqle, sqle);
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
256 return false;
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
257 }
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
258
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
259 return true;
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
260 }
da1e897c7224 Set the BFG_ID for current discharge tables in FLYS.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5188
diff changeset
261
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
262 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
263 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
264 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
265 )
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
266 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
267 {
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
268 log.info("FLYS: Updating gauge '" + gauge.getAftName() + "'.");
4775
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
269 // We need to load all discharge tables from both databases
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
270 // of the gauge and do some pairing based on their bfg_id.
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
271
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
272 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
273
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
274 ConnectedStatements flysStatements = context.getFlysStatements();
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
275
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
276 flysStatements.beginTransaction();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
277 try {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
278 List<DischargeTable> flysDTs =
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
279 DischargeTable.loadFlysDischargeTables(
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
280 context, gauge.getFlysId());
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
281
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
282 List<DischargeTable> aftDTs =
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
283 DischargeTable.loadAftDischargeTables(
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
284 context, gauge.getOfficialNumber());
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
285
4775
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
286 Map<String, DischargeTable> bfgId2FlysDT =
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
287 new HashMap<String, DischargeTable>();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
288
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
289 for (DischargeTable dt: flysDTs) {
4775
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
290 String bfgId = dt.getBfgId();
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
291 if (bfgId == null) {
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
292 log.warn("FLYS: discharge table " + dt.getId()
4775
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
293 + " has no bfg_id. Ignored.");
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
294 continue;
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
295 }
4775
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
296 bfgId2FlysDT.put(bfgId, dt);
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
297 }
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
298
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
299 List<DischargeTable> createDTs = new ArrayList<DischargeTable>();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
300
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
301 for (DischargeTable aftDT: aftDTs) {
4775
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
302 String bfgId = aftDT.getBfgId();
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
303 DischargeTable flysDT = bfgId2FlysDT.remove(bfgId);
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
304 if (flysDT != null) {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
305 // Found in AFT and FLYS.
4775
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
306 log.info("FLYS: Discharge table '" + bfgId
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
307 + "' found in AFT and FLYS. -> update");
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
308 // Create the W/Q diff.
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
309 modified |= writeWQChanges(context, flysDT, aftDT);
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
310 }
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
311 else {
4775
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
312 log.info("FLYS: Discharge table '" + bfgId
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
313 + "' not found in FLYS. -> create");
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
314 createDTs.add(aftDT);
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
315 }
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
316 }
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
317
4775
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
318 for (String bfgId: bfgId2FlysDT.keySet()) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4774
diff changeset
319 log.info("FLYS: Discharge table '" + bfgId
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
320 + "' found in FLYS but not in AFT. -> ignore");
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
321 }
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
322
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
323 log.info("FLYS: Copy " + createDTs.size() +
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
324 " discharge tables over from AFT.");
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
325
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
326 // Create the new discharge tables.
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
327 for (DischargeTable aftDT: createDTs) {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
328 createDischargeTable(context, aftDT, gauge.getFlysId());
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
329 modified = true;
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
330 }
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
331
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
332 flysStatements.commitTransaction();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
333 }
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
334 catch (SQLException sqle) {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
335 flysStatements.rollbackTransaction();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
336 log.error(sqle, sqle);
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
337 modified = false;
4100
981de0b77c6b If gauges exist in FLYS and AFT store the discharge tables in FLYS that are only in AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
338 }
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
339
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
340 return modified;
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
341 }
4079
42094f01afa6 Added model for DIPS gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4078
diff changeset
342
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
343 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
344 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
345 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
346 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
347 )
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
348 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
349 {
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
350 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
351 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
352 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
353 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
354 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
355 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
356 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
357 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
358 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
359
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
360 protected boolean createGauges(
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
361 SyncContext context,
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
362 Map<Long, DIPSGauge> gauges
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
363 )
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
364 throws SQLException
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
365 {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
366 ConnectedStatements flysStatements = context.getFlysStatements();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
367
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
368 SymbolicStatement.Instance nextId =
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
369 flysStatements.getStatement("next.gauge.id");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
370
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
371 SymbolicStatement.Instance insertStmnt =
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
372 flysStatements.getStatement("insert.gauge");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
373
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
374 boolean modified = false;
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
375
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
376 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
377 Long officialNumber = entry.getKey();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
378 DIPSGauge gauge = entry.getValue();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
379
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
380 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
381 "' 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
382
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
383 if (!gauge.hasDatums()) {
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
384 log.warn("DIPS: Gauge '" +
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
385 gauge.getAftName() + "' has no datum. Ignored.");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
386 continue;
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
387 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
388
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
389 ResultSet rs = null;
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
390 flysStatements.beginTransaction();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
391 try {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
392 (rs = nextId.executeQuery()).next();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
393 int gaugeId = rs.getInt("gauge_id");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
394 rs.close(); rs = null;
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
395
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
396 insertStmnt
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
397 .clearParameters()
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
398 .setInt("id", gaugeId)
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
399 .setString("name", gauge.getAftName())
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
400 .setInt("river_id", id1)
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
401 .setDouble("station", gauge.getStation())
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
402 .setDouble("aeo", gauge.getAeo())
4100
981de0b77c6b If gauges exist in FLYS and AFT store the discharge tables in FLYS that are only in AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
403 .setLong("official_number", officialNumber)
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
404 .setDouble("datum", gauge.getLatestDatum().getValue());
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
405
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
406 insertStmnt.execute();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
407
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
408 log.info("FLYS: Created gauge '" + gauge.getAftName() +
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
409 "' with id " + gaugeId + ".");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
410
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
411 gauge.setFlysId(gaugeId);
4100
981de0b77c6b If gauges exist in FLYS and AFT store the discharge tables in FLYS that are only in AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
412 createDischargeTables(context, gauge);
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
413 flysStatements.commitTransaction();
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
414 modified = true;
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
415 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
416 catch (SQLException sqle) {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
417 flysStatements.rollbackTransaction();
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
418 log.error(sqle, sqle);
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
419 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
420 finally {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
421 if (rs != null) {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
422 rs.close();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
423 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
424 }
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
425 }
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
426
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
427 return modified;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
428 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
429
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
430 protected void createDischargeTable(
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
431 SyncContext context,
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
432 DischargeTable aftDT,
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
433 int flysGaugeId
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
434 )
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
435 throws SQLException
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
436 {
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
437 aftDT.persistFlysTimeInterval(context);
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
438 int flysId = aftDT.persistFlysDischargeTable(context, flysGaugeId);
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
439
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
440 aftDT.loadAftValues(context);
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
441 aftDT.storeFlysValues(context, flysId);
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
442 }
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
443
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
444 protected void createDischargeTables(
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
445 SyncContext context,
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
446 DIPSGauge gauge
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
447 )
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
448 throws SQLException
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
449 {
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
450 log.info("FLYS: Create discharge tables for '" +
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
451 gauge.getAftName() + "'.");
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
452
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
453 // 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
454 List<DischargeTable> dts = loadAftDischargeTables(
4100
981de0b77c6b If gauges exist in FLYS and AFT store the discharge tables in FLYS that are only in AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
455 context, gauge);
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
456
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
457 // 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
458 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
459
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
460 // Persist the discharge tables
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
461 int [] flysDTIds = persistFlysDischargeTables(
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
462 context, dts, 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
463
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
464 // 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
465 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
466 }
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
467
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
468 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
469 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
470 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
471 )
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
472 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
473 {
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
474 return DischargeTable.loadAftDischargeTables(
4100
981de0b77c6b If gauges exist in FLYS and AFT store the discharge tables in FLYS that are only in AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
475 context, gauge.getOfficialNumber(), 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
476 }
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
477
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
478 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
479 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
480 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
481 )
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
482 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
483 {
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
484 for (DischargeTable dt: dts) {
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
485 dt.persistFlysTimeInterval(context);
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
486 }
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
487 }
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
488
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
489 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
490 SyncContext context,
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
491 List<DischargeTable> dts,
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
492 int flysGaugeId
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
493 )
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
494 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
495 {
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
496 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
497
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
498 for (int i = 0; i < flysDTIds.length; ++i) {
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
499 flysDTIds[i] = dts.get(i)
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4100
diff changeset
500 .persistFlysDischargeTable(context, flysGaugeId);
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
501 }
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
502
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
503 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
504 }
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
505
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
506 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
507 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
508 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
509 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
510 )
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
511 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
512 {
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
513 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
514 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
515 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
516 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
517 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
518 }
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
519 }
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
520
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
521 public String toString() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
522 return "[River: name=" + name + ", " + super.toString() + "]";
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
523 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
524 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
525 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org