From 064913cf50a1897754344d9f412eabd2b3eb02e5 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 11 Oct 2024 16:49:14 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20handle=20possible=20null=20for=20the=20c?= =?UTF-8?q?ontaminantPollenBv=20recalculate=20but=E2=80=A6=20(#1669)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ca/bc/gov/backendstartapi/dto/PtValsCalReqDto.java | 2 +- .../gov/backendstartapi/service/ParentTreeService.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/dto/PtValsCalReqDto.java b/backend/src/main/java/ca/bc/gov/backendstartapi/dto/PtValsCalReqDto.java index 94cff9744..6d22d0a4a 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/dto/PtValsCalReqDto.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/dto/PtValsCalReqDto.java @@ -13,4 +13,4 @@ public record PtValsCalReqDto( @NotNull List orchardPtVals, @NotNull List smpMixIdAndProps, @NotNull Integer smpParentsOutside, - @NotNull BigDecimal contaminantPollenBv) {} + BigDecimal contaminantPollenBv) {} diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/ParentTreeService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/ParentTreeService.java index 1a05562c3..400d110e8 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/ParentTreeService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/ParentTreeService.java @@ -203,7 +203,12 @@ public PtCalculationResDto calculatePtVals(PtValsCalReqDto ptVals) { Integer totalNonOrchardPollen = 0; Integer numNonOrchardPollen = 0; - SparLog.debug("ptVals.contaminantPollenBv(): {}", ptVals.contaminantPollenBv()); + double contaminantPollenBvDouble = 0; + if (ValueUtil.hasValue(ptVals.contaminantPollenBv())) { + contaminantPollenBvDouble = ptVals.contaminantPollenBv().doubleValue(); + } + + SparLog.debug("contaminantPollenBvDouble: {}", contaminantPollenBvDouble); // --Third pass to calc values that depend on totals derived above and the remainder for (OrchardParentTreeValsDto parentTreeRow : ptVals.orchardPtVals()) { @@ -257,7 +262,7 @@ public PtCalculationResDto calculatePtVals(PtValsCalReqDto ptVals) { // --col:AA double vmContamContrib = - (auxValueAa * ptVals.contaminantPollenBv().doubleValue()) * femaleCropPop.doubleValue(); + (auxValueAa * contaminantPollenBvDouble) * femaleCropPop.doubleValue(); // --col:AB (depends on SUM(X)=v_sum_m_gw_contrib_orch_poll) double auxValueAb =