Search in sources :

Example 1 with ApproveDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO in project ArachneCentralAPI by OHDSI.

the class BaseUserController method invitationAccept.

private JsonResult<UserProfileDTO> invitationAccept(InvitationActionDTO invitationActionDTO, U user) throws NotExistException, AlreadyExistException, IOException {
    checkIfUserExists(user);
    final Boolean invitationAccepted = invitationActionDTO.getAccepted();
    final Long invitationId = invitationActionDTO.getId();
    switch(invitationActionDTO.getType()) {
        case InvitationType.COLLABORATOR:
            {
                userService.processInvitation(user, invitationId, invitationAccepted, invitationActionDTO.getComment());
                break;
            }
        case InvitationType.DATA_OWNER:
            {
                studyService.processDataSourceInvitation(user, invitationId, invitationAccepted, invitationActionDTO.getComment());
                break;
            }
        case InvitationType.UNLOCK_ANALYSIS:
            {
                analysisService.processAnalysisUnlockRequest(user, invitationId, invitationAccepted);
                break;
            }
        case InvitationType.APPROVE_EXECUTE_SUBMISSION:
            submissionService.approveSubmission(invitationId, invitationAccepted, invitationActionDTO.getComment(), user);
            break;
        case InvitationType.APPROVE_PUBLISH_SUBMISSION:
            ApproveDTO dto = new ApproveDTO(invitationId, invitationAccepted, Boolean.TRUE, invitationActionDTO.getComment());
            submissionService.approveSubmissionResult(invitationId, dto, user);
            break;
        default:
            {
                throw new IllegalArgumentException();
            }
    }
    return new JsonResult<>(NO_ERROR, conversionService.convert(userService.getByIdInAnyTenantAndInitializeCollections(user.getId()), UserProfileDTO.class));
}
Also used : UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)

Example 2 with ApproveDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO in project ArachneCentralAPI by OHDSI.

the class AnalysisSubmissionControllerTests method testApproveSubmissionByNonOwner.

@Test
@WithUserDetails(DATA_NODE_USER)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-pending.xml") })
@ExpectedDatabase(value = "/data/analysis/submission/submission-pending.xml", assertionMode = NON_STRICT)
public void testApproveSubmissionByNonOwner() throws Exception {
    ApproveDTO approveDTO = new ApproveDTO(SUBMISSION_ID, true, null, null);
    prepareAnalysisFile(STUDY_ID, ANALYSIS_ID);
    prepareSubmissionGroupFile(STUDY_ID, ANALYSIS_ID, SUBMISSION_GROUP_ID);
    mvc.perform(post("/api/v1/analysis-management/submissions/{submissionId}/approve", 1).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(approveDTO))).andExpect(PERMISSION_DENIED_CODE);
}
Also used : ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails)

Example 3 with ApproveDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO in project ArachneCentralAPI by OHDSI.

the class AnalysisSubmissionControllerTests method testApproveSubmissionResultByNonOwner.

@Test
@WithUserDetails(STUDY_LEAD)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-executed.xml") })
@ExpectedDatabase(value = "/data/analysis/submission/submission-executed.xml", assertionMode = NON_STRICT)
public void testApproveSubmissionResultByNonOwner() throws Exception {
    ApproveDTO approveDTO = new ApproveDTO(SUBMISSION_ID, true, null, null);
    prepareAnalysisFile(STUDY_ID, ANALYSIS_ID);
    prepareSubmissionGroupFile(STUDY_ID, ANALYSIS_ID, SUBMISSION_GROUP_ID);
    mvc.perform(post("/api/v1/analysis-management/submissions/{submissionId}/approveresult", 1).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(approveDTO))).andExpect(PERMISSION_DENIED_CODE);
}
Also used : ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails)

Example 4 with ApproveDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO in project ArachneCentralAPI by OHDSI.

the class BaseSubmissionController method approveSubmissionResult.

@ApiOperation("Approve submission results for show to owner")
@PostMapping("/api/v1/analysis-management/submissions/{submissionId}/approveresult")
public JsonResult<DTO> approveSubmissionResult(Principal principal, @PathVariable("submissionId") Long submissionId, @RequestBody @Valid ApproveDTO approveDTO) throws PermissionDeniedException, NotExistException {
    // ToDo remove after front will be changed
    approveDTO.setIsSuccess(true);
    Submission updatedSubmission = submissionService.approveSubmissionResult(submissionId, approveDTO, userService.getByUsername(principal.getName()));
    DTO submissionDTO = conversionService.convert(updatedSubmission, getSubmissionDTOClass());
    return new JsonResult<>(NO_ERROR, submissionDTO);
}
Also used : Submission(com.odysseusinc.arachne.portal.model.Submission) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) BaseSubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionDTO) ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) SubmissionStatusHistoryElementDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) CommonAnalysisExecutionStatusDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisExecutionStatusDTO) CreateSubmissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateSubmissionsDTO) SubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO) SubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO) BaseSubmissionAndAnalysisTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionAndAnalysisTypeDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with ApproveDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO in project ArachneCentralAPI by OHDSI.

the class BaseSubmissionController method approveSubmission.

@ApiOperation("Approve submission for execute")
@PostMapping("/api/v1/analysis-management/submissions/{submissionId}/approve")
public JsonResult<DTO> approveSubmission(Principal principal, @PathVariable("submissionId") Long id, @RequestBody @Valid ApproveDTO approveDTO) throws PermissionDeniedException, NotExistException, IOException {
    Boolean isApproved = approveDTO.getIsApproved();
    IUser user = getUser(principal);
    T updatedSubmission = submissionService.approveSubmission(id, isApproved, approveDTO.getComment(), user);
    DTO updatedSubmissionDTO = conversionService.convert(updatedSubmission, getSubmissionDTOClass());
    return new JsonResult<>(NO_ERROR, updatedSubmissionDTO);
}
Also used : IUser(com.odysseusinc.arachne.portal.model.IUser) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) BaseSubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionDTO) ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) SubmissionStatusHistoryElementDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) CommonAnalysisExecutionStatusDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisExecutionStatusDTO) CreateSubmissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateSubmissionsDTO) SubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO) SubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO) BaseSubmissionAndAnalysisTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionAndAnalysisTypeDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)11 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)8 Test (org.junit.Test)8 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)8 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)6 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)3 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)2 CommonAnalysisExecutionStatusDTO (com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisExecutionStatusDTO)2 BaseSubmissionAndAnalysisTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionAndAnalysisTypeDTO)2 BaseSubmissionDTO (com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionDTO)2 CreateSubmissionsDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateSubmissionsDTO)2 FileDTO (com.odysseusinc.arachne.portal.api.v1.dto.FileDTO)2 ResultFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO)2 SubmissionDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO)2 SubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)2 SubmissionStatusHistoryElementDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO)2 UploadFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO)2 ApiOperation (io.swagger.annotations.ApiOperation)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 UserProfileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO)1