From b425acdaf81849c4bef4759aa3cb1247bf862be0 Mon Sep 17 00:00:00 2001 From: Onur Sumer Date: Fri, 13 Sep 2024 18:58:09 -0400 Subject: [PATCH] fix clinical data NA count logic --- .../service/impl/StudyViewColumnarServiceImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java index 6ab20d58e29..ed8a341edda 100644 --- a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import java.util.Map; @@ -228,11 +229,13 @@ public static List calculateMissingNaCountsForClinicalDat } // find "NA" or else create a new one - ClinicalDataCount naClinicalDataCount = clinicalDataCountItem + Optional naClinicalDataCountOptional = clinicalDataCountItem .getCounts() .stream() .filter(c -> c.getValue().equals("NA")) - .findFirst() + .findFirst(); + + ClinicalDataCount naClinicalDataCount = naClinicalDataCountOptional .orElseGet(() -> { // this should only happen when there are multiple studies ClinicalDataCount count = new ClinicalDataCount(); @@ -242,6 +245,11 @@ public static List calculateMissingNaCountsForClinicalDat return count; }); + // if not present we need to add naClinicalDataCount to the existing counts + if (naClinicalDataCountOptional.isEmpty()) { + clinicalDataCountItem.getCounts().add(naClinicalDataCount); + } + naClinicalDataCount.setCount(naClinicalDataCount.getCount() + casesWithoutClinicalData); } }