Mercurial > dive4elements > river
annotate flys-aft/src/main/java/de/intevation/aft/DischargeTable.java @ 4091:a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
flys-aft/trunk@3601 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 05 Jan 2012 16:41:26 +0000 |
parents | d556e29592f5 |
children | b3fc044f75ba |
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; |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
4 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
|
5 |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
6 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
|
7 import java.sql.ResultSet; |
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 de.intevation.db.SymbolicStatement; |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
10 |
4090
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 public class DischargeTable |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 protected int id; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 protected int gaugeId; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 protected TimeInterval timeInterval; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 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
|
17 protected List<WQ> values; |
4090
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 public DischargeTable() { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 } |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 public DischargeTable( |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 int gaugeId, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 TimeInterval timeInterval, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 String description |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 ) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 this.gaugeId = gaugeId; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 this.timeInterval = timeInterval; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 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
|
30 values = new ArrayList<WQ>(); |
4090
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 public DischargeTable( |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 int id, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 int gaugeId, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 TimeInterval timeInterval, |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 String description |
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 this(gaugeId, timeInterval, description); |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 this.id = id; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 public int getId() { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 return id; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 public void setId(int id) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 this.id = id; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 public int getGaugeId() { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 return gaugeId; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 public void setGaugeId(int gaugeId) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 this.gaugeId = gaugeId; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 public TimeInterval getTimeInterval() { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 return timeInterval; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 public void setTimeInterval(TimeInterval timeInterval) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 this.timeInterval = timeInterval; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 public String getDescription() { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 return description; |
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 |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 public void setDescription(String description) { |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 this.description = description; |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 } |
4091
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
74 |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
75 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
|
76 throws SQLException |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
77 { |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
78 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
|
79 while (rs.next()) { |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
80 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
|
81 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
|
82 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
|
83 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
|
84 } |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
85 rs.close(); |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
86 } |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
87 |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
88 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
|
89 loadValues(context.getAftStatements() |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
90 .getStatement("select.tafelwert") |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
91 .clearParameters() |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
92 .setInt("number", getId())); |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
93 } |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
94 |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
95 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
|
96 loadValues(context.getFlysStatements() |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
97 .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
|
98 .clearParameters() |
a91c7e982c32
Make W/Q values from AFT and FLYS loadable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4090
diff
changeset
|
99 .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
|
100 } |
4090
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 } |
d556e29592f5
Create new discharge tables if needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |