Skip to content

Commit

Permalink
Fix Sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman committed Nov 14, 2024
1 parent 1e641db commit 0436da7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public List<ClinicalDataCountItem> 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));
Expand All @@ -192,8 +192,7 @@ public List<ClinicalDataCountItem> getClinicalDataCounts(StudyViewFilter studyVi
condition = "@cacheEnabledConfig.getEnabledClickhouse()"
)
public List<ClinicalAttribute> getClinicalAttributesForStudies(List<String> studyIds) {
return studyViewRepository.getClinicalAttributesForStudies(studyIds).stream()
.collect(Collectors.toList());
return studyViewRepository.getClinicalAttributesForStudies(studyIds).stream().toList();
}

@Cacheable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
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;
import java.util.stream.Collectors;

public class StudyViewColumnarServiceUtil {

private StudyViewColumnarServiceUtil() {}

public static List<ClinicalDataCountItem> mergeClinicalDataCounts(
List<ClinicalDataCountItem> items
) {
items.forEach(attr -> {
Map<String, List<ClinicalDataCount>> countsPerType = attr.getCounts().stream()
.collect(Collectors.groupingBy(ClinicalDataCount::getValue));
List<ClinicalDataCount> res = countsPerType.entrySet().stream().map((entry) -> {
List<ClinicalDataCount> 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;
Expand All @@ -42,7 +42,7 @@ public static List<ClinicalDataCountItem> addClinicalDataCountsForMissingAttribu
List<ClinicalDataCountItem> result = new ArrayList<>(counts);

attributes.forEach(attr -> {
Integer count = attr.getPatientAttribute() ? filteredPatientCount : filteredSampleCount;
Integer count = attr.getPatientAttribute().booleanValue() == true ? filteredPatientCount : filteredSampleCount;

if (!map.containsKey(attr.getAttrId())) {
ClinicalDataCountItem newItem = new ClinicalDataCountItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0436da7

Please sign in to comment.