Skip to content

Commit

Permalink
Extract column store endpoints into StudyViewColumnStoreController (c…
Browse files Browse the repository at this point in the history
…BioPortal#10245)

* Extract column store endpoints into StudyViewControllerColumnStore

* rename
  • Loading branch information
haynescd authored and jagnathan committed Nov 8, 2023
1 parent cfb6c7d commit d6756a5
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 39 deletions.
38 changes: 0 additions & 38 deletions web/src/main/java/org/cbioportal/web/StudyViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,24 +209,6 @@ public ResponseEntity<List<AlterationCountByGene>> fetchMutatedGenes(
return new ResponseEntity<>(alterationCountByGenes, HttpStatus.OK);
}

@PreAuthorize("hasPermission(#involvedCancerStudies, 'Collection<CancerStudyId>', T(org.cbioportal.utils.security.AccessLevel).READ)")
@RequestMapping(value = "/column-store/mutated-genes/fetch", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation("Fetch mutated genes by study view filter")
public ResponseEntity<List<AlterationCountByGene>> fetchMutatedGenesFromColumnStore(
@ApiParam(required = true, value = "Study view filter")
@Valid @RequestBody(required = false) StudyViewFilter studyViewFilter,
@ApiIgnore // prevent reference to this attribute in the swagger-ui interface
@RequestAttribute(required = false, value = "involvedCancerStudies") Collection<String> involvedCancerStudies,
@ApiIgnore // prevent reference to this attribute in the swagger-ui interface. this attribute is needed for the @PreAuthorize tag above.
@Valid @RequestAttribute(required = false, value = "interceptedStudyViewFilter") StudyViewFilter interceptedStudyViewFilter
) {
return new ResponseEntity<>(
studyViewService.getMutatedGenesFromColumnstore(interceptedStudyViewFilter),
HttpStatus.OK
);
}

@Cacheable(
cacheResolver = "staticRepositoryCacheOneResolver",
condition = "@cacheEnabledConfig.getEnabled() && #singleStudyUnfiltered"
Expand Down Expand Up @@ -349,26 +331,6 @@ public ResponseEntity<List<Sample>> fetchFilteredSamples(
return new ResponseEntity<>(result, HttpStatus.OK);
}

@PreAuthorize("hasPermission(#involvedCancerStudies, 'Collection<CancerStudyId>', T(org.cbioportal.utils.security.AccessLevel).READ)")
@RequestMapping(value = "/column-store/filtered-samples/fetch", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation("Fetch sample IDs by study view filter")
public ResponseEntity<List<Sample>> fetchFilteredSamplesFromColumnStore(
@ApiParam("Whether to negate the study view filters")
@RequestParam(defaultValue = "false") Boolean negateFilters,
@ApiIgnore // prevent reference to this attribute in the swagger-ui interface
@RequestAttribute(required = false, value = "involvedCancerStudies") Collection<String> involvedCancerStudies,
@ApiIgnore // prevent reference to this attribute in the swagger-ui interface. this attribute is needed for the @PreAuthorize tag above.
@Valid @RequestAttribute(required = false, value = "interceptedStudyViewFilter") StudyViewFilter interceptedStudyViewFilter,
@ApiParam(required = true, value = "Study view filter")
@Valid @RequestBody(required = false) StudyViewFilter studyViewFilter) {

return new ResponseEntity<>(
studyViewService.getFilteredSamplesFromColumnstore(interceptedStudyViewFilter),
HttpStatus.OK
);
}

@PreAuthorize("hasPermission(#involvedCancerStudies, 'Collection<CancerStudyId>', T(org.cbioportal.utils.security.AccessLevel).READ)")
@RequestMapping(value = "/molecular-profile-sample-counts/fetch", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.cbioportal.web.columnstore;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.cbioportal.model.AlterationCountByGene;
import org.cbioportal.model.Sample;
import org.cbioportal.service.StudyViewService;
import org.cbioportal.web.config.annotation.InternalApi;
import org.cbioportal.webparam.StudyViewFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;
import java.util.Collection;
import java.util.List;

@InternalApi
@RestController
@Validated
@Api(tags = "Study View Column Store")
public class StudyViewColumnStoreController {

@Autowired
private StudyViewService studyViewService;

@PreAuthorize("hasPermission(#involvedCancerStudies, 'Collection<CancerStudyId>', T(org.cbioportal.utils.security.AccessLevel).READ)")
@PostMapping(value = "/column-store/filtered-samples/fetch",
consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation("Fetch sample IDs by study view filter")
public ResponseEntity<List<Sample>> fetchFilteredSamples(
@ApiParam("Whether to negate the study view filters")
@RequestParam(defaultValue = "false") Boolean negateFilters,
@ApiIgnore // prevent reference to this attribute in the swagger-ui interface
@RequestAttribute(required = false, value = "involvedCancerStudies") Collection<String> involvedCancerStudies,
@ApiIgnore // prevent reference to this attribute in the swagger-ui interface. this attribute is needed for the @PreAuthorize tag above.
@Valid @RequestAttribute(required = false, value = "interceptedStudyViewFilter") StudyViewFilter interceptedStudyViewFilter,
@ApiParam(required = true, value = "Study view filter")
@Valid @RequestBody(required = false) StudyViewFilter studyViewFilter) {
return new ResponseEntity<>(
studyViewService.getFilteredSamplesFromColumnstore(interceptedStudyViewFilter),
HttpStatus.OK
);
}

@PreAuthorize("hasPermission(#involvedCancerStudies, 'Collection<CancerStudyId>', T(org.cbioportal.utils.security.AccessLevel).READ)")
@PostMapping(value = "/column-store/mutated-genes/fetch",
consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation("Fetch mutated genes by study view filter")
public ResponseEntity<List<AlterationCountByGene>> fetchMutatedGenes(
@ApiParam(required = true, value = "Study view filter")
@Valid @RequestBody(required = false) StudyViewFilter studyViewFilter,
@ApiIgnore // prevent reference to this attribute in the swagger-ui interface
@RequestAttribute(required = false, value = "involvedCancerStudies") Collection<String> involvedCancerStudies,
@ApiIgnore // prevent reference to this attribute in the swagger-ui interface. this attribute is needed for the @PreAuthorize tag above.
@Valid @RequestAttribute(required = false, value = "interceptedStudyViewFilter") StudyViewFilter interceptedStudyViewFilter
) {
return new ResponseEntity<>(
studyViewService.getMutatedGenesFromColumnstore(interceptedStudyViewFilter),
HttpStatus.OK
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.cbioportal.model.AlterationFilter;
import org.cbioportal.model.MolecularProfile;
import org.cbioportal.model.MolecularProfileCaseIdentifier;
Expand Down Expand Up @@ -132,7 +133,7 @@ public class InvolvedCancerStudyExtractorInterceptor extends HandlerInterceptorA
if (!request.getMethod().equals("POST")) {
return true; // no attribute extraction needed because all user supplied filter objects are in POST requests
}
String requestPathInfo = request.getPathInfo();
String requestPathInfo = StringUtils.removeStart(request.getPathInfo(), "/column-store");
if (requestPathInfo.equals(PATIENT_FETCH_PATH)) {
return extractAttributesFromPatientFilter(request);
} else if (requestPathInfo.equals(SAMPLE_FETCH_PATH)) {
Expand Down

0 comments on commit d6756a5

Please sign in to comment.