comparison flys-backend/src/main/java/de/intevation/flys/model/Gauge.java @ 3790:6546c0bbc6f9

Backend: 'Pegelinfo' needs min/max Q, too. flys-backend/trunk@5417 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 10 Sep 2012 09:50:43 +0000
parents 9f92c42b7a81
children e72c7fe202dd
comparison
equal deleted inserted replaced
3789:9f92c42b7a81 3790:6546c0bbc6f9
295 Query query = session.createQuery( 295 Query query = session.createQuery(
296 "select max(mv.value) as max, min(mv.value) as min " + 296 "select max(mv.value) as max, min(mv.value) as min " +
297 "from MainValue as mv " + 297 "from MainValue as mv " +
298 "join mv.mainValue as nmv " + 298 "join mv.mainValue as nmv " +
299 "join nmv.type mvt " + 299 "join nmv.type mvt " +
300 "where mvt.name = 'W' and mv.gauge.id = :gauge_id " + 300 "where mvt.name in ('W', 'Q') " +
301 "and mv.gauge.id = :gauge_id " +
301 "group by mvt.name order by mvt.name" 302 "group by mvt.name order by mvt.name"
302 ); 303 );
303 304
304 query.setParameter("gauge_id", getId()); 305 query.setParameter("gauge_id", getId());
305 306
306 List<Object> results = query.list(); 307 List<Object> results = query.list();
307 if (results.size() == 0) { 308 if (results.isEmpty()) {
308 // No values found 309 // No values found
309 return new MinMaxWQ(); 310 return new MinMaxWQ();
310 } 311 }
311 312
312 BigDecimal maxw; 313 Object[] arr = (Object[]) results.get(0);
313 BigDecimal minw; 314 BigDecimal maxw = (BigDecimal)arr[0];
315 BigDecimal minw = (BigDecimal)arr[1];
314 BigDecimal maxq = null; 316 BigDecimal maxq = null;
315 BigDecimal minq = null; 317 BigDecimal minq = null;
316 318
317 Object[] arr = (Object[]) results.get(0);
318 maxw = (BigDecimal)arr[0];
319 minw = (BigDecimal)arr[1];
320 319
321 if (results.size() > 1) { 320 if (results.size() > 1) {
322 arr = (Object[]) results.get(1); 321 arr = (Object[]) results.get(1);
323 maxq = (BigDecimal)arr[0]; 322 maxq = (BigDecimal)arr[0];
324 minq = (BigDecimal)arr[1]; 323 minq = (BigDecimal)arr[1];

http://dive4elements.wald.intevation.org