Mercurial > dive4elements > river
changeset 2791:c9815016a3bb
Merged revisions 4536 via svnmerge from
file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-artifacts/trunk
........
r4536 | ingo | 2012-05-27 15:35:15 +0200 (So, 27 Mai 2012) | 1 line
Added more checks in CrossSectionFactory.isNewst() to prevent IndexOutOfBoundsExceptions.
........
flys-artifacts/tags/2.7@4538 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Sun, 27 May 2012 13:39:30 +0000 |
parents | 19c119601111 |
children | fe987587ebc9 |
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:39:30 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:39:30 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()); + } }