Mercurial > dive4elements > river
changeset 2989:ee3dbc4a802d
Added more checks in CrossSectionFactory.isNewst() to prevent IndexOutOfBoundsExceptions.
flys-artifacts/trunk@4536 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Sun, 27 May 2012 13:35:15 +0000 (2012-05-27) |
parents | 5a8ec40752ea |
children | 749a40c76ca3 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionFactory.java |
diffstat | 2 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Sun May 27 10:50:11 2012 +0000 +++ b/flys-artifacts/ChangeLog Sun May 27 13:35:15 2012 +0000 @@ -1,3 +1,10 @@ +2012-05-27 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/CrossSectionFactory.java: + CrossSectionFactory.isNewest() will return true if the CrossSection is + the only CrossSection found in the database. No IndexOutOfBounds is + thrown. + 2012-05-27 Ingo Weinzierl <ingo@intevation.de> * Tagged module as '2.7'.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionFactory.java Sun May 27 10:50:11 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionFactory.java Sun May 27 13:35:15 2012 +0000 @@ -64,8 +64,15 @@ + " order by timeInterval.stopTime desc, timeInterval.startTime desc"); query.setParameter("riverid", section.getRiver().getId()); - CrossSection cs = (CrossSection) query.list().get(0); - return section.getId().equals(cs.getId()); + List result = query.list(); + + if (result == null || result.isEmpty()) { + return true; + } + else { + CrossSection cs = (CrossSection) result.get(0); + return section.getId().equals(cs.getId()); + } }