diff --git a/src/main/java/org/cbioportal/service/ClinicalDataDensityPlotService.java b/src/main/java/org/cbioportal/service/ClinicalDataDensityPlotService.java index 641ea3dbeb4..211963e11b8 100644 --- a/src/main/java/org/cbioportal/service/ClinicalDataDensityPlotService.java +++ b/src/main/java/org/cbioportal/service/ClinicalDataDensityPlotService.java @@ -2,11 +2,12 @@ import org.cbioportal.model.ClinicalData; import org.cbioportal.model.DensityPlotData; +import org.cbioportal.web.parameter.StudyViewFilter; import org.cbioportal.web.util.DensityPlotParameters; import java.math.BigDecimal; import java.util.List; public interface ClinicalDataDensityPlotService { - DensityPlotData getDensityPlotData(List filteredClinicalData, DensityPlotParameters densityPlotParameters); + DensityPlotData getDensityPlotData(List filteredClinicalData, DensityPlotParameters densityPlotParameters, StudyViewFilter studyViewFilter); } diff --git a/src/main/java/org/cbioportal/service/ViolinPlotService.java b/src/main/java/org/cbioportal/service/ViolinPlotService.java index 2737ffc24a1..37eade2f739 100644 --- a/src/main/java/org/cbioportal/service/ViolinPlotService.java +++ b/src/main/java/org/cbioportal/service/ViolinPlotService.java @@ -3,6 +3,7 @@ import org.cbioportal.model.ClinicalData; import org.cbioportal.model.ClinicalViolinPlotData; import org.cbioportal.model.Sample; +import org.cbioportal.web.parameter.StudyViewFilter; import java.math.BigDecimal; import java.util.List; @@ -15,6 +16,7 @@ ClinicalViolinPlotData getClinicalViolinPlotData( BigDecimal axisEnd, BigDecimal numCurvePoints, Boolean useLogScale, - BigDecimal sigmaMultiplier + BigDecimal sigmaMultiplier, + StudyViewFilter studyViewFilter ); } diff --git a/src/main/java/org/cbioportal/service/impl/ClinicalDataDensityPlotServiceImpl.java b/src/main/java/org/cbioportal/service/impl/ClinicalDataDensityPlotServiceImpl.java index b6e4a55e679..e4abf2e631c 100644 --- a/src/main/java/org/cbioportal/service/impl/ClinicalDataDensityPlotServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/ClinicalDataDensityPlotServiceImpl.java @@ -8,6 +8,7 @@ import org.cbioportal.model.DensityPlotData; import org.cbioportal.service.ClinicalDataDensityPlotService; import org.cbioportal.web.columnar.StudyViewColumnStoreController; +import org.cbioportal.web.parameter.StudyViewFilter; import org.cbioportal.web.util.DensityPlotParameters; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @@ -25,10 +26,10 @@ public class ClinicalDataDensityPlotServiceImpl implements ClinicalDataDensityPl @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override - public DensityPlotData getDensityPlotData(List sampleClinicalData, DensityPlotParameters densityPlotParameters) { + public DensityPlotData getDensityPlotData(List sampleClinicalData, DensityPlotParameters densityPlotParameters, StudyViewFilter studyViewFilter) { DensityPlotData result = new DensityPlotData(); result.setBins(new ArrayList<>()); diff --git a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java index 26e988f73cb..5402ddc6584 100644 --- a/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/StudyViewColumnarServiceImpl.java @@ -51,11 +51,10 @@ public StudyViewColumnarServiceImpl(StudyViewRepository studyViewRepository, Alt this.treatmentCountReportService = treatmentCountReportService; this.customDataFilterUtil = customDataFilterUtil; } - - // should condition = "@cacheEnabledConfig.getEnabledClickhouse() && #singleStudyUnfiltered" + @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getFilteredSamples(StudyViewFilter studyViewFilter) { @@ -65,7 +64,7 @@ public List getFilteredSamples(StudyViewFilter studyViewFilter) { @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getMutatedGenes(StudyViewFilter studyViewFilter) throws StudyNotFoundException { @@ -74,7 +73,7 @@ public List getMutatedGenes(StudyViewFilter studyViewFilt @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getMolecularProfileSampleCounts(StudyViewFilter studyViewFilter) { @@ -83,7 +82,7 @@ public List getMolecularProfileSampleCounts(StudyViewFilter st @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getClinicalEventTypeCounts(StudyViewFilter studyViewFilter) { @@ -92,7 +91,7 @@ public List getClinicalEventTypeCounts(StudyViewFilter s @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public PatientTreatmentReport getPatientTreatmentReport(StudyViewFilter studyViewFilter) { @@ -101,7 +100,7 @@ public PatientTreatmentReport getPatientTreatmentReport(StudyViewFilter studyVie @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewFilter) { @@ -110,7 +109,7 @@ public SampleTreatmentReport getSampleTreatmentReport(StudyViewFilter studyViewF @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getGenomicDataBinCounts(StudyViewFilter studyViewFilter, List genomicDataBinFilters) { @@ -119,7 +118,7 @@ public List getGenomicDataBinCounts(StudyViewFilter study @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getGenericAssayDataBinCounts(StudyViewFilter studyViewFilter, List genericAssayDataBinFilters) { @@ -132,7 +131,7 @@ public List getCnaGenes(StudyViewFilter studyViewFilter) @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getStructuralVariantGenes(StudyViewFilter studyViewFilter) throws StudyNotFoundException { @@ -141,7 +140,7 @@ public List getStructuralVariantGenes(StudyViewFilter stu @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public Map getClinicalAttributeDatatypeMap() { @@ -150,7 +149,7 @@ public Map getClinicalAttributeDatatypeMap() { @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getClinicalDataCounts(StudyViewFilter studyViewFilter, List filteredAttributes) { @@ -169,7 +168,7 @@ public List getClinicalDataCounts(StudyViewFilter studyVi @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getCaseListDataCounts(StudyViewFilter studyViewFilter) { @@ -181,7 +180,7 @@ public List getCaseListDataCounts(StudyViewFilter studyViewFi @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getPatientClinicalData(StudyViewFilter studyViewFilter, List attributeIds) { @@ -190,7 +189,7 @@ public List getPatientClinicalData(StudyViewFilter studyViewFilter @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getSampleClinicalData(StudyViewFilter studyViewFilter, List attributeIds) { @@ -199,7 +198,7 @@ public List getSampleClinicalData(StudyViewFilter studyViewFilter, @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getCNACountsByGeneSpecific(StudyViewFilter studyViewFilter, List genomicDataFilters) { @@ -208,7 +207,7 @@ public List getCNACountsByGeneSpecific(StudyViewFilter stu @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getGenericAssayDataCounts(StudyViewFilter studyViewFilter, List genericAssayDataFilters) { @@ -217,7 +216,7 @@ public List getGenericAssayDataCounts(StudyViewFilter @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getMutationCountsByGeneSpecific(StudyViewFilter studyViewFilter, List genomicDataFilters) { @@ -238,7 +237,7 @@ public List getMutationCountsByGeneSpecific(StudyViewFilte @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) @Override public List getMutationTypeCountsByGeneSpecific(StudyViewFilter studyViewFilter, List genomicDataFilters) { diff --git a/src/main/java/org/cbioportal/service/impl/ViolinPlotServiceImpl.java b/src/main/java/org/cbioportal/service/impl/ViolinPlotServiceImpl.java index 53e7f620874..e3da1e50019 100644 --- a/src/main/java/org/cbioportal/service/impl/ViolinPlotServiceImpl.java +++ b/src/main/java/org/cbioportal/service/impl/ViolinPlotServiceImpl.java @@ -5,6 +5,7 @@ import org.apache.commons.math3.stat.descriptive.rank.Percentile; import org.cbioportal.model.*; import org.cbioportal.service.ViolinPlotService; +import org.cbioportal.web.parameter.StudyViewFilter; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @@ -20,7 +21,7 @@ public class ViolinPlotServiceImpl implements ViolinPlotService { @Cacheable( cacheResolver = "staticRepositoryCacheOneResolver", - condition = "@cacheEnabledConfig.getEnabledClickhouse()" + condition = "@cacheEnabledConfig.getEnabledClickhouse() && @studyViewFilterUtil.isUnfiltered(#studyViewFilter)" ) public ClinicalViolinPlotData getClinicalViolinPlotData( List sampleClinicalDataForViolinPlot, @@ -29,7 +30,8 @@ public ClinicalViolinPlotData getClinicalViolinPlotData( BigDecimal axisEnd, BigDecimal numCurvePoints, Boolean useLogScale, - BigDecimal sigmaMultiplier + BigDecimal sigmaMultiplier, + StudyViewFilter studyViewFilter ) { ClinicalViolinPlotData result = new ClinicalViolinPlotData(); result.setAxisStart(Double.POSITIVE_INFINITY); diff --git a/src/main/java/org/cbioportal/web/StudyViewController.java b/src/main/java/org/cbioportal/web/StudyViewController.java index 87b2f043578..c5bf0c4777c 100644 --- a/src/main/java/org/cbioportal/web/StudyViewController.java +++ b/src/main/java/org/cbioportal/web/StudyViewController.java @@ -862,7 +862,8 @@ public ResponseEntity fetchClinicalDataViolinPlots( axisEnd, numCurvePoints, useLogScale, - sigmaMultiplier + sigmaMultiplier, + interceptedStudyViewFilter ); return new ResponseEntity<>(result, HttpStatus.OK); diff --git a/src/main/java/org/cbioportal/web/columnar/StudyViewColumnStoreController.java b/src/main/java/org/cbioportal/web/columnar/StudyViewColumnStoreController.java index 7ae5c15fc08..d74af6613b9 100644 --- a/src/main/java/org/cbioportal/web/columnar/StudyViewColumnStoreController.java +++ b/src/main/java/org/cbioportal/web/columnar/StudyViewColumnStoreController.java @@ -309,7 +309,7 @@ public ResponseEntity fetchClinicalDataDensityPlot( .build(); List sampleClinicalDataList = studyViewColumnarService.getSampleClinicalData(interceptedStudyViewFilter, xyAttributeId); - DensityPlotData result = clinicalDataDensityPlotService.getDensityPlotData(sampleClinicalDataList, densityPlotParameters); + DensityPlotData result = clinicalDataDensityPlotService.getDensityPlotData(sampleClinicalDataList, densityPlotParameters, interceptedStudyViewFilter); return new ResponseEntity<>(result, HttpStatus.OK); } @@ -378,7 +378,8 @@ public ResponseEntity fetchClinicalDataViolinPlots( axisEnd, numCurvePoints, useLogScale, - sigmaMultiplier + sigmaMultiplier, + interceptedStudyViewFilter ); return new ResponseEntity<>(result, HttpStatus.OK); diff --git a/src/main/java/org/cbioportal/web/util/StudyViewFilterUtil.java b/src/main/java/org/cbioportal/web/util/StudyViewFilterUtil.java index 3ebb8021d50..c91a7229b09 100644 --- a/src/main/java/org/cbioportal/web/util/StudyViewFilterUtil.java +++ b/src/main/java/org/cbioportal/web/util/StudyViewFilterUtil.java @@ -200,8 +200,16 @@ public List getClinicalDataCountsFromCustomData(Collectio } public boolean isSingleStudyUnfiltered(StudyViewFilter filter) { + return isSingleStudy(filter) && isUnfiltered(filter); + } + + public boolean isSingleStudy(StudyViewFilter filter) { + return filter.getStudyIds() != null && + filter.getStudyIds().size() == 1; + } + + public boolean isUnfiltered(StudyViewFilter filter) { return filter.getStudyIds() != null && - filter.getStudyIds().size() == 1 && (filter.getClinicalDataFilters() == null || filter.getClinicalDataFilters().isEmpty()) && (filter.getGeneFilters() == null || filter.getGeneFilters().isEmpty()) && (filter.getSampleTreatmentFilters() == null || filter.getSampleTreatmentFilters().getFilters().isEmpty()) && diff --git a/src/test/java/org/cbioportal/service/impl/ViolinPlotServiceImplTest.java b/src/test/java/org/cbioportal/service/impl/ViolinPlotServiceImplTest.java index 2403f035f47..2b00e7f2c66 100644 --- a/src/test/java/org/cbioportal/service/impl/ViolinPlotServiceImplTest.java +++ b/src/test/java/org/cbioportal/service/impl/ViolinPlotServiceImplTest.java @@ -4,6 +4,7 @@ import org.cbioportal.model.ClinicalViolinPlotData; import org.cbioportal.model.ClinicalViolinPlotRowData; import org.cbioportal.model.Sample; +import org.cbioportal.web.parameter.StudyViewFilter; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -77,7 +78,8 @@ public void getClinicalViolinPlotData() throws Exception { new BigDecimal(1), new BigDecimal(NUM_CURVE_POINTS), false, - new BigDecimal(1) + new BigDecimal(1), + new StudyViewFilter() );