[Dive4elements-commits] [PATCH 2 of 2] AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river
Wald Commits
scm-commit at wald.intevation.org
Thu Jan 3 14:39:56 CET 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1357220388 -3600
# Node ID 04377ccef10a22285124fd38a8f3e46bfae5c3eb
# Parent a310aceb2e51dda4203de73b5e71aa13ffeeb27f
AFT: Reject AFT gauges which are not inside the calculation range of the corresponding FLYS river.
diff -r a310aceb2e51 -r 04377ccef10a flys-aft/src/main/java/de/intevation/aft/River.java
--- a/flys-aft/src/main/java/de/intevation/aft/River.java Thu Jan 03 14:19:45 2013 +0100
+++ b/flys-aft/src/main/java/de/intevation/aft/River.java Thu Jan 03 14:39:48 2013 +0100
@@ -70,44 +70,59 @@
ConnectedStatements flysStatements = context.getFlysStatements();
ConnectedStatements aftStatements = context.getAftStatements();
+ String riverName = getName();
+
+ Map<Long, DIPSGauge> aftDIPSGauges = new HashMap<Long, DIPSGauge>();
+
ResultSet messstellenRs = aftStatements
.getStatement("select.messstelle")
.clearParameters()
.setInt("GEWAESSER_NR", id2).executeQuery();
- String riverName = getName();
+ try {
+ while (messstellenRs.next()) {
+ String name = messstellenRs.getString("NAME");
+ String num = messstellenRs.getString("MESSSTELLE_NR");
+ double station = messstellenRs.getDouble("STATIONIERUNG");
- Map<Long, DIPSGauge> aftDIPSGauges = new HashMap<Long, DIPSGauge>();
+ if (messstellenRs.wasNull()) {
+ log.warn("AFT: STATION of MESSSTELLE '"+name+"' is NULL -> ignored.");
+ continue;
+ }
- while (messstellenRs.next()) {
- String name = messstellenRs.getString("NAME");
- String num = messstellenRs.getString("MESSSTELLE_NR");
- Long number = SyncContext.numberToLong(num);
- if (number == null) {
- log.warn("AFT: Invalid MESSSTELLE_NR for MESSSTELLE '"+name+"'");
- continue;
+ if (!inside(station)) {
+ log.warn("AFT: MESSSTELLE '"+name+"' out of calculation range -> ignored.");
+ continue;
+ }
+
+ Long number = SyncContext.numberToLong(num);
+ if (number == null) {
+ log.warn("AFT: Invalid MESSSTELLE_NR for MESSSTELLE '"+name+"'");
+ continue;
+ }
+ DIPSGauge dipsGauge = dipsGauges.get(number);
+ if (dipsGauge == null) {
+ log.warn(
+ "DIPS: MESSSTELLE '" + name + "' not found in DIPS. " +
+ "Gauge number used for lookup: " + number);
+ continue;
+ }
+ String gaugeRiver = dipsGauge.getRiverName();
+ if (!gaugeRiver.equalsIgnoreCase(riverName)) {
+ log.warn(
+ "DIPS: MESSSTELLE '" + name +
+ "' is assigned to river '" + gaugeRiver +
+ "'. Needs to be on '" + riverName + "'.");
+ continue;
+ }
+ dipsGauge.setAftName(name);
+ dipsGauge.setOfficialNumber(number);
+ aftDIPSGauges.put(number, dipsGauge);
}
- DIPSGauge dipsGauge = dipsGauges.get(number);
- if (dipsGauge == null) {
- log.warn(
- "DIPS: MESSSTELLE '" + name + "' not found in DIPS. " +
- "Gauge number used for lookup: " + number);
- continue;
- }
- String gaugeRiver = dipsGauge.getRiverName();
- if (!gaugeRiver.equalsIgnoreCase(riverName)) {
- log.warn(
- "DIPS: MESSSTELLE '" + name +
- "' is assigned to river '" + gaugeRiver +
- "'. Needs to be on '" + riverName + "'.");
- continue;
- }
- dipsGauge.setAftName(name);
- dipsGauge.setOfficialNumber(number);
- aftDIPSGauges.put(number, dipsGauge);
}
-
- messstellenRs.close();
+ finally {
+ messstellenRs.close();
+ }
List<DIPSGauge> updateGauges = new ArrayList<DIPSGauge>();
@@ -116,28 +131,32 @@
.clearParameters()
.setInt("river_id", id1).executeQuery();
- while (gaugesRs.next()) {
- int gaugeId = gaugesRs.getInt("id");
- String name = gaugesRs.getString("name");
- long number = gaugesRs.getLong("official_number");
- if (gaugesRs.wasNull()) {
- log.warn("FLYS: Gauge '" + name +
- "' has no official number. Ignored.");
- continue;
+ try {
+ while (gaugesRs.next()) {
+ int gaugeId = gaugesRs.getInt("id");
+ String name = gaugesRs.getString("name");
+ long number = gaugesRs.getLong("official_number");
+ if (gaugesRs.wasNull()) {
+ log.warn("FLYS: Gauge '" + name +
+ "' has no official number. Ignored.");
+ continue;
+ }
+ Long key = Long.valueOf(number);
+ DIPSGauge aftDIPSGauge = aftDIPSGauges.remove(key);
+ if (aftDIPSGauge == null) {
+ log.warn("FLYS: Gauge '" + name + "' number " + number +
+ " is not found in AFT/DIPS.");
+ continue;
+ }
+ aftDIPSGauge.setFlysId(gaugeId);
+ log.info("Gauge '" + name +
+ "' found in FLYS, AFT and DIPS. -> Update");
+ updateGauges.add(aftDIPSGauge);
}
- Long key = Long.valueOf(number);
- DIPSGauge aftDIPSGauge = aftDIPSGauges.remove(key);
- if (aftDIPSGauge == null) {
- log.warn("FLYS: Gauge '" + name + "' number " + number +
- " is not found in AFT/DIPS.");
- continue;
- }
- aftDIPSGauge.setFlysId(gaugeId);
- log.info("Gauge '" + name +
- "' found in FLYS, AFT and DIPS. -> Update");
- updateGauges.add(aftDIPSGauge);
}
- gaugesRs.close();
+ finally {
+ gaugesRs.close();
+ }
boolean modified = createGauges(context, aftDIPSGauges);
diff -r a310aceb2e51 -r 04377ccef10a flys-aft/src/main/resources/sql/aft-common.properties
--- a/flys-aft/src/main/resources/sql/aft-common.properties Thu Jan 03 14:19:45 2013 +0100
+++ b/flys-aft/src/main/resources/sql/aft-common.properties Thu Jan 03 14:39:48 2013 +0100
@@ -1,5 +1,8 @@
select.gewaesser = SELECT GEWAESSER_NR, NAME FROM SL_GEWAESSER
-select.messstelle = SELECT NAME, MESSSTELLE_NR FROM MESSSTELLE WHERE GEWAESSER_NR = :GEWAESSER_NR
+select.messstelle = \
+ SELECT NAME, MESSSTELLE_NR, STATIONIERUNG \
+ FROM MESSSTELLE \
+ WHERE GEWAESSER_NR = :GEWAESSER_NR
select.abflusstafel = SELECT ABFLUSSTAFEL_NR, \
ABFLUSSTAFEL_BEZ, \
strftime('%s', GUELTIG_VON) * 1000 AS GUELTIG_VON, \
More information about the Dive4elements-commits
mailing list