changeset 7819:b468dc65154a minfo-opt

Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 12 Mar 2014 11:16:45 +0100 (2014-03-12)
parents 521865ad8512
children 5c80f419aea4
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(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Fri Mar 07 11:16:24 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Wed Mar 12 11:16:45 2014 +0100
@@ -116,6 +116,7 @@
         "       JOIN units u ON u.id = sy.unit_id " +
         "   WHERE   r.name = :name " +
         "       AND ti.stop_time IS NOT NULL " +
+        "       AND sy.kind = 0" +
         "       AND syv.station BETWEEN :startKm AND :endKm";
 
     public static final String SQL_SELECT_SINGLES_DATA_BY_ID =
@@ -169,6 +170,7 @@
         "   WHERE   r.name = :name " +
         "       AND sy.description = :descr " +
         "       AND gf.name = 'unknown' " +
+        "       AND sy.kind = :type" +
         "   ORDER BY syv.station";
 
     public static final String SQL_SELECT_UNKNOWN =
@@ -817,14 +819,15 @@
 
     public static SedimentLoad getLoadUnknown(
         String river,
-        String description
+        String description,
+        String type
     ) {
         log.debug("SedimentLoadFactory.getLoadWithData");
         Cache cache = CacheFactory.getCache(LOAD_DATA_CACHE_NAME);
 
         if (cache == null) {
             log.debug("Cache not configured.");
-            return getSedimentLoadUnknownUncached(river, description);
+            return getSedimentLoadUnknownUncached(river, description, type);
         }
 
         StaticSedimentLoadCacheKey key =
@@ -837,7 +840,8 @@
             return (SedimentLoad)element.getValue();
         }
 
-        SedimentLoad values = getSedimentLoadUnknownUncached(river, description);
+        SedimentLoad values =
+            getSedimentLoadUnknownUncached(river, description, type);
 
         if (values != null && key != null) {
             log.debug("Store static bed height values in cache.");
@@ -855,7 +859,8 @@
      */
     public static SedimentLoad getSedimentLoadUnknownUncached(
         String river,
-        String description
+        String description,
+        String type
     ) {
         log.debug("SedimentLoadFactory.getSedimentLoadWithDataUncached");
         Session session = SessionHolder.HOLDER.get();
@@ -870,6 +875,12 @@
             .addScalar("unit", StandardBasicTypes.STRING);
         sqlQuery.setString("name", river);
         sqlQuery.setString("descr", description);
+        if (type.equals("off_epoch")) {
+            sqlQuery.setInteger("type", 1);
+        }
+        else {
+            sqlQuery.setInteger("type", 0);
+        }
         List<Object []> results = sqlQuery.list();
         SedimentLoad load = new SedimentLoad();
         if (results.isEmpty()) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java	Fri Mar 07 11:16:24 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java	Wed Mar 12 11:16:45 2014 +0100
@@ -41,7 +41,7 @@
                 access.getYearEpoch());
 
         SedimentLoad load = SedimentLoadFactory.getLoadUnknown(
-            river, unknown[index].getDescription());
+            river, unknown[index].getDescription(), access.getYearEpoch());
         return load;
     }
 

http://dive4elements.wald.intevation.org