annotate etl/src/main/java/org/dive4elements/river/etl/aft/DischargeTable.java @ 5917:c73977be1795

ETL: Do not ignore open ended discharge tables.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 07 May 2013 19:53:48 +0200
parents 8bd9b551456c
children 6f80d5f375fd
rev   line source
5841
8bd9b551456c Added header to Java files in ETL process.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
8bd9b551456c Added header to Java files in ETL process.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
8bd9b551456c Added header to Java files in ETL process.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
8bd9b551456c Added header to Java files in ETL process.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
8bd9b551456c Added header to Java files in ETL process.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8bd9b551456c Added header to Java files in ETL process.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
8bd9b551456c Added header to Java files in ETL process.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
8bd9b551456c Added header to Java files in ETL process.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5826
9438e9259213 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5825
diff changeset
9 package org.dive4elements.river.etl.aft;
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
5826
9438e9259213 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5825
diff changeset
11 import org.dive4elements.river.etl.db.ConnectedStatements;
9438e9259213 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5825
diff changeset
12 import org.dive4elements.river.etl.db.SymbolicStatement;
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
13
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
14 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
15 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
16 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
17
4772
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
18 import java.util.ArrayList;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
19 import java.util.Date;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
20 import java.util.List;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
21 import java.util.Set;
f939e1e6cfa4 Sorted imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
22 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
23
4101
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
24 import org.apache.log4j.Logger;
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
25
5372
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4775
diff changeset
26 /** A Discharge Table. */
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 public class DischargeTable
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 {
4101
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
29 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
30
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 protected int id;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 protected int gaugeId;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 protected TimeInterval timeInterval;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 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
35 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
36 protected Set<WQ> values;
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 public DischargeTable() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 public DischargeTable(
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
42 int gaugeId,
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
43 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
44 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
45 String bfgId
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 ) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 this.gaugeId = gaugeId;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 this.timeInterval = timeInterval;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 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
50 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
51 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
52 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 public DischargeTable(
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
55 int id,
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
56 int gaugeId,
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
57 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
58 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
59 String bfgId
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 ) {
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
61 this(gaugeId, timeInterval, description, bfgId);
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 this.id = id;
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
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 public int getId() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 return id;
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
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 public void setId(int id) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 this.id = id;
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
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 public int getGaugeId() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 return gaugeId;
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
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 public void setGaugeId(int gaugeId) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 this.gaugeId = gaugeId;
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
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 public TimeInterval getTimeInterval() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 return timeInterval;
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
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 public void setTimeInterval(TimeInterval timeInterval) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 this.timeInterval = timeInterval;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 public String getDescription() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 return description;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 public void setDescription(String description) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 this.description = description;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 }
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
96
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
97 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
98 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
99 }
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
100
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
101 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
102 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
103 }
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
104
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
105
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
106 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
107 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
108 }
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
109
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
110 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
111 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
112 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
113
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
114 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
115 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
116 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
117
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
118
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
119 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
120 throws SQLException
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 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
123 while (rs.next()) {
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
124 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
125 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
126 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
127 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
128 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
129 }
4091
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 rs.close();
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
132 }
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
133
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
134 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
135 loadValues(context.getAftStatements()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
136 .getStatement("select.tafelwert")
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
137 .clearParameters()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
138 .setInt("number", getId()));
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
139 }
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
140
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
141 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
142 loadValues(context.getFlysStatements()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
143 .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
144 .clearParameters()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
145 .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
146 }
4092
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
147
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
148 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
149 SyncContext context,
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
150 int dischargeTableId
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
151 )
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
152 throws SQLException
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
153 {
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
154 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
155
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
156 // 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
157 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
158 .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
159
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
160 // 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
161 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
162 .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
163
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
164 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
165 int wqId;
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
166 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
167 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
168 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
169 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
170 }
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
171 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
172 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
173 }
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
174
4092
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
175 insertDTV
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
176 .clearParameters()
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
177 .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
178 .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
179 .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
180 .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
181 .execute();
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
182 }
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
183 }
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
184
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 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
186 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
187 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
188 )
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 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
190 {
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
191 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
192
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
193 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
194 .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
195 .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
196 .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
197 .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
198 .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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
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 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
208 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
209 }
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 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
211 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
212 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
213 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
214 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
215 }
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 }
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
217 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
218 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
219 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
220 ? 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
221 : 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
222
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
223 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
224 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
225 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
226 }
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
227 }
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
228 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
229 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
230 }
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
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 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
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 )
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 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
240 {
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 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
242 }
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 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
245 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
246 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
247 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
248 )
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 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
250 {
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
251 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
252
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
253 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
254 .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
255 .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
256 .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
257 .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
258 .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
259 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
260 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
261 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
262 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
263 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
264
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
265 if (from == null) {
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4477
diff changeset
266 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
267 + 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
268 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
269 }
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
270
5917
c73977be1795 ETL: Do not ignore open ended discharge tables.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5841
diff changeset
271 if (to != null && from.after(to)) {
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
272 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
273 + 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
274 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
275 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
276 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
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
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 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
280 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
281 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
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
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 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
285 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
286 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
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
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 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
290 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
291 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
292 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
293 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
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
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 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
298
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 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
300 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
301 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
302 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
303 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
304 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
305 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
306 }
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
307 }
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
308 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
309 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
310 }
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
311
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 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
313 }
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
314
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 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
316 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
317 )
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 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
319 {
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 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
321 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
322 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
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
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 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
327 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
328 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
329 )
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 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
331 {
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 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
333 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
334
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
335 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
336
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
337 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
338 .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
339 .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
340 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
341 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
342 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
343 }
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 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
345 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
346 }
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
347
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 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
349 .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
350 .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
351 .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
352 .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
353 .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
354 .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
355
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 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
357 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
358 }
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 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
360 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
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
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 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
364
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 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
366 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
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
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 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
370 }
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
371 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
372 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org