Skip to content

Commit

Permalink
Change mybatis mapper to use uppercase table and column names
Browse files Browse the repository at this point in the history
  • Loading branch information
pvannierop committed Apr 18, 2024
1 parent 8b07d3f commit c267a89
Show file tree
Hide file tree
Showing 32 changed files with 1,250 additions and 1,250 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

<select id="getAlterationDriverAnnotations" resultType="org.cbioportal.model.AlterationDriverAnnotation">
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
FROM alteration_driver_annotation
INNER JOIN genetic_profile ON
genetic_profile.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID
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
<where>
<if test="molecularProfileIds != null and !molecularProfileIds.isEmpty()">
genetic_profile.STABLE_ID IN
GENETIC_PROFILE.STABLE_ID IN
<foreach item="id" collection="molecularProfileIds" open="(" separator="," close=")">
#{id}
</foreach>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<mapper namespace="org.cbioportal.persistence.mybatis.CancerTypeMapper">

<sql id="select">
type_of_cancer.TYPE_OF_CANCER_ID AS "${prefix}typeOfCancerId"
TYPE_OF_CANCER.TYPE_OF_CANCER_ID AS "${prefix}typeOfCancerId"
<if test="projection == 'SUMMARY' || projection == 'DETAILED'">
,
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"
</if>
</sql>

Expand All @@ -19,12 +19,12 @@
<include refid="select">
<property name="prefix" value=""/>
</include>
FROM type_of_cancer
FROM TYPE_OF_CANCER
<if test="sortBy != null and projection != 'ID'">
ORDER BY "${sortBy}" ${direction}
</if>
<if test="projection == 'ID'">
ORDER BY type_of_cancer.TYPE_OF_CANCER_ID ASC
ORDER BY TYPE_OF_CANCER.TYPE_OF_CANCER_ID ASC
</if>
<if test="limit != null and limit != 0">
LIMIT #{limit} OFFSET #{offset}
Expand All @@ -34,16 +34,16 @@
<select id="getMetaCancerTypes" resultType="org.cbioportal.model.meta.BaseMeta">
SELECT
COUNT(*) AS "totalCount"
FROM type_of_cancer
FROM TYPE_OF_CANCER
</select>

<select id="getCancerType" resultType="org.cbioportal.model.TypeOfCancer">
SELECT
<include refid="select">
<property name="prefix" value=""/>
</include>
FROM type_of_cancer
WHERE type_of_cancer.TYPE_OF_CANCER_ID = #{cancerTypeId}
FROM TYPE_OF_CANCER
WHERE TYPE_OF_CANCER.TYPE_OF_CANCER_ID = #{cancerTypeId}
</select>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@
<mapper namespace="org.cbioportal.persistence.mybatis.ClinicalAttributeMapper">

<sql id="select">
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"
<if test="projection == 'SUMMARY' || projection == 'DETAILED'">
,
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"
</if>
</sql>

<sql id="joinSample">
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 ONSAMPLE.PATIENT_ID = PATIENT.INTERNAL_ID
INNER JOIN CANCER_STUDY ON PATIENT.CANCER_STUDY_ID = CANCER_STUDY.CANCER_STUDY_ID
</sql>

<sql id="joinPatient">
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 ONCLINICAL_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
</sql>

<sql id="whereSample">
<where>
<if test="sampleIds == null">
cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]}
CANCER_STUDY.CANCER_STUDY_IDENTIFIER = #{studyIds[0]}
</if>
<if test="sampleIds != null">
<if test="@java.util.Arrays@stream(studyIds.toArray()).distinct().count() == 1">
cancer_study.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND
sample.STABLE_ID IN
CANCER_STUDY.CANCER_STUDY_IDENTIFIER = #{studyIds[0]} AND
SAMPLE.STABLE_ID IN
<foreach item="item" collection="sampleIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="@java.util.Arrays@stream(studyIds.toArray()).distinct().count() > 1">
(cancer_study.CANCER_STUDY_IDENTIFIER, sample.STABLE_ID) IN
(CANCER_STUDY.CANCER_STUDY_IDENTIFIER, SAMPLE.STABLE_ID) IN
<foreach index="i" collection="sampleIds" open="(" separator="," close=")">
(#{studyIds[${i}]}, #{sampleIds[${i}]})
</foreach>
Expand All @@ -54,12 +54,12 @@

<sql id="whereBySampleListId">
<where>
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
)
</where>
</sql>
Expand All @@ -69,11 +69,11 @@
<include refid="select">
<property name="prefix" value=""/>
</include>
FROM clinical_attribute_meta
INNER JOIN cancer_study ON clinical_attribute_meta.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID
FROM CLINICAL_ATTRIBUTE_META
INNER JOIN CANCER_STUDY ON CLINICAL_ATTRIBUTE_META.CANCER_STUDY_ID = CANCER_STUDY.CANCER_STUDY_ID
<where>
<if test="studyIds != null and !studyIds.isEmpty()">
cancer_study.CANCER_STUDY_IDENTIFIER IN
CANCER_STUDY.CANCER_STUDY_IDENTIFIER IN
<foreach item="item" collection="studyIds" open="(" separator="," close=")">
#{item}
</foreach>
Expand All @@ -83,7 +83,7 @@
ORDER BY "${sortBy}" ${direction}
</if>
<if test="projection == 'ID'">
ORDER BY clinical_attribute_meta.ATTR_ID ASC
ORDER BY CLINICAL_ATTRIBUTE_META.ATTR_ID ASC
</if>
<if test="limit != null and limit != 0">
LIMIT #{limit} OFFSET #{offset}
Expand All @@ -93,11 +93,11 @@
<select id="getMetaClinicalAttributes" resultType="org.cbioportal.model.meta.BaseMeta">
SELECT
COUNT(*) AS "totalCount"
FROM clinical_attribute_meta
INNER JOIN cancer_study ON clinical_attribute_meta.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID
FROM CLINICAL_ATTRIBUTE_META
INNER JOIN CANCER_STUDY ON CLINICAL_ATTRIBUTE_META.CANCER_STUDY_ID = CANCER_STUDY.CANCER_STUDY_ID
<where>
<if test="list != null and !list.isEmpty()">
cancer_study.CANCER_STUDY_IDENTIFIER IN
CANCER_STUDY.CANCER_STUDY_IDENTIFIER IN
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
Expand All @@ -110,68 +110,68 @@
<include refid="select">
<property name="prefix" value=""/>
</include>
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}
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}
</select>

<select id="getClinicalAttributeCountsBySampleIds" resultType="org.cbioportal.model.ClinicalAttributeCount">
SELECT count(*) as "count",
clinical_sample.ATTR_ID as "attrId"
FROM clinical_sample
CLINICAL_SAMPLE.ATTR_ID as "attrId"
FROM CLINICAL_SAMPLE
<include refid="joinSample"/>
<include refid="whereSample"/>
GROUP BY clinical_sample.ATTR_ID
GROUP BY CLINICAL_SAMPLE.ATTR_ID

UNION

SELECT count(*) as "count",
clinical_patient.ATTR_ID as "attrId"
FROM clinical_patient
CLINICAL_PATIENT.ATTR_ID as "attrId"
FROM CLINICAL_PATIENT
<include refid="joinPatient"/>
<include refid="whereSample"/>
GROUP BY clinical_patient.ATTR_ID
GROUP BY CLINICAL_PATIENT.ATTR_ID
</select>

<select id="getClinicalAttributeCountsBySampleListId" resultType="org.cbioportal.model.ClinicalAttributeCount">
SELECT count(*) as "count",
clinical_sample.ATTR_ID as "attrId"
FROM clinical_sample
CLINICAL_SAMPLE.ATTR_ID as "attrId"
FROM CLINICAL_SAMPLE
<include refid="joinSample"/>
<include refid="whereBySampleListId"/>
GROUP BY clinical_sample.ATTR_ID
GROUP BY CLINICAL_SAMPLE.ATTR_ID

UNION

SELECT count(*) as "count",
clinical_patient.ATTR_ID as "attrId"
FROM clinical_patient
CLINICAL_PATIENT.ATTR_ID as "attrId"
FROM CLINICAL_PATIENT
<include refid="joinPatient"/>
<include refid="whereBySampleListId"/>
GROUP BY clinical_patient.ATTR_ID
GROUP BY CLINICAL_PATIENT.ATTR_ID
</select>

<select id="getClinicalAttributesByStudyIdsAndAttributeIds" resultType="org.cbioportal.model.ClinicalAttribute">
SELECT
clinical_attribute_meta.ATTR_ID AS "attrId",
cancer_study.CANCER_STUDY_IDENTIFIER AS "cancerStudyIdentifier",
clinical_attribute_meta.CANCER_STUDY_ID AS "cancerStudyId",
clinical_attribute_meta.PATIENT_ATTRIBUTE AS "patientAttribute",
clinical_attribute_meta.DISPLAY_NAME AS "displayName",
clinical_attribute_meta.DATATYPE AS "datatype"
FROM clinical_attribute_meta
INNER JOIN cancer_study ON clinical_attribute_meta.CANCER_STUDY_ID = cancer_study.CANCER_STUDY_ID
CLINICAL_ATTRIBUTE_META.ATTR_ID AS "attrId",
CANCER_STUDY.CANCER_STUDY_IDENTIFIER AS "cancerStudyIdentifier",
CLINICAL_ATTRIBUTE_META.CANCER_STUDY_ID AS "cancerStudyId",
CLINICAL_ATTRIBUTE_META.PATIENT_ATTRIBUTE AS "patientAttribute",
CLINICAL_ATTRIBUTE_META.DISPLAY_NAME AS "displayName",
CLINICAL_ATTRIBUTE_META.DATATYPE AS "datatype"
FROM CLINICAL_ATTRIBUTE_META
INNER JOIN CANCER_STUDY ON CLINICAL_ATTRIBUTE_META.CANCER_STUDY_ID = CANCER_STUDY.CANCER_STUDY_ID
<where>
<if test="studyIds != null and !studyIds.isEmpty()">
cancer_study.CANCER_STUDY_IDENTIFIER IN
CANCER_STUDY.CANCER_STUDY_IDENTIFIER IN
<foreach item="item" collection="studyIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="attributeIds != null and !attributeIds.isEmpty()">
AND
clinical_attribute_meta.ATTR_ID IN
CLINICAL_ATTRIBUTE_META.ATTR_ID IN
<foreach item="item" collection="attributeIds" open="(" separator="," close=")">
#{item}
</foreach>
Expand Down
Loading

0 comments on commit c267a89

Please sign in to comment.