comparison flys-aft/src/main/java/de/intevation/aft/DischargeTable.java @ 4102:e8967ee1cb05

Fixed logic bug when writing discharge tables of an gauge existing in both dbs. flys-aft/trunk@3631 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 09 Jan 2012 16:43:14 +0000
parents b6a18d706cbe
children 2305731f563c
comparison
equal deleted inserted replaced
4101:b6a18d706cbe 4102:e8967ee1cb05
4 import java.util.Date; 4 import java.util.Date;
5 import java.util.ArrayList; 5 import java.util.ArrayList;
6 6
7 import java.sql.SQLException; 7 import java.sql.SQLException;
8 import java.sql.ResultSet; 8 import java.sql.ResultSet;
9 import java.sql.Types;
9 10
10 import de.intevation.db.SymbolicStatement; 11 import de.intevation.db.SymbolicStatement;
11 import de.intevation.db.ConnectedStatements; 12 import de.intevation.db.ConnectedStatements;
12 13
13 import org.apache.log4j.Logger; 14 import org.apache.log4j.Logger;
246 } 247 }
247 rs.close(); 248 rs.close();
248 249
249 return dts; 250 return dts;
250 } 251 }
252
253 public void persistFlysTimeInterval(
254 SyncContext context
255 )
256 throws SQLException
257 {
258 if (timeInterval != null) {
259 timeInterval = context.fetchOrCreateFLYSTimeInterval(
260 timeInterval);
261 }
262 }
263
264 public int persistFlysDischargeTable(
265 SyncContext context,
266 int gaugeId
267 )
268 throws SQLException
269 {
270 ConnectedStatements flysStatements =
271 context.getFlysStatements();
272
273 ResultSet rs = flysStatements
274 .getStatement("next.discharge.id")
275 .executeQuery();
276
277 rs.next();
278 int flysId = rs.getInt("discharge_table_id");
279 rs.close();
280
281 SymbolicStatement.Instance insertDT = flysStatements
282 .getStatement("insert.dischargetable")
283 .clearParameters()
284 .setInt("id", flysId)
285 .setInt("gauge_id", gaugeId)
286 .setString("description", description);
287
288 if (timeInterval != null) {
289 insertDT.setInt("time_interval_id", timeInterval.getId());
290 }
291 else {
292 insertDT.setNull("time_interval_id", Types.INTEGER);
293 }
294
295 insertDT.execute();
296
297 if (log.isDebugEnabled()) {
298 log.debug("FLYS: Created discharge table id: " + id);
299 }
300
301 return flysId;
302 }
251 } 303 }
252 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 304 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org