diff flys-backend/src/main/java/de/intevation/flys/model/Wst.java @ 2372:027736510a30

Added a new method Wst.determineMinMaxQ(double,double). flys-backend/trunk@3552 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 28 Dec 2011 12:16:52 +0000
parents 0acf28a3d28a
children ab1e642e7c85
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/model/Wst.java	Mon Dec 19 11:21:25 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Wst.java	Wed Dec 28 12:16:52 2011 +0000
@@ -129,6 +129,27 @@
      * @return the min and max Q values of this WST.
      */
     public double[] determineMinMaxQ(Range range) {
+        if (range != null) {
+            return determineMinMaxQ(
+                range.getA().doubleValue(),
+                range.getB().doubleValue());
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Determines the min and max Q values of this WST in the given range. The
+     * min value is placed in the first field of the resulting array - the max
+     * value is placed in the second field.
+     *
+     * @param fromKm the lower km value.
+     * @param toKm the upper km value.
+     *
+     * @return the min and max Q values of this WST.
+     */
+    public double[] determineMinMaxQ(double fromKm, double toKm) {
         Session session = SessionHolder.HOLDER.get();
 
         Query query = session.createQuery(
@@ -140,8 +161,8 @@
           "  (select id from Range where not (a > :end or b < :start))");
 
         query.setParameter("wst",   getId());
-        query.setParameter("start", range.getA());
-        query.setParameter("end",   range.getB());
+        query.setParameter("start", new BigDecimal(fromKm));
+        query.setParameter("end",   new BigDecimal(toKm));
 
         List<Object []> results = query.list();
 

http://dive4elements.wald.intevation.org