Search in sources :

Example 1 with RefSetMemberRequestResolver

use of com.b2international.snowowl.snomed.core.rest.request.RefSetMemberRequestResolver in project snow-owl by b2ihealthcare.

the class SnomedReferenceSetMemberRestService method executeAction.

@Operation(summary = "Executes an action", description = "Executes an action specified via the request body on a reference set member." + "<p>Supported actions are:" + "&bull; 'sync' - Executes sync action on a query type member" + "&bull; 'create|update|delete' - allowed (mainly resolved and used in bulk requests), but in case of single member action use the dedicated endpoints instead" + "</p>")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "Action execution successful"), @ApiResponse(responseCode = "204", description = "No content"), @ApiResponse(responseCode = "404", description = "Branch or member not found") })
@PostMapping(value = "/{id}/actions", consumes = { AbstractRestService.JSON_MEDIA_TYPE }, produces = { AbstractRestService.JSON_MEDIA_TYPE })
@ResponseBody
public Object executeAction(@Parameter(description = "The resource path", required = true) @PathVariable(value = "path") final String path, @Parameter(description = "The reference set member identifier") @PathVariable(value = "id") final String memberId, @Parameter(description = "Reference set member action") @RequestBody final SnomedResourceRequest<RestRequest> body, @RequestHeader(value = X_AUTHOR, required = false) final String author) {
    final RequestResolver<TransactionContext> resolver = new RefSetMemberRequestResolver();
    final RestRequest change = body.getChange();
    final String commitComment = body.getCommitComment();
    final String defaultModuleId = body.getDefaultModuleId();
    change.setSource("memberId", memberId);
    return SnomedRequests.prepareCommit().setDefaultModuleId(defaultModuleId).setAuthor(author).setBody(change.resolve(resolver)).setCommitComment(commitComment).build(path).execute(getBus()).getSync();
}
Also used : RestRequest(com.b2international.snowowl.snomed.core.rest.request.RestRequest) TransactionContext(com.b2international.snowowl.core.domain.TransactionContext) RefSetMemberRequestResolver(com.b2international.snowowl.snomed.core.rest.request.RefSetMemberRequestResolver) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

TransactionContext (com.b2international.snowowl.core.domain.TransactionContext)1 RefSetMemberRequestResolver (com.b2international.snowowl.snomed.core.rest.request.RefSetMemberRequestResolver)1 RestRequest (com.b2international.snowowl.snomed.core.rest.request.RestRequest)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1