Mercurial > dive4elements > river
diff flys-aft/src/main/java/de/intevation/aft/River.java @ 4097:83c72bc07591
Load all discharge tables from AFT and FLYS of a gauge which needs updating.
flys-aft/trunk@3618 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 06 Jan 2012 18:32:08 +0000 |
parents | b20b710aa86f |
children | 9215253ad0be |
line wrap: on
line diff
--- a/flys-aft/src/main/java/de/intevation/aft/River.java Fri Jan 06 17:16:46 2012 +0000 +++ b/flys-aft/src/main/java/de/intevation/aft/River.java Fri Jan 06 18:32:08 2012 +0000 @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import java.util.Date; import java.sql.ResultSet; import java.sql.SQLException; @@ -76,6 +75,7 @@ continue; } dipsGauge.setAftName(name); + dipsGauge.setOfficialNumber(number); aftDIPSGauges.put(number, dipsGauge); } @@ -113,6 +113,47 @@ boolean modified = createGauges(context, aftDIPSGauges); + modified |= updateGauges(context, updateGauges); + + return modified; + } + + protected boolean updateGauges( + SyncContext context, + List<DIPSGauge> gauges + ) + throws SQLException + { + boolean modified = false; + + for (DIPSGauge gauge: gauges) { + modified |= updateGauge(context, gauge); + } + + return modified; + } + + protected boolean updateGauge( + SyncContext context, + DIPSGauge gauge + ) + throws SQLException + { + // We need to load all discharge tables from both database + // of the gauge and do some pairing based on their descriptions. + + boolean modified = false; + + List<DischargeTable> flysDTs = + DischargeTable.loadFlysDischargeTables( + context, gauge.getFlysId()); + + List<DischargeTable> aftDTs = + DischargeTable.loadAftDischargeTables( + context, gauge.getOfficialNumber()); + + // TODO: Do pairing + return modified; } @@ -216,59 +257,8 @@ ) throws SQLException { - boolean debug = log.isDebugEnabled(); - - List<DischargeTable> dts = new ArrayList<DischargeTable>(); - - ResultSet rs = null; - try { - rs = context - .getAftStatements() - .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"); - String description = rs.getString("ABFLUSSTAFEL_BEZ"); - if (description == null) { - description = String.valueOf(officialNumber); - } - - 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); - log.debug("description: " + description); - } - - TimeInterval timeInterval = from == null - ? null - : new TimeInterval(from, to); - - DischargeTable dt = new DischargeTable( - dtId, - gauge.getFlysId(), - timeInterval, - description); - dts.add(dt); - } - } - finally { - if (rs != null) { - rs.close(); - rs = null; - } - } - - return dts; + return DischargeTable.loadAftDischargeTables( + context, officialNumber, gauge.getFlysId()); } protected void persistFlysTimeIntervals(