[PATCH] Avoid NPE if some meta data does not exist

Wald Commits scm-commit at wald.intevation.org
Thu Jul 3 13:27:22 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1404386834 -7200
# Branch facet-metadata
# Node ID b15a6ed7c613113896033f310fb92b010eb75755
# Parent  95301de332bebd514c28437bd8ac214d4c7e41e6
Avoid NPE if some meta data does not exist.

diff -r 95301de332be -r b15a6ed7c613 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java
--- 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) {


More information about the Dive4Elements-commits mailing list