changeset 3780:7fa38f8bcd8d

Avoid NPE if the user selects onlyone sort of characteristic diameter. flys-artifacts/trunk@5487 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 17 Sep 2012 09:16:20 +0000
parents 3530e23e5c3e
children 8e713e9bb4d7
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java
diffstat 3 files changed, 28 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Sun Sep 16 20:45:24 2012 +0000
+++ b/flys-artifacts/ChangeLog	Mon Sep 17 09:16:20 2012 +0000
@@ -1,3 +1,11 @@
+2012-09-17  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java:
+	  Extract characteristic diameter only if the user selected a diameter.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java:
+	  Calculate for selected diameter only.
+
 2012-09-16	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java	Sun Sep 16 20:45:24 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java	Mon Sep 17 09:16:20 2012 +0000
@@ -47,15 +47,17 @@
     }
 
     public List<String> getBedDiameter() {
-        if (bedDiameter == null) {
-            bedDiameter = extractDiameter(getString("bed_diameter"));
+        String value = getString("bed_diameter");
+        if (bedDiameter == null && value != null) {
+            bedDiameter = extractDiameter(value);
         }
         return bedDiameter;
     }
 
     public List<String> getBedloadDiameter() {
-        if (bedloadDiameter == null) {
-            bedloadDiameter = extractDiameter(getString("load_diameter"));
+        String value = getString("load_diameter");
+        if (bedloadDiameter == null && value != null) {
+            bedloadDiameter = extractDiameter(value);
         }
         return bedloadDiameter;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java	Sun Sep 16 20:45:24 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java	Mon Sep 17 09:16:20 2012 +0000
@@ -99,20 +99,23 @@
                     to,
                     dr.getFrom(),
                     dr.getTo());
+            if (bedDiameter != null) {
+                for (String bd : bedDiameter) {
+                    BedQualityResult bedResult =
+                        calculateBed(bedMeasurements, bd, dr);
 
-            for (String bd : bedDiameter) {
-                BedQualityResult bedResult =
-                    calculateBed(bedMeasurements, bd, dr);
-
-                //Avoid adding empty result sets.
-                if (!bedResult.isEmpty()) {
-                    results.add(bedResult);
+                    // Avoid adding empty result sets.
+                    if (!bedResult.isEmpty()) {
+                        results.add(bedResult);
+                    }
                 }
             }
-            for (String bld : bedloadDiameter) {
-               BedQualityResult loadResult =
-                    calculateBedload(loadMeasurements, bld, dr);
-                results.add(loadResult);
+            if (bedloadDiameter != null) {
+                for (String bld : bedloadDiameter) {
+                    BedQualityResult loadResult =
+                        calculateBedload(loadMeasurements, bld, dr);
+                    results.add(loadResult);
+                }
             }
         }
 

http://dive4elements.wald.intevation.org