# HG changeset patch # User Raimund Renkert # Date 1347873380 0 # Node ID 7fa38f8bcd8d3c74f59100a7e788d7bddb926a0e # Parent 3530e23e5c3ead4f14bce83e61d665f413664708 Avoid NPE if the user selects onlyone sort of characteristic diameter. flys-artifacts/trunk@5487 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3530e23e5c3e -r 7fa38f8bcd8d flys-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/artifacts/model/MainValuesQFacet.java, diff -r 3530e23e5c3e -r 7fa38f8bcd8d flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.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 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 getBedloadDiameter() { - if (bedloadDiameter == null) { - bedloadDiameter = extractDiameter(getString("load_diameter")); + String value = getString("load_diameter"); + if (bedloadDiameter == null && value != null) { + bedloadDiameter = extractDiameter(value); } return bedloadDiameter; } diff -r 3530e23e5c3e -r 7fa38f8bcd8d flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java --- 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); + } } }