|
97 | 97 | </sql> |
98 | 98 |
|
99 | 99 | <sql id="selectResource"> |
100 | | - DISPLAY_NAME AS displayName, |
101 | | - rd.DESCRIPTION AS description, |
102 | | - rd.RESOURCE_TYPE AS resourceType, |
103 | | - rd.PRIORITY AS priority, |
104 | | - rd.OPEN_BY_DEFAULT AS openByDefault, |
105 | | - CANCER_STUDY_IDENTIFIER as cancerStudyIdentifier, |
106 | | - rd.CUSTOM_METADATA AS customMetaData |
| 100 | + display_name AS displayName, |
| 101 | + rd.description AS description, |
| 102 | + rd.resource_type AS resourceType, |
| 103 | + rd.priority AS priority, |
| 104 | + rd.open_by_default AS openByDefault, |
| 105 | + cancer_study_identifier as cancerStudyIdentifier, |
| 106 | + rd.custom_metadata AS customMetaData |
107 | 107 | </sql> |
108 | 108 |
|
109 | 109 | <sql id="selectSampleResourceCounts"> |
110 | 110 | <include refid="selectResource"/>, |
111 | | - rs.RESOURCE_ID AS resourceId, |
112 | | - COUNT(DISTINCT rs.INTERNAL_ID) AS sampleCount, |
113 | | - COUNT(DISTINCT p.INTERNAL_ID) AS patientCount |
| 111 | + rs.resource_id AS resourceId, |
| 112 | + COUNT(DISTINCT rs.internal_id) AS sampleCount, |
| 113 | + COUNT(DISTINCT p.internal_id) AS patientCount |
114 | 114 | </sql> |
115 | 115 |
|
116 | 116 | <sql id="fromResourceSample"> |
117 | 117 | FROM resource_sample AS rs |
118 | | - INNER JOIN resource_definition rd ON rd.RESOURCE_ID = rs.RESOURCE_ID |
119 | | - INNER JOIN sample s ON s.INTERNAL_ID = rs.INTERNAL_ID |
120 | | - INNER JOIN patient p ON p.INTERNAL_ID = s.PATIENT_ID |
121 | | - INNER JOIN cancer_study cs ON cs.CANCER_STUDY_ID = p.CANCER_STUDY_ID |
| 118 | + INNER JOIN resource_definition rd ON rd.resource_id = rs.resource_id |
| 119 | + INNER JOIN sample s ON s.internal_id = rs.internal_id |
| 120 | + INNER JOIN patient p ON p.internal_id = s.patient_id |
| 121 | + INNER JOIN cancer_study cs ON cs.cancer_study_id = p.cancer_study_id |
122 | 122 | </sql> |
123 | 123 |
|
124 | 124 | <sql id="selectPatientResourceCounts"> |
125 | 125 | <include refid="selectResource"/>, |
126 | | - rp.RESOURCE_ID AS resourceId, |
127 | | - COUNT(DISTINCT s.INTERNAL_ID) AS sampleCount, |
128 | | - COUNT(DISTINCT rp.INTERNAL_ID) AS patientCount |
| 126 | + rp.resource_id AS resourceId, |
| 127 | + COUNT(DISTINCT s.internal_id) AS sampleCount, |
| 128 | + COUNT(DISTINCT rp.internal_id) AS patientCount |
129 | 129 | </sql> |
130 | 130 |
|
131 | 131 | <sql id="fromResourcePatient"> |
132 | 132 | FROM cancer_study cs |
133 | | - INNER JOIN patient p ON cs.CANCER_STUDY_ID = p.CANCER_STUDY_ID |
134 | | - LEFT JOIN sample s ON p.INTERNAL_ID = s.PATIENT_ID |
135 | | - INNER JOIN resource_patient rp ON rp.INTERNAL_ID = s.PATIENT_ID |
136 | | - INNER JOIN resource_definition rd ON rd.RESOURCE_ID = rp.RESOURCE_ID |
| 133 | + INNER JOIN patient p ON cs.cancer_study_id = p.cancer_study_id |
| 134 | + LEFT JOIN sample s ON p.internal_id = s.patient_id |
| 135 | + INNER JOIN resource_patient rp ON rp.internal_id = s.patient_id |
| 136 | + INNER JOIN resource_definition rd ON rd.resource_id = rp.resource_id |
137 | 137 | </sql> |
138 | 138 |
|
139 | 139 | <select id="getStudies" resultType="org.cbioportal.legacy.model.CancerStudy"> |
|
240 | 240 | <include refid="fromResourceSample"/> |
241 | 241 | <where> |
242 | 242 | <if test="studyIds != null and !studyIds.isEmpty()"> |
243 | | - cs.CANCER_STUDY_IDENTIFIER IN |
| 243 | + cs.cancer_study_identifier IN |
244 | 244 | <foreach item="item" collection="studyIds" open="(" separator="," close=")"> |
245 | 245 | #{item} |
246 | 246 | </foreach> |
|
253 | 253 | <include refid="fromResourcePatient"/> |
254 | 254 | <where> |
255 | 255 | <if test="studyIds != null and !studyIds.isEmpty()"> |
256 | | - cs.CANCER_STUDY_IDENTIFIER IN |
| 256 | + cs.cancer_study_identifier IN |
257 | 257 | <foreach item="item" collection="studyIds" open="(" separator="," close=")"> |
258 | 258 | #{item} |
259 | 259 | </foreach> |
|
0 commit comments