Mercurial > dive4elements > river
diff flys-aft/src/main/java/de/intevation/aft/DischargeTable.java @ 4092:b3fc044f75ba
Added code to store W/Q values into FLYS database.
flys-aft/trunk@3602 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 05 Jan 2012 17:06:29 +0000 |
parents | a91c7e982c32 |
children | 7bddd4601707 |
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/DischargeTable.java Thu Jan 05 16:41:26 2012 +0000 +++ b/flys-aft/src/main/java/de/intevation/aft/DischargeTable.java Thu Jan 05 17:06:29 2012 +0000 @@ -7,6 +7,7 @@ import java.sql.ResultSet; import de.intevation.db.SymbolicStatement; +import de.intevation.db.ConnectedStatements; public class DischargeTable { @@ -98,5 +99,41 @@ .clearParameters() .setInt("table_id", getId())); } + + public void storeFlysValues( + SyncContext context, + int dischargeTableId + ) + throws SQLException + { + ConnectedStatements flysStatements = context.getFlysStatements(); + + // Create the ids. + SymbolicStatement.Instance nextId = flysStatements + .getStatement("next.discharge.table.values.id"); + + int [] ids = new int[values.size()]; + for (int i = 0; i < ids.length; ++i) { + ResultSet rs = nextId.executeQuery(); + rs.next(); + ids[i] = rs.getInt("discharge_table_values_id"); + rs.close(); + } + + // Insert the values. + SymbolicStatement.Instance insertDTV = flysStatements + .getStatement("insert.discharge.table.value"); + + for (int i = 0; i < ids.length; ++i) { + WQ wq = values.get(i); + insertDTV + .clearParameters() + .setInt("id", ids[i]) + .setInt("table_id", dischargeTableId) + .setDouble("w", wq.getW()) + .setDouble("q", wq.getQ()) + .execute(); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :