Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/DischargeTable.java Wed Jan 04 17:59:26 2012 +0000 +++ b/flys-aft/src/main/java/de/intevation/aft/DischargeTable.java Thu Jan 05 16:41:26 2012 +0000 @@ -1,11 +1,20 @@ package de.intevation.aft; +import java.util.List; +import java.util.ArrayList; + +import java.sql.SQLException; +import java.sql.ResultSet; + +import de.intevation.db.SymbolicStatement; + public class DischargeTable { protected int id; protected int gaugeId; protected TimeInterval timeInterval; protected String description; + protected List<WQ> values; public DischargeTable() { } @@ -18,6 +27,7 @@ this.gaugeId = gaugeId; this.timeInterval = timeInterval; this.description = description; + values = new ArrayList<WQ>(); } public DischargeTable( @@ -61,6 +71,32 @@ public void setDescription(String description) { this.description = description; } + + protected void loadValues(SymbolicStatement.Instance query) + throws SQLException + { + ResultSet rs = query.executeQuery(); + while (rs.next()) { + int id = rs.getInt("id"); + double w = rs.getDouble("w"); + double q = rs.getDouble("q"); + values.add(new WQ(id, w, q)); + } + rs.close(); + } + + public void loadAftValues(SyncContext context) throws SQLException { + loadValues(context.getAftStatements() + .getStatement("select.tafelwert") + .clearParameters() + .setInt("number", getId())); + } + + public void loadFlysValues(SyncContext context) throws SQLException { + loadValues(context.getFlysStatements() + .getStatement("select.discharge.table.values") + .clearParameters() + .setInt("table_id", getId())); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : -