Mercurial > dive4elements > river
changeset 469:b5ca22aae092
Fixed index problem when an empty list is returned.
flys-backend/trunk@1708 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 15 Apr 2011 14:30:54 +0000 |
parents | 8d76556c9616 |
children | f4afea9b7537 |
files | flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/Wst.java |
diffstat | 2 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/ChangeLog Fri Apr 15 13:45:06 2011 +0000 +++ b/flys-backend/ChangeLog Fri Apr 15 14:30:54 2011 +0000 @@ -1,3 +1,8 @@ +2011-04-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/model/Wst.java (determineMinMaxQ): + Fixed index problem when an empty list is returned. + 2011-04-15 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/model/Wst.java: A Wst is now able to @@ -17,7 +22,7 @@ BEGIN; ALTER TABLE discharge_tables ADD COLUMN kind int NOT NULL DEFAULT 0; ALTER TABLE wsts ADD COLUMN kind int NOT NULL DEFAULT 0; - END; + COMMIT; * src/main/java/de/intevation/flys/model/DischargeTable.java src/main/java/de/intevation/flys/model/Wst.java,
--- a/flys-backend/src/main/java/de/intevation/flys/model/Wst.java Fri Apr 15 13:45:06 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/Wst.java Fri Apr 15 14:30:54 2011 +0000 @@ -126,18 +126,21 @@ " and range.id in " + " (select id from Range where not (a > :end or b < :start))"); - query.setParameter("wst", getId()); + query.setParameter("wst", getId()); query.setParameter("start", range.getA()); - query.setParameter("end", range.getB()); + query.setParameter("end", range.getB()); - List results = query.list(); - Object[] result = (Object[]) results.get(0); + List<Object []> results = query.list(); - return result != null - ? new double[] { - ((BigDecimal) result[0]).doubleValue(), - ((BigDecimal) result[1]).doubleValue() } - : null; + if (results.isEmpty()) { + return null; + } + + Object [] result = results.get(0); + + return new double [] { + ((BigDecimal)result[0]).doubleValue(), + ((BigDecimal)result[1]).doubleValue() }; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :