Mercurial > dive4elements > river
changeset 8815:c4ce25093953
Avoid some annoying NPEs when developing with sparsely filled database.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 09 May 2017 17:58:10 +0200 (2017-05-09) |
parents | 19fa9fc39fa2 |
children | f5e126739c36 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/services/RiverInfoService.java backend/src/main/java/org/dive4elements/river/model/River.java |
diffstat | 2 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/RiverInfoService.java Tue May 09 16:05:42 2017 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/RiverInfoService.java Tue May 09 17:58:10 2017 +0200 @@ -64,17 +64,20 @@ double[] minmax = river.determineMinMaxDistance(); double[] minmaxq = river.determineMinMaxQ(); + Long offnumber = river.getOfficialNumber(); Element r = ec.create("river"); ec.addAttr(r, "name", river.getName(), true); - ec.addAttr(r, "start", Double.toString(minmax[0]), true); - ec.addAttr(r, "end", Double.toString(minmax[1]), true); + ec.addAttr(r, "start", + minmax != null ? Double.toString(minmax[0]) : "", true); + ec.addAttr(r, "end", + minmax != null ? Double.toString(minmax[1]) : "", true); ec.addAttr(r, "wstunit", river.getWstUnit().getName(), true); ec.addAttr(r, "kmup", Boolean.toString(river.getKmUp()), true); ec.addAttr(r, "minq", Double.toString(minmaxq[0]), true); ec.addAttr(r, "maxq", Double.toString(minmaxq[1]), true); - ec.addAttr(r, "official", Long.toString(river.getOfficialNumber()), - true); + ec.addAttr(r, "official", + offnumber != null ? Long.toString(offnumber) : "", true); ec.addAttr(r, "model-uuid", river.getModelUuid(), true); riverele.appendChild(r);
--- a/backend/src/main/java/org/dive4elements/river/model/River.java Tue May 09 16:05:42 2017 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/River.java Tue May 09 17:58:10 2017 +0200 @@ -393,8 +393,10 @@ if (!result.isEmpty()) { Object[] minMax = result.get(0); - return new double[] { ((BigDecimal)minMax[0]).doubleValue(), - ((BigDecimal)minMax[1]).doubleValue() }; + if (minMax[0] != null && minMax[1] != null) { + return new double[] { ((BigDecimal)minMax[0]).doubleValue(), + ((BigDecimal)minMax[1]).doubleValue() }; + } } return null;