Skip to content

Commit

Permalink
Update cBioPortal to dynamically load ch Components only when propert…
Browse files Browse the repository at this point in the history
…y clickhouse_enabled is set
  • Loading branch information
haynescd committed Dec 4, 2024
1 parent b72ddaa commit 1155336
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
run: |
cd ./data && ./init.sh && rm -rf ./studies/* && cd ../config && \
cat $PORTAL_SOURCE_DIR/src/main/resources/application.properties | \
sed 's|spring.datasource.mysql.url=.*|spring.datasource.mysql.url=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false|' | \
sed 's|spring.datasource.mysql.username=.*|spring.datasource.mysql.username=cbio_user|' | \
sed 's|spring.datasource.mysql.password=.*|spring.datasource.mysql.password=somepassword|' \
sed 's|spring.datasource.url=.*|spring.datasource.url=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false|' | \
sed 's|spring.datasource.username=.*|spring.datasource.username=cbio_user|' | \
sed 's|spring.datasource.password=.*|spring.datasource.password=somepassword|' \
> application.properties
- name: 'Copy cgds.sql file into Docker Compose'
run: cp ./cbioportal/src/main/resources/db-scripts/cgds.sql ./cbioportal-docker-compose/data/.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
package org.cbioportal.persistence.mybatis;

import org.cbioportal.model.AlterationCountByGene;
import org.cbioportal.model.CaseListDataCount;
import org.cbioportal.model.ClinicalAttribute;
import org.cbioportal.model.ClinicalData;
import org.cbioportal.model.ClinicalDataCount;
import org.cbioportal.model.ClinicalDataCountItem;
import org.cbioportal.model.ClinicalEventTypeCount;
import org.cbioportal.model.CopyNumberCountByGene;
import org.cbioportal.model.GenericAssayDataCountItem;
import org.cbioportal.model.GenomicDataCount;
import org.cbioportal.model.GenomicDataCountItem;
import org.cbioportal.model.MolecularProfile;
import org.cbioportal.model.PatientTreatment;
import org.cbioportal.model.Sample;
import org.cbioportal.model.SampleTreatment;
import org.cbioportal.model.StudyViewFilterContext;
import org.cbioportal.persistence.StudyViewRepository;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.parameter.ClinicalDataType;
import org.cbioportal.web.parameter.GenericAssayDataBinFilter;
import org.cbioportal.web.parameter.GenericAssayDataFilter;
import org.cbioportal.web.parameter.GenomicDataBinFilter;
import org.cbioportal.web.parameter.GenomicDataFilter;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Repository
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "false", matchIfMissing = true)
public class UnImplementedStudyViewMyBatisRepository implements StudyViewRepository {
@Override
public List<Sample> getFilteredSamples(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<String> getFilteredStudyIds(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<ClinicalData> getSampleClinicalData(StudyViewFilterContext studyViewFilterContext, List<String> attributeIds) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<ClinicalData> getPatientClinicalData(StudyViewFilterContext studyViewFilterContext, List<String> attributeIds) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");

}

@Override
public List<AlterationCountByGene> getMutatedGenes(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<AlterationCountByGene> getStructuralVariantGenes(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<CopyNumberCountByGene> getCnaGenes(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<ClinicalDataCountItem> getClinicalDataCounts(StudyViewFilterContext studyViewFilterContext, List<String> filteredAttributes) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<GenomicDataCount> getMolecularProfileSampleCounts(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public Map<String, ClinicalDataType> getClinicalAttributeDatatypeMap() {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<CaseListDataCount> getCaseListDataCountsPerStudy(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public Map<String, Integer> getTotalProfiledCounts(StudyViewFilterContext studyViewFilterContext, String alterationType, List<MolecularProfile> molecularProfiles) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<ClinicalAttribute> getClinicalAttributes() {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<ClinicalAttribute> getClinicalAttributesForStudies(List<String> studyIds) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public int getFilteredSamplesCount(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public int getFilteredPatientCount(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public Map<String, Set<String>> getMatchingGenePanelIds(StudyViewFilterContext studyViewFilterContext, String alterationType) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public int getTotalProfiledCountsByAlterationType(StudyViewFilterContext studyViewFilterContext, String alterationType) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public int getSampleProfileCountWithoutPanelData(StudyViewFilterContext studyViewFilterContext, String alterationType) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<ClinicalEventTypeCount> getClinicalEventTypeCounts(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<PatientTreatment> getPatientTreatments(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public int getTotalPatientTreatmentCount(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<SampleTreatment> getSampleTreatments(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public int getTotalSampleTreatmentCount(StudyViewFilterContext studyViewFilterContext) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<GenomicDataCountItem> getCNACounts(StudyViewFilterContext studyViewFilterContext, List<GenomicDataFilter> genomicDataFilters) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<GenericAssayDataCountItem> getGenericAssayDataCounts(StudyViewFilterContext studyViewFilterContext, List<GenericAssayDataFilter> genericAssayDataFilters) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public Map<String, Integer> getMutationCounts(StudyViewFilterContext studyViewFilterContext, GenomicDataFilter genomicDataFilter) {
throw new UnsupportedOperationException("StudyViewRepository Feature Not supported... Contact cbio admin.");
}

@Override
public List<GenomicDataCountItem> getMutationCountsByType(StudyViewFilterContext studyViewFilterContext, List<GenomicDataFilter> genomicDataFilters) {
return List.of();
}

@Override
public List<ClinicalDataCount> getGenomicDataBinCounts(StudyViewFilterContext studyViewFilterContext, List<GenomicDataBinFilter> genomicDataBinFilters) {
return List.of();
}

@Override
public List<ClinicalDataCount> getGenericAssayDataBinCounts(StudyViewFilterContext studyViewFilterContext, List<GenericAssayDataBinFilter> genericAssayDataBinFilters) {
return List.of();
}

@Override
public List<MolecularProfile> getGenericAssayProfiles() {
return List.of();
}

@Override
public List<MolecularProfile> getFilteredMolecularProfilesByAlterationType(StudyViewFilterContext studyViewFilterContext, String alterationType) {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.cbioportal.model.Sample;
import org.cbioportal.persistence.mybatis.typehandler.SampleTypeTypeHandler;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
Expand Down Expand Up @@ -33,7 +34,19 @@ public void customize(org.apache.ibatis.session.Configuration configuration) {
}

@Bean("sqlSessionFactory")
public SqlSessionFactoryBean sqlSessionFactory(@Qualifier("mysqlDataSource") DataSource dataSource, ApplicationContext applicationContext) throws IOException {
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public SqlSessionFactoryBean sqlSessionFactorySpecifyDataSource(@Qualifier("mysqlDataSource") DataSource dataSource, ApplicationContext applicationContext) throws IOException {
return sqlSessionFactory(dataSource, applicationContext);
}

@Bean("sqlSessionFactory")
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "false", matchIfMissing = true)
public SqlSessionFactoryBean sqlSessionFactoryDefault(DataSource dataSource, ApplicationContext applicationContext) throws IOException {
return sqlSessionFactory(dataSource, applicationContext);
}


private SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource, ApplicationContext applicationContext) throws IOException {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setMapperLocations(
Expand All @@ -43,8 +56,9 @@ public SqlSessionFactoryBean sqlSessionFactory(@Qualifier("mysqlDataSource") Dat
return sessionFactory;
}

@Bean
public DataSourceTransactionManager transactionManager(@Qualifier("mysqlDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public DataSourceTransactionManager transactionManager(@Qualifier("mysqlDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.cbioportal.persistence.helper.AlterationFilterHelper;
import org.cbioportal.persistence.helper.StudyViewFilterHelper;
import org.cbioportal.service.util.StudyViewColumnarServiceUtil;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.parameter.ClinicalDataType;
import org.cbioportal.web.parameter.GenericAssayDataBinFilter;
import org.cbioportal.web.parameter.GenericAssayDataFilter;
Expand All @@ -38,6 +39,7 @@
import java.util.stream.Collectors;

@Repository
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class StudyViewMyBatisRepository implements StudyViewRepository {

private final StudyViewMapper studyViewMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.cbioportal.persistence.mybatisclickhouse.config;

import org.cbioportal.persistence.mybatis.typehandler.SampleTypeTypeHandler;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -13,6 +14,7 @@


@Configuration
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
@MapperScan(value= "org.cbioportal.persistence.mybatisclickhouse", sqlSessionFactoryRef ="sqlColumnarSessionFactory")
public class PersistenceColumnarConfig {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.cbioportal.properties;

import org.springframework.beans.factory.annotation.Qualifier;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -9,6 +9,7 @@
import javax.sql.DataSource;

@Configuration
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class CustomDataSourceConfiguration {
@Bean
@ConfigurationProperties("spring.datasource.mysql")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.cbioportal.web.parameter.Projection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.cbioportal.service.exception.StudyNotFoundException;
import org.cbioportal.service.treatment.TreatmentCountReportService;
import org.cbioportal.service.util.StudyViewColumnarServiceUtil;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.parameter.ClinicalDataType;
import org.cbioportal.web.parameter.CustomSampleIdentifier;
import org.cbioportal.web.parameter.GenericAssayDataBinFilter;
Expand All @@ -38,6 +39,7 @@
import java.util.stream.Collectors;

@Service
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class StudyViewColumnarServiceImpl implements StudyViewColumnarService {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import org.cbioportal.model.StudyViewFilterContext;
import org.cbioportal.model.TemporalRelation;
import org.cbioportal.persistence.StudyViewRepository;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;
import java.util.stream.Stream;

@Service
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class TreatmentCountReportServiceImpl implements TreatmentCountReportService {

private final StudyViewRepository studyViewRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.cbioportal.service.CustomDataService;
import org.cbioportal.service.StudyViewColumnarService;
import org.cbioportal.service.util.CustomDataSession;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.columnar.util.CustomDataFilterUtil;
import org.cbioportal.web.columnar.util.NewClinicalDataBinUtil;
import org.cbioportal.web.parameter.*;
Expand All @@ -25,6 +26,7 @@
// but BasicDataBinner can support clinical data counts too
// after we switched clinical data counts to use this, then We can remove ClinicalDataBinner
@Component
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class BasicDataBinner {
private final StudyViewColumnarService studyViewColumnarService;
private final DataBinner dataBinner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.cbioportal.model.ClinicalDataCount;
import org.cbioportal.model.ClinicalDataCountItem;
import org.cbioportal.service.StudyViewColumnarService;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.columnar.util.NewClinicalDataBinUtil;
import org.cbioportal.web.parameter.ClinicalDataBinCountFilter;
import org.cbioportal.web.parameter.ClinicalDataBinFilter;
Expand All @@ -21,6 +22,7 @@
import java.util.stream.Collectors;

@Component
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class ClinicalDataBinner {
private final StudyViewColumnarService studyViewColumnarService;
private final DataBinner dataBinner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.cbioportal.service.ViolinPlotService;
import org.cbioportal.service.exception.StudyNotFoundException;
import org.cbioportal.service.util.CustomDataSession;
import org.cbioportal.utils.config.annotation.ConditionalOnProperty;
import org.cbioportal.web.columnar.util.CustomDataFilterUtil;
import org.cbioportal.web.columnar.util.NewStudyViewFilterUtil;
import org.cbioportal.web.config.annotation.InternalApi;
Expand Down Expand Up @@ -78,6 +79,7 @@
@RestController()
@RequestMapping("/api")
@Validated
@ConditionalOnProperty(name = "clickhouse_mode", havingValue = "true")
public class StudyViewColumnStoreController {

private final StudyViewColumnarService studyViewColumnarService;
Expand Down
Loading

0 comments on commit 1155336

Please sign in to comment.