Mercurial > dive4elements > river
changeset 3794:42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
flys-backend/trunk@5437 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Wed, 12 Sep 2012 10:28:26 +0000 (2012-09-12) |
parents | 8f232119011e |
children | f210432f4383 |
files | flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/River.java |
diffstat | 2 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/ChangeLog Tue Sep 11 13:55:08 2012 +0000 +++ b/flys-backend/ChangeLog Wed Sep 12 10:28:26 2012 +0000 @@ -1,3 +1,9 @@ +2012-09-12 Björn Ricks <bjoern.ricks@intevation.de> + + * src/main/java/de/intevation/flys/model/River.java: + Add new method determineMinMaxQ to fetch the mimimum and maximum q values + from the database. + 2012-09-10 Sascha L. Teichmann <sascha.teichmann@intevation.de> * postgresql-minfo.sql: Added missing tables.
--- a/flys-backend/src/main/java/de/intevation/flys/model/River.java Tue Sep 11 13:55:08 2012 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/River.java Wed Sep 12 10:28:26 2012 +0000 @@ -220,6 +220,33 @@ return gauges.isEmpty() ? null : gauges.get(0); } + public double[] determineMinMaxQ() { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "select min(wqr.q) as min, max(wqr.q) as max from Wst w " + + "join WstColumns as wc " + + "join WstColumnQRange as wcqr " + + "join WstQRange as wqr " + + "where w.kind = 0 and river_id = :river_id"); + + query.setParameter("river", getId()); + + double minmax[] = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; + + List<Object> results = query.list(); + + if (!results.isEmpty()) { + Object[] arr = (Object[]) results.get(0); + BigDecimal minq = (BigDecimal)arr[0]; + BigDecimal maxq = (BigDecimal)arr[1]; + minmax[0] = minq.doubleValue(); + minmax[1] = maxq.doubleValue(); + } + + return minmax; + } + /** * This method returns the first gauge that is intersected by <i>a</i> and