# HG changeset patch # User Sascha L. Teichmann # Date 1302877854 0 # Node ID b5ca22aae092f60e8510d6af0ad15f151c543aaa # Parent 8d76556c961684c553a03e63106f5203fb2c4e2c Fixed index problem when an empty list is returned. flys-backend/trunk@1708 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 8d76556c9616 -r b5ca22aae092 flys-backend/ChangeLog --- 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 + + * src/main/java/de/intevation/flys/model/Wst.java (determineMinMaxQ): + Fixed index problem when an empty list is returned. + 2011-04-15 Ingo Weinzierl * 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, diff -r 8d76556c9616 -r b5ca22aae092 flys-backend/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 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 :