From 85b47c20e6e6cb08dfd356b46b4ff5a8b6f00113 Mon Sep 17 00:00:00 2001 From: Charles Haynes Date: Mon, 6 Jan 2025 17:24:09 -0500 Subject: [PATCH 01/31] Update initial Mappers to fix Patient View Page --- .../mybatis/AlterationCountsMapper.xml | 403 +++++++++--------- .../AlterationDriverAnnotationMapper.xml | 24 +- .../persistence/mybatis/CancerTypeMapper.xml | 16 +- .../mybatis/ClinicalAttributeMapper.xml | 122 +++--- .../mybatis/ClinicalDataMapper.xml | 303 +++++-------- .../mybatis/ClinicalEventMapper.xml | 236 +++------- .../mybatis/CopyNumberSegmentMapper.xml | 79 ++-- .../persistence/mybatis/CosmicCountMapper.xml | 16 +- .../mybatis/DataAccessTokenMapper.xml | 20 +- .../mybatis/DiscreteCopyNumberMapper.xml | 181 ++++---- .../legacy/persistence/mybatis/GeneMapper.xml | 66 ++- .../persistence/mybatis/GenePanelMapper.xml | 113 +++-- .../mybatis/GenericAssayMapper.xml | 52 +-- .../mybatis/GenesetHierarchyMapper.xml | 64 ++- .../persistence/mybatis/GenesetMapper.xml | 35 +- .../mybatis/MolecularDataMapper.xml | 138 +++--- .../mybatis/MolecularProfileMapper.xml | 137 +++--- .../persistence/mybatis/MutationMapper.xml | 295 ++++++------- .../persistence/mybatis/PatientMapper.xml | 77 ++-- .../mybatis/ReferenceGenomeGeneMapper.xml | 60 ++- .../mybatis/ResourceDataMapper.xml | 114 ++--- .../mybatis/ResourceDefinitionMapper.xml | 35 +- .../persistence/mybatis/SampleListMapper.xml | 72 ++-- .../persistence/mybatis/SampleMapper.xml | 118 +++-- .../persistence/mybatis/SecurityMapper.xml | 8 +- .../SignificantCopyNumberRegionMapper.xml | 39 +- .../SignificantlyMutatedGeneMapper.xml | 22 +- .../mybatis/StaticDataTimestampMapper.xml | 18 +- .../mybatis/StructuralVariantMapper.xml | 254 ++++++----- .../persistence/mybatis/StudyMapper.xml | 158 +++---- .../persistence/mybatis/TreatmentMapper.xml | 110 +++-- .../mybatis/VariantCountMapper.xml | 22 +- 32 files changed, 1490 insertions(+), 1917 deletions(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/AlterationCountsMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/AlterationCountsMapper.xml index c2bc086ada4..d5be2b8eb25 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/AlterationCountsMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/AlterationCountsMapper.xml @@ -3,12 +3,13 @@ - + SELECT + entrez_gene_id AS "entrezGeneId", + hugo_gene_symbol AS "hugoGeneSymbol", COUNT(*) AS "totalCount", - COUNT(DISTINCT(CASE_ID)) AS "numberOfAlteredCases" + COUNT(DISTINCT(case_id)) AS "numberOfAlteredCases", + 1 AS QueryCategory FROM ( @@ -30,19 +31,20 @@ - ) as JoinedTable + ) AS JoinedTable - GROUP BY ENTREZ_GENE_ID, HUGO_GENE_SYMBOL; + GROUP BY entrez_gene_id, hugo_gene_symbol; - + - + @@ -210,9 +212,9 @@ LEFT JOIN alteration_driver_annotation ON - mutation.MUTATION_EVENT_ID = alteration_driver_annotation.ALTERATION_EVENT_ID - AND mutation.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - AND mutation.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID + mutation.mutation_event_id = alteration_driver_annotation.alteration_event_id + AND mutation.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND mutation.sample_id = alteration_driver_annotation.sample_id @@ -224,12 +226,12 @@ LEFT JOIN alteration_driver_annotation ON - sample_cna_event.CNA_EVENT_ID = alteration_driver_annotation.ALTERATION_EVENT_ID - AND sample_cna_event.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - AND sample_cna_event.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID + sample_cna_event.cna_event_id = alteration_driver_annotation.alteration_event_id + AND sample_cna_event.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND sample_cna_event.sample_id = alteration_driver_annotation.sample_id - + @@ -238,18 +240,18 @@ LEFT JOIN alteration_driver_annotation ON - structural_variant.INTERNAL_ID = alteration_driver_annotation.ALTERATION_EVENT_ID - AND structural_variant.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - AND structural_variant.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID + structural_variant.internal_id = alteration_driver_annotation.alteration_event_id + AND structural_variant.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND structural_variant.sample_id = alteration_driver_annotation.sample_id ( - structural_variant.SITE2_ENTREZ_GENE_ID != structural_variant.SITE1_ENTREZ_GENE_ID + structural_variant.site2_entrez_gene_id != structural_variant.site1_entrez_gene_id OR - structural_variant.SITE1_ENTREZ_GENE_ID IS NULL + structural_variant.site1_entrez_gene_id IS NULL ) @@ -260,14 +262,14 @@ - OR LOWER(DRIVER_FILTER) = 'putative_driver' + OR LOWER(driver_filter) = 'putative_driver' - OR LOWER(DRIVER_FILTER) = 'putative_passenger' + OR LOWER(driver_filter) = 'putative_passenger' - OR DRIVER_FILTER IS NULL - OR LOWER(DRIVER_FILTER) IN ('unknown', 'na', '') + OR driver_filter IS NULL + OR LOWER(driver_filter) IN ('unknown', 'na', '') @@ -280,22 +282,20 @@ - + - + - OR DRIVER_TIERS_FILTER IN - - #{item} - + OR driver_tiers_filter IN + #{item} - OR DRIVER_TIERS_FILTER IS NULL - OR LOWER(DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + OR driver_tiers_filter IS NULL + OR LOWER(driver_tiers_filter) IN ('', 'na', 'unknown') @@ -307,7 +307,7 @@ - + @@ -316,15 +316,15 @@ OR - LOWER(mutation.MUTATION_STATUS) LIKE '%germline%' + LOWER(mutation.mutation_status) LIKE '%germline%' OR - LOWER(mutation.MUTATION_STATUS) = 'somatic' + LOWER(mutation.mutation_status) = 'somatic' OR - (LOWER(mutation.MUTATION_STATUS) != 'somatic' AND LOWER(mutation.MUTATION_STATUS) NOT LIKE '%germline%') + (LOWER(mutation.mutation_status) != 'somatic' AND LOWER(mutation.mutation_status) NOT LIKE '%germline%') @@ -345,15 +345,15 @@ OR - LOWER(SV_STATUS) = 'germline' + LOWER(sv_status) = 'germline' OR - LOWER(SV_STATUS) = 'somatic' + LOWER(sv_status) = 'somatic' OR - LOWER(SV_STATUS) NOT IN ('germline', 'somatic') + LOWER(sv_status) NOT IN ('germline', 'somatic') @@ -372,64 +372,59 @@ AND NULL - AND JoinedTable.ENTREZ_GENE_ID IN - - #{entrezGeneId} - + AND JoinedTable.entrez_gene_id IN + #{entrezGeneId} - + AND NULL - AND cna_event.ENTREZ_GENE_ID IN - - #{entrezGeneId} - + AND cna_event.entrez_gene_id IN + #{entrezGeneId} SELECT - as CASE_ID, - mutation.ENTREZ_GENE_ID, - gene.HUGO_GENE_SYMBOL, - mutation_event.MUTATION_TYPE - FROM mutation - INNER JOIN mutation_event ON mutation_event.MUTATION_EVENT_ID = mutation.MUTATION_EVENT_ID - INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID - INNER JOIN genetic_profile ON mutation.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON sample.INTERNAL_ID = mutation.SAMPLE_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID + AS case_id, + mutation.entrez_gene_id AS "entrez_gene_id", + gene.hugo_gene_symbol AS "hugo_gene_symbol", + mutation_event.mutation_type + FROM + mutation + INNER JOIN mutation_event ON mutation_event.mutation_event_id = mutation.mutation_event_id + INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id + INNER JOIN genetic_profile ON mutation.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON sample.internal_id = mutation.sample_id + INNER JOIN patient ON sample.patient_id = patient.internal_id NULL - LOWER(mutation_event.MUTATION_TYPE) + LOWER(mutation_event.mutation_type) - - NOT IN - - - IN - - - - LOWER(#{type}) - + + NOT IN + + + IN + + + LOWER(#{type}) - + @@ -437,57 +432,56 @@ SELECT - as CASE_ID, - cna_event.ENTREZ_GENE_ID, - gene.HUGO_GENE_SYMBOL, - CAST(cna_event.ALTERATION AS CHAR(3)) - FROM cna_event - INNER JOIN sample_cna_event ON cna_event.CNA_EVENT_ID = sample_cna_event.CNA_EVENT_ID - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID - INNER JOIN genetic_profile ON sample_cna_event.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN patient ON patient.CANCER_STUDY_ID = genetic_profile.CANCER_STUDY_ID - INNER JOIN sample ON sample.PATIENT_ID = patient.INTERNAL_ID AND sample.INTERNAL_ID = sample_cna_event.SAMPLE_ID - INNER JOIN cancer_study ON cancer_study.CANCER_STUDY_ID = genetic_profile.CANCER_STUDY_ID + AS case_id, + cna_event.entrez_gene_id AS "entrez_gene_id", + gene.hugo_gene_symbol AS "hugo_gene_symbol", + CAST(cna_event.alteration AS CHAR(3)) + FROM + cna_event + INNER JOIN sample_cna_event ON cna_event.cna_event_id = sample_cna_event.cna_event_id + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id + INNER JOIN genetic_profile ON sample_cna_event.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN patient ON patient.cancer_study_id = genetic_profile.cancer_study_id + INNER JOIN sample ON sample.patient_id = patient.internal_id AND sample.internal_id = sample_cna_event.sample_id + INNER JOIN cancer_study ON cancer_study.cancer_study_id = genetic_profile.cancer_study_id NULL - cna_event.ALTERATION IN - - #{type} - + cna_event.alteration IN + #{type} - + - + - SELECT - caseUniqueId as "CASE_ID", - entrezGeneId as "ENTREZ_GENE_ID", - hugoGeneSymbol as "HUGO_GENE_SYMBOL", - NULL as "DUMMY_COLUMN" + SELECT + caseUniqueId AS "case_id", + entrez_gene_id, + hugo_gene_symbol, + 7 AS "DUMMY_COLUMN" FROM - (SELECT - gene.ENTREZ_GENE_ID AS "entrezGeneId", - gene.HUGO_GENE_SYMBOL AS "hugoGeneSymbol", - as "caseUniqueId", - as "caseStableId", - genetic_profile.GENETIC_PROFILE_ID as "geneticProfileId", - structural_variant.SV_STATUS as "SV_STATUS" + (SELECT + gene.entrez_gene_id AS "entrez_gene_id", + gene.hugo_gene_symbol AS "hugo_gene_symbol", + AS "caseUniqueId", + AS "caseStableId", + genetic_profile.genetic_profile_id AS "geneticProfileId", + structural_variant.sv_status AS "sv_status" FROM structural_variant - INNER JOIN genetic_profile ON structural_variant.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON structural_variant.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN gene ON structural_variant.SITE1_ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN genetic_profile ON structural_variant.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON structural_variant.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN gene ON structural_variant.site1_entrez_gene_id = gene.entrez_gene_id @@ -495,19 +489,19 @@ UNION ALL - SELECT - gene.ENTREZ_GENE_ID AS entrezGeneId, - gene.HUGO_GENE_SYMBOL AS hugoGeneSymbol, - as caseUniqueId, - as caseStableId, - genetic_profile.GENETIC_PROFILE_ID as geneticProfileId, - structural_variant.SV_STATUS as SV_STATUS + SELECT + gene.entrez_gene_id AS "entrez_gene_id", + gene.hugo_gene_symbol AS "hugo_gene_symbol", + AS caseUniqueId, + AS caseStableId, + genetic_profile.genetic_profile_id AS geneticProfileId, + structural_variant.sv_status AS sv_status FROM structural_variant - INNER JOIN genetic_profile ON structural_variant.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON structural_variant.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN gene ON structural_variant.SITE2_ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN genetic_profile ON structural_variant.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON structural_variant.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN gene ON structural_variant.site2_entrez_gene_id = gene.entrez_gene_id @@ -521,7 +515,7 @@ - + @@ -534,15 +528,11 @@ AND ${geneticProfileIdentifier} = #{${identifiers}[0].molecularProfileId} AND IN - - #{id.caseId} - + #{id.caseId} - AND (${geneticProfileIdentifier}, ) IN - - (#{id.molecularProfileId}, #{id.caseId}) - + AND (${geneticProfileIdentifier},) IN + (#{id.molecularProfileId},#{id.caseId}) @@ -552,10 +542,10 @@ - sample.STABLE_ID + sample.stable_id - patient.STABLE_ID + patient.stable_id @@ -563,10 +553,10 @@ - sample.INTERNAL_ID + sample.internal_id - patient.INTERNAL_ID + patient.internal_id @@ -574,26 +564,27 @@ caseStableId - + caseUniqueId - + SELECT - alteration_driver_annotation.ALTERATION_EVENT_ID as alterationEventId, - alteration_driver_annotation.GENETIC_PROFILE_ID as geneticProfileId, - alteration_driver_annotation.SAMPLE_ID as sampleId, - alteration_driver_annotation.DRIVER_FILTER as driverFilter, - alteration_driver_annotation.DRIVER_FILTER_ANNOTATION as driverFilterAnnotation, - alteration_driver_annotation.DRIVER_TIERS_FILTER as driverTiersFilter, - alteration_driver_annotation.DRIVER_TIERS_FILTER_ANNOTATION as driverTiersFilterAnnotation + alteration_driver_annotation.alteration_event_id as alterationEventId, + alteration_driver_annotation.genetic_profile_id as geneticProfileId, + alteration_driver_annotation.sample_id as sampleId, + alteration_driver_annotation.driver_filter as driverFilter, + alteration_driver_annotation.driver_filter_annotation as driverFilterAnnotation, + alteration_driver_annotation.driver_tiers_filter as driverTiersFilter, + alteration_driver_annotation.driver_tiers_filter_annotation as driverTiersFilterAnnotation FROM alteration_driver_annotation INNER JOIN genetic_profile ON - genetic_profile.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID + genetic_profile.genetic_profile_id = alteration_driver_annotation.genetic_profile_id - genetic_profile.STABLE_ID IN - - #{id} - + genetic_profile.stable_id IN + #{id} - \ No newline at end of file + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CancerTypeMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CancerTypeMapper.xml index f1a93ec450a..e3e63867a96 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CancerTypeMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CancerTypeMapper.xml @@ -4,16 +4,16 @@ - type_of_cancer.TYPE_OF_CANCER_ID AS "${prefix}typeOfCancerId" + type_of_cancer.type_of_cancer_id AS "${prefix}typeOfCancerId" , - type_of_cancer.NAME AS "${prefix}name", - type_of_cancer.DEDICATED_COLOR AS "${prefix}dedicatedColor", - type_of_cancer.SHORT_NAME AS "${prefix}shortName", - type_of_cancer.PARENT AS "${prefix}parent" + type_of_cancer.name AS "${prefix}name", + type_of_cancer.dedicated_color AS "${prefix}dedicatedColor", + type_of_cancer.short_name AS "${prefix}shortName", + type_of_cancer.parent AS "${prefix}parent" - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml index a552a83ffa2..1320aed0c9d 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml @@ -4,49 +4,45 @@ - clinical_attribute_meta.ATTR_ID AS "${prefix}attrId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier", - clinical_attribute_meta.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - clinical_attribute_meta.PATIENT_ATTRIBUTE AS "${prefix}patientAttribute", - clinical_attribute_meta.DISPLAY_NAME AS "${prefix}displayName" + clinical_attribute_meta.attr_id AS "${prefix}attrId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier", + clinical_attribute_meta.cancer_study_id AS "${prefix}cancerStudyId", + clinical_attribute_meta.patient_attribute AS "${prefix}patientAttribute", + clinical_attribute_meta.display_name AS "${prefix}displayName" , - clinical_attribute_meta.DESCRIPTION AS "${prefix}description", - clinical_attribute_meta.DATATYPE AS "${prefix}datatype", - clinical_attribute_meta.PRIORITY AS "${prefix}priority" + clinical_attribute_meta.description AS "${prefix}description", + clinical_attribute_meta.datatype AS "${prefix}datatype", + clinical_attribute_meta.priority AS "${prefix}priority" - INNER JOIN sample ON clinical_sample.INTERNAL_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN sample ON clinical_sample.internal_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - INNER JOIN patient ON clinical_patient.INTERNAL_ID = patient.INTERNAL_ID - INNER JOIN sample ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN patient ON clinical_patient.internal_id = patient.internal_id + INNER JOIN sample ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} + cancer_study.cancer_study_identifier = #{studyIds[0]} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - sample.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + sample.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + (cancer_study.cancer_study_identifier, sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) @@ -54,12 +50,12 @@ - sample.INTERNAL_ID IN + sample.internal_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID = #{sampleListId} - AND sample_list_list.SAMPLE_ID = sample.INTERNAL_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id = #{sampleListId} + AND sample_list_list.sample_id = sample.internal_id ) @@ -70,20 +66,18 @@ FROM clinical_attribute_meta - INNER JOIN cancer_study ON clinical_attribute_meta.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON clinical_attribute_meta.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + cancer_study.cancer_study_identifier IN + #{item} ORDER BY "${sortBy}" ${direction} - ORDER BY clinical_attribute_meta.ATTR_ID ASC + ORDER BY clinical_attribute_meta.attr_id ASC LIMIT #{limit} OFFSET #{offset} @@ -94,13 +88,11 @@ SELECT COUNT(*) AS "totalCount" FROM clinical_attribute_meta - INNER JOIN cancer_study ON clinical_attribute_meta.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON clinical_attribute_meta.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + cancer_study.cancer_study_identifier IN + #{item} @@ -111,70 +103,66 @@ FROM clinical_attribute_meta - INNER JOIN cancer_study ON clinical_attribute_meta.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - WHERE clinical_attribute_meta.ATTR_ID = #{clinicalAttributeId} - AND cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + INNER JOIN cancer_study ON clinical_attribute_meta.cancer_study_id = cancer_study.cancer_study_id + WHERE clinical_attribute_meta.attr_id = #{clinicalAttributeId} + AND cancer_study.cancer_study_identifier = #{studyId} - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml index 129fdce9494..01c21075d02 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml @@ -4,14 +4,14 @@ - clinical_sample.INTERNAL_ID AS "${prefix}internalId", - sample.STABLE_ID AS "${prefix}sampleId", - patient.STABLE_ID AS "${prefix}patientId", - clinical_sample.ATTR_ID AS "${prefix}attrId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}studyId" + clinical_sample.internal_id AS "${prefix}internalId", + sample.stable_id AS "${prefix}sampleId", + patient.stable_id AS "${prefix}patientId", + clinical_sample.attr_id AS "${prefix}attrId", + cancer_study.cancer_study_identifier AS "${prefix}studyId" - , clinical_sample.ATTR_VALUE AS "${prefix}attrValue" + , clinical_sample.attr_value AS "${prefix}attrValue" , @@ -23,13 +23,13 @@ - clinical_patient.INTERNAL_ID AS "${prefix}internalId", - patient.STABLE_ID AS "${prefix}patientId", - clinical_patient.ATTR_ID AS "${prefix}attrId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}studyId" + clinical_patient.internal_id AS "${prefix}internalId", + patient.stable_id AS "${prefix}patientId", + clinical_patient.attr_id AS "${prefix}attrId", + cancer_study.cancer_study_identifier AS "${prefix}studyId" - , clinical_patient.ATTR_VALUE AS "${prefix}attrValue" + , clinical_patient.attr_value AS "${prefix}attrValue" , @@ -39,47 +39,45 @@ - FROM clinical_sample - INNER JOIN sample ON clinical_sample.INTERNAL_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN sample ON clinical_sample.internal_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + + + + + LEFT JOIN clinical_patient ON clinical_patient.internal_id = patient.internal_id FROM clinical_patient - INNER JOIN patient ON clinical_patient.INTERNAL_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN patient ON clinical_patient.internal_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} + cancer_study.cancer_study_identifier = #{studyIds[0]} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - sample.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + sample.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + (cancer_study.cancer_study_identifier, sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) - AND clinical_sample.ATTR_ID IN - - #{item} - + AND clinical_sample.attr_id IN + #{item} @@ -87,60 +85,28 @@ - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} + cancer_study.cancer_study_identifier = #{studyIds[0]} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - patient.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + patient.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, patient.STABLE_ID) IN - - (#{studyIds[${i}]}, #{patientIds[${i}]}) - + (cancer_study.cancer_study_identifier, patient.stable_id) IN + (#{studyIds[${i}]},#{patientIds[${i}]}) - AND clinical_patient.ATTR_ID IN - - #{item} - + AND clinical_patient.attr_id IN + #{item} - - - - - + SELECT count(*) as count, - clinical_sample.ATTR_ID as attributeId, - clinical_sample.ATTR_VALUE as value + clinical_sample.attr_id as attributeId, + clinical_sample.attr_value as value - GROUP BY clinical_sample.ATTR_ID, clinical_sample.ATTR_VALUE + GROUP BY clinical_sample.attr_id, clinical_sample.attr_value - + SELECT + + + + + - - SELECT - DISTINCT sample.INTERNAL_ID sampleInternalId - FROM sample - INNER JOIN patient ON patient.INTERNAL_ID = sample.PATIENT_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN clinical_sample cs on sample.INTERNAL_ID = cs.INTERNAL_ID - INNER JOIN clinical_patient cp on patient.INTERNAL_ID = cp.INTERNAL_ID + + + + INNER JOIN ( + SELECT DISTINCT clinical_sample.internal_id + + + , sample.stable_id AS sort_by + + + , patient.stable_id AS sort_by + + + + + , CASE + WHEN clinical_sample.attr_id = #{sortBy} THEN clinical_sample.attr_value + WHEN clinical_patient.attr_id = #{sortBy} THEN clinical_patient.attr_value + ELSE NULL + END AS sort_by + + + - AND ( - cs.ATTR_VALUE LIKE CONCAT('%', #{searchTerm}, '%') - OR cp.ATTR_VALUE LIKE CONCAT('%', #{searchTerm}, '%') - OR sample.STABLE_ID LIKE CONCAT('%', #{searchTerm}, '%') - OR patient.STABLE_ID LIKE CONCAT('%', #{searchTerm}, '%') - ) - - - - - - SELECT sample.INTERNAL_ID sampleInternalId, sample.STABLE_ID sampleId, patient.STABLE_ID patientId, clinical_patient.ATTR_ID sortAttrId, + + AND + clinical_sample.attr_value LIKE CONCAT('%', #{searchTerm}, '%') + + + - CONVERT(clinical_patient.ATTR_VALUE, DECIMAL) sortAttrValue + + ORDER BY ISNULL(sort_by), sort_by ${direction} - - clinical_patient.ATTR_VALUE sortAttrValue - - - FROM sample - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - LEFT JOIN clinical_patient ON patient.INTERNAL_ID = clinical_patient.INTERNAL_ID AND clinical_patient.ATTR_ID = #{sortAttrId} - - - SELECT sample.INTERNAL_ID sampleInternalId, sample.STABLE_ID sampleId, patient.STABLE_ID patientId, clinical_sample.ATTR_ID sortAttrId, - - - CONVERT(clinical_sample.ATTR_VALUE, DECIMAL) sortAttrValue + + ORDER BY sort_by ${direction} NULLS LAST - - clinical_sample.ATTR_VALUE sortAttrValue - - FROM clinical_sample - INNER JOIN sample ON clinical_sample.INTERNAL_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - WHERE clinical_sample.ATTR_ID = #{sortAttrId} - - + + + + LIMIT #{limit} OFFSET #{offset} + + ) AS sample_id_subquery + ON clinical_sample.internal_id = sample_id_subquery.internal_id diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalEventMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalEventMapper.xml index badc8b79702..fb551affe1c 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalEventMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalEventMapper.xml @@ -2,35 +2,34 @@ - - clinical_event.CLINICAL_EVENT_ID AS "clinicalEventId", - clinical_event.EVENT_TYPE AS "eventType", - patient.STABLE_ID AS "patientId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "studyId" + clinical_event.clinical_event_id AS "clinicalEventId", + clinical_event.event_type AS "eventType", + patient.stable_id AS "patientId", + cancer_study.cancer_study_identifier AS "studyId" , - clinical_event.START_DATE AS "startDate", - clinical_event.STOP_DATE AS "stopDate" + clinical_event.start_date AS "startDate", + clinical_event.stop_date AS "stopDate" FROM clinical_event - INNER JOIN patient ON clinical_event.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN patient ON clinical_event.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} - AND patient.STABLE_ID = #{patientId} + cancer_study.cancer_study_identifier = #{studyId} + AND patient.stable_id = #{patientId} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + cancer_study.cancer_study_identifier = #{studyId} @@ -43,7 +42,7 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY clinical_event.PATIENT_ID ASC + ORDER BY clinical_event.patient_id ASC LIMIT #{limit} OFFSET #{offset} @@ -59,16 +58,14 @@ @@ -82,59 +79,47 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY clinical_event.PATIENT_ID ASC + ORDER BY clinical_event.patient_id ASC LIMIT #{limit} OFFSET #{offset} - + - + - - - - - - - - - - - - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml index 0d3503c6fd5..890d503c214 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml @@ -2,67 +2,66 @@ - - copy_number_seg.SEG_ID AS "segId", - copy_number_seg.CANCER_STUDY_ID AS "cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "cancerStudyIdentifier", - copy_number_seg.SAMPLE_ID AS "sampleId", - patient.STABLE_ID AS "patientId", - sample.STABLE_ID AS "sampleStableId", - copy_number_seg.CHR AS "chr", - copy_number_seg.START AS "start", - copy_number_seg.END AS "end", - copy_number_seg.NUM_PROBES AS "numProbes", - copy_number_seg.SEGMENT_MEAN AS "segmentMean" + copy_number_seg.seg_id AS "segId", + copy_number_seg.cancer_study_id AS "cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudyIdentifier", + copy_number_seg.sample_id AS "sampleId", + patient.stable_id AS "patientId", + sample.stable_id AS "sampleStableId", + copy_number_seg.chr AS "chr", + copy_number_seg.start AS "start", + copy_number_seg.end AS "end", + copy_number_seg.num_probes AS "numProbes", + copy_number_seg.segment_mean AS "segmentMean" FROM copy_number_seg - INNER JOIN cancer_study ON copy_number_seg.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN sample ON copy_number_seg.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID + INNER JOIN cancer_study ON copy_number_seg.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN sample ON copy_number_seg.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id - + - (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + (cancer_study.cancer_study_identifier, sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) - + - - + + - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CosmicCountMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CosmicCountMapper.xml index 5541cb31f7b..04eda3439e6 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CosmicCountMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CosmicCountMapper.xml @@ -2,20 +2,18 @@ - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DataAccessTokenMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DataAccessTokenMapper.xml index 9aa8776df70..b5435629ae3 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DataAccessTokenMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DataAccessTokenMapper.xml @@ -4,10 +4,10 @@ - data_access_tokens.TOKEN AS "${prefix}token", - data_access_tokens.USERNAME AS "${prefix}username", - data_access_tokens.EXPIRATION AS "${prefix}expiration", - data_access_tokens.CREATION AS "${prefix}creation" + data_access_tokens.token AS "${prefix}token", + data_access_tokens.username AS "${prefix}username", + data_access_tokens.expiration AS "${prefix}expiration", + data_access_tokens.creation AS "${prefix}creation" DELETE FROM data_access_tokens - WHERE TOKEN = #{token} + WHERE token = #{token} DELETE FROM data_access_tokens - WHERE USERNAME = #{username} + WHERE username = #{username} INSERT - INTO data_access_tokens(TOKEN, USERNAME, EXPIRATION, CREATION) + INTO data_access_tokens(token, username, expiration, creation) VALUES (#{token}, #{username}, #{expiration}, #{creation}) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DiscreteCopyNumberMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DiscreteCopyNumberMapper.xml index 338347d24ef..3f49b35b9bb 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DiscreteCopyNumberMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DiscreteCopyNumberMapper.xml @@ -4,83 +4,73 @@ - cna_event.ENTREZ_GENE_ID as entrezGeneId, - cna_event.ALTERATION AS "alteration", - genetic_profile.STABLE_ID AS "molecularProfileId", - sample_cna_event.ANNOTATION_JSON as annotationJson, - sample.STABLE_ID AS "sampleId", - patient.STABLE_ID AS "patientId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "studyId", - alteration_driver_annotation.DRIVER_FILTER AS "driverFilter", - alteration_driver_annotation.DRIVER_FILTER_ANNOTATION AS "driverFilterAnnotation", - alteration_driver_annotation.DRIVER_TIERS_FILTER AS "driverTiersFilter", - alteration_driver_annotation.DRIVER_TIERS_FILTER_ANNOTATION AS "driverTiersFilterAnnotation" + cna_event.entrez_gene_id as entrezGeneId, + cna_event.alteration AS "alteration", + genetic_profile.stable_id AS "molecularProfileId", + sample_cna_event.annotation_json as annotationJson, + sample.stable_id AS "sampleId", + patient.stable_id AS "patientId", + cancer_study.cancer_study_identifier AS "studyId", + alteration_driver_annotation.driver_filter AS "driverFilter", + alteration_driver_annotation.driver_filter_annotation AS "driverFilterAnnotation", + alteration_driver_annotation.driver_tiers_filter AS "driverTiersFilter", + alteration_driver_annotation.driver_tiers_filter_annotation AS "driverTiersFilterAnnotation" , - + FROM cna_event - INNER JOIN sample_cna_event ON cna_event.CNA_EVENT_ID = sample_cna_event.CNA_EVENT_ID - INNER JOIN genetic_profile ON sample_cna_event.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON sample_cna_event.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN sample_cna_event ON cna_event.cna_event_id = sample_cna_event.cna_event_id + INNER JOIN genetic_profile ON sample_cna_event.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON sample_cna_event.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id LEFT JOIN alteration_driver_annotation ON - sample_cna_event.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - and sample_cna_event.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID - and sample_cna_event.CNA_EVENT_ID = alteration_driver_annotation.ALTERATION_EVENT_ID + sample_cna_event.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + and sample_cna_event.sample_id = alteration_driver_annotation.sample_id + and sample_cna_event.cna_event_id = alteration_driver_annotation.alteration_event_id - genetic_profile.STABLE_ID = #{molecularProfileId} + genetic_profile.stable_id = #{molecularProfileId} - AND sample.STABLE_ID IN - - #{item} - + AND sample.stable_id IN + #{item} - AND cna_event.ENTREZ_GENE_ID IN - - #{item} - + AND cna_event.entrez_gene_id IN + #{item} - AND cna_event.ALTERATION IN - - #{item} - + AND cna_event.alteration IN + #{item} - genetic_profile.STABLE_ID = #{molecularProfileId} - AND sample_cna_event.SAMPLE_ID IN + genetic_profile.stable_id = #{molecularProfileId} + AND sample_cna_event.sample_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID = #{sampleListId} - AND sample_list_list.SAMPLE_ID = sample_cna_event.SAMPLE_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id = #{sampleListId} + AND sample_list_list.sample_id = sample_cna_event.sample_id ) - AND cna_event.ENTREZ_GENE_ID IN - - #{item} - + AND cna_event.entrez_gene_id IN + #{item} - AND cna_event.ALTERATION IN - - #{item} - + AND cna_event.alteration IN + #{item} @@ -88,29 +78,21 @@ - genetic_profile.STABLE_ID = #{molecularProfileIds[0]} AND - sample.STABLE_ID IN - - #{item} - + genetic_profile.stable_id = #{molecularProfileIds[0]} AND + sample.stable_id IN + #{item} - (sample.STABLE_ID, genetic_profile.STABLE_ID) IN - - (#{sampleIds[${i}]}, #{molecularProfileIds[${i}]}) - + (sample.stable_id, genetic_profile.stable_id) IN + (#{sampleIds[${i}]},#{molecularProfileIds[${i}]}) - AND cna_event.ENTREZ_GENE_ID IN - - #{item} - + AND cna_event.entrez_gene_id IN + #{item} - AND cna_event.ALTERATION IN - - #{item} - + AND cna_event.alteration IN + #{item} @@ -120,21 +102,21 @@ AND - ( cna_event.ENTREZ_GENE_ID = '${geneFilterQuery.getEntrezGeneId()}' + ( cna_event.entrez_gene_id = '${geneFilterQuery.getEntrezGeneId()}' - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_driver' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_driver' - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_passenger' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_passenger' - OR alteration_driver_annotation.DRIVER_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) IN ('unknown', 'na', '') + OR alteration_driver_annotation.driver_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_filter) IN ('unknown', 'na', '') @@ -150,20 +132,18 @@ - AND NOT alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - AND NOT LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + AND NOT alteration_driver_annotation.driver_tiers_filter IS NULL + AND NOT LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IN - - #{item} - + OR alteration_driver_annotation.driver_tiers_filter IN + #{item} - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + OR alteration_driver_annotation.driver_tiers_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') @@ -178,10 +158,8 @@ - OR cna_event.ALTERATION IN - - ${item.getCode()} - + OR cna_event.alteration IN + ${item.getCode()} @@ -198,7 +176,7 @@ - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id @@ -215,7 +193,7 @@ - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id @@ -225,7 +203,7 @@ - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id @@ -235,7 +213,7 @@ - INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON cna_event.entrez_gene_id = gene.entrez_gene_id @@ -249,30 +227,27 @@ diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GeneMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GeneMapper.xml index eab4878cfb3..78376b637e4 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GeneMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GeneMapper.xml @@ -4,34 +4,34 @@ - gene.ENTREZ_GENE_ID AS "${prefix}entrezGeneId", - gene.HUGO_GENE_SYMBOL AS "${prefix}hugoGeneSymbol" + gene.entrez_gene_id AS "${prefix}entrezGeneId", + gene.hugo_gene_symbol AS "${prefix}hugoGeneSymbol" , - gene.TYPE AS "${prefix}type" + gene.type AS "${prefix}type" FROM gene - INNER JOIN gene_alias ON gene.ENTREZ_GENE_ID = gene_alias.ENTREZ_GENE_ID + INNER JOIN gene_alias ON gene.entrez_gene_id = gene_alias.entrez_gene_id - gene_alias.GENE_ALIAS = #{alias} + gene_alias.gene_alias = #{alias} - gene.HUGO_GENE_SYMBOL like CONCAT('%', #{item}, '%') + gene.hugo_gene_symbol like CONCAT('%', #{item}, '%') - + - + @@ -115,10 +115,8 @@ FROM gene - gene.ENTREZ_GENE_ID IN - - #{item} - + gene.entrez_gene_id IN + #{item} FALSE @@ -132,10 +130,8 @@ FROM gene - gene.ENTREZ_GENE_ID IN - - #{item} - + gene.entrez_gene_id IN + #{item} FALSE @@ -151,10 +147,8 @@ FROM gene - gene.HUGO_GENE_SYMBOL IN - - #{item} - + gene.hugo_gene_symbol IN + #{item} FALSE @@ -168,10 +162,8 @@ FROM gene - gene.HUGO_GENE_SYMBOL IN - - #{item} - + gene.hugo_gene_symbol IN + #{item} FALSE diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenePanelMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenePanelMapper.xml index 289f4df0127..f98afb95dfd 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenePanelMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenePanelMapper.xml @@ -2,34 +2,33 @@ - - gene_panel.INTERNAL_ID AS "internalId", - gene_panel.STABLE_ID AS "stableId" + gene_panel.internal_id AS "internalId", + gene_panel.stable_id AS "stableId" , - gene_panel.DESCRIPTION AS "description" + gene_panel.description AS "description" - gene_panel.STABLE_ID AS "genePanelId", - sample.STABLE_ID AS "sampleId", - patient.STABLE_ID AS "patientId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "studyId", - genetic_profile.STABLE_ID AS "molecularProfileId", - sample_profile.GENETIC_PROFILE_ID IS NOT NULL AS "profiled" + gene_panel.stable_id AS "genePanelId", + sample.stable_id AS "sampleId", + patient.stable_id AS "patientId", + cancer_study.cancer_study_identifier AS "studyId", + genetic_profile.stable_id AS "molecularProfileId", + sample_profile.genetic_profile_id IS NOT NULL AS "profiled" FROM sample - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - LEFT JOIN genetic_profile ON cancer_study.CANCER_STUDY_ID = genetic_profile.CANCER_STUDY_ID - LEFT JOIN sample_profile ON sample_profile.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID AND sample.INTERNAL_ID = sample_profile.SAMPLE_ID - LEFT JOIN gene_panel ON sample_profile.PANEL_ID = gene_panel.INTERNAL_ID + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + LEFT JOIN genetic_profile ON cancer_study.cancer_study_id = genetic_profile.cancer_study_id + LEFT JOIN sample_profile ON sample_profile.genetic_profile_id = genetic_profile.genetic_profile_id AND sample.internal_id = sample_profile.sample_id + LEFT JOIN gene_panel ON sample_profile.panel_id = gene_panel.internal_id - + - + - + - + @@ -121,10 +114,8 @@ WHERE - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - SELECT genetic_entity.STABLE_ID as stableId, - genetic_entity.ENTITY_TYPE as entityType + SELECT genetic_entity.stable_id as stableId, + genetic_entity.entity_type as entityType FROM genetic_entity - genetic_entity.STABLE_ID IN - - #{item} - + genetic_entity.stable_id IN + #{item} diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenesetHierarchyMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenesetHierarchyMapper.xml index f8e105e4e64..71b5ce0c193 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenesetHierarchyMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenesetHierarchyMapper.xml @@ -4,58 +4,54 @@ - a.NODE_ID AS nodeId, - a.NODE_NAME AS nodeName, - a.PARENT_ID AS parentId, - b.NODE_NAME AS parentNodeName + a.node_id AS nodeId, + a.node_name AS nodeName, + a.parent_id AS parentId, + b.node_name AS parentNodeName - + - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenesetMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenesetMapper.xml index 5a6674a2be4..bf1ac8eab7b 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenesetMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/GenesetMapper.xml @@ -4,11 +4,11 @@ - geneset.ID AS "${prefix}internalId", - geneset.EXTERNAL_ID AS "${prefix}genesetId", - geneset.NAME as "${prefix}name", - geneset.DESCRIPTION as "${prefix}description", - geneset.REF_LINK as "${prefix}refLink" + geneset.id AS "${prefix}internalId", + geneset.external_id AS "${prefix}genesetId", + geneset.name AS "${prefix}name", + geneset.description AS "${prefix}description", + geneset.ref_link AS "${prefix}refLink" - + - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml index e6f22dcdf63..9f835819626 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml @@ -6,57 +6,49 @@ - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - AND gene.ENTREZ_GENE_ID IN - - #{item} - + AND gene.entrez_gene_id IN + #{item} - + @@ -69,24 +61,22 @@ --> @@ -94,52 +84,50 @@ @@ -147,24 +135,22 @@ @@ -177,24 +163,22 @@ --> diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularProfileMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularProfileMapper.xml index bf59ea76beb..9c23dcd91f1 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularProfileMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularProfileMapper.xml @@ -4,27 +4,36 @@ - genetic_profile.GENETIC_PROFILE_ID AS "${prefix}molecularProfileId", - genetic_profile.STABLE_ID AS "${prefix}stableId", - genetic_profile.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier" + genetic_profile.genetic_profile_id AS "${prefix}molecularProfileId", + genetic_profile.stable_id AS "${prefix}stableId", + genetic_profile.cancer_study_id AS "${prefix}cancerStudyId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier" , - genetic_profile.GENETIC_ALTERATION_TYPE AS "${prefix}molecularAlterationType", - genetic_profile.DATATYPE AS "${prefix}datatype", - genetic_profile.NAME AS "${prefix}name", - genetic_profile.DESCRIPTION AS "${prefix}description", - genetic_profile.SHOW_PROFILE_IN_ANALYSIS_TAB AS "${prefix}showProfileInAnalysisTab", - genetic_profile.PIVOT_THRESHOLD AS "${prefix}pivotThreshold", - genetic_profile.SORT_ORDER AS "${prefix}sortOrder", - genetic_profile.GENERIC_ASSAY_TYPE AS "${prefix}genericAssayType", - genetic_profile.PATIENT_LEVEL AS "${prefix}patientLevel" + genetic_profile.genetic_alteration_type AS "${prefix}molecularAlterationType", + genetic_profile.datatype AS "${prefix}datatype", + genetic_profile.name AS "${prefix}name", + genetic_profile.description AS "${prefix}description", + genetic_profile.show_profile_in_analysis_tab AS "${prefix}showProfileInAnalysisTab", + genetic_profile.pivot_threshold AS "${prefix}pivotThreshold", + genetic_profile.sort_order AS "${prefix}sortOrder", + genetic_profile.generic_assay_type AS "${prefix}genericAssayType", + genetic_profile.patient_level AS "${prefix}patientLevel" , - - - + cancer_study.cancer_study_id AS "cancerStudy.cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudy.cancerStudyIdentifier", + cancer_study.type_of_cancer_id AS "cancerStudy.typeOfCancerId", + cancer_study.name AS "cancerStudy.name", + cancer_study.description AS "cancerStudy.description", + cancer_study.public AS "cancerStudy.publicStudy", + cancer_study.pmid AS "cancerStudy.pmid", + cancer_study.citation AS "cancerStudy.citation", + cancer_study.groups AS "cancerStudy.groups", + cancer_study.status AS "cancerStudy.status", + cancer_study.import_date AS "cancerStudy.importDate", + reference_genome.name AS "cancerStudy.referenceGenome" @@ -34,24 +43,18 @@ FROM genetic_profile - INNER JOIN cancer_study ON genetic_profile.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN cancer_study ON genetic_profile.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id - WHERE cancer_study.CANCER_STUDY_IDENTIFIER IN - - (NULL) - - - - #{item} - - + WHERE cancer_study.cancer_study_identifier IN + (NULL) + #{item} ORDER BY "${sortBy}" ${direction} - ORDER BY genetic_profile.STABLE_ID ASC + ORDER BY genetic_profile.stable_id ASC LIMIT #{limit} OFFSET #{offset} @@ -63,24 +66,22 @@ COUNT(*) AS totalCount FROM genetic_profile - INNER JOIN cancer_study ON genetic_profile.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID - WHERE cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + INNER JOIN cancer_study ON genetic_profile.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id + WHERE cancer_study.cancer_study_identifier IN + #{item} - + @@ -107,47 +106,45 @@ FROM genetic_profile - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - + - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MutationMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MutationMapper.xml index eb82f54b0e0..2554887fb38 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MutationMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MutationMapper.xml @@ -4,44 +4,44 @@ - genetic_profile.STABLE_ID AS "molecularProfileId", - sample.STABLE_ID AS "sampleId", - patient.STABLE_ID AS "patientId", - mutation.ENTREZ_GENE_ID AS "entrezGeneId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "studyId" + genetic_profile.stable_id AS "molecularProfileId", + sample.stable_id AS "sampleId", + patient.stable_id AS "patientId", + mutation.entrez_gene_id AS "entrezGeneId", + cancer_study.cancer_study_identifier AS "studyId" , - mutation.CENTER AS "center", - mutation.MUTATION_STATUS AS "mutationStatus", - mutation.VALIDATION_STATUS AS "validationStatus", - mutation.TUMOR_ALT_COUNT AS "tumorAltCount", - mutation.TUMOR_REF_COUNT AS "tumorRefCount", - mutation.NORMAL_ALT_COUNT AS "normalAltCount", - mutation.NORMAL_REF_COUNT AS "normalRefCount", - mutation.AMINO_ACID_CHANGE AS "aminoAcidChange", - mutation_event.CHR AS "chr", - mutation_event.START_POSITION AS "startPosition", - mutation_event.END_POSITION AS "endPosition", - mutation_event.REFERENCE_ALLELE AS "referenceAllele", - mutation_event.TUMOR_SEQ_ALLELE AS "tumorSeqAllele", - mutation_event.PROTEIN_CHANGE AS "proteinChange", - mutation_event.MUTATION_TYPE AS "mutationType", - mutation_event.NCBI_BUILD AS "ncbiBuild", - mutation_event.VARIANT_TYPE AS "variantType", - mutation_event.REFSEQ_MRNA_ID AS "refseqMrnaId", - mutation_event.PROTEIN_POS_START AS "proteinPosStart", - mutation_event.PROTEIN_POS_END AS "proteinPosEnd", - mutation_event.KEYWORD AS "keyword", - mutation.ANNOTATION_JSON AS "annotationJSON", - alteration_driver_annotation.DRIVER_FILTER AS "driverFilter", - alteration_driver_annotation.DRIVER_FILTER_ANNOTATION AS "driverFilterAnnotation", - alteration_driver_annotation.DRIVER_TIERS_FILTER AS "driverTiersFilter", - alteration_driver_annotation.DRIVER_TIERS_FILTER_ANNOTATION as "driverTiersFilterAnnotation" + mutation.center AS "center", + mutation.mutation_status AS "mutationStatus", + mutation.validation_status AS "validationStatus", + mutation.tumor_alt_count AS "tumorAltCount", + mutation.tumor_ref_count AS "tumorRefCount", + mutation.normal_alt_count AS "normalAltCount", + mutation.normal_ref_count AS "normalRefCount", + mutation.amino_acid_change AS "aminoAcidChange", + mutation_event.chr AS "chr", + mutation_event.start_position AS "startPosition", + mutation_event.end_position AS "endPosition", + mutation_event.reference_allele AS "referenceAllele", + mutation_event.tumor_seq_allele AS "tumorSeqAllele", + mutation_event.protein_change AS "proteinChange", + mutation_event.mutation_type AS "mutationType", + mutation_event.ncbi_build AS "ncbiBuild", + mutation_event.variant_type AS "variantType", + mutation_event.refseq_mrna_id AS "refseqMrnaId", + mutation_event.protein_pos_start AS "proteinPosStart", + mutation_event.protein_pos_end AS "proteinPosEnd", + mutation_event.keyword AS "keyword", + mutation.annotation_json AS "annotationJSON", + alteration_driver_annotation.driver_filter AS "driverFilter", + alteration_driver_annotation.driver_filter_annotation AS "driverFilterAnnotation", + alteration_driver_annotation.driver_tiers_filter AS "driverTiersFilter", + alteration_driver_annotation.driver_tiers_filter_annotation as "driverTiersFilterAnnotation" , - + , @@ -49,13 +49,13 @@ - + ORDER BY "${sortBy}" ${direction} - ORDER BY genetic_profile.STABLE_ID ASC, sample.STABLE_ID ASC, mutation.ENTREZ_GENE_ID ASC + ORDER BY genetic_profile.stable_id ASC, sample.stable_id ASC, mutation.entrez_gene_id ASC LIMIT #{limit} OFFSET #{offset} @@ -64,60 +64,54 @@ FROM mutation - INNER JOIN genetic_profile ON mutation.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - INNER JOIN sample ON mutation.SAMPLE_ID = sample.INTERNAL_ID - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN genetic_profile ON mutation.genetic_profile_id = genetic_profile.genetic_profile_id + INNER JOIN sample ON mutation.sample_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id LEFT JOIN alteration_driver_annotation ON - mutation.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - and mutation.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID - and mutation.MUTATION_EVENT_ID = alteration_driver_annotation.ALTERATION_EVENT_ID + mutation.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND mutation.sample_id = alteration_driver_annotation.sample_id + AND mutation.mutation_event_id = alteration_driver_annotation.alteration_event_id - genetic_profile.STABLE_ID = #{molecularProfileId} + genetic_profile.stable_id = #{molecularProfileId} - AND sample.STABLE_ID IN - - #{item} - + AND sample.stable_id IN + #{item} - AND mutation.ENTREZ_GENE_ID IN - - #{item} - + AND mutation.entrez_gene_id IN + #{item} - AND mutation_event.REFERENCE_ALLELE IN ('A','T','C','G') - AND mutation_event.TUMOR_SEQ_ALLELE IN ('A','T','C','G') + AND mutation_event.reference_allele IN ('A','T','C','G') + AND mutation_event.tumor_seq_allele IN ('A','T','C','G') - genetic_profile.STABLE_ID = #{molecularProfileId} - AND mutation.SAMPLE_ID IN + genetic_profile.stable_id = #{molecularProfileId} + AND mutation.sample_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID = #{sampleListId} - AND sample_list_list.SAMPLE_ID = mutation.SAMPLE_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id = #{sampleListId} + AND sample_list_list.sample_id = mutation.sample_id ) - AND mutation.ENTREZ_GENE_ID IN - - #{item} - + AND mutation.entrez_gene_id IN + #{item} - AND mutation_event.REFERENCE_ALLELE IN ('A','T','C','G') - AND mutation_event.TUMOR_SEQ_ALLELE IN ('A','T','C','G') + AND mutation_event.reference_allele IN ('A','T','C','G') + AND mutation_event.tumor_seq_allele IN ('A','T','C','G') @@ -125,49 +119,38 @@ - mutation.SAMPLE_ID IN ( - SELECT sample.INTERNAL_ID from sample - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN genetic_profile ON patient.CANCER_STUDY_ID = genetic_profile.CANCER_STUDY_ID + mutation.sample_id IN ( + SELECT sample.internal_id FROM sample + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN genetic_profile ON patient.cancer_study_id = genetic_profile.cancer_study_id WHERE - genetic_profile.STABLE_ID = #{molecularProfileIds[0]} AND - sample.STABLE_ID IN - - #{item} - + genetic_profile.stable_id = #{molecularProfileIds[0]} AND + sample.stable_id IN + #{item} - (sample.STABLE_ID, genetic_profile.STABLE_ID) IN - - (#{sampleIds[${i}]}, #{molecularProfileIds[${i}]}) - - AND genetic_profile.STABLE_ID IN - - #{item} - + (sample.stable_id, genetic_profile.stable_id) IN + (#{sampleIds[${i}]},#{molecularProfileIds[${i}]}) + AND genetic_profile.stable_id IN + #{item} - AND sample.INTERNAL_ID = mutation.SAMPLE_ID ) - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - AND mutation.ENTREZ_GENE_ID IN - - #{item} - + AND mutation.entrez_gene_id IN + #{item} - AND mutation_event.REFERENCE_ALLELE IN ('A','T','C','G') - AND mutation_event.TUMOR_SEQ_ALLELE IN ('A','T','C','G') + AND mutation_event.reference_allele IN ('A','T','C','G') + AND mutation_event.tumor_seq_allele IN ('A','T','C','G') @@ -176,20 +159,20 @@ AND - ( mutation.ENTREZ_GENE_ID = '${geneFilterQuery.getEntrezGeneId()}' + ( mutation.entrez_gene_id = '${geneFilterQuery.getEntrezGeneId()}' - OR LOWER(mutation.MUTATION_STATUS) = 'germline' + OR LOWER(mutation.mutation_status) = 'germline' - OR LOWER(mutation.MUTATION_STATUS) = 'somatic' + OR LOWER(mutation.mutation_status) = 'somatic' - OR LOWER(mutation.MUTATION_STATUS) NOT IN ('somatic', 'germline') + OR LOWER(mutation.mutation_status) NOT IN ('somatic', 'germline') @@ -199,21 +182,21 @@ - + - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_driver' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_driver' - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_passenger' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_passenger' - OR alteration_driver_annotation.DRIVER_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) IN ('unknown', 'na', '') + OR alteration_driver_annotation.driver_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_filter) IN ('unknown', 'na', '') @@ -229,20 +212,18 @@ - AND NOT alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - AND NOT LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + AND NOT alteration_driver_annotation.driver_tiers_filter IS NULL + AND NOT LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IN - - #{item} - + OR alteration_driver_annotation.driver_tiers_filter IN + #{item} - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + OR alteration_driver_annotation.driver_tiers_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') @@ -259,20 +240,20 @@ - allele_specific_copy_number.ASCN_INTEGER_COPY_NUMBER AS "${prefix}ascnIntegerCopyNumber", - allele_specific_copy_number.ASCN_METHOD AS "${prefix}ascnMethod", - allele_specific_copy_number.CCF_EXPECTED_COPIES_UPPER AS "${prefix}ccfExpectedCopiesUpper", - allele_specific_copy_number.CCF_EXPECTED_COPIES AS "${prefix}ccfExpectedCopies", - allele_specific_copy_number.CLONAL AS "${prefix}clonal", - allele_specific_copy_number.MINOR_COPY_NUMBER AS "${prefix}minorCopyNumber", - allele_specific_copy_number.EXPECTED_ALT_COPIES AS "${prefix}expectedAltCopies", - allele_specific_copy_number.TOTAL_COPY_NUMBER AS "${prefix}totalCopyNumber" + allele_specific_copy_number.ascn_integer_copy_number AS "${prefix}ascnIntegerCopyNumber", + allele_specific_copy_number.ascn_method AS "${prefix}ascnMethod", + allele_specific_copy_number.ccf_expected_copies_upper AS "${prefix}ccfExpectedCopiesUpper", + allele_specific_copy_number.ccf_expected_copies AS "${prefix}ccfExpectedCopies", + allele_specific_copy_number.clonal AS "${prefix}clonal", + allele_specific_copy_number.minor_copy_number AS "${prefix}minorCopyNumber", + allele_specific_copy_number.expected_alt_copies AS "${prefix}expectedAltCopies", + allele_specific_copy_number.total_copy_number AS "${prefix}totalCopyNumber" - LEFT JOIN allele_specific_copy_number ON mutation.MUTATION_EVENT_ID = allele_specific_copy_number.MUTATION_EVENT_ID - AND mutation.GENETIC_PROFILE_ID = allele_specific_copy_number.GENETIC_PROFILE_ID - AND mutation.SAMPLE_ID = allele_specific_copy_number.SAMPLE_ID + LEFT JOIN allele_specific_copy_number ON mutation.mutation_event_id = allele_specific_copy_number.mutation_event_id + AND mutation.genetic_profile_id = allele_specific_copy_number.genetic_profile_id + AND mutation.sample_id = allele_specific_copy_number.sample_id @@ -293,9 +274,9 @@ SELECT - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID + INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id - INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id @@ -303,7 +284,7 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY genetic_profile.STABLE_ID ASC, sample.STABLE_ID ASC, mutation.ENTREZ_GENE_ID ASC + ORDER BY genetic_profile.stable_id ASC, sample.stable_id ASC, mutation.entrez_gene_id ASC LIMIT #{limit} OFFSET #{offset} @@ -313,9 +294,9 @@ @@ -323,9 +304,9 @@ SELECT - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID + INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id - INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id @@ -336,9 +317,9 @@ SELECT - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID + INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id - INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id @@ -348,61 +329,63 @@ - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml index 009a363d46f..bb6d69808f2 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml @@ -4,42 +4,49 @@ - patient.INTERNAL_ID AS "${prefix}internalId", - patient.STABLE_ID AS "${prefix}stableId", - patient.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier" + patient.internal_id AS "${prefix}internalId", + patient.stable_id AS "${prefix}stableId", + patient.cancer_study_id AS "${prefix}cancerStudyId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier" , - - - + cancer_study.cancer_study_id AS "cancerStudy.cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudy.cancerStudyIdentifier", + cancer_study.type_of_cancer_id AS "cancerStudy.typeOfCancerId", + cancer_study.name AS "cancerStudy.name", + cancer_study.description AS "cancerStudy.description", + cancer_study.public AS "cancerStudy.publicStudy", + cancer_study.pmid AS "cancerStudy.pmid", + cancer_study.citation AS "cancerStudy.citation", + cancer_study.groups AS "cancerStudy.groups", + cancer_study.status AS "cancerStudy.status", + cancer_study.import_date AS "cancerStudy.importDate", + reference_genome.name AS "cancerStudy.referenceGenome" FROM patient - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} + cancer_study.cancer_study_identifier = #{studyIds[0]} - (cancer_study.CANCER_STUDY_IDENTIFIER, patient.STABLE_ID) IN - - (#{studyIds[${i}]}, #{patientIds[${i}]}) - + (cancer_study.cancer_study_identifier,patient.stable_id) IN + (#{studyIds[${i}]},#{patientIds[${i}]}) - patient.STABLE_ID like CONCAT('%', #{item}, '%') + patient.stable_id like CONCAT('%', #{item}, '%') OR - sample.STABLE_ID like CONCAT('%', #{item}, '%') + sample.stable_id like CONCAT('%', #{item}, '%') @@ -52,17 +59,17 @@ - INNER JOIN sample ON patient.INTERNAL_ID = sample.PATIENT_ID + INNER JOIN sample ON patient.internal_id = sample.patient_id ORDER BY "${sortBy}" ${direction} - ORDER BY patient.STABLE_ID ASC + ORDER BY patient.stable_id ASC - ORDER BY CASE WHEN patient.STABLE_ID LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, patient.STABLE_ID + ORDER BY CASE WHEN patient.stable_id LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, patient.stable_id LIMIT #{limit} OFFSET #{offset} @@ -74,7 +81,7 @@ COUNT(*) AS totalCount - INNER JOIN sample ON patient.INTERNAL_ID = sample.PATIENT_ID + INNER JOIN sample ON patient.internal_id = sample.patient_id @@ -85,30 +92,26 @@ - WHERE patient.STABLE_ID = #{patientId} - AND cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + WHERE patient.stable_id = #{patientId} + AND cancer_study.cancer_study_identifier = #{studyId} @@ -37,15 +37,13 @@ FROM reference_genome_gene - INNER JOIN reference_genome ON reference_genome.REFERENCE_GENOME_ID = reference_genome_gene.REFERENCE_GENOME_ID - INNER JOIN gene ON gene.ENTREZ_GENE_ID = reference_genome_gene.ENTREZ_GENE_ID + INNER JOIN reference_genome ON reference_genome.reference_genome_id = reference_genome_gene.reference_genome_id + INNER JOIN gene ON gene.entrez_gene_id = reference_genome_gene.entrez_gene_id - gene.HUGO_GENE_SYMBOL IN - - #{item} - - AND reference_genome.NAME = #{genomeName} + gene.hugo_gene_symbol IN + #{item} + AND reference_genome.name = #{genomeName} FALSE @@ -59,34 +57,32 @@ FROM reference_genome_gene - INNER JOIN reference_genome ON reference_genome.REFERENCE_GENOME_ID = reference_genome_gene.REFERENCE_GENOME_ID - INNER JOIN gene ON gene.ENTREZ_GENE_ID = reference_genome_gene.ENTREZ_GENE_ID + INNER JOIN reference_genome ON reference_genome.reference_genome_id = reference_genome_gene.reference_genome_id + INNER JOIN gene ON gene.entrez_gene_id = reference_genome_gene.entrez_gene_id - gene.ENTREZ_GENE_ID IN - - #{item} - - AND reference_genome.NAME = #{genomeName} + gene.entrez_gene_id IN + #{item} + AND reference_genome.name = #{genomeName} FALSE - + - - - - - \ No newline at end of file + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ResourceDefinitionMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ResourceDefinitionMapper.xml index 6612d86078d..1beb899fca8 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ResourceDefinitionMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ResourceDefinitionMapper.xml @@ -2,19 +2,18 @@ - - resource_definition.RESOURCE_ID AS "${prefix}resourceId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier", - resource_definition.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - resource_definition.DISPLAY_NAME AS "${prefix}displayName" + resource_definition.resource_id AS "${prefix}resourceId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier", + resource_definition.cancer_study_id AS "${prefix}cancerStudyId", + resource_definition.display_name AS "${prefix}displayName" , - resource_definition.OPEN_BY_DEFAULT AS "${prefix}openByDefault", - resource_definition.DESCRIPTION AS "${prefix}description", - resource_definition.RESOURCE_TYPE AS "${prefix}resourceType", - resource_definition.PRIORITY AS "${prefix}priority", - resource_definition.CUSTOM_METADATA AS "${prefix}customMetaData" + resource_definition.open_by_default AS "${prefix}openByDefault", + resource_definition.description AS "${prefix}description", + resource_definition.resource_type AS "${prefix}resourceType", + resource_definition.priority AS "${prefix}priority", + resource_definition.custom_metadata AS "${prefix}customMetaData" @@ -24,17 +23,15 @@ FROM resource_definition - INNER JOIN cancer_study ON resource_definition.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON resource_definition.cancer_study_id = cancer_study.cancer_study_id NULL - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{id} - + cancer_study.cancer_study_identifier IN + #{id} @@ -42,7 +39,7 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY resource_definition.RESOURCE_ID ASC + ORDER BY resource_definition.resource_id ASC LIMIT #{limit} OFFSET #{offset} @@ -55,13 +52,13 @@ FROM resource_definition - INNER JOIN cancer_study ON resource_definition.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON resource_definition.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + cancer_study.cancer_study_identifier = #{studyId} - AND resource_definition.RESOURCE_ID = #{resourceId} + AND resource_definition.resource_id = #{resourceId} diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml index 3cbce6bf85c..bb990d81d8b 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml @@ -4,15 +4,16 @@ - sample_list.LIST_ID AS "${prefix}listId", - sample_list.STABLE_ID AS "${prefix}stableId" + + ANY_VALUE(sample_list.list_id) AS "${prefix}listId", + ANY_VALUE(sample_list.stable_id) AS "${prefix}stableId" , - sample_list.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier", - sample_list.CATEGORY AS "${prefix}category", - sample_list.NAME AS "${prefix}name", - sample_list.DESCRIPTION AS "${prefix}description" + ANY_VALUE(sample_list.cancer_study_id) AS "${prefix}cancerStudyId", + ANY_VALUE(cancer_study.cancer_study_identifier) AS "${prefix}cancerStudyIdentifier", + ANY_VALUE(sample_list.category) AS "${prefix}category", + ANY_VALUE(sample_list.name) AS "${prefix}name", + ANY_VALUE(sample_list.description) AS "${prefix}description" , @@ -28,25 +29,22 @@ FROM sample_list - INNER JOIN cancer_study ON sample_list.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN cancer_study ON sample_list.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id WHERE FALSE - WHERE cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + WHERE cancer_study.cancer_study_identifier IN + #{item} - + ORDER BY "${sortBy}" ${direction} - ORDER BY sample_list.STABLE_ID ASC + ORDER BY sample_list.stable_id ASC LIMIT #{limit} OFFSET #{offset} @@ -58,8 +56,8 @@ COUNT(*) AS totalCount FROM sample_list - INNER JOIN cancer_study ON sample_list.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - WHERE cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + INNER JOIN cancer_study ON sample_list.cancer_study_id = cancer_study.cancer_study_id + WHERE cancer_study.cancer_study_identifier = #{studyId} @@ -69,9 +67,9 @@ FROM sample_list - INNER JOIN cancer_study ON sample_list.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID - WHERE sample_list.STABLE_ID = #{sampleListId} + INNER JOIN cancer_study ON sample_list.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id + WHERE sample_list.stable_id = #{sampleListId} diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml index 291946fe0ed..2e6b7877bc2 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml @@ -4,65 +4,55 @@ - sample.INTERNAL_ID AS "${prefix}internalId", - sample.STABLE_ID AS "${prefix}stableId", - patient.STABLE_ID AS "${prefix}patientStableId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier" + sample.internal_id AS "${prefix}internalId", + sample.stable_id AS "${prefix}stableId", + patient.stable_id AS "${prefix}patientStableId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier" , - sample.SAMPLE_TYPE AS "${prefix}sampleType", - sample.PATIENT_ID AS "${prefix}patientId" + sample.sample_type AS "${prefix}sampleType", + sample.patient_id AS "${prefix}patientId" , - + FROM sample - INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id - cancer_study.CANCER_STUDY_IDENTIFIER IN - - (NULL) - - - - #{item} - - + cancer_study.cancer_study_identifier IN + (NULL) + #{item} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - sample.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + sample.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + (cancer_study.cancer_study_identifier,sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) - AND patient.STABLE_ID = #{patientId} + AND patient.stable_id = #{patientId} AND - sample.STABLE_ID like CONCAT('%', #{item}, '%') + sample.stable_id like CONCAT('%', #{item}, '%') @@ -79,10 +69,10 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY sample.STABLE_ID ASC + ORDER BY sample.stable_id ASC - ORDER BY CASE WHEN sample.STABLE_ID LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, sample.STABLE_ID + ORDER BY CASE WHEN sample.stable_id LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, sample.stable_id LIMIT #{limit} OFFSET #{offset} @@ -95,15 +85,13 @@ - WHERE sample.INTERNAL_ID IN + WHERE sample.internal_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID IN - - #{item} - - AND sample_list_list.SAMPLE_ID = sample.INTERNAL_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id IN + #{item} + AND sample_list_list.sample_id = sample.internal_id ) @@ -118,15 +106,13 @@ SELECT COUNT(*) AS "totalCount" - WHERE sample.INTERNAL_ID IN + WHERE sample.internal_id IN ( - SELECT sample_list_list.SAMPLE_ID FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID - WHERE sample_list.STABLE_ID IN - - #{item} - - AND sample_list_list.SAMPLE_ID = sample.INTERNAL_ID + SELECT sample_list_list.sample_id FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE sample_list.stable_id IN + #{item} + AND sample_list_list.sample_id = sample.internal_id ) @@ -136,8 +122,8 @@ - WHERE sample.STABLE_ID = #{sampleId} - AND cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + WHERE sample.stable_id = #{sampleId} + AND cancer_study.cancer_study_identifier = #{studyId} - + @@ -189,17 +171,13 @@ WHERE - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - patient.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + patient.stable_id IN + #{item} - (cancer_study.CANCER_STUDY_IDENTIFIER, patient.STABLE_ID) IN - - (#{studyIds[${i}]}, #{patientIds[${i}]}) - + (cancer_study.cancer_study_identifier,patient.stable_id) IN + (#{studyIds[${i}]},#{patientIds[${i}]}) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SecurityMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SecurityMapper.xml index 8c2c7694833..32c9cf254d5 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SecurityMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SecurityMapper.xml @@ -4,7 +4,7 @@ - + @@ -40,9 +40,9 @@ diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SignificantCopyNumberRegionMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SignificantCopyNumberRegionMapper.xml index c4cbfb34809..c1359de7706 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SignificantCopyNumberRegionMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SignificantCopyNumberRegionMapper.xml @@ -2,26 +2,25 @@ - - gistic.GISTIC_ROI_ID AS "gisticRoiId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "cancerStudyId", - gistic.CHROMOSOME AS "chromosome", - gistic.CYTOBAND AS "cytoband", - gistic.WIDE_PEAK_START AS "widePeakStart", - gistic.WIDE_PEAK_END AS "widePeakEnd", - gistic.Q_VALUE AS "qValue", - gistic.AMP AS "amp" + gistic.gistic_roi_id AS "gisticRoiId", + cancer_study.cancer_study_identifier AS "cancerStudyId", + gistic.chromosome AS "chromosome", + gistic.cytoband AS "cytoband", + gistic.wide_peak_start AS "widePeakStart", + gistic.wide_peak_end AS "widePeakEnd", + gistic.q_value AS "qValue", + gistic.amp AS "amp" FROM gistic - INNER JOIN cancer_study ON gistic.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON gistic.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + cancer_study.cancer_study_identifier = #{studyId} @@ -34,7 +33,7 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY gistic.CANCER_STUDY_ID ASC + ORDER BY gistic.cancer_study_id ASC LIMIT #{limit} OFFSET #{offset} @@ -47,20 +46,18 @@ - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SignificantlyMutatedGeneMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SignificantlyMutatedGeneMapper.xml index a3b4a463011..968b5304709 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SignificantlyMutatedGeneMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SignificantlyMutatedGeneMapper.xml @@ -4,25 +4,25 @@ - mut_sig.ENTREZ_GENE_ID AS "entrezGeneId", - mut_sig.CANCER_STUDY_ID AS "cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "cancerStudyIdentifier", - gene.HUGO_GENE_SYMBOL AS "hugoGeneSymbol", - mut_sig.`RANK` AS `rank`, + mut_sig.entrez_gene_id AS "entrezGeneId", + mut_sig.cancer_study_id AS "cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudyIdentifier", + gene.hugo_gene_symbol AS "hugoGeneSymbol", + mut_sig.`rank` AS `rank`, mut_sig.NumBasesCovered AS "numBasesCovered", mut_sig.NumMutations AS "numMutations", - mut_sig.P_VALUE AS "pValue", - mut_sig.Q_VALUE AS "qValue" + mut_sig.p_value AS "pValue", + mut_sig.q_value AS "qValue" FROM mut_sig - INNER JOIN cancer_study ON mut_sig.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN cancer_study ON mut_sig.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} + cancer_study.cancer_study_identifier = #{studyId} @@ -30,13 +30,13 @@ SELECT - INNER JOIN gene ON mut_sig.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + INNER JOIN gene ON mut_sig.entrez_gene_id = gene.entrez_gene_id ORDER BY "${sortBy}" ${direction} - ORDER BY mut_sig.ENTREZ_GENE_ID ASC + ORDER BY mut_sig.entrez_gene_id ASC LIMIT #{limit} OFFSET #{offset} diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StaticDataTimestampMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StaticDataTimestampMapper.xml index fd058d34c0d..7de6f0863ba 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StaticDataTimestampMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StaticDataTimestampMapper.xml @@ -6,18 +6,16 @@ - \ No newline at end of file + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StructuralVariantMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StructuralVariantMapper.xml index 45ea024fca7..ecb102b2783 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StructuralVariantMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StructuralVariantMapper.xml @@ -2,79 +2,72 @@ - - genetic_profile.STABLE_ID AS "${prefix}molecularProfileId", - sample.STABLE_ID AS "${prefix}sampleId", - patient.STABLE_ID AS "${prefix}patientId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}studyId", - structural_variant.SITE1_ENTREZ_GENE_ID AS "${prefix}site1EntrezGeneId", - gene1.HUGO_GENE_SYMBOL AS "${prefix}site1HugoSymbol", - structural_variant.SITE1_ENSEMBL_TRANSCRIPT_ID AS "${prefix}site1EnsemblTranscriptId", - structural_variant.SITE1_CONTIG AS "${prefix}site1Contig", - structural_variant.SITE1_REGION AS "${prefix}site1Region", - structural_variant.SITE1_REGION_NUMBER AS "${prefix}site1RegionNumber", - structural_variant.SITE1_CHROMOSOME AS "${prefix}site1Chromosome", - structural_variant.SITE1_POSITION AS "${prefix}site1Position", - structural_variant.SITE1_DESCRIPTION AS "${prefix}site1Description", - structural_variant.SITE2_ENTREZ_GENE_ID AS "${prefix}site2EntrezGeneId", - gene2.HUGO_GENE_SYMBOL AS "${prefix}site2HugoSymbol", - structural_variant.SITE2_ENSEMBL_TRANSCRIPT_ID AS "${prefix}site2EnsemblTranscriptId", - structural_variant.SITE2_CONTIG AS "${prefix}site2Contig", - structural_variant.SITE2_REGION AS "${prefix}site2Region", - structural_variant.SITE2_REGION_NUMBER AS "${prefix}site2RegionNumber", - structural_variant.SITE2_CHROMOSOME AS "${prefix}site2Chromosome", - structural_variant.SITE2_POSITION AS "${prefix}site2Position", - structural_variant.SITE2_DESCRIPTION AS "${prefix}site2Description", - structural_variant.SITE2_EFFECT_ON_FRAME AS "${prefix}site2EffectOnFrame", - structural_variant.NCBI_BUILD AS "${prefix}ncbiBuild", - structural_variant.DNA_SUPPORT AS "${prefix}dnaSupport", - structural_variant.RNA_SUPPORT AS "${prefix}rnaSupport", - structural_variant.NORMAL_READ_COUNT AS "${prefix}normalReadCount", - structural_variant.TUMOR_READ_COUNT AS "${prefix}tumorReadCount", - structural_variant.NORMAL_VARIANT_COUNT AS "${prefix}normalVariantCount", - structural_variant.TUMOR_VARIANT_COUNT AS "${prefix}tumorVariantCount", - structural_variant.NORMAL_PAIRED_END_READ_COUNT AS "${prefix}normalPairedEndReadCount", - structural_variant.TUMOR_PAIRED_END_READ_COUNT AS "${prefix}tumorPairedEndReadCount", - structural_variant.NORMAL_SPLIT_READ_COUNT AS "${prefix}normalSplitReadCount", - structural_variant.TUMOR_SPLIT_READ_COUNT AS "${prefix}tumorSplitReadCount", - structural_variant.ANNOTATION AS "${prefix}annotation", - structural_variant.BREAKPOINT_TYPE AS "${prefix}breakpointType", - structural_variant.CONNECTION_TYPE AS "${prefix}connectionType", - structural_variant.EVENT_INFO AS "${prefix}eventInfo", - structural_variant.CLASS AS "${prefix}variantClass", - structural_variant.LENGTH AS "${prefix}length", - structural_variant.COMMENTS AS "${prefix}comments", - structural_variant.SV_STATUS AS "${prefix}svStatus", - structural_variant.ANNOTATION_JSON AS "${prefix}annotationJson", - alteration_driver_annotation.DRIVER_FILTER AS "${prefix}driverFilter", - alteration_driver_annotation.DRIVER_FILTER_ANNOTATION AS "${prefix}driverFilterAnn", - alteration_driver_annotation.DRIVER_TIERS_FILTER AS "${prefix}driverTiersFilter", - alteration_driver_annotation.DRIVER_TIERS_FILTER_ANNOTATION AS "${prefix}driverTiersFilterAnn" + genetic_profile.stable_id AS "${prefix}molecularProfileId", + sample.stable_id AS "${prefix}sampleId", + patient.stable_id AS "${prefix}patientId", + cancer_study.cancer_study_identifier AS "${prefix}studyId", + structural_variant.site1_entrez_gene_id AS "${prefix}site1EntrezGeneId", + gene1.hugo_gene_symbol AS "${prefix}site1HugoSymbol", + structural_variant.site1_ensembl_transcript_id AS "${prefix}site1EnsemblTranscriptId", + structural_variant.site1_contig AS "${prefix}site1Contig", + structural_variant.site1_region AS "${prefix}site1Region", + structural_variant.site1_region_number AS "${prefix}site1RegionNumber", + structural_variant.site1_chromosome AS "${prefix}site1Chromosome", + structural_variant.site1_position AS "${prefix}site1Position", + structural_variant.site1_description AS "${prefix}site1Description", + structural_variant.site2_entrez_gene_id AS "${prefix}site2EntrezGeneId", + gene2.hugo_gene_symbol AS "${prefix}site2HugoSymbol", + structural_variant.site2_ensembl_transcript_id AS "${prefix}site2EnsemblTranscriptId", + structural_variant.site2_contig AS "${prefix}site2Contig", + structural_variant.site2_region AS "${prefix}site2Region", + structural_variant.site2_region_number AS "${prefix}site2RegionNumber", + structural_variant.site2_chromosome AS "${prefix}site2Chromosome", + structural_variant.site2_position AS "${prefix}site2Position", + structural_variant.site2_description AS "${prefix}site2Description", + structural_variant.site2_effect_on_frame AS "${prefix}site2EffectOnFrame", + structural_variant.ncbi_build AS "${prefix}ncbiBuild", + structural_variant.dna_support AS "${prefix}dnaSupport", + structural_variant.rna_support AS "${prefix}rnaSupport", + structural_variant.normal_read_count AS "${prefix}normalReadCount", + structural_variant.tumor_read_count AS "${prefix}tumorReadCount", + structural_variant.normal_variant_count AS "${prefix}normalVariantCount", + structural_variant.tumor_variant_count AS "${prefix}tumorVariantCount", + structural_variant.normal_paired_end_read_count AS "${prefix}normalPairedEndReadCount", + structural_variant.tumor_paired_end_read_count AS "${prefix}tumorPairedEndReadCount", + structural_variant.normal_split_read_count AS "${prefix}normalSplitReadCount", + structural_variant.tumor_split_read_count AS "${prefix}tumorSplitReadCount", + structural_variant.annotation AS "${prefix}annotation", + structural_variant.breakpoint_type AS "${prefix}breakpointType", + structural_variant.connection_type AS "${prefix}connectionType", + structural_variant.event_info AS "${prefix}eventInfo", + structural_variant.class AS "${prefix}variantClass", + structural_variant.length AS "${prefix}length", + structural_variant.comments AS "${prefix}comments", + structural_variant.sv_status AS "${prefix}svStatus", + structural_variant.annotation_json AS "${prefix}annotationJson", + alteration_driver_annotation.driver_filter AS "${prefix}driverFilter", + alteration_driver_annotation.driver_filter_annotation AS "${prefix}driverFilterAnn", + alteration_driver_annotation.driver_tiers_filter AS "${prefix}driverTiersFilter", + alteration_driver_annotation.driver_tiers_filter_annotation AS "${prefix}driverTiersFilterAnn" - AND + AND - genetic_profile.STABLE_ID IN - - #{item} - + genetic_profile.stable_id IN + #{item} - genetic_profile.STABLE_ID = #{molecularProfileIds[0]} AND - sample.STABLE_ID IN - - #{item} - + genetic_profile.stable_id = #{molecularProfileIds[0]} AND + sample.stable_id IN + #{item} - (sample.STABLE_ID, genetic_profile.STABLE_ID) IN - - (#{sampleIds[${i}]}, #{molecularProfileIds[${i}]}) - + (sample.stable_id,genetic_profile.stable_id) IN + (#{sampleIds[${i}]},#{molecularProfileIds[${i}]}) @@ -86,32 +79,32 @@ ( - (structural_variant.SITE1_ENTREZ_GENE_ID = ${geneFilterQuery.getEntrezGeneId()} - OR structural_variant.SITE2_ENTREZ_GENE_ID = ${geneFilterQuery.getEntrezGeneId()}) + (structural_variant.site1_entrez_gene_id = ${geneFilterQuery.getEntrezGeneId()} + OR structural_variant.site2_entrez_gene_id = ${geneFilterQuery.getEntrezGeneId()}) - AND structural_variant.SITE1_ENTREZ_GENE_ID IS NULL + AND structural_variant.site1_entrez_gene_id IS NULL - AND structural_variant.SITE1_ENTREZ_GENE_ID = ${geneFilterQuery.getGene1Query().getEntrezId()} + AND structural_variant.site1_entrez_gene_id = ${geneFilterQuery.getGene1Query().getEntrezId()} AND - structural_variant.SITE2_ENTREZ_GENE_ID IS NULL + structural_variant.site2_entrez_gene_id IS NULL AND - structural_variant.SITE2_ENTREZ_GENE_ID = ${geneFilterQuery.getGene2Query().getEntrezId()} + structural_variant.site2_entrez_gene_id = ${geneFilterQuery.getGene2Query().getEntrezId()} - + @@ -120,13 +113,13 @@ - OR LOWER(structural_variant.SV_STATUS) = 'germline' + OR LOWER(structural_variant.sv_status) = 'germline' - OR LOWER(structural_variant.SV_STATUS) = 'somatic' + OR LOWER(structural_variant.sv_status) = 'somatic' - OR LOWER(structural_variant.SV_STATUS) NOT IN ('somatic', 'germline') + OR LOWER(structural_variant.sv_status) NOT IN ('somatic', 'germline') ) @@ -145,14 +138,14 @@ - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_driver' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_driver' - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) = 'putative_passenger' + OR LOWER(alteration_driver_annotation.driver_filter) = 'putative_passenger' - OR alteration_driver_annotation.DRIVER_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_FILTER) IN ('unknown', 'na', '') + OR alteration_driver_annotation.driver_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_filter) IN ('unknown', 'na', '') @@ -169,20 +162,18 @@ - AND NOT alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - AND NOT LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + AND NOT alteration_driver_annotation.driver_tiers_filter IS NULL + AND NOT LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IN - - #{item} - + OR alteration_driver_annotation.driver_tiers_filter IN + #{item} - OR alteration_driver_annotation.DRIVER_TIERS_FILTER IS NULL - OR LOWER(alteration_driver_annotation.DRIVER_TIERS_FILTER) IN ('', 'na', 'unknown') + OR alteration_driver_annotation.driver_tiers_filter IS NULL + OR LOWER(alteration_driver_annotation.driver_tiers_filter) IN ('', 'na', 'unknown') @@ -196,19 +187,15 @@ ) - + OR ( - structural_variant.SITE1_ENTREZ_GENE_ID in - - #{item} - - OR - structural_variant.SITE2_ENTREZ_GENE_ID IN - - #{item} - + structural_variant.site1_entrez_gene_id IN + #{item} + OR + structural_variant.site2_entrez_gene_id IN + #{item} ) @@ -218,22 +205,22 @@ OR ( - structural_variant.SITE1_ENTREZ_GENE_ID=#{item.gene1.entrezId} + structural_variant.site1_entrez_gene_id=#{item.gene1.entrezId} - structural_variant.SITE1_ENTREZ_GENE_ID IS NULL - + structural_variant.site1_entrez_gene_id IS NULL + TRUE - + AND - + - structural_variant.SITE2_ENTREZ_GENE_ID=#{item.gene2.entrezId} + structural_variant.site2_entrez_gene_id=#{item.gene2.entrezId} - structural_variant.SITE2_ENTREZ_GENE_ID IS NULL + structural_variant.site2_entrez_gene_id IS NULL TRUE @@ -249,16 +236,15 @@ FROM structural_variant - JOIN genetic_profile ON structural_variant.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID - LEFT JOIN gene gene1 ON structural_variant.SITE1_ENTREZ_GENE_ID = gene1.ENTREZ_GENE_ID - LEFT JOIN gene gene2 ON structural_variant.SITE2_ENTREZ_GENE_ID = gene2.ENTREZ_GENE_ID - JOIN sample ON structural_variant.SAMPLE_ID = sample.INTERNAL_ID - JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID AND genetic_profile.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID - LEFT JOIN alteration_driver_annotation ON - structural_variant.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID - and structural_variant.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID - and structural_variant.INTERNAL_ID = alteration_driver_annotation.ALTERATION_EVENT_ID + JOIN genetic_profile ON structural_variant.genetic_profile_id = genetic_profile.genetic_profile_id + LEFT JOIN gene gene1 ON structural_variant.site1_entrez_gene_id = gene1.entrez_gene_id + LEFT JOIN gene gene2 ON structural_variant.site2_entrez_gene_id = gene2.entrez_gene_id + JOIN sample ON structural_variant.sample_id = sample.internal_id + JOIN patient ON sample.patient_id = patient.internal_id + JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id AND genetic_profile.cancer_study_id = cancer_study.cancer_study_id + LEFT JOIN alteration_driver_annotation ON structural_variant.genetic_profile_id = alteration_driver_annotation.genetic_profile_id + AND structural_variant.sample_id = alteration_driver_annotation.sample_id + AND structural_variant.internal_id = alteration_driver_annotation.alteration_event_id @@ -266,7 +252,7 @@ - ORDER BY gene1.HUGO_GENE_SYMBOL, gene2.HUGO_GENE_SYMBOL + ORDER BY gene1.hugo_gene_symbol, gene2.hugo_gene_symbol - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StudyMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StudyMapper.xml index eff6ccbd3b5..3b8808570ed 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StudyMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StudyMapper.xml @@ -4,92 +4,93 @@ - cancer_study.CANCER_STUDY_ID AS "${prefix}cancerStudyId", - cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier" + ANY_VALUE(cancer_study.cancer_study_id) AS "${prefix}cancerStudyId", + ANY_VALUE(cancer_study.cancer_study_identifier) AS "${prefix}cancerStudyIdentifier" , - cancer_study.TYPE_OF_CANCER_ID AS "${prefix}typeOfCancerId", - cancer_study.NAME AS "${prefix}name", - cancer_study.DESCRIPTION AS "${prefix}description", - cancer_study.PUBLIC AS "${prefix}publicStudy", - cancer_study.PMID AS "${prefix}pmid", - cancer_study.CITATION AS "${prefix}citation", - cancer_study.GROUPS AS "${prefix}groups", - cancer_study.STATUS AS "${prefix}status", - cancer_study.IMPORT_DATE AS "${prefix}importDate", - reference_genome.NAME AS "${prefix}referenceGenome" + ANY_VALUE(cancer_study.type_of_cancer_id) AS "${prefix}typeOfCancerId", + ANY_VALUE(cancer_study.name) AS "${prefix}name", + ANY_VALUE(cancer_study.description) AS "${prefix}description", + ANY_VALUE(cancer_study.public) AS "${prefix}publicStudy", + ANY_VALUE(cancer_study.pmid) AS "${prefix}pmid", + ANY_VALUE(cancer_study.citation) AS "${prefix}citation", + ANY_VALUE(cancer_study.groups) AS "${prefix}groups", + ANY_VALUE(cancer_study.status) AS "${prefix}status", + ANY_VALUE(cancer_study.import_date) AS "${prefix}importDate", + ANY_VALUE(reference_genome.name) AS "${prefix}referenceGenome" , - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_sequenced') THEN 1 ELSE NULL END) AS sequencedSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_cna') THEN 1 ELSE NULL END) AS cnaSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_rna_seq_mrna') THEN 1 ELSE NULL END) AS mrnaRnaSeqSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_rna_seq_v2_mrna') THEN 1 ELSE NULL END) AS mrnaRnaSeqV2SampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_microrna') THEN 1 ELSE NULL END) AS miRnaSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_mrna') THEN 1 ELSE NULL END) AS mrnaMicroarraySampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_methylation_hm27') THEN 1 ELSE NULL END) AS methylationHm27SampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_rppa') THEN 1 ELSE NULL END) AS rppaSampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_protein_quantification') THEN 1 ELSE NULL END) AS massSpectrometrySampleCount, - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_3way_complete') THEN 1 ELSE NULL END) AS completeSampleCount, - IFNULL(treatment.count, 0 ) as treatmentCount, - COALESCE(structural_variant.count, 0) as structuralVariantCount, - type_of_cancer.TYPE_OF_CANCER_ID AS "typeOfCancer.typeOfCancerId" + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_sequenced') THEN 1 ELSE NULL END) AS sequencedSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_cna') THEN 1 ELSE NULL END) AS cnaSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_rna_seq_mrna') THEN 1 ELSE NULL END) AS mrnaRnaSeqSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_rna_seq_v2_mrna') THEN 1 ELSE NULL END) AS mrnaRnaSeqV2SampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_microrna') THEN 1 ELSE NULL END) AS miRnaSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_mrna') THEN 1 ELSE NULL END) AS mrnaMicroarraySampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_methylation_hm27') THEN 1 ELSE NULL END) AS methylationHm27SampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_rppa') THEN 1 ELSE NULL END) AS rppaSampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_protein_quantification') THEN 1 ELSE NULL END) AS massSpectrometrySampleCount, + COUNT(CASE WHEN sample_list.stable_id = CONCAT(cancer_study.cancer_study_identifier,'_3way_complete') THEN 1 ELSE NULL END) AS completeSampleCount, + IFNULL(ANY_VALUE(treatment.count), 0 ) as treatmentCount, + COALESCE(ANY_VALUE(structural_variant.count), 0) as structuralVariantCount, + ANY_VALUE(type_of_cancer.type_of_cancer_id) AS "typeOfCancer.typeOfCancerId" , - type_of_cancer.NAME AS "typeOfCancer.name", - type_of_cancer.DEDICATED_COLOR AS "typeOfCancer.dedicatedColor", - type_of_cancer.SHORT_NAME AS "typeOfCancer.shortName", - type_of_cancer.PARENT AS "typeOfCancer.parent" + ANY_VALUE(type_of_cancer.name) AS "typeOfCancer.name", + ANY_VALUE(type_of_cancer.dedicated_color) AS "typeOfCancer.dedicatedColor", + ANY_VALUE(type_of_cancer.short_name) AS "typeOfCancer.shortName", + ANY_VALUE(type_of_cancer.parent) AS "typeOfCancer.parent" FROM cancer_study - INNER JOIN sample_list ON cancer_study.CANCER_STUDY_ID = sample_list.CANCER_STUDY_ID - INNER JOIN sample_list_list ON sample_list.LIST_ID = sample_list_list.LIST_ID - INNER JOIN reference_genome ON cancer_study.REFERENCE_GENOME_ID = reference_genome.REFERENCE_GENOME_ID + INNER JOIN sample_list ON cancer_study.cancer_study_id = sample_list.cancer_study_id + + INNER JOIN sample_list_list ON sample_list.list_id = sample_list_list.list_id + INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id - INNER JOIN type_of_cancer ON cancer_study.TYPE_OF_CANCER_ID = type_of_cancer.TYPE_OF_CANCER_ID - left JOIN + INNER JOIN type_of_cancer ON cancer_study.type_of_cancer_id = type_of_cancer.type_of_cancer_id + LEFT JOIN ( - SELECT Count(Distinct(clinical_event.PATIENT_ID)) as count, - patient.CANCER_STUDY_ID as CANCER_STUDY_ID + SELECT + COUNT(DISTINCT(clinical_event.patient_id)) as count, + patient.cancer_study_id as cancer_study_id FROM cancer_study - INNER JOIN patient on cancer_study.CANCER_STUDY_ID = patient.CANCER_STUDY_ID - Left Join clinical_event on clinical_event.PATIENT_ID = patient.INTERNAL_ID - WHERE clinical_event.EVENT_TYPE = 'Treatment' - GROUP BY patient.CANCER_STUDY_ID - ) as treatment on cancer_study.CANCER_STUDY_ID = treatment.CANCER_STUDY_ID + INNER JOIN patient ON cancer_study.cancer_study_id = patient.cancer_study_id + LEFT JOIN clinical_event on clinical_event.patient_id = patient.internal_id + WHERE clinical_event.event_type = 'Treatment' + GROUP BY patient.cancer_study_id + ) as treatment on cancer_study.cancer_study_id = treatment.cancer_study_id LEFT JOIN ( - SELECT COUNT(DISTINCT(structural_variant.SAMPLE_ID)) as count, - patient.CANCER_STUDY_ID as CANCER_STUDY_ID + SELECT + COUNT(DISTINCT(structural_variant.sample_id)) as count, + patient.cancer_study_id as cancer_study_id FROM cancer_study - INNER JOIN patient on cancer_study.CANCER_STUDY_ID = patient.CANCER_STUDY_ID - LEFT JOIN sample on patient.INTERNAL_ID = sample.PATIENT_ID - INNER JOIN structural_variant on structural_variant.SAMPLE_ID = sample.INTERNAL_ID - GROUP BY patient.CANCER_STUDY_ID - ) as structural_variant on structural_variant.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN patient ON cancer_study.cancer_study_id = patient.cancer_study_id + LEFT JOIN sample ON patient.internal_id = sample.patient_id + INNER JOIN structural_variant on structural_variant.sample_id = sample.internal_id + GROUP BY patient.cancer_study_id + ) as structural_variant on structural_variant.cancer_study_id = cancer_study.cancer_study_id - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - + cancer_study.cancer_study_identifier IN + #{item} - cancer_study.NAME like CONCAT('%', #{item}, '%') OR - cancer_study.CANCER_STUDY_IDENTIFIER like CONCAT('%', #{item}, '%') OR - type_of_cancer.NAME like CONCAT('%', #{item}, '%') OR - type_of_cancer.TYPE_OF_CANCER_ID like CONCAT('%', #{item}, '%') + cancer_study.name like CONCAT('%', #{item}, '%') OR + cancer_study.cancer_study_identifier like CONCAT('%', #{item}, '%') OR + type_of_cancer.name like CONCAT('%', #{item}, '%') OR + type_of_cancer.type_of_cancer_id like CONCAT('%', #{item}, '%') @@ -102,23 +103,25 @@ , - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_all') THEN 1 ELSE NULL END) AS allSampleCount + + + 1 AS allSampleCount - GROUP BY cancer_study.CANCER_STUDY_ID + GROUP BY cancer_study.cancer_study_id ORDER BY "${sortBy}" ${direction} - ORDER BY cancer_study.CANCER_STUDY_IDENTIFIER ASC + ORDER BY cancer_study.cancer_study_identifier ASC - ORDER BY CASE WHEN cancer_study.NAME LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, - CASE WHEN cancer_study.NAME LIKE '%tcga%' THEN 0 ELSE 1 END, cancer_study.NAME + ORDER BY CASE WHEN cancer_study.name LIKE CONCAT(#{keyword}, '%') THEN 0 ELSE 1 END, + CASE WHEN cancer_study.name LIKE '%tcga%' THEN 0 ELSE 1 END, cancer_study.name LIMIT #{limit} OFFSET #{offset} @@ -130,7 +133,7 @@ COUNT(*) AS totalCount FROM cancer_study - INNER JOIN type_of_cancer ON cancer_study.TYPE_OF_CANCER_ID = type_of_cancer.TYPE_OF_CANCER_ID + INNER JOIN type_of_cancer ON cancer_study.type_of_cancer_id = type_of_cancer.type_of_cancer_id @@ -142,38 +145,37 @@ , - COUNT(CASE WHEN sample_list.STABLE_ID = CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER,'_all') THEN 1 ELSE NULL END) AS allSampleCount + + + 1 AS allSampleCount - WHERE cancer_study.CANCER_STUDY_IDENTIFIER = #{studyId} - GROUP BY cancer_study.CANCER_STUDY_ID + WHERE cancer_study.cancer_study_identifier = #{studyId} - + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml index 91037a138f4..a192237613d 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml @@ -5,48 +5,48 @@ @@ -55,13 +55,13 @@ * FROM clinical_event - INNER JOIN clinical_event_data ON clinical_event.CLINICAL_EVENT_ID = clinical_event_data.CLINICAL_EVENT_ID - INNER JOIN patient ON clinical_event.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN sample ON patient.INTERNAL_ID = sample.PATIENT_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN clinical_event_data ON clinical_event.clinical_event_id = clinical_event_data.clinical_event_id + INNER JOIN patient ON clinical_event.patient_id = patient.internal_id + INNER JOIN sample ON patient.internal_id = sample.patient_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - AND clinical_event.EVENT_TYPE = 'TREATMENT' - AND clinical_event_data.KEY = #{key} LIMIT 1 + AND clinical_event.event_type = 'TREATMENT' + AND clinical_event_data.key = #{key} LIMIT 1 ) @@ -70,47 +70,35 @@ * FROM clinical_event - INNER JOIN clinical_event_data ON clinical_event.CLINICAL_EVENT_ID = clinical_event_data.CLINICAL_EVENT_ID - INNER JOIN patient ON clinical_event.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN sample ON clinical_event_data.VALUE = sample.STABLE_ID - INNER JOIN cancer_study ON patient.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID + INNER JOIN clinical_event_data ON clinical_event.clinical_event_id = clinical_event_data.clinical_event_id + INNER JOIN patient ON clinical_event.patient_id = patient.internal_id + INNER JOIN sample ON clinical_event_data.value = sample.stable_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - AND clinical_event_data.KEY = 'SAMPLE_ID' - AND (clinical_event.EVENT_TYPE LIKE 'Sample Acquisition' OR clinical_event.EVENT_TYPE LIKE 'SPECIMEN') LIMIT 1) + AND clinical_event_data.key = 'SAMPLE_ID' + AND (clinical_event.event_type LIKE 'Sample Acquisition' OR clinical_event.event_type LIKE 'SPECIMEN') LIMIT 1) - cancer_study.CANCER_STUDY_IDENTIFIER IN - - (NULL) - - - - #{item} - - + cancer_study.cancer_study_identifier IN + (NULL) + #{item} - cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - sample.STABLE_ID IN - - #{item} - + cancer_study.cancer_study_identifier = #{studyIds[0]} AND + sample.stable_id IN + #{item} - cancer_study.CANCER_STUDY_IDENTIFIER IN - - #{item} - - AND (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + cancer_study.cancer_study_identifier IN + #{item} + AND (cancer_study.cancer_study_identifier,sample.stable_id) IN + (#{studyIds[${i}]},#{sampleIds[${i}]}) - \ No newline at end of file + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/VariantCountMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/VariantCountMapper.xml index 35376d31c39..d80a4b609d2 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/VariantCountMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/VariantCountMapper.xml @@ -5,25 +5,25 @@ From 32f527ca49dc37de73cd08fd37bebad4828b8944 Mon Sep 17 00:00:00 2001 From: Charles Haynes Date: Mon, 2 Jun 2025 15:19:44 -0400 Subject: [PATCH 03/31] Fix mybatis xml --- .../legacy/persistence/mybatis/AlterationCountsMapper.xml | 2 +- .../legacy/persistence/mybatis/ClinicalDataMapper.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/AlterationCountsMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/AlterationCountsMapper.xml index d5be2b8eb25..cbbac691a53 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/AlterationCountsMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/AlterationCountsMapper.xml @@ -3,7 +3,7 @@ - SELECT entrez_gene_id AS "entrezGeneId", hugo_gene_symbol AS "hugoGeneSymbol", diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml index 01c21075d02..f0fa76e57d6 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml @@ -213,7 +213,7 @@ GROUP BY clinical_patient.attr_id, clinical_patient.attr_value - SELECT From 611aa9175ea42a367080169e68fbaea64d4977b8 Mon Sep 17 00:00:00 2001 From: Charles Haynes Date: Tue, 3 Jun 2025 15:14:24 -0400 Subject: [PATCH 04/31] Remove GeneMemoizer call --- .../legacy/web/ReferenceGenomeGeneController.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/cbioportal/legacy/web/ReferenceGenomeGeneController.java b/src/main/java/org/cbioportal/legacy/web/ReferenceGenomeGeneController.java index b2aaa48241c..b62806cf77d 100644 --- a/src/main/java/org/cbioportal/legacy/web/ReferenceGenomeGeneController.java +++ b/src/main/java/org/cbioportal/legacy/web/ReferenceGenomeGeneController.java @@ -60,11 +60,7 @@ public ResponseEntity> getAllReferenceGenomeGenes( @Parameter(required = true, description = "Name of Reference Genome hg19") @PathVariable String genomeName) { - List genes = geneMemoizerService.fetchGenes(genomeName); - if (genes == null) { - genes = referenceGenomeGeneService.fetchAllReferenceGenomeGenes(genomeName); - geneMemoizerService.cacheGenes(genes, genomeName); - } + var genes = referenceGenomeGeneService.fetchAllReferenceGenomeGenes(genomeName); return new ResponseEntity<>(genes, HttpStatus.OK); } From de029adee7919bfdd1104ea7e7ee6ec9d30c0a19 Mon Sep 17 00:00:00 2001 From: alisman Date: Thu, 21 Aug 2025 12:06:26 -0400 Subject: [PATCH 05/31] Optimize PatientMapper IN clauses for ClickHouse JDBC performance (#11673) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace foreach loops generating multiple prepared statement parameters with single array parameter using ArrayTypeHandler. This significantly improves performance with ClickHouse JDBC connections by reducing parameter overhead. - Use CONCAT(study_id, ':', patient_id) with ArrayTypeHandler - Add SqlUtils.combineStudyAndPatientIds() utility method - Apply optimization to both patient and sample lookup queries - Maintain security through proper parameter binding 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude --- .../persistence/mybatis/util/SqlUtils.java | 30 +++++++++++++++++++ .../persistence/mybatis/PatientMapper.xml | 12 +++++--- 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/cbioportal/legacy/persistence/mybatis/util/SqlUtils.java diff --git a/src/main/java/org/cbioportal/legacy/persistence/mybatis/util/SqlUtils.java b/src/main/java/org/cbioportal/legacy/persistence/mybatis/util/SqlUtils.java new file mode 100644 index 00000000000..5cb098aa91f --- /dev/null +++ b/src/main/java/org/cbioportal/legacy/persistence/mybatis/util/SqlUtils.java @@ -0,0 +1,30 @@ +package org.cbioportal.legacy.persistence.mybatis.util; + +import java.util.List; + +/** Utility class for SQL operations in MyBatis mappers */ +public class SqlUtils { + + /** + * Combines study IDs and patient/sample IDs into unique keys for efficient array parameter usage. + * This helps optimize ClickHouse JDBC performance by reducing the number of prepared statement + * parameters. + * + * @param studyIds List of study identifiers + * @param entityIds List of patient or sample identifiers (corresponding to studyIds by index) + * @return Array of combined unique keys in format "studyId:entityId" + */ + public static String[] combineStudyAndPatientIds(List studyIds, List entityIds) { + if (studyIds == null || entityIds == null || studyIds.size() != entityIds.size()) { + throw new IllegalArgumentException( + "studyIds and entityIds must be non-null and have the same size"); + } + + String[] combinedKeys = new String[studyIds.size()]; + for (int i = 0; i < studyIds.size(); i++) { + combinedKeys[i] = studyIds.get(i) + ":" + entityIds.get(i); + } + + return combinedKeys; + } +} diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml index bb6d69808f2..64dd96b0ebd 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml @@ -38,8 +38,10 @@ cancer_study.cancer_study_identifier = #{studyIds[0]} - (cancer_study.cancer_study_identifier,patient.stable_id) IN - (#{studyIds[${i}]},#{patientIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', patient.stable_id) IN ( + #{patientUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) @@ -110,8 +112,10 @@ #{item} - (cancer_study.cancer_study_identifier,sample.stable_id) IN - (#{studyIds[${i}]},#{sampleIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', sample.stable_id) IN ( + #{sampleUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) FALSE From 000498cd112aefd7322b0211ce2f1bbe274e8a25 Mon Sep 17 00:00:00 2001 From: Onur Sumer Date: Tue, 2 Sep 2025 17:19:05 -0400 Subject: [PATCH 06/31] improve molecular data query (#11669) --- .../mybatis/MolecularDataMapper.xml | 61 ++++++++++++------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml index 9f835819626..b9dea15031e 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml @@ -3,15 +3,44 @@ + + genetic_alteration.genetic_profile_id = ( + SELECT gp.genetic_profile_id + FROM genetic_profile gp + WHERE gp.stable_id = #{molecularProfileId} + ) + + + + genetic_alteration.genetic_entity_id IN ( + SELECT g.genetic_entity_id + FROM gene g + WHERE g.entrez_gene_id IN + #{item} + ) + + + + + + + AND + + + + - genetic_profile.stable_id IN - #{item} + genetic_alteration.genetic_profile_id IN ( + SELECT gp.genetic_profile_id + FROM genetic_profile gp + WHERE gp.stable_id IN + #{item} + ) - AND gene.entrez_gene_id IN - #{item} + AND @@ -44,13 +73,7 @@ FROM genetic_alteration INNER JOIN genetic_profile ON genetic_alteration.genetic_profile_id = genetic_profile.genetic_profile_id INNER JOIN gene ON genetic_alteration.genetic_entity_id = gene.genetic_entity_id - - genetic_profile.stable_id = #{molecularProfileId} - - AND gene.entrez_gene_id IN - #{item} - - + @@ -90,7 +107,7 @@ INNER JOIN genetic_profile ON genetic_alteration.genetic_profile_id = genetic_profile.genetic_profile_id INNER JOIN gene ON genetic_alteration.genetic_entity_id = gene.genetic_entity_id - genetic_profile.stable_id = #{molecularProfileId} + @@ -124,7 +141,7 @@ INNER JOIN genetic_profile ON genetic_alteration.genetic_profile_id = genetic_profile.genetic_profile_id INNER JOIN geneset ON genetic_alteration.genetic_entity_id = geneset.genetic_entity_id - genetic_profile.stable_id = #{molecularProfileId} + AND geneset.external_id IN #{item} @@ -147,7 +164,7 @@ INNER JOIN genetic_profile ON genetic_alteration.genetic_profile_id = genetic_profile.genetic_profile_id INNER JOIN genetic_entity ON genetic_alteration.genetic_entity_id = genetic_entity.id - genetic_profile.stable_id = #{molecularProfileId} + AND genetic_entity.stable_id IN #{item} @@ -175,7 +192,7 @@ INNER JOIN genetic_profile ON genetic_alteration.genetic_profile_id = genetic_profile.genetic_profile_id INNER JOIN genetic_entity ON genetic_alteration.genetic_entity_id = genetic_entity.id - genetic_profile.stable_id = #{molecularProfileId} + AND genetic_entity.stable_id IN #{item} From c28418132e827858f69b3769c2674f627a5d574e Mon Sep 17 00:00:00 2001 From: Bryan Lai <56288120+gblaih@users.noreply.github.com> Date: Wed, 10 Sep 2025 11:25:20 -0400 Subject: [PATCH 07/31] add back clinical data mapper queries for clinical table (#11700) Co-authored-by: Bryan Lai --- .../mybatis/ClinicalDataMapper.xml | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml index f0fa76e57d6..0f1d41a42ea 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml @@ -273,4 +273,127 @@ ON clinical_sample.internal_id = sample_id_subquery.internal_id + + + + SELECT + DISTINCT sample.internal_id sampleInternalId + FROM sample + INNER JOIN patient ON patient.internal_id = sample.patient_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + INNER JOIN clinical_sample cs on sample.internal_id = cs.internal_id + INNER JOIN clinical_patient cp on patient.internal_id = cp.internal_id + + AND ( + cs.ATTR_VALUE LIKE CONCAT('%', #{searchTerm}, '%') + OR cp.ATTR_VALUE LIKE CONCAT('%', #{searchTerm}, '%') + OR sample.STABLE_ID LIKE CONCAT('%', #{searchTerm}, '%') + OR patient.STABLE_ID LIKE CONCAT('%', #{searchTerm}, '%') + ) + + + + + + SELECT sample.internal_id sampleInternalId, sample.stable_id sampleId, patient.stable_id patientId, clinical_patient.attr_id sortAttrId, + + CONVERT(clinical_patient.attr_value, DECIMAL) sortAttrValue + + + clinical_patient.attr_value sortAttrValue + + + FROM sample + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + LEFT JOIN clinical_patient ON patient.internal_id = clinical_patient.internal_id AND clinical_patient.attr_id = #{sortAttrId} + + + SELECT sample.internal_id sampleInternalId, sample.stable_id sampleId, patient.stable_id patientId, clinical_sample.attr_id sortAttrId, + + + CONVERT(clinical_sample.attr_value, DECIMAL) sortAttrValue + + + clinical_sample.attr_value sortAttrValue + + + FROM clinical_sample + INNER JOIN sample ON clinical_sample.internal_id = sample.internal_id + INNER JOIN patient ON sample.patient_id = patient.internal_id + INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id + WHERE clinical_sample.attr_id = #{sortAttrId} + + + + + + + + From 3fd466284dd83e7ed3adc3f307a668cfe5408a6f Mon Sep 17 00:00:00 2001 From: alisman Date: Thu, 11 Sep 2025 11:46:24 -0400 Subject: [PATCH 08/31] Optimize ClinicalAttributeMapper sample ID queries for ClickHouse JDBC performance (#11703) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply ArrayTypeHandler optimization strategy to whereSample include, following the same approach used in PatientMapper (commit 2e2ec228). This significantly improves performance with ClickHouse JDBC connections by reducing parameter overhead. Changes: - Replace foreach loops in whereSample with ArrayTypeHandler for both single-study and multi-study queries - Use SqlUtils.combineStudyAndPatientIds() for multi-study scenarios with CONCAT-based unique key matching - Optimize getClinicalAttributeCountsBySampleIds query performance through updated whereSample include This reduces prepared statement parameters from potentially thousands to single array parameters, maintaining security through proper parameter binding. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude --- .../persistence/mybatis/ClinicalAttributeMapper.xml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml index d85af759166..fc42615243c 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml @@ -37,12 +37,15 @@ cancer_study.cancer_study_identifier = #{studyIds[0]} AND - sample.stable_id IN - #{item} + sample.stable_id IN ( + #{sampleIds, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (cancer_study.cancer_study_identifier, sample.stable_id) IN - (#{studyIds[${i}]},#{sampleIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', sample.stable_id) IN ( + #{sampleUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) From 688a55274d0596412e40274318e95fd6764e4084 Mon Sep 17 00:00:00 2001 From: alisman Date: Thu, 11 Sep 2025 15:38:51 -0400 Subject: [PATCH 09/31] Comprehensive ArrayTypeHandler optimization for ClickHouse JDBC performance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply ArrayTypeHandler optimization strategy across all high-priority MyBatis mappers to dramatically improve ClickHouse JDBC performance by reducing prepared statement parameter overhead. SqlUtils Enhancements: - Add listToArray() utility method to convert List to String[] for ArrayTypeHandler - Extend combineStudyAndPatientIds() usage for multi-study query optimization Optimized MyBatis Mappers (11 files): - ClinicalAttributeMapper.xml - clinical attribute count queries with sample IDs - ClinicalDataMapper.xml - sample and patient clinical data queries - ClinicalEventMapper.xml - clinical events by sample and patient IDs - CopyNumberSegmentMapper.xml - copy number segment queries - DiscreteCopyNumberMapper.xml - discrete copy number queries - MutationMapper.xml - mutation queries with sample/profile pairs - NamespaceMapper.xml - sample ID namespace queries - SampleMapper.xml - sample queries with study/sample and study/patient pairs - StructuralVariantMapper.xml - structural variant queries - TreatmentMapper.xml - treatment sample ID queries Optimization Strategy Applied: - Single-study queries: Use + ArrayTypeHandler for direct List→Array conversion - Multi-study queries: Use SqlUtils.combineStudyAndPatientIds() with CONCAT matching - Replace foreach loops generating multiple prepared statement parameters - Use proper elements to avoid MyBatis parameter binding errors Performance Impact: - Reduces prepared statement parameters from potentially thousands to single arrays - Follows same proven optimization pattern from PatientMapper (commit 2e2ec228) - Maintains security through proper parameter binding - Significant improvement for ClickHouse JDBC connections 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../persistence/mybatis/util/SqlUtils.java | 14 ++++++++++ .../mybatis/ClinicalAttributeMapper.xml | 3 ++- .../mybatis/ClinicalDataMapper.xml | 24 +++++++++++------ .../mybatis/ClinicalEventMapper.xml | 26 ++++++++++++------- .../mybatis/CopyNumberSegmentMapper.xml | 6 +++-- .../mybatis/DiscreteCopyNumberMapper.xml | 12 ++++++--- .../persistence/mybatis/MutationMapper.xml | 18 ++++++++----- .../persistence/mybatis/NamespaceMapper.xml | 16 ++++++------ .../persistence/mybatis/SampleMapper.xml | 24 +++++++++++------ .../mybatis/StructuralVariantMapper.xml | 12 ++++++--- .../persistence/mybatis/TreatmentMapper.xml | 14 +++++----- 11 files changed, 112 insertions(+), 57 deletions(-) diff --git a/src/main/java/org/cbioportal/legacy/persistence/mybatis/util/SqlUtils.java b/src/main/java/org/cbioportal/legacy/persistence/mybatis/util/SqlUtils.java index 5cb098aa91f..9cd830b97c1 100644 --- a/src/main/java/org/cbioportal/legacy/persistence/mybatis/util/SqlUtils.java +++ b/src/main/java/org/cbioportal/legacy/persistence/mybatis/util/SqlUtils.java @@ -27,4 +27,18 @@ public static String[] combineStudyAndPatientIds(List studyIds, List list) { + if (list == null) { + return null; + } + return list.toArray(new String[0]); + } } diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml index fc42615243c..142b11214f5 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalAttributeMapper.xml @@ -36,9 +36,10 @@ + cancer_study.cancer_study_identifier = #{studyIds[0]} AND sample.stable_id IN ( - #{sampleIds, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + #{sampleArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} ) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml index 0f1d41a42ea..8a0f6bb5ca3 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml @@ -65,13 +65,17 @@ + cancer_study.cancer_study_identifier = #{studyIds[0]} AND - sample.stable_id IN - #{item} + sample.stable_id IN ( + #{sampleArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (cancer_study.cancer_study_identifier, sample.stable_id) IN - (#{studyIds[${i}]},#{sampleIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', sample.stable_id) IN ( + #{sampleUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) @@ -90,13 +94,17 @@ + cancer_study.cancer_study_identifier = #{studyIds[0]} AND - patient.stable_id IN - #{item} + patient.stable_id IN ( + #{patientArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (cancer_study.cancer_study_identifier, patient.stable_id) IN - (#{studyIds[${i}]},#{patientIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', patient.stable_id) IN ( + #{patientUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalEventMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalEventMapper.xml index fb551affe1c..322f061d0ac 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalEventMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalEventMapper.xml @@ -111,15 +111,17 @@ + cancer_study.cancer_study_identifier = #{studyIds[0]} AND - sample.stable_id IN - #{item} + sample.stable_id IN ( + #{sampleArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - cancer_study.cancer_study_identifier IN - #{item} - AND (cancer_study.cancer_study_identifier, sample.stable_id) IN - (#{studyIds[${i}]},#{sampleIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', sample.stable_id) IN ( + #{sampleUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) @@ -146,13 +148,17 @@ + cancer_study.cancer_study_identifier = #{studyIds[0]} AND - patient.stable_id IN - #{item} + patient.stable_id IN ( + #{patientArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (cancer_study.cancer_study_identifier, patient.stable_id) IN - (#{studyIds[${i}]},#{patientIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', patient.stable_id) IN ( + #{patientUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml index 890d503c214..000348363b8 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml @@ -26,8 +26,10 @@ - (cancer_study.cancer_study_identifier, sample.stable_id) IN - (#{studyIds[${i}]},#{sampleIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', sample.stable_id) IN ( + #{sampleUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DiscreteCopyNumberMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DiscreteCopyNumberMapper.xml index 478f18d9378..165b7e896ed 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DiscreteCopyNumberMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/DiscreteCopyNumberMapper.xml @@ -77,13 +77,17 @@ + genetic_profile.stable_id = #{molecularProfileIds[0]} AND - sample.stable_id IN - #{item} + sample.stable_id IN ( + #{sampleArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (sample.stable_id, genetic_profile.stable_id) IN - (#{sampleIds[${i}]},#{molecularProfileIds[${i}]}) + + CONCAT(sample.stable_id, ':', genetic_profile.stable_id) IN ( + #{sampleProfileKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) AND cna_event.entrez_gene_id IN diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MutationMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MutationMapper.xml index 4de2f93e126..931a031e8c5 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MutationMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MutationMapper.xml @@ -124,15 +124,21 @@ INNER JOIN genetic_profile ON patient.cancer_study_id = genetic_profile.cancer_study_id WHERE + genetic_profile.stable_id = #{molecularProfileIds[0]} AND - sample.stable_id IN - #{item} + sample.stable_id IN ( + #{sampleArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (sample.stable_id, genetic_profile.stable_id) IN - (#{sampleIds[${i}]},#{molecularProfileIds[${i}]}) - AND genetic_profile.stable_id IN - #{item} + + CONCAT(sample.stable_id, ':', genetic_profile.stable_id) IN ( + #{sampleProfileKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) + + AND genetic_profile.stable_id IN ( + #{profileArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) ) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/NamespaceMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/NamespaceMapper.xml index ac7f9de75d8..6e409e88e66 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/NamespaceMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/NamespaceMapper.xml @@ -28,17 +28,17 @@ + cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND - sample.STABLE_ID IN - - #{item} - + sample.STABLE_ID IN ( + #{sampleArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN - - (#{studyIds[${i}]}, #{sampleIds[${i}]}) - + + CONCAT(cancer_study.CANCER_STUDY_IDENTIFIER, ':', sample.STABLE_ID) IN ( + #{sampleUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml index a2c7d7c5f6e..bcb8ea28763 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml @@ -37,13 +37,17 @@ + cancer_study.cancer_study_identifier = #{studyIds[0]} AND - sample.stable_id IN - #{item} + sample.stable_id IN ( + #{sampleArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (cancer_study.cancer_study_identifier,sample.stable_id) IN - (#{studyIds[${i}]},#{sampleIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', sample.stable_id) IN ( + #{sampleUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) @@ -170,13 +174,17 @@ WHERE + cancer_study.cancer_study_identifier = #{studyIds[0]} AND - patient.stable_id IN - #{item} + patient.stable_id IN ( + #{patientArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (cancer_study.cancer_study_identifier,patient.stable_id) IN - (#{studyIds[${i}]},#{patientIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', patient.stable_id) IN ( + #{patientUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StructuralVariantMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StructuralVariantMapper.xml index ecb102b2783..d96fb4c8a85 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StructuralVariantMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StructuralVariantMapper.xml @@ -61,13 +61,17 @@ + genetic_profile.stable_id = #{molecularProfileIds[0]} AND - sample.stable_id IN - #{item} + sample.stable_id IN ( + #{sampleArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - (sample.stable_id,genetic_profile.stable_id) IN - (#{sampleIds[${i}]},#{molecularProfileIds[${i}]}) + + CONCAT(sample.stable_id, ':', genetic_profile.stable_id) IN ( + #{sampleProfileKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml index a192237613d..51f0d027f74 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml @@ -88,15 +88,17 @@ + cancer_study.cancer_study_identifier = #{studyIds[0]} AND - sample.stable_id IN - #{item} + sample.stable_id IN ( + #{sampleArray, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) - cancer_study.cancer_study_identifier IN - #{item} - AND (cancer_study.cancer_study_identifier,sample.stable_id) IN - (#{studyIds[${i}]},#{sampleIds[${i}]}) + + CONCAT(cancer_study.cancer_study_identifier, ':', sample.stable_id) IN ( + #{sampleUniqueKeys, typeHandler=org.apache.ibatis.type.ArrayTypeHandler} + ) From 94aaee9179e15207d783e95d31a553d641d556d9 Mon Sep 17 00:00:00 2001 From: alisman Date: Wed, 17 Sep 2025 16:16:39 -0400 Subject: [PATCH 10/31] Fix capitalization of field names in sql --- .../legacy/persistence/mybatis/ClinicalDataMapper.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml index 8a0f6bb5ca3..d0a84823b3d 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ClinicalDataMapper.xml @@ -336,10 +336,10 @@ INNER JOIN clinical_patient cp on patient.internal_id = cp.internal_id AND ( - cs.ATTR_VALUE LIKE CONCAT('%', #{searchTerm}, '%') - OR cp.ATTR_VALUE LIKE CONCAT('%', #{searchTerm}, '%') - OR sample.STABLE_ID LIKE CONCAT('%', #{searchTerm}, '%') - OR patient.STABLE_ID LIKE CONCAT('%', #{searchTerm}, '%') + cs.attr_value LIKE CONCAT('%', #{searchTerm}, '%') + OR cp.attr_value LIKE CONCAT('%', #{searchTerm}, '%') + OR sample.stable_id LIKE CONCAT('%', #{searchTerm}, '%') + OR patient.stable_id LIKE CONCAT('%', #{searchTerm}, '%') ) From 6189f4ffd9f4ad52077526022bd5ed82e5e0ff35 Mon Sep 17 00:00:00 2001 From: Onur Sumer Date: Thu, 25 Sep 2025 11:11:30 -0400 Subject: [PATCH 11/31] make sure treatment mapper string comparisons are case-insensitive (#11720) --- .../persistence/mybatis/TreatmentMapper.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml index 51f0d027f74..5713a3a4b62 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml @@ -17,8 +17,8 @@ INNER JOIN sample ON patient.internal_id = sample.patient_id INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - AND clinical_event.event_type = 'TREATMENT' - AND clinical_event_data.key = #{key} + AND clinical_event.event_type ILIKE 'TREATMENT' + AND clinical_event_data.key ILIKE #{key} @@ -75,8 +75,8 @@ INNER JOIN sample ON clinical_event_data.value = sample.stable_id INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id - AND clinical_event_data.key = 'SAMPLE_ID' - AND (clinical_event.event_type LIKE 'Sample Acquisition' OR clinical_event.event_type LIKE 'SPECIMEN') LIMIT 1) + AND clinical_event_data.key ILIKE 'SAMPLE_ID' + AND (clinical_event.event_type ILIKE 'Sample Acquisition' OR clinical_event.event_type ILIKE 'SPECIMEN') LIMIT 1) From e5fdccf3ccf8262de5f2755d77c17479ba6c3df7 Mon Sep 17 00:00:00 2001 From: Onur Sumer Date: Thu, 25 Sep 2025 11:12:05 -0400 Subject: [PATCH 12/31] fix broken resource data endpoints (#11719) --- .../mybatis/ResourceDataMapper.java | 18 ------------------ .../mybatis/ResourceDataMyBatisRepository.java | 6 ++++-- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/cbioportal/legacy/persistence/mybatis/ResourceDataMapper.java b/src/main/java/org/cbioportal/legacy/persistence/mybatis/ResourceDataMapper.java index a712646c9ea..b66940b5739 100644 --- a/src/main/java/org/cbioportal/legacy/persistence/mybatis/ResourceDataMapper.java +++ b/src/main/java/org/cbioportal/legacy/persistence/mybatis/ResourceDataMapper.java @@ -33,22 +33,4 @@ List getResourceDataForStudy( Integer offset, String sortBy, String direction); - - List getResourceDataForAllPatientsInStudy( - String studyId, - String resourceId, - String projection, - Integer limit, - Integer offset, - String sortBy, - String direction); - - List getResourceDataForAllSamplesInStudy( - String studyId, - String resourceId, - String projection, - Integer limit, - Integer offset, - String sortBy, - String direction); } diff --git a/src/main/java/org/cbioportal/legacy/persistence/mybatis/ResourceDataMyBatisRepository.java b/src/main/java/org/cbioportal/legacy/persistence/mybatis/ResourceDataMyBatisRepository.java index ed0088ae731..0f47d8a5f48 100644 --- a/src/main/java/org/cbioportal/legacy/persistence/mybatis/ResourceDataMyBatisRepository.java +++ b/src/main/java/org/cbioportal/legacy/persistence/mybatis/ResourceDataMyBatisRepository.java @@ -86,8 +86,9 @@ public List getResourceDataForAllPatientsInStudy( String sortBy, String direction) { - return resourceDataMapper.getResourceDataForAllPatientsInStudy( + return resourceDataMapper.getResourceDataOfPatientInStudy( studyId, + null, resourceId, projection, pageSize, @@ -106,8 +107,9 @@ public List getResourceDataForAllSamplesInStudy( String sortBy, String direction) { - return resourceDataMapper.getResourceDataForAllSamplesInStudy( + return resourceDataMapper.getResourceDataOfSampleInStudy( studyId, + null, resourceId, projection, pageSize, From c90509bdda82cf8db6e97f45e0fb8b7135c35b04 Mon Sep 17 00:00:00 2001 From: Onur Sumer Date: Thu, 25 Sep 2025 11:40:46 -0400 Subject: [PATCH 13/31] improve generic_assay_data sql performance (#11706) --- .../persistence/mybatis/MolecularDataMapper.xml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml index b9dea15031e..1958fb8c00f 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml @@ -19,6 +19,15 @@ #{item} ) + + + genetic_alteration.genetic_entity_id IN ( + SELECT ge.id + FROM genetic_entity ge + WHERE ge.stable_id IN + #{item} + ) + @@ -166,8 +175,7 @@ - AND genetic_entity.stable_id IN - #{item} + AND @@ -194,8 +202,7 @@ - AND genetic_entity.stable_id IN - #{item} + AND From 528230a6d7c25f47532a5ece095983d911fdfc32 Mon Sep 17 00:00:00 2001 From: alisman Date: Wed, 24 Sep 2025 14:04:04 -0400 Subject: [PATCH 14/31] Refactor GenePanelServiceImpl to use batch repository call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace individual fetchGenePanelDataByMolecularProfileId calls with a single fetchGenePanelDataByMolecularProfileIds batch call to reduce database round trips and improve performance. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../legacy/service/impl/GenePanelServiceImpl.java | 12 +++++------- .../legacy/persistence/mybatis/TreatmentMapper.xml | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/cbioportal/legacy/service/impl/GenePanelServiceImpl.java b/src/main/java/org/cbioportal/legacy/service/impl/GenePanelServiceImpl.java index 0b0087aaaaf..b58545bdac2 100644 --- a/src/main/java/org/cbioportal/legacy/service/impl/GenePanelServiceImpl.java +++ b/src/main/java/org/cbioportal/legacy/service/impl/GenePanelServiceImpl.java @@ -139,14 +139,12 @@ public List fetchGenePanelDataByMolecularProfileIds( Set uniqueMolecularProfileIds = molecularProfiles.stream().map(MolecularProfile::getStableId).collect(toSet()); + List allGenePanelData = + genePanelRepository.fetchGenePanelDataByMolecularProfileIds(uniqueMolecularProfileIds); + Map> molecularProfileIdToGenePanelDataMap = - uniqueMolecularProfileIds.stream() - // query database with each profile id so data cached in a modular way for each profile - .collect( - Collectors.toMap( - Function.identity(), - profileId -> - genePanelRepository.fetchGenePanelDataByMolecularProfileId(profileId))); + allGenePanelData.stream() + .collect(Collectors.groupingBy(GenePanelData::getMolecularProfileId)); Map molecularProfileIdMap = molecularProfiles.stream() diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml index 5713a3a4b62..eb974509b90 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/TreatmentMapper.xml @@ -51,7 +51,7 @@ + + + + - (WITH profiled_count_by_genes AS ( - SELECT gptg.gene as hugoGeneSymbol, - COUNT(DISTINCT stgp.${unique_id}) as profiled_count - FROM sample_to_gene_panel_derived stgp - INNER JOIN gene_panel_to_gene_derived gptg on stgp.gene_panel_id = gptg.gene_panel_id - - - stgp.genetic_profile_id IN (#{molecularProfiles,typeHandler=org.apache.ibatis.type.ArrayTypeHandler}) - - - AND stgp.sample_unique_id IN (#{samples,typeHandler=org.apache.ibatis.type.ArrayTypeHandler}) - - - GROUP BY gptg.gene), - total_count_by_genes AS ( - SELECT ged.hugo_gene_symbol AS hugoGeneSymbol, - ged.entrez_gene_id as entrezGeneId, - COUNT(DISTINCT ${unique_id}) as numberOfAlteredCases, - COUNT(DISTINCT CASE WHEN off_panel = 0 THEN ${unique_id} END) as numberOfAlteredCasesOnPanel - FROM genomic_event_derived ged - - ged.mutation_status != 'UNCALLED' - + WITH total_count_by_genes AS ( + SELECT ged.hugo_gene_symbol AS hugoGeneSymbol, + ged.entrez_gene_id as entrezGeneId, + COUNT(DISTINCT ${unique_id}) as numberOfAlteredCases, + COUNT(DISTINCT CASE WHEN off_panel = 0 THEN ${unique_id} END) as numberOfAlteredCasesOnPanel + FROM genomic_event_derived ged + ged.mutation_status != 'UNCALLED' + AND ged.genetic_profile_stable_id IN (#{molecularProfiles,typeHandler=org.apache.ibatis.type.ArrayTypeHandler}) - AND ged.sample_unique_id IN (#{samples,typeHandler=org.apache.ibatis.type.ArrayTypeHandler}) + AND ${unique_id} IN (#{samples,typeHandler=org.apache.ibatis.type.ArrayTypeHandler}) GROUP BY ged.entrez_gene_id, ged.hugo_gene_symbol ) - SELECT - pgb.hugoGeneSymbol AS hugoGeneSymbol, + tcg.hugoGeneSymbol AS hugoGeneSymbol, ifNull(tcg.entrezGeneId, 0) AS entrezGeneId, tcg.numberOfAlteredCases as numberOfAlteredCases, - tcg.numberOfAlteredCasesOnPanel as numberOfAlteredCasesOnPanel, - pgb.profiled_count as numberOfProfiledCases + tcg.numberOfAlteredCasesOnPanel as numberOfAlteredCasesOnPanel FROM total_count_by_genes tcg - RIGHT JOIN profiled_count_by_genes pgb ON tcg.hugoGeneSymbol = pgb.hugoGeneSymbol - ) - + + arrayStringConcat( + arrayMap( + x -> multiIf ( + -- Special Case 1: Non-numeric values + -- Leave non-numeric values as is, otherwise they will be converted to zero. + isNull(accurateCastOrNull(x, 'Float64')), + x, + -- Special Case 2: Very small numbers + -- Convert very small numbers to scientific notation first and then truncate, + -- otherwise they will be converted to zero. + abs(toFloat64OrZero(x)) < 0.0001, + concat( + toString( + -- round the base to 4 significant digits + round(toFloat64OrZero(x) / pow(10, floor(log10(abs(toFloat64OrZero(x))))), 3) + ), + 'e', + toString( + -- calculate the exponent + floor(log10(abs(toFloat64OrZero(x)))) + ) + ), + -- All other cases: Truncate to 4 significant digits. + toString(round(toFloat64OrZero(x), 4)) + ), + splitByChar(',', genetic_alteration.`values`) + ), + ',' + ) AS "values" + + SELECT - gene.entrez_gene_id AS "entrezGeneId", - genetic_alteration.`values` AS "values" + gene.entrez_gene_id AS "entrezGeneId", + , @@ -110,8 +142,8 @@ SELECT - gene.entrez_gene_id AS "entrezGeneId", - genetic_alteration.`values` AS "values", - genetic_profile.stable_id AS "molecularProfileId" + gene.entrez_gene_id AS "entrezGeneId", + , + genetic_profile.stable_id AS "molecularProfileId" , @@ -144,7 +176,7 @@ NULL AS "values" - genetic_alteration.`values` AS "values" + FROM genetic_alteration INNER JOIN genetic_profile ON genetic_alteration.genetic_profile_id = genetic_profile.genetic_profile_id @@ -167,7 +199,7 @@ NULL AS "values" - genetic_alteration.`values` AS "values" + FROM genetic_alteration INNER JOIN genetic_profile ON genetic_alteration.genetic_profile_id = genetic_profile.genetic_profile_id @@ -194,7 +226,7 @@ NULL AS "values" - genetic_alteration.`values` AS "values" + FROM genetic_alteration INNER JOIN genetic_profile ON genetic_alteration.genetic_profile_id = genetic_profile.genetic_profile_id From bfd1299bd75827ec58e48b07b26658ed796b9c6d Mon Sep 17 00:00:00 2001 From: alisman Date: Tue, 14 Oct 2025 11:11:10 -0400 Subject: [PATCH 24/31] In the molecular data truncation SQL, add case for zero values (#11751) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix zero value handling in molecular data truncation Add special case handling for zero values in the molecular data value truncation logic to prevent them from being converted incorrectly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude * Update src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml Co-authored-by: Onur Sumer --------- Co-authored-by: Claude Co-authored-by: Onur Sumer --- .../legacy/persistence/mybatis/MolecularDataMapper.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml index 075c6795749..2a0ddb5fd9b 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/MolecularDataMapper.xml @@ -76,7 +76,12 @@ -- Leave non-numeric values as is, otherwise they will be converted to zero. isNull(accurateCastOrNull(x, 'Float64')), x, - -- Special Case 2: Very small numbers + -- Special Case 2: Zero values + -- We need to handle zero values separately otherwise they will break the very small number logic + -- due to the fact that log10(0) is equal to -Infinity + toFloat64OrZero(x) = 0, + '0', + -- Special Case 3: Very small numbers -- Convert very small numbers to scientific notation first and then truncate, -- otherwise they will be converted to zero. abs(toFloat64OrZero(x)) < 0.0001, From c2e4117a460c276aa6a129b22ebbf7fc8f0bd356 Mon Sep 17 00:00:00 2001 From: Charles Haynes <33608920+haynescd@users.noreply.github.com> Date: Wed, 15 Oct 2025 15:43:23 -0500 Subject: [PATCH 25/31] Fix column store study endpoint (#11747) * :recycle: Refactor Cancer Study PermissionEvaluator * :lock: Add Support for CancerStudyMetadata obj * Update field typeOfCancer to cancerType --- .../mapper/CancerStudyMetadataMapper.java | 6 +- .../rest/response/CancerStudyMetadataDTO.java | 2 +- .../CancerStudyPermissionEvaluator.java | 379 ++++++++++-------- .../cbioportal/application/security/README.md | 48 +++ .../security/config/MethodSecurityConfig.java | 3 +- .../GetCancerStudyMetadataUseCase.java | 7 +- 6 files changed, 266 insertions(+), 179 deletions(-) create mode 100644 src/main/java/org/cbioportal/application/security/README.md diff --git a/src/main/java/org/cbioportal/application/rest/mapper/CancerStudyMetadataMapper.java b/src/main/java/org/cbioportal/application/rest/mapper/CancerStudyMetadataMapper.java index efacc478cf8..d49842ec0a4 100644 --- a/src/main/java/org/cbioportal/application/rest/mapper/CancerStudyMetadataMapper.java +++ b/src/main/java/org/cbioportal/application/rest/mapper/CancerStudyMetadataMapper.java @@ -14,14 +14,10 @@ public interface CancerStudyMetadataMapper { @Mapping(target = "importDate", source = "importDate", dateFormat = "yyyy-MM-dd HH:mm:ss") @Mapping(target = "studyId", source = "cancerStudyIdentifier") @Mapping(target = "cancerTypeId", source = "typeOfCancerId") + @Mapping(target = "cancerType", source = "typeOfCancer") // TODO: ReadPermission needs to be implemented @Mapping(target = "readPermission", source = "publicStudy") CancerStudyMetadataDTO toDto(CancerStudyMetadata cancerStudyMetadata); - @Mapping(target = "importDate", source = "importDate", dateFormat = "yyyy-MM-dd HH:mm:ss") - @Mapping(target = "studyId", source = "cancerStudyIdentifier") - @Mapping(target = "cancerTypeId", source = "typeOfCancerId") - // TODO: ReadPermission needs to be implemented - @Mapping(target = "readPermission", source = "publicStudy") List toDtos(List cancerStudyMetadataList); } diff --git a/src/main/java/org/cbioportal/application/rest/response/CancerStudyMetadataDTO.java b/src/main/java/org/cbioportal/application/rest/response/CancerStudyMetadataDTO.java index 5f7d9b30ee1..0d6fabd918b 100644 --- a/src/main/java/org/cbioportal/application/rest/response/CancerStudyMetadataDTO.java +++ b/src/main/java/org/cbioportal/application/rest/response/CancerStudyMetadataDTO.java @@ -29,5 +29,5 @@ public record CancerStudyMetadataDTO( String referenceGenome, Integer treatmentCount, Integer structuralVariantCount, - TypeOfCancer typeOfCancer, + TypeOfCancer cancerType, Boolean readPermission) {} diff --git a/src/main/java/org/cbioportal/application/security/CancerStudyPermissionEvaluator.java b/src/main/java/org/cbioportal/application/security/CancerStudyPermissionEvaluator.java index e4b32bd5ea3..7cace5249af 100644 --- a/src/main/java/org/cbioportal/application/security/CancerStudyPermissionEvaluator.java +++ b/src/main/java/org/cbioportal/application/security/CancerStudyPermissionEvaluator.java @@ -33,9 +33,15 @@ package org.cbioportal.application.security; import java.io.Serializable; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.cbioportal.application.security.util.CancerStudyExtractorUtil; +import org.cbioportal.domain.cancerstudy.CancerStudyMetadata; import org.cbioportal.legacy.model.CancerStudy; import org.cbioportal.legacy.model.MolecularProfile; import org.cbioportal.legacy.model.MolecularProfileCaseIdentifier; @@ -135,7 +141,7 @@ public boolean hasPermission( } return false; } - CancerStudy cancerStudy = getRelevantCancerStudyFromTarget(targetDomainObject); + CancerStudy cancerStudy = extractCancerStudy(targetDomainObject); if (log.isDebugEnabled()) { if (cancerStudy == null) { log.debug("hasPermission(), stable cancer study is null."); @@ -185,118 +191,218 @@ public boolean hasPermission( } return false; } - if (TARGET_TYPE_CANCER_STUDY_ID.equals(targetType)) { - return hasAccessToCancerStudy(authentication, (String) targetId, permission); - } else if (TARGET_TYPE_MOLECULAR_PROFILE_ID.equals(targetType) - || TARGET_TYPE_GENETIC_PROFILE_ID.equals(targetType)) { - return hasAccessToMolecularProfile(authentication, (String) targetId, permission); - } else if (TARGET_TYPE_SAMPLE_LIST_ID.equals(targetType)) { - return hasAccessToSampleList(authentication, (String) targetId, permission); - } else if (TARGET_TYPE_COLLECTION_OF_CANCER_STUDY_IDS.equals(targetType)) { - return hasAccessToCancerStudies(authentication, (Collection) targetId, permission); - } else if (TARGET_TYPE_COLLECTION_OF_MOLECULAR_PROFILE_IDS.equals(targetType) - || TARGET_TYPE_COLLECTION_OF_GENETIC_PROFILE_IDS.equals(targetType)) { - return hasAccessToMolecularProfiles( - authentication, (Collection) targetId, permission); - } else if (TARGET_TYPE_COLLECTION_OF_SAMPLE_LIST_IDS.equals(targetType)) { - return hasAccessToSampleLists(authentication, (Collection) targetId, permission); - } else if (targetType.contains("Filter")) { - switch (targetId) { - case SampleFilter sampleFilter -> { - return hasAccessToCancerStudies( - authentication, - CancerStudyExtractorUtil.extractCancerStudyIdsFromSampleFilter( - sampleFilter, this.cacheMapUtil), - permission); - } - case StudyViewFilter studyViewFilter -> { - return hasAccessToCancerStudies( - authentication, studyViewFilter.getUniqueStudyIds(), permission); - } - case ClinicalDataCountFilter clinicalDataCountFilter -> { - Set studyIds = new HashSet<>(); - if (clinicalDataCountFilter.getStudyViewFilter() != null) { - studyIds = clinicalDataCountFilter.getStudyViewFilter().getUniqueStudyIds(); - } - return hasAccessToCancerStudies(authentication, studyIds, permission); + + try { + Collection cancerStudies = extractCancerStudiesFromTarget(targetId, targetType); + for (CancerStudy cs : cancerStudies) { + if (cs == null || !hasAccessToCancerStudy(authentication, cs, (AccessLevel) permission)) { + return false; } - case DataBinCountFilter dataBinCountFilter -> { - Set studyIds = new HashSet<>(); - if (dataBinCountFilter.getStudyViewFilter() != null) { - studyIds = dataBinCountFilter.getStudyViewFilter().getUniqueStudyIds(); - } - return hasAccessToCancerStudies(authentication, studyIds, permission); + } + return true; + } catch (Exception e) { + return false; + } + } + + /** + * Extracts the associated {@code CancerStudy} from a given domain object. Access is always + * resolved to the CancerStudy, regardless of the target type. + * + * @param target The domain object instance. Expected to be one of {@code CancerStudy}, {@code + * MolecularProfile}, {@code SampleList}, or {@code Patient}. + * @return The associated {@code CancerStudy} object, or {@code null} if the study cannot be found + * or the target type is not supported. + */ + private CancerStudy extractCancerStudy(Object target) { + CancerStudy extractedCancerStudy = null; + switch (target) { + case CancerStudy cs -> extractedCancerStudy = cs; + case MolecularProfile mp -> { + var cs = mp.getCancerStudy(); + if (mp.getCancerStudy() == null) { + cs = cacheMapUtil.getCancerStudyMap().get(mp.getCancerStudyIdentifier()); } - case GenomicDataCountFilter genomicDataCountFilter -> { - Set studyIds = new HashSet<>(); - if (genomicDataCountFilter.getStudyViewFilter() != null) { - studyIds = genomicDataCountFilter.getStudyViewFilter().getUniqueStudyIds(); - } - return hasAccessToCancerStudies(authentication, studyIds, permission); + extractedCancerStudy = cs; + } + case SampleList sl -> { + var cs = sl.getCancerStudy(); + if (cs == null) { + cs = cacheMapUtil.getCancerStudyMap().get(sl.getCancerStudyIdentifier()); } - case GenericAssayDataCountFilter genericAssayDataCountFilter -> { - Set studyIds = new HashSet<>(); - if (genericAssayDataCountFilter.getStudyViewFilter() != null) { - studyIds = genericAssayDataCountFilter.getStudyViewFilter().getUniqueStudyIds(); - } - return hasAccessToCancerStudies(authentication, studyIds, permission); + extractedCancerStudy = cs; + } + case Patient p -> { + var cs = p.getCancerStudy(); + if (cs == null) { + cs = cacheMapUtil.getCancerStudyMap().get(p.getCancerStudyIdentifier()); } + extractedCancerStudy = cs; + } + case CancerStudyMetadata csm -> { + extractedCancerStudy = cacheMapUtil.getCancerStudyMap().get(csm.cancerStudyIdentifier()); + } - case MolecularProfileCasesGroupAndAlterationTypeFilter - molecularProfileCasesGroupAndAlterationTypeFilter -> { - Set molecularProfileIds = - molecularProfileCasesGroupAndAlterationTypeFilter - .getMolecularProfileCasesGroupFilter() - .stream() - .flatMap(group -> group.getMolecularProfileCaseIdentifiers().stream()) - .map(MolecularProfileCaseIdentifier::getMolecularProfileId) - .collect(Collectors.toSet()); - return hasAccessToMolecularProfiles(authentication, molecularProfileIds, permission); - } + default -> + log.debug("hasPermission(), unknown targetType '" + target.getClass().getName() + "'"); + } + return extractedCancerStudy; + } - default -> log.debug("hasPermission(), unknown targetType '" + targetType + "'"); + /** + * Converts a target ID/collection/filter into a set of unique {@code CancerStudy} objects. + * + * @param target The target object, which can be a single ID, a collection of IDs, or a filter + * object. + * @param targetType The string indicating the type of the target (e.g., 'MolecularProfileId', + * 'Collection'). + * @return A {@code Set} of associated {@code CancerStudy} objects. Returns an empty set if the + * target is null or unknown. + * @throws ClassCastException if a collection target cannot be cast to {@code Collection}. + */ + private Set extractCancerStudiesFromTarget(Object target, String targetType) { + if (target == null) { + return new HashSet<>(); + } + + // Handle Filter Types + if (targetType.contains("Filter")) { + Set studyIds = extractStudyIdsFromFilter(target); + return extractCancerStudiesFromIds(studyIds, TARGET_TYPE_COLLECTION_OF_CANCER_STUDY_IDS); + } + + // Handle Collections + if (target instanceof Collection collection) { + Collection ids = (Collection) collection; + return extractCancerStudiesFromIds(ids, targetType); + } + + if (target instanceof String id) { + CancerStudy study = extractCancerStudyById(id, targetType); + return study != null ? Set.of(study) : new HashSet<>(); + } + + log.debug( + "hasPermission(targetId, targetType), unknown type '" + target.getClass().getName() + "'"); + return new HashSet<>(); + } + + /** + * Resolves a single ID string of a specific type to its associated {@code CancerStudy}. + * + * @param id The string identifier. + * @param targetType The type of the ID (e.g., {@code TARGET_TYPE_MOLECULAR_PROFILE_ID}). + * @return The associated {@code CancerStudy}, or {@code null} if not found or type is unknown. + */ + private CancerStudy extractCancerStudyById(String id, String targetType) { + return switch (targetType) { + case TARGET_TYPE_CANCER_STUDY_ID -> cacheMapUtil.getCancerStudyMap().get(id); + case TARGET_TYPE_MOLECULAR_PROFILE_ID, TARGET_TYPE_GENETIC_PROFILE_ID -> { + var mp = cacheMapUtil.getMolecularProfileMap().get(id); + yield extractCancerStudy(mp); } - } else { - if (log.isDebugEnabled()) { + case TARGET_TYPE_SAMPLE_LIST_ID -> { + var sampleList = cacheMapUtil.getSampleListMap().get(id); + yield extractCancerStudy(sampleList); + } + default -> { log.debug("hasPermission(), unknown targetType '" + targetType + "'"); + yield null; } - } - return false; + }; } - private CancerStudy getRelevantCancerStudyFromTarget(Object targetDomainObject) { - if (targetDomainObject instanceof CancerStudy) { - return (CancerStudy) targetDomainObject; - } else if (targetDomainObject instanceof MolecularProfile) { - MolecularProfile molecularProfile = (MolecularProfile) targetDomainObject; - if (molecularProfile.getCancerStudy() != null) { - return molecularProfile.getCancerStudy(); - } - // cancer study was not included so get it from cache - return cacheMapUtil.getCancerStudyMap().get(molecularProfile.getCancerStudyIdentifier()); - } else if (targetDomainObject instanceof SampleList) { - SampleList sampleList = (SampleList) targetDomainObject; - if (sampleList.getCancerStudy() != null) { - return sampleList.getCancerStudy(); + /** + * Converts a collection of identifiers (of a specific type) into a set of unique {@code + * CancerStudy} objects. + * + * @param ids The collection of ID strings. + * @param targetType The type of the collection (e.g., {@code + * TARGET_TYPE_COLLECTION_OF_MOLECULAR_PROFILE_IDS}). + * @return A {@code Set} containing all unique, non-null studies linked to the + * provided IDs. + */ + private Set extractCancerStudiesFromIds(Collection ids, String targetType) { + return ids.stream() + .map(id -> extractCancerStudyById(id, getSingleTargetType(targetType))) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + } + + /** + * Converts a collection-based target type string into its single-item equivalent. This is used + * when iterating over a collection of IDs to determine the type of each individual ID. + * + * @param collectionTargetType The collection type string (e.g., {@code + * TARGET_TYPE_COLLECTION_OF_CANCER_STUDY_IDS}). + * @return The corresponding single-item type string (e.g., {@code TARGET_TYPE_CANCER_STUDY_ID}). + */ + private String getSingleTargetType(String collectionTargetType) { + return switch (collectionTargetType) { + case TARGET_TYPE_COLLECTION_OF_CANCER_STUDY_IDS -> TARGET_TYPE_CANCER_STUDY_ID; + case TARGET_TYPE_COLLECTION_OF_MOLECULAR_PROFILE_IDS -> TARGET_TYPE_MOLECULAR_PROFILE_ID; + case TARGET_TYPE_COLLECTION_OF_GENETIC_PROFILE_IDS -> TARGET_TYPE_GENETIC_PROFILE_ID; + case TARGET_TYPE_COLLECTION_OF_SAMPLE_LIST_IDS -> TARGET_TYPE_SAMPLE_LIST_ID; + default -> collectionTargetType; + }; + } + + /** + * Extracts a set of {@code CancerStudy} identifiers from various application-specific filter + * objects. + * + * @param filter An object instance of a known filter type (e.g., {@code SampleFilter}, {@code + * StudyViewFilter}). + * @return A {@code Set} of unique cancer study identifiers referenced by the filter. + * Returns an empty set for unknown filter types or filters that yield no studies. + * @throws IllegalStateException if a molecular profile ID is encountered but the corresponding + * MolecularProfile object cannot be found. + */ + private Set extractStudyIdsFromFilter(Object filter) { + return switch (filter) { + case SampleFilter sampleFilter -> + CancerStudyExtractorUtil.extractCancerStudyIdsFromSampleFilter( + sampleFilter, this.cacheMapUtil) + .stream() + .collect(Collectors.toSet()); + case StudyViewFilter studyViewFilter -> studyViewFilter.getUniqueStudyIds(); + case ClinicalDataCountFilter clinicalDataCountFilter -> + clinicalDataCountFilter.getStudyViewFilter() != null + ? clinicalDataCountFilter.getStudyViewFilter().getUniqueStudyIds() + : new HashSet<>(); + case DataBinCountFilter dataBinCountFilter -> + dataBinCountFilter.getStudyViewFilter() != null + ? dataBinCountFilter.getStudyViewFilter().getUniqueStudyIds() + : new HashSet<>(); + case GenomicDataCountFilter genomicDataCountFilter -> + genomicDataCountFilter.getStudyViewFilter() != null + ? genomicDataCountFilter.getStudyViewFilter().getUniqueStudyIds() + : new HashSet<>(); + case GenericAssayDataCountFilter genericAssayDataCountFilter -> + genericAssayDataCountFilter.getStudyViewFilter() != null + ? genericAssayDataCountFilter.getStudyViewFilter().getUniqueStudyIds() + : new HashSet<>(); + case MolecularProfileCasesGroupAndAlterationTypeFilter mpgFilter -> { + Collection molecularProfiles = + mpgFilter.getMolecularProfileCasesGroupFilter().stream() + .flatMap(group -> group.getMolecularProfileCaseIdentifiers().stream()) + .map(MolecularProfileCaseIdentifier::getMolecularProfileId) + .map(id -> cacheMapUtil.getMolecularProfileMap().get(id)) + .collect(Collectors.toList()); + + if (molecularProfiles.contains(null)) { + throw new IllegalStateException("MolecularProfile not found "); + } + + yield molecularProfiles.stream() + .map(m -> m.getCancerStudyIdentifier()) + .collect(Collectors.toSet()); } - // cancer study was not included so get it from cache - return cacheMapUtil.getCancerStudyMap().get(sampleList.getCancerStudyIdentifier()); - } else if (targetDomainObject instanceof Patient) { - Patient patient = (Patient) targetDomainObject; - if (patient.getCancerStudy() != null) { - return patient.getCancerStudy(); + default -> { + log.debug("hasPermission(), unknown filter type: " + filter.getClass().getName()); + yield new HashSet<>(); } - // cancer study was not included so get it from cache - return cacheMapUtil.getCancerStudyMap().get(patient.getCancerStudyIdentifier()); - } - // unable to handle targetDomainObject type - if (log.isDebugEnabled()) { - log.debug( - "hasPermission(), targetDomainObject class is '" - + targetDomainObject.getClass().getName() - + "'"); - } - return null; + }; } /** @@ -355,7 +461,8 @@ private boolean hasAccessToCancerStudy( || stableStudyID.equalsIgnoreCase("ALL_TARGET_PHASE2"))) { if (log.isDebugEnabled()) { log.debug( - "hasAccessToCancerStudy(), user has access to ALL_NCI_TARGET cancer studies return true"); + "hasAccessToCancerStudy(), user has access to ALL_NCI_TARGET cancer studies return" + + " true"); } return true; } @@ -393,74 +500,6 @@ private boolean hasAccessToCancerStudy( return toReturn; } - private boolean hasAccessToCancerStudy( - Authentication authentication, String cancerStudyId, Object permission) { - // everybody has access the 'all' cancer study - // we have to check this right here (instead of checking later) - // because the 'all' cancer study does not exist in the database - if (cancerStudyId.equalsIgnoreCase(ALL_CANCER_STUDIES_ID)) { - return true; - } - CancerStudy cancerStudy = cacheMapUtil.getCancerStudyMap().get(cancerStudyId); - if (cancerStudy == null) { - return false; - } - return hasPermission(authentication, cancerStudy, permission); - } - - private boolean hasAccessToMolecularProfile( - Authentication authentication, String molecularProfileId, Object permission) { - MolecularProfile molecularProfile = - cacheMapUtil.getMolecularProfileMap().get(molecularProfileId); - if (molecularProfile == null) { - return false; - } - return hasPermission(authentication, molecularProfile, permission); - } - - private boolean hasAccessToSampleList( - Authentication authentication, String sampleListId, Object permission) { - SampleList sampleList = cacheMapUtil.getSampleListMap().get(sampleListId); - if (sampleList == null) { - return false; - } - return hasPermission(authentication, sampleList, permission); - } - - private boolean hasAccessToCancerStudies( - Authentication authentication, Collection cancerStudyIds, Object permission) { - for (String cancerStudyId : cancerStudyIds) { - if (!hasPermission(authentication, cancerStudyId, TARGET_TYPE_CANCER_STUDY_ID, permission)) { - return false; - } - } - return true; - } - - private boolean hasAccessToMolecularProfiles( - Authentication authentication, Collection molecularProfileIds, Object permission) { - for (String molecularProfileId : molecularProfileIds) { - MolecularProfile molecularProfile = - cacheMapUtil.getMolecularProfileMap().get(molecularProfileId); - if (molecularProfile == null - || !hasPermission(authentication, molecularProfile, permission)) { - return false; - } - } - return true; - } - - private boolean hasAccessToSampleLists( - Authentication authentication, Collection sampleListIds, Object permission) { - for (String sampleListId : sampleListIds) { - SampleList sampleList = cacheMapUtil.getSampleListMap().get(sampleListId); - if (sampleList == null || !hasPermission(authentication, sampleList, permission)) { - return false; - } - } - return true; - } - private Set getGrantedAuthorities(Authentication authentication) { String appName = getAppName().toUpperCase(); // need to filter out empty authorities, this can cause issue if grantedAuthorities and groups diff --git a/src/main/java/org/cbioportal/application/security/README.md b/src/main/java/org/cbioportal/application/security/README.md new file mode 100644 index 00000000000..b470bfb4907 --- /dev/null +++ b/src/main/java/org/cbioportal/application/security/README.md @@ -0,0 +1,48 @@ +# 🛡️ Study Permission Evaluator + +This class is an implementation of the **Spring Security `PermissionEvaluator`** interface. Its purpose is to enforce fine-grained access control across the application's data model, ensuring that authenticated users have the required `AccessLevel` to interact with specific cancer research entities. + +Access control is centrally determined at the **`CancerStudy`** level. All other related entities (profiles, lists, patients) inherit their access policy from their associated study. + +*** + +## Core Functionality + +The evaluator implements two primary permission checking methods: + +### 1. Object-Based Permission Check + +| Method | `hasPermission(Authentication, Object targetDomainObject, Object permission)` | +| :--- | :--- | +| **Purpose** | Checks permission on a **single, loaded domain object instance** (e.g., a `MolecularProfile` object). | +| **Process** | It uses `extractCancerStudy()` to resolve the target object back to its parent `CancerStudy` and delegates the final access check to a business logic method (`hasAccessToCancerStudy`). | + +### 2. ID-Based Permission Check + +| Method | `hasPermission(Authentication, Serializable targetId, String targetType, Object permission)` | +| :--- | :--- | +| **Purpose** | Checks permission on resources identified by an **ID, a collection of IDs, or a filter object**. | +| **Process** | It resolves the IDs/filter into a collection of unique `CancerStudy` objects. It then enforces an **all-or-nothing** policy: access is granted only if the user has permission to **every single** associated `CancerStudy`. | + +*** + +## Supported Target Types + +The evaluator is designed to handle access checks for objects and identifiers spanning the core data model: + +| Target Object/ID Type | Description | +| :--- | :--- | +| `CancerStudy` | Direct object or ID. The root entity for access control. | +| `MolecularProfile` | Object or ID. Access is determined by its parent study. | +| `SampleList` | Object or ID. Access is determined by its parent study. | +| `Patient` | Direct object. Access is determined by its parent study. | +| `Collection<...Ids>` | A bulk check on a collection of any supported ID type. | +| `*Filter` Objects | Various application-specific filter classes (e.g., `SampleFilter`, `StudyViewFilter`) that implicitly reference a set of `CancerStudy` IDs. | + +*** + +## Dependencies + +* **`Authentication`**: The standard Spring Security principal representing the logged-in user. +* **`cacheMapUtil`**: A utility used for high-performance retrieval of domain objects (like `CancerStudy`, `MolecularProfile`) by their string identifiers, crucial for efficient ID-based permission checks. +* **`AccessLevel`**: An external enumeration (cast from the `permission` object) defining the specific level of access requested (e.g., `READ`, `WRITE`). diff --git a/src/main/java/org/cbioportal/application/security/config/MethodSecurityConfig.java b/src/main/java/org/cbioportal/application/security/config/MethodSecurityConfig.java index a58c96e32de..20c396372c3 100644 --- a/src/main/java/org/cbioportal/application/security/config/MethodSecurityConfig.java +++ b/src/main/java/org/cbioportal/application/security/config/MethodSecurityConfig.java @@ -14,7 +14,8 @@ @EnableMethodSecurity(prePostEnabled = true) // We are allowing users to enable method_authorization if optional_oauth2 is selected @ConditionalOnExpression( - "{'oauth2','saml', 'saml_plus_basic'}.contains('${authenticate}') or ('optional_oauth2' eq '${authenticate}' and 'true' eq '${security.method_authorization_enabled}')") + "{'oauth2','saml', 'saml_plus_basic'}.contains('${authenticate}') or ('optional_oauth2' eq" + + " '${authenticate}' and 'true' eq '${security.method_authorization_enabled}')") public class MethodSecurityConfig { @Bean diff --git a/src/main/java/org/cbioportal/domain/cancerstudy/usecase/GetCancerStudyMetadataUseCase.java b/src/main/java/org/cbioportal/domain/cancerstudy/usecase/GetCancerStudyMetadataUseCase.java index f998077739b..01ec5184c26 100644 --- a/src/main/java/org/cbioportal/domain/cancerstudy/usecase/GetCancerStudyMetadataUseCase.java +++ b/src/main/java/org/cbioportal/domain/cancerstudy/usecase/GetCancerStudyMetadataUseCase.java @@ -7,6 +7,7 @@ import org.cbioportal.shared.SortAndSearchCriteria; import org.cbioportal.shared.enums.ProjectionType; import org.springframework.context.annotation.Profile; +import org.springframework.security.access.prepost.PostFilter; import org.springframework.stereotype.Service; /** @@ -25,7 +26,7 @@ * private final GetCancerStudyMetadataUseCase getCancerStudyMetadataUseCase; * * public CancerStudyController(GetCancerStudyMetadataUseCase getCancerStudyMetadataUseCase) { - * this.getCancerStudyMetadataUseCase = getCancerStudyMetadataUseCase; + * this.getCancerStudyMetadataUseCase = getCancerStudyMetadataUseCase; * } * * // Retrieve detailed metadata for cancer studies @@ -41,7 +42,7 @@ */ @Service @Profile("clickhouse") -public final class GetCancerStudyMetadataUseCase { +public class GetCancerStudyMetadataUseCase { private final CancerStudyRepository studyRepository; @@ -75,6 +76,8 @@ public GetCancerStudyMetadataUseCase(CancerStudyRepository studyRepository) { * @see ProjectionType * @see CancerStudyMetadata */ + @PostFilter( + "hasPermission(filterObject, T(org.cbioportal.legacy.utils.security.AccessLevel).READ)") public List execute( ProjectionType projectionType, SortAndSearchCriteria sortAndSearchCriteria) { return switch (projectionType) { From 93874153dddaab7092c82233023a70f0766e9019 Mon Sep 17 00:00:00 2001 From: Gaofei Zhao <15748980+dippindots@users.noreply.github.com> Date: Fri, 17 Oct 2025 15:44:27 -0400 Subject: [PATCH 26/31] Fix sample list error (clickhouse-only) (#11753) * Fix sample list query for clickhouse * Change cancer study details query in sample list query * Clean up SampleListMapper.xml by removing unused prefix properties --- .../persistence/mybatis/SampleListMapper.xml | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml index bb990d81d8b..c66ba62046f 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml @@ -4,30 +4,34 @@ - - ANY_VALUE(sample_list.list_id) AS "${prefix}listId", - ANY_VALUE(sample_list.stable_id) AS "${prefix}stableId" + sample_list.list_id AS "listId", + sample_list.stable_id AS "stableId" , - ANY_VALUE(sample_list.cancer_study_id) AS "${prefix}cancerStudyId", - ANY_VALUE(cancer_study.cancer_study_identifier) AS "${prefix}cancerStudyIdentifier", - ANY_VALUE(sample_list.category) AS "${prefix}category", - ANY_VALUE(sample_list.name) AS "${prefix}name", - ANY_VALUE(sample_list.description) AS "${prefix}description" + sample_list.cancer_study_id AS "cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudyIdentifier", + sample_list.category AS "category", + sample_list.name AS "name", + sample_list.description AS "description" , - - - + cancer_study.type_of_cancer_id AS "cancerStudy.typeOfCancerId", + cancer_study.name AS "cancerStudy.name", + cancer_study.description AS "cancerStudy.description", + cancer_study.public AS "cancerStudy.publicStudy", + cancer_study.pmid AS "cancerStudy.pmid", + cancer_study.citation AS "cancerStudy.citation", + cancer_study.groups AS "cancerStudy.groups", + cancer_study.status AS "cancerStudy.status", + cancer_study.import_date AS "cancerStudy.importDate", + reference_genome.name AS "cancerStudy.referenceGenome" SELECT - - - + FROM sample_list INNER JOIN cancer_study ON sample_list.cancer_study_id = cancer_study.cancer_study_id INNER JOIN reference_genome ON cancer_study.reference_genome_id = reference_genome.reference_genome_id @@ -74,9 +76,7 @@ SELECT - - - ANY_VALUE(clinical_event.clinical_event_id) AS clinicalEventId, - - - clinical_event.clinical_event_id AS clinicalEventId, - - - clinical_event.event_type AS eventType, - patient.stable_id AS patientId + ANY_VALUE(clinical_event.clinical_event_id) AS clinicalEventId, + clinical_event.event_type AS eventType, + patient.stable_id AS patientId @@ -179,4 +172,110 @@ GROUP BY clinical_event.event_type, patient.stable_id + + + + + + + + + + + + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml index 000348363b8..e2e968496d7 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/CopyNumberSegmentMapper.xml @@ -35,19 +35,16 @@ @@ -84,16 +81,14 @@ SELECT - WHERE cancer_study.cancer_study_identifier = #{studyId} + INNER JOIN sample_list_list ON copy_number_seg.sample_id = sample_list_list.sample_id + INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id + WHERE + cancer_study.cancer_study_identifier = #{studyId} + AND + sample_list.stable_id = #{sampleListId} AND copy_number_seg.chr = #{chromosome} - AND copy_number_seg.sample_id IN - ( - SELECT sample_list_list.sample_id FROM sample_list_list - INNER JOIN sample_list ON sample_list_list.list_id = sample_list.list_id - WHERE sample_list.stable_id = #{sampleListId} - AND sample_list_list.sample_id = copy_number_seg.sample_id - ) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml index 64dd96b0ebd..3b941472d83 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/PatientMapper.xml @@ -3,6 +3,7 @@ + patient.internal_id AS "${prefix}internalId", patient.stable_id AS "${prefix}stableId", @@ -10,18 +11,18 @@ cancer_study.cancer_study_identifier AS "${prefix}cancerStudyIdentifier" , - cancer_study.cancer_study_id AS "cancerStudy.cancerStudyId", - cancer_study.cancer_study_identifier AS "cancerStudy.cancerStudyIdentifier", - cancer_study.type_of_cancer_id AS "cancerStudy.typeOfCancerId", - cancer_study.name AS "cancerStudy.name", - cancer_study.description AS "cancerStudy.description", - cancer_study.public AS "cancerStudy.publicStudy", - cancer_study.pmid AS "cancerStudy.pmid", - cancer_study.citation AS "cancerStudy.citation", - cancer_study.groups AS "cancerStudy.groups", - cancer_study.status AS "cancerStudy.status", - cancer_study.import_date AS "cancerStudy.importDate", - reference_genome.name AS "cancerStudy.referenceGenome" + cancer_study.cancer_study_id AS "${prefix}cancerStudy.cancerStudyId", + cancer_study.cancer_study_identifier AS "${prefix}cancerStudy.cancerStudyIdentifier", + cancer_study.type_of_cancer_id AS "${prefix}cancerStudy.typeOfCancerId", + cancer_study.name AS "${prefix}cancerStudy.name", + cancer_study.description AS "${prefix}cancerStudy.description", + cancer_study.public AS "${prefix}cancerStudy.publicStudy", + cancer_study.pmid AS "${prefix}cancerStudy.pmid", + cancer_study.citation AS "${prefix}cancerStudy.citation", + cancer_study.groups AS "${prefix}cancerStudy.groups", + cancer_study.status AS "${prefix}cancerStudy.status", + cancer_study.import_date AS "${prefix}cancerStudy.importDate", + reference_genome.name AS "${prefix}cancerStudy.referenceGenome" diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ResourceDataMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ResourceDataMapper.xml index 1c6f2152cc5..e7ed41ed46a 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ResourceDataMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/ResourceDataMapper.xml @@ -6,10 +6,10 @@ sample.stable_id AS "${prefix}sampleId", patient.stable_id AS "${prefix}patientId", - resource_patient.resource_id AS "${prefix}resourceId", + resource_sample.resource_id AS "${prefix}resourceId", cancer_study.cancer_study_identifier AS "${prefix}studyId" - , resource_patient.url AS "${prefix}url" + , resource_sample.url AS "${prefix}url" , @@ -49,8 +49,8 @@ - FROM resource_patient - INNER JOIN sample ON resource_patient.internal_id = sample.internal_id + FROM resource_sample + INNER JOIN sample ON resource_sample.internal_id = sample.internal_id INNER JOIN patient ON sample.patient_id = patient.internal_id INNER JOIN cancer_study ON patient.cancer_study_id = cancer_study.cancer_study_id @@ -76,7 +76,7 @@ sample.stable_id = #{sampleId} - AND resource_patient.resource_id = #{resourceId} + AND resource_sample.resource_id = #{resourceId} @@ -112,7 +112,7 @@ - INNER JOIN resource_definition ON resource_patient.resource_id = resource_definition.resource_id + INNER JOIN resource_definition ON resource_sample.resource_id = resource_definition.resource_id AND cancer_study.cancer_study_id = resource_definition.cancer_study_id @@ -120,7 +120,7 @@ ORDER BY "${sortBy}" ${direction} - ORDER BY resource_patient.resource_id ASC + ORDER BY resource_sample.resource_id ASC LIMIT #{limit} OFFSET #{offset} diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml index c66ba62046f..15021f7fde9 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleListMapper.xml @@ -16,6 +16,8 @@ , + cancer_study.cancer_study_id AS "cancerStudy.cancerStudyId", + cancer_study.cancer_study_identifier AS "cancerStudy.cancerStudyIdentifier", cancer_study.type_of_cancer_id AS "cancerStudy.typeOfCancerId", cancer_study.name AS "cancerStudy.name", cancer_study.description AS "cancerStudy.description", diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml index bcb8ea28763..c2da3df2bf2 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/SampleMapper.xml @@ -107,16 +107,12 @@ SELECT COUNT(*) AS "totalCount", - COUNT(DISTINCT(mutation.sample_id)) AS "sampleCount" + COUNT(DISTINCT(sampleId)) AS "sampleCount" - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id @@ -309,9 +298,7 @@ SELECT - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id - INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id @@ -322,9 +309,7 @@ SELECT - INNER JOIN mutation_event ON mutation.mutation_event_id = mutation_event.mutation_event_id - INNER JOIN gene ON mutation.entrez_gene_id = gene.entrez_gene_id @@ -334,63 +319,60 @@ From 2164b456d8943bb995105cad258839ea4672c035 Mon Sep 17 00:00:00 2001 From: alisman Date: Fri, 31 Oct 2025 15:56:14 -0400 Subject: [PATCH 29/31] Fix upper case column issues in merged code --- .../legacy/persistence/mybatis/InfoMapper.xml | 10 ++-- .../persistence/mybatis/StudyMapper.xml | 46 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/InfoMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/InfoMapper.xml index fbdfb2ad47e..2a724944e87 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/InfoMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/InfoMapper.xml @@ -4,14 +4,14 @@ - - - - + + + + diff --git a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StudyMapper.xml b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StudyMapper.xml index dcec5970e0e..bf5e01e18b9 100644 --- a/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StudyMapper.xml +++ b/src/main/resources/org/cbioportal/legacy/persistence/mybatis/StudyMapper.xml @@ -97,43 +97,43 @@ - DISPLAY_NAME AS displayName, - rd.DESCRIPTION AS description, - rd.RESOURCE_TYPE AS resourceType, - rd.PRIORITY AS priority, - rd.OPEN_BY_DEFAULT AS openByDefault, - CANCER_STUDY_IDENTIFIER as cancerStudyIdentifier, - rd.CUSTOM_METADATA AS customMetaData + display_name AS displayName, + rd.description AS description, + rd.resource_type AS resourceType, + rd.priority AS priority, + rd.open_by_default AS openByDefault, + cancer_study_identifier as cancerStudyIdentifier, + rd.custom_metadata AS customMetaData , - rs.RESOURCE_ID AS resourceId, - COUNT(DISTINCT rs.INTERNAL_ID) AS sampleCount, - COUNT(DISTINCT p.INTERNAL_ID) AS patientCount + rs.resource_id AS resourceId, + COUNT(DISTINCT rs.internal_id) AS sampleCount, + COUNT(DISTINCT p.internal_id) AS patientCount FROM resource_sample AS rs - INNER JOIN resource_definition rd ON rd.RESOURCE_ID = rs.RESOURCE_ID - INNER JOIN sample s ON s.INTERNAL_ID = rs.INTERNAL_ID - INNER JOIN patient p ON p.INTERNAL_ID = s.PATIENT_ID - INNER JOIN cancer_study cs ON cs.CANCER_STUDY_ID = p.CANCER_STUDY_ID + INNER JOIN resource_definition rd ON rd.resource_id = rs.resource_id + INNER JOIN sample s ON s.internal_id = rs.internal_id + INNER JOIN patient p ON p.internal_id = s.patient_id + INNER JOIN cancer_study cs ON cs.cancer_study_id = p.cancer_study_id , - rp.RESOURCE_ID AS resourceId, - COUNT(DISTINCT s.INTERNAL_ID) AS sampleCount, - COUNT(DISTINCT rp.INTERNAL_ID) AS patientCount + rp.resource_id AS resourceId, + COUNT(DISTINCT s.internal_id) AS sampleCount, + COUNT(DISTINCT rp.internal_id) AS patientCount FROM cancer_study cs - INNER JOIN patient p ON cs.CANCER_STUDY_ID = p.CANCER_STUDY_ID - LEFT JOIN sample s ON p.INTERNAL_ID = s.PATIENT_ID - INNER JOIN resource_patient rp ON rp.INTERNAL_ID = s.PATIENT_ID - INNER JOIN resource_definition rd ON rd.RESOURCE_ID = rp.RESOURCE_ID + INNER JOIN patient p ON cs.cancer_study_id = p.cancer_study_id + LEFT JOIN sample s ON p.internal_id = s.patient_id + INNER JOIN resource_patient rp ON rp.internal_id = s.patient_id + INNER JOIN resource_definition rd ON rd.resource_id = rp.resource_id