[PATCH 1 of 2] Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data

Wald Commits scm-commit at wald.intevation.org
Wed Mar 19 15:09:16 CET 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1394619405 -3600
# Branch minfo-opt
# Node ID b468dc65154a06106d79a139f97cb328c3130f8c
# Parent  521865ad8512467d15ea8992b0d8f8cc2dc0dfc7
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.

diff -r 521865ad8512 -r b468dc65154a 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	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()) {
diff -r 521865ad8512 -r b468dc65154a artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java
--- 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;
     }
 


More information about the Dive4Elements-commits mailing list