[PATCH] (issue1750) Check for stations according to measurement station range logic

Wald Commits scm-commit at wald.intevation.org
Fri Mar 20 17:31:09 CET 2015


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1426869066 -3600
# Node ID 958342db7a157fe66c3aa48e03800e7ddbf8dc46
# Parent  eed4e31ca1b3358f9dcfbbb56228e119ea9ca5a3
(issue1750) Check for stations according to measurement station range logic

diff -r eed4e31ca1b3 -r 958342db7a15 artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/StaticSQFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/StaticSQFactory.java	Fri Mar 20 16:36:37 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/StaticSQFactory.java	Fri Mar 20 17:31:06 2015 +0100
@@ -35,9 +35,19 @@
             "JOIN ranges ra ON ra.id = ms.range_id " +
             "JOIN rivers r ON r.id = ra.river_id " +
             "WHERE r.name = :river AND " +
-            "ms.range_id = (SELECT range_id " +
-                           "FROM measurement_station " +
-                           "WHERE id = :ms_id)";
+            "CASE WHEN r.km_up = 1 AND ra.b IS NOT NULL " +
+                "THEN ra.b " +
+                "ELSE ra.a " +
+            "END = (SELECT " +
+                       "CASE WHEN r.km_up = 1 AND ra.b IS NOT NULL " +
+                           "THEN ra.b " +
+                           "ELSE ra.a " +
+                       "END " +
+                       "FROM measurement_station ms " +
+                       "JOIN ranges ra ON ra.id = ms.range_id " +
+                       "JOIN rivers r ON r.id = ra.river_id " +
+                       "WHERE r.name = :river AND " +
+                       "ms.id = :ms_id)";
 
     public static final String SQL_SQ =
         "SELECT " +
@@ -93,6 +103,8 @@
         List<Integer> list = query.list();
         if (list == null || list.isEmpty()) {
             log.error("Did not even find one measurement station. Broken Query?");
+            log.debug("River: " + river);
+            log.debug("Mesurement station id: " + measurementStation);
             return retval;
         }
 


More information about the Dive4Elements-commits mailing list