annotate flys-aft/src/main/java/de/intevation/aft/DischargeTable.java @ 4572:4bd42fe098b4

i18n fix.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 27 Nov 2012 10:49:57 +0100
parents 79bb64f66c74
children b195fede1c3b
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
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
3 import java.util.List;
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
4 import java.util.Date;
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
5 import java.util.ArrayList;
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
6 import java.util.TreeSet;
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
7 import java.util.Set;
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
8
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
9 import java.sql.SQLException;
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
10 import java.sql.ResultSet;
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
11 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
12
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
13 import de.intevation.db.SymbolicStatement;
4092
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
14 import de.intevation.db.ConnectedStatements;
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;
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
26 protected Set<WQ> values;
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 public DischargeTable() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 }
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 public DischargeTable(
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 int gaugeId,
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 TimeInterval timeInterval,
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 String description
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 ) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 this.gaugeId = gaugeId;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 this.timeInterval = timeInterval;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 this.description = description;
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
39 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
40 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 public DischargeTable(
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 int id,
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 int gaugeId,
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 TimeInterval timeInterval,
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 String description
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 ) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 this(gaugeId, timeInterval, description);
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 this.id = id;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 public int getId() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 return 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 void setId(int id) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 this.id = 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 int getGaugeId() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 return gaugeId;
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 void setGaugeId(int gaugeId) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 this.gaugeId = 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 TimeInterval getTimeInterval() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 return timeInterval;
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 void setTimeInterval(TimeInterval timeInterval) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 this.timeInterval = 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 String getDescription() {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 return description;
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 void setDescription(String description) {
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 this.description = description;
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 }
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
83
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
84 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
85 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
86 }
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
87
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
88 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
89 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
90 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
91
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
92 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
93 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
94 }
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
95
006e99437fb9 Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4097
diff changeset
96
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
97 protected void loadValues(SymbolicStatement.Instance query)
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
98 throws SQLException
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
99 {
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
100 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
101 while (rs.next()) {
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
102 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
103 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
104 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
105 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
106 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
107 }
4091
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
108 }
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
109 rs.close();
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
110 }
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
111
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
112 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
113 loadValues(context.getAftStatements()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
114 .getStatement("select.tafelwert")
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
115 .clearParameters()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
116 .setInt("number", getId()));
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
117 }
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
118
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
119 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
120 loadValues(context.getFlysStatements()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
121 .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
122 .clearParameters()
a91c7e982c32 Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4090
diff changeset
123 .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
124 }
4092
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
125
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
126 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
127 SyncContext context,
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
128 int dischargeTableId
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
129 )
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
130 throws SQLException
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
131 {
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
132 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
133
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
134 // 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
135 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
136 .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
137
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
138 // 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
139 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
140 .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
141
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
142 for (WQ wq: values) {
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
143 ResultSet rs = nextId.executeQuery();
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
144 rs.next();
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
145 int wqId = rs.getInt("discharge_table_values_id");
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
146 rs.close();
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
147
4092
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
148 insertDTV
b3fc044f75ba Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4091
diff changeset
149 .clearParameters()
4103
2305731f563c Store W/Q in sets to prevent value duplications.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4102
diff changeset
150 .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
151 .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
152 .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
153 .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
154 .execute();
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 }
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
157
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
158 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
159 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
160 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
161 )
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
162 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
163 {
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
164 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
165
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
166 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
167 .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
168 .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
169 .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
170 .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
171 .executeQuery();
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
172
4105
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
173 OUTER: while (rs.next()) {
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
174 int id = rs.getInt("id");
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 String description = rs.getString("description");
4105
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
176 if (description == null) {
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
177 description = "";
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
178 }
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
179 for (DischargeTable dt: dts) {
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
180 if (dt.getDescription().equals(description)) {
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
181 log.warn("FLYS: Found discharge table '" +
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
182 description + "' with same description. -> ignore");
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
183 continue OUTER;
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
184 }
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
185 }
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
186 Date startTime = rs.getDate("start_time");
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
187 Date stopTime = rs.getDate("stop_time");
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
188 TimeInterval ti = startTime == null
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 ? null
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 : new TimeInterval(startTime, stopTime);
4105
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
191
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
192 DischargeTable dt = new 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
193 id, gaugeId, ti, description);
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 dts.add(dt);
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 }
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 rs.close();
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
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 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
199 }
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
200
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
201 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
202 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
203 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
204 )
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
205 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
206 {
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
207 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
208 }
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
209
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
210 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
211 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
212 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
213 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
214 )
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
215 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
216 {
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
217 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
218
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
219 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
220 .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
221 .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
222 .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
223 .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
224 .executeQuery();
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
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 OUTER: while (rs.next()) {
4101
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
227 int dtId = rs.getInt("ABFLUSSTAFEL_NR");
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
228 Date from = rs.getDate("GUELTIG_VON");
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
229 Date to = rs.getDate("GUELTIG_BIS");
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
230
4134
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
231 if (from == null) {
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
232 log.warn("AFT: ABFLUSSTAFEL_NR = "
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
233 + dtId + ": GUELTIG_VON = NULL -> ignored.");
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
234 }
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
235
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
236 if (to == null) {
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
237 log.warn("AFT: ABFLUSSTAFEL_NR = "
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
238 + dtId + ": GUELTIG_BIS = NULL -> ignored.");
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
239 }
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
240
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
241 if (from == null || to == null) {
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
242 continue;
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
243 }
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
244
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
245 if (from.compareTo(to) > 0) {
4110
06891562e633 Extracted and documented the error messages of the process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4105
diff changeset
246 log.warn("AFT: ABFLUSSTAFEL_NR = "
4101
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
247 + dtId + ": " + from + " > " + to + ". -> swap");
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
248 Date temp = from;
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
249 from = to;
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
250 to = temp;
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
251 }
b6a18d706cbe Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4099
diff changeset
252
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
253 String description = rs.getString("ABFLUSSTAFEL_BEZ");
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 if (description == null) {
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 description = String.valueOf(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
256 }
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
4105
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
258 for (DischargeTable dt: dts) {
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
259 if (dt.getDescription().equals(description)) {
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
260 log.warn("AFT: Found discharge table '" +
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
261 description + "' with same description. -> ignore.");
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
262 continue OUTER;
309d4ca09816 Prevent redundant and ever growing discharge table lists in FLYS db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4103
diff changeset
263 }
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
4134
9c78264109ad AFT: Ignored tables with unset GUELTIG_VON or GUELTIG_BIS values.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4110
diff changeset
266 TimeInterval timeInterval = new TimeInterval(from, to);
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
267
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
268 DischargeTable dt = new 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
269 dtId,
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 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
271 timeInterval,
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
272 description);
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
273 dts.add(dt);
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
274 }
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
275 rs.close();
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
276
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
277 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
278 }
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
279
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
280 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
281 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
282 )
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
283 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
284 {
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
285 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
286 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
287 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
288 }
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
289 }
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
290
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
291 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
292 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
293 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
294 )
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
295 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
296 {
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
297 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
298 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
299
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
300 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
301 .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
302 .executeQuery();
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
303
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
304 rs.next();
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
305 int flysId = rs.getInt("discharge_table_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
306 rs.close();
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
307
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
308 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
309 .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
310 .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
311 .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
312 .setInt("gauge_id", 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
313 .setString("description", description);
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 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
316 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
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 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
319 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
320 }
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
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 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
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 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
325 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
326 }
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
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 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
329 }
4090
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
330 }
d556e29592f5 Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
331 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org