comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 6785:6da574f78d60

SedimentLoadFactory: Survive not completely defined sediment loads.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 08 Aug 2013 16:03:41 +0200
parents 91c43293e538
children 70b440dc5317
comparison
equal deleted inserted replaced
6784:4d157de77d86 6785:6da574f78d60
393 sqlQuery.setDate("begin", start.getTime()); 393 sqlQuery.setDate("begin", start.getTime());
394 sqlQuery.setDate("end", end.getTime()); 394 sqlQuery.setDate("end", end.getTime());
395 sqlQuery.setString("grain", "total"); 395 sqlQuery.setString("grain", "total");
396 List<Object []> results = sqlQuery.list(); 396 List<Object []> results = sqlQuery.list();
397 SedimentLoad load = new SedimentLoad(); 397 SedimentLoad load = new SedimentLoad();
398 Object[] row = results.get(0); 398 if (results.isEmpty()) {
399 load = new SedimentLoad( 399 log.warn("Empty result for year calculation.");
400 (String) row[0], 400 }
401 (Date) row[1], 401 else {
402 null, 402 Object[] row = results.get(0);
403 false, 403 load = new SedimentLoad(
404 (String) row[4]); 404 (String) row[0],
405 getValues("coarse", sqlQuery, load, floatStations); 405 (Date) row[1],
406 getValues("fine_middle", sqlQuery, load, floatStations); 406 null,
407 getValues("sand", sqlQuery, load, floatStations); 407 false,
408 getValues("suspended_sediment", sqlQuery, load, suspStations); 408 (String) row[4]);
409 getValues("susp_sand_bed", sqlQuery, load, floatStations); 409 }
410 getValues("susp_sand", sqlQuery, load, floatStations); 410 load = getValues("coarse", sqlQuery, load, floatStations);
411 load = getValues("fine_middle", sqlQuery, load, floatStations);
412 load = getValues("sand", sqlQuery, load, floatStations);
413 load = getValues("suspended_sediment", sqlQuery, load, suspStations);
414 load = getValues("susp_sand_bed", sqlQuery, load, floatStations);
415 load = getValues("susp_sand", sqlQuery, load, floatStations);
416
417 log.debug("sqlQ: " + sqlQuery.toString());
418 log.debug("sqlQ2: " + sqlQuery.getQueryString());
411 419
412 return load; 420 return load;
413 } 421 }
414 else if (type.equals("off_epoch")) { 422 else if (type.equals("off_epoch")) {
415 // Set calendars to fetch the epochs by their start and end 423 // Set calendars to fetch the epochs by their start and end
626 return load; 634 return load;
627 } 635 }
628 636
629 /** 637 /**
630 * Return sediment loads with 'unknown' fraction type. 638 * Return sediment loads with 'unknown' fraction type.
639 * @param river Name of the river
631 * @param unit Restrict result set to those of given unit. 640 * @param unit Restrict result set to those of given unit.
632 * @param type Type like year, epoch, off_epoch 641 * @param type Type like year, epoch, off_epoch
633 */ 642 */
634 public static SedimentLoad[] getSedimentLoadUnknown( 643 public static SedimentLoad[] getSedimentLoadUnknown(
635 String river, 644 String river,

http://dive4elements.wald.intevation.org