Search in sources :

Example 1 with InvitationActionDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionDTO 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 InvitationActionDTO

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

the class AnalysisLockingControllerTests method testProcessUnlockRequest.

@Test
@WithUserDetails(value = "user@mail.com")
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-with-contributor-and-leader-before.xml"), @DatabaseSetup("/data/analysis/analysis-after-locking.xml"), @DatabaseSetup("/data/analysis/analysis-unlock-requests-before-processing.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-with-contributor-and-leader-before.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-list.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-unlock-requests-after-processing.xml", assertionMode = NON_STRICT) })
public void testProcessUnlockRequest() throws Exception {
    InvitationActionDTO actionDTO = new InvitationActionDTO();
    actionDTO.setAccepted(true);
    actionDTO.setId(30L);
    actionDTO.setType(InvitationType.UNLOCK_ANALYSIS);
    mvc.perform(post("/api/v1/user-management/users/invitations").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(actionDTO))).andExpect(NO_ERROR_CODE);
}
Also used : InvitationActionDTO(com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 3 with InvitationActionDTO

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

the class StudyControllerTests method testInvitation.

public void testInvitation(Boolean accepted) throws Exception {
    InvitationActionDTO invitationActionDTO = new InvitationActionDTO();
    invitationActionDTO.setType(COLLABORATOR);
    invitationActionDTO.setAccepted(accepted);
    invitationActionDTO.setId(2L);
    mvc.perform(post("/api/v1/user-management/users/invitations/").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(invitationActionDTO))).andExpect(NO_ERROR_CODE).andExpect(jsonPath("$.result").isNotEmpty());
}
Also used : InvitationActionDTO(com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionDTO)

Aggregations

InvitationActionDTO (com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionDTO)2 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)1 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)1 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)1 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)1 UserProfileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO)1 Test (org.junit.Test)1 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)1