[PATCH] SedimentLoadFactory: Survive not completely defined sediment loads
Wald Commits
scm-commit at wald.intevation.org
Thu Aug 8 15:53:48 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1375970621 -7200
# Node ID 6da574f78d609b25bb6ae80d6ce6598c12b20070
# Parent 4d157de77d866866bda40761a496606fdee7d600
SedimentLoadFactory: Survive not completely defined sediment loads.
diff -r 4d157de77d86 -r 6da574f78d60 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Thu Aug 08 15:46:18 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Thu Aug 08 16:03:41 2013 +0200
@@ -395,19 +395,27 @@
sqlQuery.setString("grain", "total");
List<Object []> results = sqlQuery.list();
SedimentLoad load = new SedimentLoad();
- Object[] row = results.get(0);
- load = new SedimentLoad(
- (String) row[0],
- (Date) row[1],
- null,
- false,
- (String) row[4]);
- getValues("coarse", sqlQuery, load, floatStations);
- getValues("fine_middle", sqlQuery, load, floatStations);
- getValues("sand", sqlQuery, load, floatStations);
- getValues("suspended_sediment", sqlQuery, load, suspStations);
- getValues("susp_sand_bed", sqlQuery, load, floatStations);
- getValues("susp_sand", sqlQuery, load, floatStations);
+ if (results.isEmpty()) {
+ log.warn("Empty result for year calculation.");
+ }
+ else {
+ Object[] row = results.get(0);
+ load = new SedimentLoad(
+ (String) row[0],
+ (Date) row[1],
+ null,
+ false,
+ (String) row[4]);
+ }
+ load = getValues("coarse", sqlQuery, load, floatStations);
+ load = getValues("fine_middle", sqlQuery, load, floatStations);
+ load = getValues("sand", sqlQuery, load, floatStations);
+ load = getValues("suspended_sediment", sqlQuery, load, suspStations);
+ load = getValues("susp_sand_bed", sqlQuery, load, floatStations);
+ load = getValues("susp_sand", sqlQuery, load, floatStations);
+
+ log.debug("sqlQ: " + sqlQuery.toString());
+ log.debug("sqlQ2: " + sqlQuery.getQueryString());
return load;
}
@@ -628,6 +636,7 @@
/**
* Return sediment loads with 'unknown' fraction type.
+ * @param river Name of the river
* @param unit Restrict result set to those of given unit.
* @param type Type like year, epoch, off_epoch
*/
More information about the Dive4elements-commits
mailing list