changeset 6755:91c43293e538

issue1433: Filter loaded unknown sediment yields by kind.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 06 Aug 2013 12:25:53 +0200
parents e032e9e6d09e
children 9cc0b03656fb
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Tue Aug 06 11:06:25 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Tue Aug 06 12:25:53 2013 +0200
@@ -137,6 +137,7 @@
         "    JOIN units u ON sy.unit_id = u.id " +
         "WHERE r.name = :river " +
         "    AND gf.name = 'unknown' " +
+        "    AND sy.kind = :type " +
         "    AND u.name = :unit";
 
     public static final String SQL_SELECT_EPOCHS_DATA =
@@ -628,8 +629,12 @@
     /**
      * Return sediment loads with 'unknown' fraction type.
      * @param unit Restrict result set to those of given unit.
+     * @param type Type like year, epoch, off_epoch
      */
-    public static SedimentLoad[] getSedimentLoadUnknown(String river, String unit) {
+    public static SedimentLoad[] getSedimentLoadUnknown(
+        String river,
+        String unit,
+        String type) {
         Session session = SessionHolder.HOLDER.get();
         SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_UNKNOWN)
             .addScalar("description", StandardBasicTypes.STRING)
@@ -637,6 +642,12 @@
             .addScalar("end", StandardBasicTypes.DATE);
         sqlQuery.setString("river", river);
         sqlQuery.setString("unit", unit);
+        if (type.equals("off_epoch")) {
+            sqlQuery.setInteger("type", 1);
+        }
+        else {
+            sqlQuery.setInteger("type", 0);
+        }
         List<Object[]> results = sqlQuery.list();
         SedimentLoad[] loads = new SedimentLoad[results.size()];
         int counter = 0;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java	Tue Aug 06 11:06:25 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java	Tue Aug 06 12:25:53 2013 +0200
@@ -35,7 +35,10 @@
         String river = access.getRiver();
         String unit  = access.getUnit();
         SedimentLoad[] unknown =
-            SedimentLoadFactory.getSedimentLoadUnknown(river, unit.replace("_per_","/"));
+            SedimentLoadFactory.getSedimentLoadUnknown(
+                river,
+                unit.replace("_per_","/"),
+                access.getYearEpoch());
 
         SedimentLoad load = SedimentLoadFactory.getLoadUnknown(
             river, unknown[index].getDescription());

http://dive4elements.wald.intevation.org