annotate flys-aft/src/main/java/de/intevation/aft/River.java @ 4753:a310aceb2e51

Fetch calculation range (Berechnungsstrecke) for FLYS rivers, too.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 03 Jan 2013 14:19:45 +0100
parents b195fede1c3b
children 04377ccef10a
rev   line source
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.aft;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
3 import java.util.List;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
4 import java.util.ArrayList;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
5 import java.util.HashMap;
4078
0944cdd2ee90 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4077
diff changeset
6 import java.util.Map;
0944cdd2ee90 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4077
diff changeset
7
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
8 import java.sql.ResultSet;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 import java.sql.SQLException;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import org.apache.log4j.Logger;
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import de.intevation.db.ConnectedStatements;
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
14 import de.intevation.db.SymbolicStatement;
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
4084
9178beeb7b05 Moved DIPS gauge number -> DIPS gauge index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
68 Map<Long, DIPSGauge> dipsGauges = context.getDIPSGauges();
4081
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
69
4077
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
70 ConnectedStatements flysStatements = context.getFlysStatements();
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
71 ConnectedStatements aftStatements = context.getAftStatements();
97de7a552b79 Load DIPS XML
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4076
diff changeset
72
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
73 ResultSet messstellenRs = aftStatements
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
74 .getStatement("select.messstelle")
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
75 .clearParameters()
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
76 .setInt("GEWAESSER_NR", id2).executeQuery();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
77
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
78 String riverName = getName();
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
79
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
80 Map<Long, DIPSGauge> aftDIPSGauges = new HashMap<Long, DIPSGauge>();
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
81
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
82 while (messstellenRs.next()) {
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
83 String name = messstellenRs.getString("NAME");
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
84 String num = messstellenRs.getString("MESSSTELLE_NR");
4084
9178beeb7b05 Moved DIPS gauge number -> DIPS gauge index.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4083
diff changeset
85 Long number = SyncContext.numberToLong(num);
4081
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
86 if (number == null) {
4110
06891562e633 Extracted and documented the error messages of the process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4104
diff changeset
87 log.warn("AFT: Invalid MESSSTELLE_NR for MESSSTELLE '"+name+"'");
4081
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
88 continue;
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
89 }
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
90 DIPSGauge dipsGauge = dipsGauges.get(number);
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
91 if (dipsGauge == null) {
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
92 log.warn(
4110
06891562e633 Extracted and documented the error messages of the process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4104
diff changeset
93 "DIPS: MESSSTELLE '" + name + "' not found in DIPS. " +
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
94 "Gauge number used for lookup: " + number);
4081
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
95 continue;
7a7b0f0cb653 Check if AFT gauges are in DIPS, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4079
diff changeset
96 }
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
97 String gaugeRiver = dipsGauge.getRiverName();
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
98 if (!gaugeRiver.equalsIgnoreCase(riverName)) {
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
99 log.warn(
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
100 "DIPS: MESSSTELLE '" + name +
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
101 "' is assigned to river '" + gaugeRiver +
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
102 "'. Needs to be on '" + riverName + "'.");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
103 continue;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
104 }
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
105 dipsGauge.setAftName(name);
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
106 dipsGauge.setOfficialNumber(number);
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
107 aftDIPSGauges.put(number, dipsGauge);
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
108 }
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
109
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
110 messstellenRs.close();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
111
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
112 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
113
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
114 ResultSet gaugesRs = flysStatements
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
115 .getStatement("select.gauges")
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
116 .clearParameters()
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
117 .setInt("river_id", id1).executeQuery();
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
118
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
119 while (gaugesRs.next()) {
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
120 int gaugeId = gaugesRs.getInt("id");
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
121 String name = gaugesRs.getString("name");
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
122 long number = gaugesRs.getLong("official_number");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
123 if (gaugesRs.wasNull()) {
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
124 log.warn("FLYS: Gauge '" + name +
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
125 "' has no official number. Ignored.");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
126 continue;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
127 }
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
128 Long key = Long.valueOf(number);
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
129 DIPSGauge aftDIPSGauge = aftDIPSGauges.remove(key);
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
130 if (aftDIPSGauge == null) {
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
131 log.warn("FLYS: Gauge '" + name + "' number " + number +
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
132 " is not found in AFT/DIPS.");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
133 continue;
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
134 }
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
135 aftDIPSGauge.setFlysId(gaugeId);
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
136 log.info("Gauge '" + name +
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
137 "' found in FLYS, AFT and DIPS. -> Update");
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
138 updateGauges.add(aftDIPSGauge);
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
139 }
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
140 gaugesRs.close();
4076
039413d7e394 Load gauges from both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4075
diff changeset
141
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
142 boolean modified = createGauges(context, aftDIPSGauges);
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
143
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
144 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
145
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
146 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
147 }
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
148
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
149 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
150 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
151 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
152 )
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
153 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
154 {
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
155 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
156
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
157 for (DIPSGauge gauge: gauges) {
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
158 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
159 }
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
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 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
162 }
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 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
165 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
166 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
167 )
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 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
169 {
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
170 log.info("FLYS: Updating gauge '" + gauge.getAftName() + "'.");
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
171 // We need to load all discharge tables from both database
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
172 // of the gauge and do some pairing based on their descriptions.
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4094
diff changeset
173
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
174 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
175
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
176 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
177
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
178 flysStatements.beginTransaction();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
179 try {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
180 List<DischargeTable> flysDTs =
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
181 DischargeTable.loadFlysDischargeTables(
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
182 context, gauge.getFlysId());
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
183
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
184 List<DischargeTable> aftDTs =
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
185 DischargeTable.loadAftDischargeTables(
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
186 context, gauge.getOfficialNumber());
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
187
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
188 Map<String, DischargeTable> desc2FlysDT =
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
189 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
190
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
191 for (DischargeTable dt: flysDTs) {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
192 String description = dt.getDescription();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
193 if (description == null) {
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
194 log.warn("FLYS: discharge table " + dt.getId()
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
195 + " has no description. Ignored.");
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
196 continue;
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
197 }
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
198 desc2FlysDT.put(description, 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
199 }
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
200
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
201 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
202
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
203 for (DischargeTable aftDT: aftDTs) {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
204 String description = aftDT.getDescription();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
205 DischargeTable flysDT = desc2FlysDT.remove(description);
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
206 if (flysDT != null) {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
207 // Found in AFT and FLYS.
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
208 log.info("FLYS: Discharge table '" + description
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
209 + "' 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
210 // 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
211 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
212 }
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
213 else {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
214 log.info("FLYS: Discharge table '" + description
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
215 + "' 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
216 createDTs.add(aftDT);
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
217 }
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
218 }
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
219
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
220 for (String description: desc2FlysDT.keySet()) {
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
221 log.info("FLYS: Discharge table '" + description
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
222 + "' 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
223 }
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
224
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
225 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
226 " 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
227
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
228 // 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
229 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
230 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
231 modified = true;
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
232 }
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
233
4104
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
234 flysStatements.commitTransaction();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
235 }
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
236 catch (SQLException sqle) {
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
237 flysStatements.rollbackTransaction();
cdcf98245e36 Commit/rollback changes if a gauge is only updated.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
238 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
239 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
240 }
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
241
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
242 return modified;
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
243 }
4079
42094f01afa6 Added model for DIPS gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4078
diff changeset
244
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
245 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
246 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
247 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
248 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
249 )
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
250 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
251 {
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
252 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
253 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
254 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
255 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
256 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
257 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
258 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
259 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
260 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4098
diff changeset
261
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
262 protected boolean createGauges(
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
263 SyncContext context,
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
264 Map<Long, DIPSGauge> gauges
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
265 )
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
266 throws SQLException
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
267 {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
268 ConnectedStatements flysStatements = context.getFlysStatements();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
269
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
270 SymbolicStatement.Instance nextId =
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
271 flysStatements.getStatement("next.gauge.id");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
272
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
273 SymbolicStatement.Instance insertStmnt =
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
274 flysStatements.getStatement("insert.gauge");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
275
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
276 boolean modified = false;
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
277
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
278 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
279 Long officialNumber = entry.getKey();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
280 DIPSGauge gauge = entry.getValue();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
281
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
282 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
283 "' 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
284
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
285 if (!gauge.hasDatums()) {
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
286 log.warn("DIPS: Gauge '" +
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
287 gauge.getAftName() + "' has no datum. Ignored.");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
288 continue;
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
289 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
290
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
291 ResultSet rs = null;
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
292 flysStatements.beginTransaction();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
293 try {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
294 (rs = nextId.executeQuery()).next();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
295 int gaugeId = rs.getInt("gauge_id");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
296 rs.close(); rs = null;
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
297
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
298 insertStmnt
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
299 .clearParameters()
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
300 .setInt("id", gaugeId)
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
301 .setString("name", gauge.getAftName())
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
302 .setInt("river_id", id1)
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
303 .setDouble("station", gauge.getStation())
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
304 .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
305 .setLong("official_number", officialNumber)
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
306 .setDouble("datum", gauge.getLatestDatum().getValue());
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
307
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
308 insertStmnt.execute();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
309
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
310 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
311 "' with id " + gaugeId + ".");
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
312
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
313 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
314 createDischargeTables(context, gauge);
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
315 flysStatements.commitTransaction();
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
316 modified = true;
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
317 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
318 catch (SQLException sqle) {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
319 flysStatements.rollbackTransaction();
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
320 log.error(sqle, sqle);
4087
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
321 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
322 finally {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
323 if (rs != null) {
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
324 rs.close();
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
325 }
aad1886ea226 Store new gauges in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4085
diff changeset
326 }
4085
067341e86375 Separate FLYS gauges to be updated or to create.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4084
diff changeset
327 }
4094
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
328
b20b710aa86f Bubble up modifications up to main().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
329 return modified;
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
330 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
331
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
332 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
333 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
334 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
335 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
336 )
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
337 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
338 {
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
339 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
340 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
341
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
342 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
343 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
344 }
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
345
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
346 protected void createDischargeTables(
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
347 SyncContext context,
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
348 DIPSGauge gauge
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
349 )
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
350 throws SQLException
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
351 {
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
352 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
353 gauge.getAftName() + "'.");
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
354
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
355 // 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
356 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
357 context, gauge);
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
358
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
359 // 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
360 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
361
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
362 // 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
363 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
364 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
365
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
366 // 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
367 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
368 }
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
369
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
370 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
371 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
372 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
373 )
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
374 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
375 {
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
376 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
377 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
378 }
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
379
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
380 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
381 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
382 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
383 )
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
384 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
385 {
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
386 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
387 dt.persistFlysTimeInterval(context);
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
388 }
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
389 }
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4088
diff changeset
390
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
391 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
392 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
393 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
394 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
395 )
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
396 throws SQLException
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
397 {
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
398 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
399
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
400 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
401 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
402 .persistFlysDischargeTable(context, flysGaugeId);
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
403 }
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
404
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
405 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
406 }
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
407
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
408 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
409 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
410 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
411 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
412 )
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
413 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
414 {
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
415 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
416 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
417 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
418 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
419 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
420 }
4088
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
421 }
52cde7fe742a Fetch discharge table infos from AFT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4087
diff changeset
422
4075
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
423 public String toString() {
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
424 return "[River: name=" + name + ", " + super.toString() + "]";
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
425 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
426 }
dbd0b3b1b8b8 Sync each river.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
427 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org