# HG changeset patch # User Ingo Weinzierl # Date 1325074612 0 # Node ID 027736510a301a1b7b677f1d4c60cb4c7a5d53e2 # Parent fe89d6cf55fb89c9dd665c4a22d9044cd9df5646 Added a new method Wst.determineMinMaxQ(double,double). flys-backend/trunk@3552 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r fe89d6cf55fb -r 027736510a30 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Mon Dec 19 11:21:25 2011 +0000 +++ b/flys-backend/ChangeLog Wed Dec 28 12:16:52 2011 +0000 @@ -1,3 +1,9 @@ +2011-12-28 Ingo Weinzierl + + * src/main/java/de/intevation/flys/model/Wst.java: Added a method + determineMinMaxQ(double double) to be able to determine the Q range of a + WST without having a Range object. + 2011-12-19 Sascha L. Teichmann : * src/main/java/de/intevation/flys/importer/parsers/StaFileParser.java: diff -r fe89d6cf55fb -r 027736510a30 flys-backend/src/main/java/de/intevation/flys/model/Wst.java --- 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 results = query.list();