comparison 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
comparison
equal deleted inserted replaced
4090:d556e29592f5 4091:a91c7e982c32
1 package de.intevation.aft; 1 package de.intevation.aft;
2
3 import java.util.List;
4 import java.util.ArrayList;
5
6 import java.sql.SQLException;
7 import java.sql.ResultSet;
8
9 import de.intevation.db.SymbolicStatement;
2 10
3 public class DischargeTable 11 public class DischargeTable
4 { 12 {
5 protected int id; 13 protected int id;
6 protected int gaugeId; 14 protected int gaugeId;
7 protected TimeInterval timeInterval; 15 protected TimeInterval timeInterval;
8 protected String description; 16 protected String description;
17 protected List<WQ> values;
9 18
10 public DischargeTable() { 19 public DischargeTable() {
11 } 20 }
12 21
13 public DischargeTable( 22 public DischargeTable(
16 String description 25 String description
17 ) { 26 ) {
18 this.gaugeId = gaugeId; 27 this.gaugeId = gaugeId;
19 this.timeInterval = timeInterval; 28 this.timeInterval = timeInterval;
20 this.description = description; 29 this.description = description;
30 values = new ArrayList<WQ>();
21 } 31 }
22 32
23 public DischargeTable( 33 public DischargeTable(
24 int id, 34 int id,
25 int gaugeId, 35 int gaugeId,
59 } 69 }
60 70
61 public void setDescription(String description) { 71 public void setDescription(String description) {
62 this.description = description; 72 this.description = description;
63 } 73 }
74
75 protected void loadValues(SymbolicStatement.Instance query)
76 throws SQLException
77 {
78 ResultSet rs = query.executeQuery();
79 while (rs.next()) {
80 int id = rs.getInt("id");
81 double w = rs.getDouble("w");
82 double q = rs.getDouble("q");
83 values.add(new WQ(id, w, q));
84 }
85 rs.close();
86 }
87
88 public void loadAftValues(SyncContext context) throws SQLException {
89 loadValues(context.getAftStatements()
90 .getStatement("select.tafelwert")
91 .clearParameters()
92 .setInt("number", getId()));
93 }
94
95 public void loadFlysValues(SyncContext context) throws SQLException {
96 loadValues(context.getFlysStatements()
97 .getStatement("select.discharge.table.values")
98 .clearParameters()
99 .setInt("table_id", getId()));
100 }
64 } 101 }
65 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
66

http://dive4elements.wald.intevation.org