diff flys-backend/src/main/java/de/intevation/flys/model/River.java @ 756:ca13926b8871

River: Make search for gauges independent of from/to order. flys-backend/trunk@2011 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 26 May 2011 15:00:04 +0000
parents ce9c6f05f464
children c19d4c643526
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/model/River.java	Tue May 24 11:12:59 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/River.java	Thu May 26 15:00:04 2011 +0000
@@ -104,6 +104,8 @@
     public List<Gauge> determineGauges(double a, double b) {
         Session session = SessionHolder.HOLDER.get();
 
+        if (a > b) { double t = a; a = b; b = t; }
+
         Query query = session.createQuery(
             "from Gauge where river=:river " +
             "and not (range.a > :b or range.b < :a) order by a");
@@ -127,7 +129,7 @@
     public Gauge determineGauge(double a, double b) {
         List<Gauge> gauges = determineGauges(a, b);
 
-        return gauges != null && gauges.size() > 0 ? gauges.get(0) : null;
+        return gauges.isEmpty() ? null : gauges.get(0);
     }
 
     /**

http://dive4elements.wald.intevation.org