Mercurial > dive4elements > river
annotate flys-aft/src/main/java/de/intevation/aft/DischargeTable.java @ 4102:e8967ee1cb05
Fixed logic bug when writing discharge tables of an gauge existing in both dbs.
flys-aft/trunk@3631 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 09 Jan 2012 16:43:14 +0000 |
parents | b6a18d706cbe |
children | 2305731f563c |
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; |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
6 |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
7 import java.sql.SQLException; |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
8 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
|
9 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
|
10 |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
11 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
|
12 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
|
13 |
4101
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
14 import org.apache.log4j.Logger; |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
15 |
4090
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 public class DischargeTable |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 { |
4101
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
18 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
|
19 |
4090
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 protected int id; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 protected int gaugeId; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 protected TimeInterval timeInterval; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 protected String description; |
4091
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
24 protected List<WQ> values; |
4090
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 public DischargeTable() { |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 public DischargeTable( |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 int gaugeId, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 TimeInterval timeInterval, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 String description |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 ) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 this.gaugeId = gaugeId; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 this.timeInterval = timeInterval; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 this.description = description; |
4091
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
37 values = new ArrayList<WQ>(); |
4090
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
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 public DischargeTable( |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 int id, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 int gaugeId, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 TimeInterval timeInterval, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 String description |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 ) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 this(gaugeId, timeInterval, description); |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 this.id = id; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 public int getId() { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 return id; |
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 void setId(int id) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 this.id = id; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 public int getGaugeId() { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 return gaugeId; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 } |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 public void setGaugeId(int gaugeId) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 this.gaugeId = gaugeId; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 public TimeInterval getTimeInterval() { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 return timeInterval; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 public void setTimeInterval(TimeInterval timeInterval) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 this.timeInterval = timeInterval; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 public String getDescription() { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 return description; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 public void setDescription(String description) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 this.description = description; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 } |
4091
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
81 |
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
|
82 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
|
83 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
|
84 } |
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 |
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
|
86 public List<WQ> getValues() { |
006e99437fb9
Store the W/Q differences o existing discharge tables to FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4097
diff
changeset
|
87 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
|
88 } |
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 |
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 public void setValues(List<WQ> 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
|
91 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
|
92 } |
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 |
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 |
4091
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
96 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
|
97 throws SQLException |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
98 { |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
99 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
|
100 while (rs.next()) { |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
101 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
|
102 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
|
103 double q = rs.getDouble("q"); |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
104 values.add(new WQ(id, w, q)); |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
105 } |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
106 rs.close(); |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
107 } |
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 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
|
110 loadValues(context.getAftStatements() |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
111 .getStatement("select.tafelwert") |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
112 .clearParameters() |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
113 .setInt("number", getId())); |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
114 } |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
115 |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
116 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
|
117 loadValues(context.getFlysStatements() |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
118 .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
|
119 .clearParameters() |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
120 .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
|
121 } |
4092
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
122 |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
123 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
|
124 SyncContext context, |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
125 int dischargeTableId |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
126 ) |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
127 throws SQLException |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
128 { |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
129 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
|
130 |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
131 // 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
|
132 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
|
133 .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
|
134 |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
135 int [] ids = new int[values.size()]; |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
136 for (int i = 0; i < ids.length; ++i) { |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
137 ResultSet rs = nextId.executeQuery(); |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
138 rs.next(); |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
139 ids[i] = rs.getInt("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
|
140 rs.close(); |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
141 } |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
142 |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
143 // 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
|
144 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
|
145 .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
|
146 |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
147 for (int i = 0; i < ids.length; ++i) { |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
148 WQ wq = values.get(i); |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
149 insertDTV |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
150 .clearParameters() |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
151 .setInt("id", ids[i]) |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
152 .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
|
153 .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
|
154 .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
|
155 .execute(); |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
156 } |
b3fc044f75ba
Added code to store W/Q values into FLYS database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4091
diff
changeset
|
157 } |
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
|
158 |
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 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
|
160 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
|
161 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
|
162 ) |
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 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
|
164 { |
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 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
|
166 |
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 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
|
168 .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
|
169 .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
|
170 .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
|
171 .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
|
172 .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
|
173 |
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 while (rs.next()) { |
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 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
|
176 String description = rs.getString("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
|
177 Date startTime = rs.getDate("start_time"); |
83c72bc07591
Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4093
diff
changeset
|
178 Date stopTime = rs.getDate("stop_time"); |
83c72bc07591
Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4093
diff
changeset
|
179 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
|
180 ? 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
|
181 : new TimeInterval(startTime, stopTime); |
83c72bc07591
Load all discharge tables from AFT and FLYS of a gauge which needs updating.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4093
diff
changeset
|
182 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
|
183 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
|
184 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
|
185 } |
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 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
|
187 |
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 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
|
189 } |
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 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
|
192 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
|
193 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
|
194 ) |
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 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
|
196 { |
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 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
|
198 } |
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 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
|
201 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
|
202 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
|
203 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
|
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 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
|
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 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
|
210 .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
|
211 .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
|
212 .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
|
213 .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
|
214 .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
|
215 |
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 while (rs.next()) { |
4101
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
217 int dtId = rs.getInt("ABFLUSSTAFEL_NR"); |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
218 Date from = rs.getDate("GUELTIG_VON"); |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
219 Date to = rs.getDate("GUELTIG_BIS"); |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
220 |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
221 if (from != null && to != null && from.compareTo(to) > 0) { |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
222 log.warn("AFT: ABFLUSSTAFEL_NR = " |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
223 + dtId + ": " + from + " > " + to + ". -> swap"); |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
224 Date temp = from; |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
225 from = to; |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
226 to = temp; |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
227 } |
b6a18d706cbe
Added debugging for AFT time intervals.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4099
diff
changeset
|
228 |
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
|
229 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
|
230 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
|
231 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
|
232 } |
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 double datumValue = rs.getDouble("PEGELNULLPUNKT"); |
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 Double datum = rs.wasNull() ? null : datumValue; |
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 |
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 TimeInterval timeInterval = from == 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
|
238 ? 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
|
239 : new TimeInterval(from, to); |
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 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 } |
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 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
|
249 |
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 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
|
251 } |
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
|
252 |
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
|
253 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
|
254 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
|
255 ) |
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
|
256 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
|
257 { |
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
|
258 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
|
259 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
|
260 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
|
261 } |
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
|
262 } |
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
|
263 |
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
|
264 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
|
265 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
|
266 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
|
267 ) |
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
|
268 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
|
269 { |
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
|
270 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
|
271 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
|
272 |
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
|
273 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
|
274 .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
|
275 .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
|
276 |
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
|
277 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
|
278 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
|
279 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
|
280 |
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 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
|
282 .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
|
283 .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
|
284 .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
|
285 .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
|
286 .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
|
287 |
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 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
|
289 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
|
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 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
|
292 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
|
293 } |
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 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
|
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 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
|
298 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
|
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 |
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 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
|
302 } |
4090
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
303 } |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
304 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |