Skip to content

Commit

Permalink
Revert "Merge pull request #11051 from hweej/11004/resource-data-expa…
Browse files Browse the repository at this point in the history
…nd-all-results"

This reverts commit 8e1a02b, reversing
changes made to 2284f83.
  • Loading branch information
dippindots committed Oct 31, 2024
1 parent 8c934c4 commit f056bc4
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,5 @@ List<ResourceData> getAllResourceDataOfPatientInStudy(String studyId, String pat
@Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()")
List<ResourceData> getAllResourceDataForStudy(String studyId, String resourceId, String projection,
Integer pageSize, Integer pageNumber, String sortBy, String direction);

@Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()")
List<ResourceData> getResourceDataForAllPatientsInStudy(String studyId, String resourceId, String projection,
Integer pageSize, Integer pageNumber, String sortBy, String direction);

@Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()")
List<ResourceData> getResourceDataForAllSamplesInStudy(String studyId, String resourceId, String projection,
Integer pageSize, Integer pageNumber, String sortBy, String direction);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@ List<ResourceData> getResourceDataOfPatientInStudy(String studyId, String patien
List<ResourceData> getResourceDataForStudy(String studyId, String resourceId, String projection, Integer limit,
Integer offset, String sortBy, String direction);

List<ResourceData> getResourceDataForAllPatientsInStudy(String studyId, String resourceId, String projection, Integer limit,
Integer offset, String sortBy, String direction);

List<ResourceData> getResourceDataForAllSamplesInStudy(String studyId, String resourceId, String projection, Integer limit,
Integer offset, String sortBy, String direction);

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,4 @@ public List<ResourceData> getAllResourceDataForStudy(String studyId, String reso
PaginationCalculator.offset(pageSize, pageNumber), sortBy, direction);
}

@Override
public List<ResourceData> getResourceDataForAllPatientsInStudy(String studyId, String resourceId, String projection,
Integer pageSize, Integer pageNumber, String sortBy, String direction) {

return resourceDataMapper.getResourceDataForAllPatientsInStudy(studyId, resourceId, projection, pageSize,
PaginationCalculator.offset(pageSize, pageNumber), sortBy, direction);
}

@Override
public List<ResourceData> getResourceDataForAllSamplesInStudy(String studyId, String resourceId, String projection,
Integer pageSize, Integer pageNumber, String sortBy, String direction) {

return resourceDataMapper.getResourceDataForAllSamplesInStudy(studyId, resourceId, projection, pageSize,
PaginationCalculator.offset(pageSize, pageNumber), sortBy, direction);
}

}
3 changes: 0 additions & 3 deletions src/main/java/org/cbioportal/service/ResourceDataService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@ List<ResourceData> getAllResourceDataOfPatientInStudy(String studyId, String pat
List<ResourceData> getAllResourceDataForStudy(String studyId, String resourceId, String projection,
Integer pageSize, Integer pageNumber, String sortBy, String direction) throws StudyNotFoundException;

List<ResourceData> getAllResourceDataForStudyPatientSample(String studyId, String resourceId, String projection,
Integer pageSize, Integer pageNumber, String sortBy, String direction) throws StudyNotFoundException;

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.cbioportal.service.impl;

import java.util.List;
import java.util.ArrayList;

import org.cbioportal.model.ResourceData;
import org.cbioportal.persistence.ResourceDataRepository;
Expand Down Expand Up @@ -57,22 +56,5 @@ public List<ResourceData> getAllResourceDataForStudy(String studyId, String reso
return resourceDataRepository.getAllResourceDataForStudy(studyId, resourceId, projection, pageSize, pageNumber,
sortBy, direction);
}

@Override
public List<ResourceData> getAllResourceDataForStudyPatientSample(String studyId, String resourceId, String projection,
Integer pageSize, Integer pageNumber, String sortBy, String direction) throws StudyNotFoundException {

studyService.getStudy(studyId);

List<ResourceData> results = new ArrayList<ResourceData>();

results.addAll(resourceDataRepository.getAllResourceDataForStudy(studyId, resourceId, projection, pageSize, pageNumber,
sortBy, direction));
results.addAll(resourceDataRepository.getResourceDataForAllPatientsInStudy(studyId, resourceId, projection, pageSize, pageNumber,
sortBy, direction));
results.addAll(resourceDataRepository.getResourceDataForAllSamplesInStudy(studyId, resourceId, projection, pageSize, pageNumber,
sortBy, direction));
return results;
}

}
60 changes: 0 additions & 60 deletions src/main/java/org/cbioportal/web/ResourceDataController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;

import org.cbioportal.model.ResourceData;
import org.cbioportal.service.ResourceDataService;
import org.cbioportal.service.exception.PatientNotFoundException;
Expand All @@ -22,8 +21,6 @@
import org.cbioportal.web.parameter.Projection;
import org.cbioportal.web.parameter.sort.ResourceDataSortBy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -36,7 +33,6 @@
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Objects;

@InternalApi
@RestController()
Expand All @@ -51,17 +47,6 @@ public class ResourceDataController {
@Autowired
private ResourceDataService resourceDataService;

@Autowired
private ApplicationContext applicationContext;
ResourceDataController instance;

private ResourceDataController getInstance() {
if (Objects.isNull(instance)) {
instance = applicationContext.getBean(ResourceDataController.class);
}
return instance;
}

@PreAuthorize("hasPermission(#studyId, 'CancerStudyId', T(org.cbioportal.utils.security.AccessLevel).READ)")
@RequestMapping(value = "/studies/{studyId}/samples/{sampleId}/resource-data", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down Expand Up @@ -172,49 +157,4 @@ public ResponseEntity<List<ResourceData>> getAllStudyResourceDataInStudy(
}
}

@PreAuthorize("hasPermission(#studyId, 'CancerStudyId', T(org.cbioportal.utils.security.AccessLevel).READ)")
@RequestMapping(value = "/studies/{studyId}/resource-data-all", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(description = "Get all resource data for for all patients and all samples within a study")
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ResourceData.class))))
public ResponseEntity<List<ResourceData>> getAllStudyResourceDataInStudyPatientSample(
@Parameter(required = true, description = "Study ID e.g. acc_tcga")
@PathVariable String studyId,
@Parameter(description = "Resource ID")
@RequestParam(required = false) String resourceId,
@Parameter(description = "Level of detail of the response")
@RequestParam(defaultValue = "SUMMARY") Projection projection,
@Parameter(description = "Page size of the result list")
@Max(RESOURCE_DATA_MAX_PAGE_SIZE)
@Min(PagingConstants.MIN_PAGE_SIZE)
@RequestParam(defaultValue = RESOURCE_DATA_DEFAULT_PAGE_SIZE) Integer pageSize,
@Parameter(description = "Page number of the result list")
@Min(PagingConstants.MIN_PAGE_NUMBER)
@RequestParam(defaultValue = PagingConstants.DEFAULT_PAGE_NUMBER) Integer pageNumber,
@Parameter(description = "Name of the property that the result list is sorted by")
@RequestParam(required = false) ResourceDataSortBy sortBy,
@Parameter(description = "Direction of the sort")
@RequestParam(defaultValue = "ASC") Direction direction) throws StudyNotFoundException {

if (projection == Projection.META) {
throw new UnsupportedOperationException("Requested API is not implemented yet");
} else {
return new ResponseEntity<>(this.getInstance().cacheableFetchAllResourceDataForStudyPatientSample(
studyId, resourceId, projection.name(), pageSize, pageNumber, sortBy == null ? null : sortBy.getOriginalValue(),
direction.name()) , HttpStatus.OK);
}
}

@Cacheable(
cacheResolver = "staticRepositoryCacheOneResolver"
//condition = "@cacheEnabledConfig.getEnabled() && #unfilteredQuery && (#sortBy == null || #sortBy.isEmpty())"
)
public List<ResourceData> cacheableFetchAllResourceDataForStudyPatientSample(String studyId, String resourceId, String projectionName,
Integer pageSize, Integer pageNumber, String sortBy, String directionName) throws StudyNotFoundException {

return resourceDataService.getAllResourceDataForStudyPatientSample(studyId, resourceId, projectionName, pageSize, pageNumber,
sortBy, directionName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -171,40 +171,4 @@
</if>
</select>

<select id="getResourceDataForAllPatientsInStudy" resultType="org.cbioportal.model.ResourceData">
SELECT
<include refid="selectPatientResource">
<property name="prefix" value=""/>
</include>
FROM
cancer_study
JOIN
patient ON patient.CANCER_STUDY_ID=cancer_study.CANCER_STUDY_ID
JOIN
resource_patient ON resource_patient.INTERNAL_ID=patient.INTERNAL_ID
JOIN
resource_definition ON (resource_definition.RESOURCE_ID=resource_patient.RESOURCE_ID
AND cancer_study.CANCER_STUDY_ID=resource_definition.CANCER_STUDY_ID)
<include refid="whereStudy"/>
</select>

<select id="getResourceDataForAllSamplesInStudy" resultType="org.cbioportal.model.ResourceData">
SELECT
<include refid="selectSampleResource">
<property name="prefix" value=""/>
</include>
FROM
cancer_study
JOIN
patient ON patient.CANCER_STUDY_ID=cancer_study.CANCER_STUDY_ID
JOIN
sample ON sample.PATIENT_ID=patient.INTERNAL_ID
JOIN
resource_sample ON resource_sample.INTERNAL_ID=sample.INTERNAL_ID
JOIN
resource_definition ON (resource_definition.RESOURCE_ID=resource_sample.RESOURCE_ID
AND cancer_study.CANCER_STUDY_ID=resource_definition.CANCER_STUDY_ID)
<include refid="whereStudy"/>
</select>

</mapper>
</mapper>

0 comments on commit f056bc4

Please sign in to comment.