Mercurial > dive4elements > river
diff flys-aft/src/main/java/de/intevation/aft/River.java @ 4088:52cde7fe742a
Fetch discharge table infos from AFT.
flys-aft/trunk@3573 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 Jan 2012 11:36:07 +0000 |
parents | aad1886ea226 |
children | d556e29592f5 |
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/River.java Mon Jan 02 17:45:25 2012 +0000 +++ b/flys-aft/src/main/java/de/intevation/aft/River.java Tue Jan 03 11:36:07 2012 +0000 @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import java.util.Date; import java.sql.ResultSet; import java.sql.SQLException; @@ -163,6 +164,9 @@ log.info("FLYS: Created gauge '" + gauge.getAftName() + "' with id " + gaugeId + "."); + gauge.setFlysId(gaugeId); + createDischargeTables(context, officialNumber, gauge); + flysStatements.commitTransaction(); } catch (SQLException sqle) { @@ -177,6 +181,50 @@ } } + protected void createDischargeTables( + SyncContext context, + Long officialNumber, + DIPSGauge gauge + ) + throws SQLException + { + log.info("create discharge tables"); + + boolean debug = log.isDebugEnabled(); + + ConnectedStatements flysStatements = context.getFlysStatements(); + ConnectedStatements aftStatements = context.getAftStatements(); + + ResultSet rs = null; + try { + rs = aftStatements.getStatement("select.abflusstafel") + .clearParameters() + .setString("number", "%" + officialNumber). + executeQuery(); + + while (rs.next()) { + int dtId = rs.getInt("ABFLUSSTAFEL_NR"); + Date from = rs.getDate("GUELTIG_VON"); + Date to = rs.getDate("GUELTIG_BIS"); + + double datumValue = rs.getDouble("PEGELNULLPUNKT"); + Double datum = rs.wasNull() ? null : datumValue; + + if (debug) { + log.debug("id: " + dtId); + log.debug("valid from: " + from); + log.debug("valid to: " + to); + log.debug("datum: " + datum); + } + } + } + finally { + if (rs != null) { + rs.close(); + } + } + } + public String toString() { return "[River: name=" + name + ", " + super.toString() + "]"; }