annotate flys-aft/src/main/java/de/intevation/aft/DischargeTable.java @ 4963:1469066cc7d9 dami

Importer: Fix the order of the config check
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 04 Feb 2013 17:54:39 +0100
parents d9f1202cef78
children ae3625b89cfd
rev   line source
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.aft;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
3 import de.intevation.db.ConnectedStatements;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
4 import de.intevation.db.SymbolicStatement;
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
5
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
6 import java.sql.ResultSet;
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
7 import java.sql.SQLException;
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
8 import java.sql.Types;
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
9
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
10 import java.util.ArrayList;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
11 import java.util.Date;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
12 import java.util.List;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
13 import java.util.Set;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
14 import java.util.TreeSet;
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
15
4101
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
16 import org.apache.log4j.Logger;
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
17
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 public class DischargeTable
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 {
4101
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
20 private static Logger log = Logger.getLogger(DischargeTable.class);
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
21
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 protected int id;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 protected int gaugeId;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 protected TimeInterval timeInterval;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 protected String description;
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: 4772
diff changeset
26 protected String bfgId;
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
27 protected Set<WQ> values;
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 public DischargeTable() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 public DischargeTable(
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
33 int gaugeId,
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
34 TimeInterval timeInterval,
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: 4772
diff changeset
35 String description,
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
36 String bfgId
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 ) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 this.gaugeId = gaugeId;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 this.timeInterval = timeInterval;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 this.description = description;
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: 4772
diff changeset
41 this.bfgId = bfgId;
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
42 values = new TreeSet<WQ>(WQ.EPS_CMP);
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 public DischargeTable(
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
46 int id,
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
47 int gaugeId,
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
48 TimeInterval timeInterval,
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: 4772
diff changeset
49 String description,
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
50 String bfgId
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 ) {
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: 4772
diff changeset
52 this(gaugeId, timeInterval, description, bfgId);
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 this.id = id;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 public int getId() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 return id;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 public void setId(int id) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 this.id = id;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 public int getGaugeId() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 return gaugeId;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 public void setGaugeId(int gaugeId) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 this.gaugeId = gaugeId;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 public TimeInterval getTimeInterval() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 return timeInterval;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 public void setTimeInterval(TimeInterval timeInterval) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 this.timeInterval = timeInterval;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 public String getDescription() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 return description;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 public void setDescription(String description) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 this.description = description;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 }
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
87
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: 4772
diff changeset
88 public String 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: 4772
diff changeset
89 return bfgId;
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
90 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
91
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
92 public void setBfgId(String bfgId) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
93 this.bfgId = bfgId;
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
94 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
95
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
96
4093
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4092
diff changeset
97 public void clearValues() {
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4092
diff changeset
98 values.clear();
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4092
diff changeset
99 }
7bddd4601707 Copy over W/Q values from AFT to FLYS for new discharge tables.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4092
diff changeset
100
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
101 public Set<WQ> getValues() {
4099
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
102 return values;
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
103 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
104
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
105 public void setValues(Set<WQ> values) {
4099
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
106 this.values = values;
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
107 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
108
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
109
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
110 protected void loadValues(SymbolicStatement.Instance query)
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
111 throws SQLException
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
112 {
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
113 ResultSet rs = query.executeQuery();
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
114 while (rs.next()) {
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
115 int id = rs.getInt("id");
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
116 double w = rs.getDouble("w");
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
117 double q = rs.getDouble("q");
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
118 if (!values.add(new WQ(id, w, q))) {
4110
06891562e633 Extracted and documented the error messages of the process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4105
diff changeset
119 log.warn("FLYS/AFT: Value duplication w="+w+" q="+q+". -> ignore.");
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
120 }
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
121 }
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
122 rs.close();
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
123 }
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
124
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
125 public void loadAftValues(SyncContext context) throws SQLException {
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
126 loadValues(context.getAftStatements()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
127 .getStatement("select.tafelwert")
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
128 .clearParameters()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
129 .setInt("number", getId()));
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
130 }
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
131
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
132 public void loadFlysValues(SyncContext context) throws SQLException {
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
133 loadValues(context.getFlysStatements()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
134 .getStatement("select.discharge.table.values")
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
135 .clearParameters()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
136 .setInt("table_id", getId()));
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
137 }
4092
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
138
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
139 public void storeFlysValues(
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
140 SyncContext context,
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
141 int dischargeTableId
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
142 )
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
143 throws SQLException
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
144 {
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
145 ConnectedStatements flysStatements = context.getFlysStatements();
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
146
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
147 // Create the ids.
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
148 SymbolicStatement.Instance nextId = flysStatements
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
149 .getStatement("next.discharge.table.values.id");
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
150
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
151 // Insert the values.
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
152 SymbolicStatement.Instance insertDTV = flysStatements
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
153 .getStatement("insert.discharge.table.value");
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
154
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
155 for (WQ wq: values) {
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: 4772
diff changeset
156 int wqId;
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
157 ResultSet rs = nextId.executeQuery();
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: 4772
diff changeset
158 try {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
159 rs.next();
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
160 wqId = rs.getInt("discharge_table_values_id");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
161 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
162 finally {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
163 rs.close();
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
164 }
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
165
4092
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
166 insertDTV
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
167 .clearParameters()
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
168 .setInt("id", wqId)
4092
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
169 .setInt("table_id", dischargeTableId)
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
170 .setDouble("w", wq.getW())
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
171 .setDouble("q", wq.getQ())
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
172 .execute();
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
173 }
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
174 }
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
175
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
176 public static List<DischargeTable> loadFlysDischargeTables(
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
177 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: 4093
diff changeset
178 int gaugeId
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
179 )
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
180 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: 4093
diff changeset
181 {
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
182 List<DischargeTable> dts = new ArrayList<DischargeTable>();
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
183
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
184 ResultSet rs = context
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
185 .getFlysStatements()
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
186 .getStatement("select.gauge.discharge.tables")
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
187 .clearParameters()
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
188 .setInt("gauge_id", gaugeId)
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
189 .executeQuery();
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: 4772
diff changeset
190 try {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
191 OUTER: while (rs.next()) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
192 int id = rs.getInt("id");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
193 String description = rs.getString("description");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
194 String bfgId = rs.getString("bfg_id");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
195 if (description == null) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
196 description = "";
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
197 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
198 if (bfgId == null) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
199 bfgId = "";
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
200 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
201 for (DischargeTable dt: dts) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
202 if (dt.getBfgId().equals(bfgId)) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
203 log.warn("FLYS: Found discharge table '" +
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
204 bfgId + "' with same bfg_id. -> ignore");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
205 continue OUTER;
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
206 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
207 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
208 Date startTime = rs.getDate("start_time");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
209 Date stopTime = rs.getDate("stop_time");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
210 TimeInterval ti = startTime == null
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
211 ? null
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
212 : new TimeInterval(startTime, stopTime);
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
213
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: 4772
diff changeset
214 DischargeTable dt = new DischargeTable(
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
215 id, gaugeId, ti, description, bfgId);
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
216 dts.add(dt);
4105
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
217 }
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
218 }
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: 4772
diff changeset
219 finally {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
220 rs.close();
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
221 }
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
222
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
223 return dts;
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
224 }
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
225
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
226 public static List<DischargeTable> loadAftDischargeTables(
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
227 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: 4093
diff changeset
228 Long officialNumber
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
229 )
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
230 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: 4093
diff changeset
231 {
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
232 return loadAftDischargeTables(context, officialNumber, 0);
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
233 }
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
234
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
235 public static List<DischargeTable> loadAftDischargeTables(
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
236 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: 4093
diff changeset
237 Long officialNumber,
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
238 int flysGaugeId
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
239 )
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
240 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: 4093
diff changeset
241 {
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
242 List<DischargeTable> dts = new ArrayList<DischargeTable>();
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
243
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
244 ResultSet rs = context
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
245 .getAftStatements()
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
246 .getStatement("select.abflusstafel")
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
247 .clearParameters()
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
248 .setString("number", "%" + officialNumber)
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
249 .executeQuery();
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: 4772
diff changeset
250 try {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
251 OUTER: while (rs.next()) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
252 int dtId = rs.getInt("ABFLUSSTAFEL_NR");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
253 Date from = rs.getDate("GUELTIG_VON");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
254 Date to = rs.getDate("GUELTIG_BIS");
4101
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
255
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: 4772
diff changeset
256 if (from == null) {
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
257 log.warn("AFT: ABFLUSSTAFEL_NR = "
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: 4772
diff changeset
258 + dtId + ": GUELTIG_VON = NULL -> ignored.");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
259 }
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
260
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: 4772
diff changeset
261 if (to == null) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
262 log.warn("AFT: ABFLUSSTAFEL_NR = "
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
263 + dtId + ": GUELTIG_BIS = NULL -> ignored.");
4105
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
264 }
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
265
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: 4772
diff changeset
266 if (from == null || to == null) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
267 continue;
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
268 }
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
269
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: 4772
diff changeset
270 if (from.compareTo(to) > 0) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
271 log.warn("AFT: ABFLUSSTAFEL_NR = "
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
272 + dtId + ": " + from + " > " + to + ". -> swap");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
273 Date temp = from;
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
274 from = to;
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
275 to = temp;
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
276 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
277
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
278 String description = rs.getString("ABFLUSSTAFEL_BEZ");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
279 if (description == null) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
280 description = String.valueOf(officialNumber);
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
281 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
282
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
283 String bfgId = rs.getString("BFG_ID");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
284 if (bfgId == null) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
285 bfgId = "";
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
286 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
287
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
288 for (DischargeTable dt: dts) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
289 if (dt.getBfgId().equals(bfgId)) {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
290 log.warn("AFT: Found discharge table '" +
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
291 bfgId + "' with same bfg_id. -> ignore.");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
292 continue OUTER;
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
293 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
294 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
295
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
296 TimeInterval timeInterval = new TimeInterval(from, to);
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
297
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
298 DischargeTable dt = new DischargeTable(
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
299 dtId,
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
300 flysGaugeId,
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
301 timeInterval,
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
302 description,
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
303 bfgId);
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
304 dts.add(dt);
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
305 }
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
306 }
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: 4772
diff changeset
307 finally {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
308 rs.close();
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
309 }
4097
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
310
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
311 return dts;
83c72bc07591 Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4093
diff changeset
312 }
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
313
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
314 public void persistFlysTimeInterval(
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
315 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: 4101
diff changeset
316 )
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
317 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: 4101
diff changeset
318 {
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
319 if (timeInterval != null) {
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
320 timeInterval = context.fetchOrCreateFLYSTimeInterval(
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
321 timeInterval);
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
322 }
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
323 }
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
324
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
325 public int persistFlysDischargeTable(
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
326 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: 4101
diff changeset
327 int gaugeId
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
328 )
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
329 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: 4101
diff changeset
330 {
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
331 ConnectedStatements flysStatements =
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
332 context.getFlysStatements();
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
333
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: 4772
diff changeset
334 int flysId;
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
335
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
336 ResultSet rs = flysStatements
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
337 .getStatement("next.discharge.id")
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
338 .executeQuery();
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: 4772
diff changeset
339 try {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
340 rs.next();
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
341 flysId = rs.getInt("discharge_table_id");
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
342 }
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
343 finally {
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
344 rs.close();
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
345 }
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
346
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
347 SymbolicStatement.Instance insertDT = flysStatements
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
348 .getStatement("insert.dischargetable")
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
349 .clearParameters()
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
350 .setInt("id", flysId)
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
351 .setInt("gauge_id", gaugeId)
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: 4772
diff changeset
352 .setString("description", description)
d9f1202cef78 Do the pairing of FLYS and AFT discharge tables by the field 'ABFLUSSTAFEL.BFG_ID' in
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4772
diff changeset
353 .setString("bfg_id", bfgId);
4102
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
354
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
355 if (timeInterval != null) {
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
356 insertDT.setInt("time_interval_id", timeInterval.getId());
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
357 }
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
358 else {
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
359 insertDT.setNull("time_interval_id", Types.INTEGER);
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
360 }
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
361
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
362 insertDT.execute();
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
363
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
364 if (log.isDebugEnabled()) {
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
365 log.debug("FLYS: Created discharge table id: " + id);
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
366 }
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
367
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
368 return flysId;
e8967ee1cb05 Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4101
diff changeset
369 }
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
370 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
371 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org