diff --git a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java index 1a61936f22a..54cdf5e130a 100644 --- a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java @@ -170,7 +170,7 @@ public List getClinicalDataCounts(StudyViewFilter studyVi var attributes = getClinicalAttributesForStudies(involvedCancerStudies) .stream() .filter(attribute -> filteredAttributes.contains(attribute.getAttrId())) - .collect(Collectors.toList()); + .toList(); Integer filteredSampleCount = studyViewRepository.getFilteredSamplesCount(createContext(studyViewFilter)); Integer filteredPatientCount = studyViewRepository.getFilteredPatientCount(createContext(studyViewFilter)); @@ -192,8 +192,7 @@ public List getClinicalDataCounts(StudyViewFilter studyVi condition = "@cacheEnabledConfig.getEnabledClickhouse()" ) public List getClinicalAttributesForStudies(List studyIds) { - return studyViewRepository.getClinicalAttributesForStudies(studyIds).stream() - .collect(Collectors.toList()); + return studyViewRepository.getClinicalAttributesForStudies(studyIds).stream().toList(); } @Cacheable( diff --git a/src/main/java/org/cbioportal/service/util/StudyViewColumnarServiceUtil.java b/src/main/java/org/cbioportal/service/util/StudyViewColumnarServiceUtil.java index 1260319aae6..4975cb9730b 100644 --- a/src/main/java/org/cbioportal/service/util/StudyViewColumnarServiceUtil.java +++ b/src/main/java/org/cbioportal/service/util/StudyViewColumnarServiceUtil.java @@ -3,8 +3,6 @@ import org.cbioportal.model.ClinicalAttribute; import org.cbioportal.model.ClinicalDataCount; import org.cbioportal.model.ClinicalDataCountItem; -import org.cbioportal.model.Sample; - import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -12,19 +10,21 @@ public class StudyViewColumnarServiceUtil { + private StudyViewColumnarServiceUtil() {} + public static List mergeClinicalDataCounts( List items ) { items.forEach(attr -> { Map> countsPerType = attr.getCounts().stream() .collect(Collectors.groupingBy(ClinicalDataCount::getValue)); - List res = countsPerType.entrySet().stream().map((entry) -> { + List res = countsPerType.entrySet().stream().map(entry -> { ClinicalDataCount mergedCount = new ClinicalDataCount(); mergedCount.setAttributeId(attr.getAttributeId()); mergedCount.setValue(entry.getKey()); mergedCount.setCount(entry.getValue().stream().mapToInt(ClinicalDataCount::getCount).sum()); return mergedCount; - }).collect(Collectors.toList()); + }).toList(); attr.setCounts(res); }); return items; @@ -42,7 +42,7 @@ public static List addClinicalDataCountsForMissingAttribu List result = new ArrayList<>(counts); attributes.forEach(attr -> { - Integer count = attr.getPatientAttribute() ? filteredPatientCount : filteredSampleCount; + Integer count = attr.getPatientAttribute().booleanValue() ? filteredPatientCount : filteredSampleCount; if (!map.containsKey(attr.getAttrId())) { ClinicalDataCountItem newItem = new ClinicalDataCountItem(); diff --git a/src/test/java/org/cbioportal/service/util/StudyViewColumnarServiceUtilTest.java b/src/test/java/org/cbioportal/service/util/StudyViewColumnarServiceUtilTest.java index 6030e518ab1..9e4b0aabebf 100644 --- a/src/test/java/org/cbioportal/service/util/StudyViewColumnarServiceUtilTest.java +++ b/src/test/java/org/cbioportal/service/util/StudyViewColumnarServiceUtilTest.java @@ -3,7 +3,6 @@ import org.cbioportal.model.ClinicalAttribute; import org.cbioportal.model.ClinicalDataCount; import org.cbioportal.model.ClinicalDataCountItem; -import org.cbioportal.model.Sample; import org.junit.Assert; import org.junit.Test;