Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/River.java @ 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 |
parents | 385170ff7b34 |
children | f210432f4383 |
comparison
equal
deleted
inserted
replaced
3793:8f232119011e | 3794:42db09d101f3 |
---|---|
218 | 218 |
219 List<Gauge> gauges = query.list(); | 219 List<Gauge> gauges = query.list(); |
220 return gauges.isEmpty() ? null : gauges.get(0); | 220 return gauges.isEmpty() ? null : gauges.get(0); |
221 } | 221 } |
222 | 222 |
223 public double[] determineMinMaxQ() { | |
224 Session session = SessionHolder.HOLDER.get(); | |
225 | |
226 Query query = session.createQuery( | |
227 "select min(wqr.q) as min, max(wqr.q) as max from Wst w " + | |
228 "join WstColumns as wc " + | |
229 "join WstColumnQRange as wcqr " + | |
230 "join WstQRange as wqr " + | |
231 "where w.kind = 0 and river_id = :river_id"); | |
232 | |
233 query.setParameter("river", getId()); | |
234 | |
235 double minmax[] = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; | |
236 | |
237 List<Object> results = query.list(); | |
238 | |
239 if (!results.isEmpty()) { | |
240 Object[] arr = (Object[]) results.get(0); | |
241 BigDecimal minq = (BigDecimal)arr[0]; | |
242 BigDecimal maxq = (BigDecimal)arr[1]; | |
243 minmax[0] = minq.doubleValue(); | |
244 minmax[1] = maxq.doubleValue(); | |
245 } | |
246 | |
247 return minmax; | |
248 } | |
249 | |
223 | 250 |
224 /** | 251 /** |
225 * This method returns the first gauge that is intersected by <i>a</i> and | 252 * This method returns the first gauge that is intersected by <i>a</i> and |
226 * <i>b</i>, | 253 * <i>b</i>, |
227 * | 254 * |