Skip to content

Commit

Permalink
Address sonorcloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dippindots committed Sep 11, 2024
1 parent 002e515 commit 8c0f82b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.springframework.lang.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand All @@ -24,7 +24,7 @@ public static StudyViewFilterHelper build(@Nullable StudyViewFilter studyViewFil
studyViewFilter = new StudyViewFilter();
}
if (Objects.isNull(genericAssayProfilesMap)) {
genericAssayProfilesMap = new HashMap<>();
genericAssayProfilesMap = new EnumMap<>(DataSource.class);
}
if (Objects.isNull(customDataSamples)) {
customDataSamples = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public class StudyViewMyBatisRepository implements StudyViewRepository {

private Map<DataSource, List<ClinicalAttribute>> clinicalAttributesMap = new EnumMap<>(DataSource.class);
private Map<DataSource, List<MolecularProfile>> genericAssayProfilesMap = new EnumMap<>(DataSource.class);



private static final List<String> FILTERED_CLINICAL_ATTR_VALUES = Collections.emptyList();
private final StudyViewMapper mapper;

Expand Down Expand Up @@ -217,25 +216,18 @@ public List<ClinicalDataCount> getGenomicDataBinCounts(StudyViewFilterContext st
public List<ClinicalDataCount> getGenericAssayDataBinCounts(StudyViewFilterContext studyViewFilterContext, List<String> attributeIds) {
return mapper.getGenericAssayDataBinCounts(createStudyViewFilterHelper(studyViewFilterContext), attributeIds);
}

private void buildClinicalAttributeNameMap() {
clinicalAttributesMap = this.getClinicalAttributes()
.stream()
.collect(Collectors.groupingBy(ca -> ca.getPatientAttribute() ? DataSource.PATIENT : DataSource.SAMPLE));
.collect(Collectors.groupingBy(ca -> ca.getPatientAttribute().booleanValue() ? DataSource.PATIENT : DataSource.SAMPLE));
}

private void buildGenericAssayProfilesMap() {
genericAssayProfilesMap = this.getGenericAssayProfiles()
.stream()
.collect(Collectors.groupingBy(ca -> ca.getPatientLevel().booleanValue() ? DataSource.PATIENT : DataSource.SAMPLE));
}

private Map<DataSource, List<ClinicalAttribute>> getClinicalAttributeNameMap() {
if (clinicalAttributesMap.isEmpty()) {
buildClinicalAttributeNameMap();
}
return clinicalAttributesMap;
}

private Map<DataSource, List<MolecularProfile>> getGenericAssayProfilesMap() {
if (genericAssayProfilesMap.isEmpty()) {
Expand Down
18 changes: 4 additions & 14 deletions src/main/java/org/cbioportal/web/columnar/BasicDataBinner.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,20 @@ public <T extends DataBinCountFilter, S extends DataBinFilter, U extends DataBin

private <S extends DataBinFilter> void removeSelfFromFilter(S dataBinFilter, StudyViewFilter studyViewFilter) {
switch (dataBinFilter) {
case ClinicalDataBinFilter clinicalDataBinFilter -> {
if (studyViewFilter.getClinicalDataFilters() != null) {
case ClinicalDataBinFilter clinicalDataBinFilter when studyViewFilter.getClinicalDataFilters() != null ->
studyViewFilter.getClinicalDataFilters().removeIf(f -> f.getAttributeId().equals(clinicalDataBinFilter.getAttributeId()));
}
}
case GenomicDataBinFilter genomicDataBinFilter -> {
if (studyViewFilter.getGenomicDataFilters() != null) {
case GenomicDataBinFilter genomicDataBinFilter when studyViewFilter.getGenomicDataFilters() != null ->
studyViewFilter.getGenomicDataFilters().removeIf(f ->
f.getHugoGeneSymbol().equals(genomicDataBinFilter.getHugoGeneSymbol())
&& f.getProfileType().equals(genomicDataBinFilter.getProfileType())
);
}
}
case GenericAssayDataBinFilter genericAssayDataBinFilter -> {
if (studyViewFilter.getGenericAssayDataFilters() != null) {
case GenericAssayDataBinFilter genericAssayDataBinFilter when studyViewFilter.getGenericAssayDataFilters() != null ->
studyViewFilter.getGenericAssayDataFilters().removeIf(f ->
f.getStableId().equals(genericAssayDataBinFilter.getStableId())
&& f.getProfileType().equals(genericAssayDataBinFilter.getProfileType())
);
}
}
default -> {
// Do not remove any filters
}
}
}
Expand Down Expand Up @@ -223,7 +215,6 @@ private <T extends DataBinFilter, U extends DataBin> List<U> calculateStaticData

for (T dataBinFilter : dataBinFilters) {
// if there is data for requested attribute
// TODO: consider if this is correct to passing in a empty map
if (attributeDatatypeMap.isEmpty() || attributeDatatypeMap.containsKey(getDataBinFilterUniqueKey(dataBinFilter))) {
List<U> dataBins = dataBinner
.calculateClinicalDataBins(
Expand Down Expand Up @@ -252,7 +243,6 @@ private <T extends DataBinFilter, U extends DataBin> List<U> calculateDynamicDat

for (T dataBinFilter : dataBinFilters) {
// if there is data for requested attribute
// TODO: consider if this is correct to passing in a empty map
if (attributeDatatypeMap.isEmpty() || attributeDatatypeMap.containsKey(getDataBinFilterUniqueKey(dataBinFilter))) {
List<U> dataBins = dataBinner
.calculateDataBins(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.cbioportal.persistence.mybatisclickhouse;

import org.cbioportal.model.ClinicalAttribute;
import org.cbioportal.model.ClinicalDataCount;
import org.cbioportal.persistence.enums.DataSource;
import org.cbioportal.persistence.helper.StudyViewFilterHelper;
import org.cbioportal.persistence.mybatisclickhouse.config.MyBatisConfig;
import org.cbioportal.web.parameter.ClinicalDataFilter;
Expand All @@ -20,9 +18,7 @@

import java.math.BigDecimal;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;

Expand Down

0 comments on commit 8c0f82b

Please sign in to comment.