changeset 8006:b15a6ed7c613 facet-metadata

Avoid NPE if some meta data does not exist.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 03 Jul 2014 13:27:14 +0200
parents 95301de332be
children 5fc56103952a
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java	Thu Jul 03 12:31:13 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java	Thu Jul 03 13:27:14 2014 +0200
@@ -109,16 +109,26 @@
 
         int year = single.getYear() != null ? single.getYear() : 0;
 
+        String curElevModel = single.getCurElevationModel() != null ?
+            single.getCurElevationModel().getName() : "";
+        String oldElevModel = single.getOldElevationModel() != null ?
+            single.getOldElevationModel().getName() : "";
+        String riverElevModel = single.getRiver().getWstUnit() != null ?
+            single.getRiver().getWstUnit().getName() : "";
+        String type = single.getType() != null ?
+            single.getType().getName() : "";
+        String locationSystem = single.getLocationSystem() != null ?
+            single.getLocationSystem().getName() : "";
         MiddleBedHeightData data = new MiddleBedHeightData(
             year,
             year,
             single.getEvaluationBy(),
             single.getDescription(),
-            single.getCurElevationModel().getName(),
-            single.getOldElevationModel().getName(),
-            single.getRiver().getWstUnit().getName(),
-            single.getType().getName(),
-            single.getLocationSystem().getName(),
+            curElevModel,
+            oldElevModel,
+            riverElevModel,
+            type,
+            locationSystem,
             single.getSoundingWidth());
 
         for (BedHeightSingleValue value: values) {

http://dive4elements.wald.intevation.org