Search in sources :

Example 1 with ActionDTO

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

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

the class InvitationableToInvitationDTOConverter method convert.

@Override
public InvitationDTO convert(Invitationable source) {
    final InvitationDTO invitationDTO = new InvitationDTO();
    final List<ActionDTO> actionList = Arrays.asList(new ActionDTO("Accept", "accept", "success"), new ActionDTO("Decline", "decline", "cancel"));
    invitationDTO.setActionList(actionList);
    invitationDTO.setType(source.getInvitationType());
    invitationDTO.setId(source.getId());
    invitationDTO.setActionType(source.getActionType());
    invitationDTO.setDate(source.getCreated());
    invitationDTO.setUser(conversionService.convert(source.getAuthor(), ShortUserDTO.class));
    final Object entity = source.getEntity();
    String title = "";
    Long id = null;
    if (entity instanceof Study) {
        final Study study = (Study) entity;
        title = study.getTitle();
        id = study.getId();
    } else if (entity instanceof Paper) {
        final Paper paper = (Paper) entity;
        title = paper.getStudy().getDescription();
        id = paper.getId();
    } else if (entity instanceof Analysis) {
        final Analysis analysis = (Analysis) entity;
        title = analysis.getTitle();
        id = analysis.getId();
    }
    final InvitationEntityDTO studyShortDTO = getInvitationEntityDTO(title, id);
    invitationDTO.setEntity(studyShortDTO);
    return invitationDTO;
}
Also used : Study(com.odysseusinc.arachne.portal.model.Study) ShortUserDTO(com.odysseusinc.arachne.portal.api.v1.dto.ShortUserDTO) Analysis(com.odysseusinc.arachne.portal.model.Analysis) InvitationDTO(com.odysseusinc.arachne.portal.api.v1.dto.InvitationDTO) Paper(com.odysseusinc.arachne.portal.model.Paper) ActionDTO(com.odysseusinc.arachne.portal.api.v1.dto.ActionDTO) InvitationEntityDTO(com.odysseusinc.arachne.portal.api.v1.dto.InvitationEntityDTO)

Aggregations

DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)1 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)1 ActionDTO (com.odysseusinc.arachne.portal.api.v1.dto.ActionDTO)1 InvitationActionDTO (com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionDTO)1 InvitationDTO (com.odysseusinc.arachne.portal.api.v1.dto.InvitationDTO)1 InvitationEntityDTO (com.odysseusinc.arachne.portal.api.v1.dto.InvitationEntityDTO)1 ShortUserDTO (com.odysseusinc.arachne.portal.api.v1.dto.ShortUserDTO)1 Analysis (com.odysseusinc.arachne.portal.model.Analysis)1 Paper (com.odysseusinc.arachne.portal.model.Paper)1 Study (com.odysseusinc.arachne.portal.model.Study)1 Test (org.junit.Test)1 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)1