Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
4091:a91c7e982c32 | 4092:b3fc044f75ba |
---|---|
5 | 5 |
6 import java.sql.SQLException; | 6 import java.sql.SQLException; |
7 import java.sql.ResultSet; | 7 import java.sql.ResultSet; |
8 | 8 |
9 import de.intevation.db.SymbolicStatement; | 9 import de.intevation.db.SymbolicStatement; |
10 import de.intevation.db.ConnectedStatements; | |
10 | 11 |
11 public class DischargeTable | 12 public class DischargeTable |
12 { | 13 { |
13 protected int id; | 14 protected int id; |
14 protected int gaugeId; | 15 protected int gaugeId; |
96 loadValues(context.getFlysStatements() | 97 loadValues(context.getFlysStatements() |
97 .getStatement("select.discharge.table.values") | 98 .getStatement("select.discharge.table.values") |
98 .clearParameters() | 99 .clearParameters() |
99 .setInt("table_id", getId())); | 100 .setInt("table_id", getId())); |
100 } | 101 } |
102 | |
103 public void storeFlysValues( | |
104 SyncContext context, | |
105 int dischargeTableId | |
106 ) | |
107 throws SQLException | |
108 { | |
109 ConnectedStatements flysStatements = context.getFlysStatements(); | |
110 | |
111 // Create the ids. | |
112 SymbolicStatement.Instance nextId = flysStatements | |
113 .getStatement("next.discharge.table.values.id"); | |
114 | |
115 int [] ids = new int[values.size()]; | |
116 for (int i = 0; i < ids.length; ++i) { | |
117 ResultSet rs = nextId.executeQuery(); | |
118 rs.next(); | |
119 ids[i] = rs.getInt("discharge_table_values_id"); | |
120 rs.close(); | |
121 } | |
122 | |
123 // Insert the values. | |
124 SymbolicStatement.Instance insertDTV = flysStatements | |
125 .getStatement("insert.discharge.table.value"); | |
126 | |
127 for (int i = 0; i < ids.length; ++i) { | |
128 WQ wq = values.get(i); | |
129 insertDTV | |
130 .clearParameters() | |
131 .setInt("id", ids[i]) | |
132 .setInt("table_id", dischargeTableId) | |
133 .setDouble("w", wq.getW()) | |
134 .setDouble("q", wq.getQ()) | |
135 .execute(); | |
136 } | |
137 } | |
101 } | 138 } |
102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 139 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |