Search in sources :

Example 1 with UserProfileDTO

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

the class BaseExpertFinderController method viewProfile.

@ApiOperation("View user profile.")
@RequestMapping(value = "/api/v1/user-management/users/{userId}/profile", method = GET)
public JsonResult<UserProfileDTO> viewProfile(Principal principal, @PathVariable("userId") String userId) {
    IUser logginedUser = userService.getByEmail(principal.getName());
    JsonResult<UserProfileDTO> result;
    IUser user = userService.getByUuidAndInitializeCollections(userId);
    UserProfileDTO userProfileDTO = conversionService.convert(user, UserProfileDTO.class);
    userProfileDTO.setIsEditable(logginedUser.getUuid().equals(userId));
    result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
    result.setResult(userProfileDTO);
    return result;
}
Also used : UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) IUser(com.odysseusinc.arachne.portal.model.IUser) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with UserProfileDTO

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

the class BaseUserController method saveProfile.

@ApiOperation("Save user profile")
@RequestMapping(value = "/api/v1/user-management/users/profile", method = POST)
public JsonResult<UserProfileDTO> saveProfile(Principal principal, @RequestBody @Valid UserProfileGeneralDTO dto, BindingResult binding) throws IllegalAccessException, SolrServerException, IOException, NotExistException, NoSuchFieldException {
    JsonResult<UserProfileDTO> result;
    IUser owner = userService.getByEmail(principal.getName());
    if (binding.hasErrors()) {
        result = new JsonResult<>(VALIDATION_ERROR);
        for (FieldError fieldError : binding.getFieldErrors()) {
            result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
        }
    } else {
        U user = convertUserProfileGeneralDTO(dto);
        user.setId(owner.getId());
        user = userService.update(user);
        result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
        result.setResult(conversionService.convert(user, UserProfileDTO.class));
    }
    return result;
}
Also used : UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) IUser(com.odysseusinc.arachne.portal.model.IUser) FieldError(org.springframework.validation.FieldError) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with UserProfileDTO

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

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

the class BaseUserController method invitationAcceptViaMail.

@ApiOperation("Accept invitations via mail.")
@RequestMapping(value = "/api/v1/user-management/users/invitations/mail", method = GET)
public JsonResult<UserProfileDTO> invitationAcceptViaMail(@RequestParam("id") Long id, @RequestParam("accepted") Boolean accepted, @RequestParam("type") String type, @RequestParam("token") String token, @RequestParam(value = "userId", required = false) Long userId, HttpServletResponse response) throws NotExistException, AlreadyExistException, IOException {
    InvitationActionWithTokenDTO dto = new InvitationActionWithTokenDTO(id, type, accepted, token);
    String redirectLink;
    U user;
    try {
        user = getUserFromInvitationDto(dto, userId);
        redirectLink = getRedirectLinkFromInvitationDto(dto, id, token);
    } catch (NotExistException ex) {
        JsonResult result = new JsonResult<>(VALIDATION_ERROR);
        result.setErrorMessage(ex.getMessage());
        response.sendRedirect(INVITATION_HOME_PAGE);
        return result;
    }
    response.sendRedirect(redirectLink);
    return invitationAccept(dto, user);
}
Also used : InvitationActionWithTokenDTO(com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionWithTokenDTO) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with UserProfileDTO

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

the class SearchResultToExpertListSearchResultDTOConverter method buildContent.

protected List<UserProfileDTO> buildContent(SearchResult source) {
    List<UserProfileDTO> userProfileDTOList = new ArrayList<>();
    for (Object entity : source.getEntityList()) {
        User user = (User) entity;
        userProfileDTOList.add(conversionService.convert(user, UserProfileDTO.class));
    }
    return userProfileDTOList;
}
Also used : User(com.odysseusinc.arachne.portal.model.User) UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) ArrayList(java.util.ArrayList)

Aggregations

UserProfileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO)11 ApiOperation (io.swagger.annotations.ApiOperation)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 FieldError (org.springframework.validation.FieldError)3 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)2 SkillDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO)2 IUser (com.odysseusinc.arachne.portal.model.IUser)2 Skill (com.odysseusinc.arachne.portal.model.Skill)2 User (com.odysseusinc.arachne.portal.model.User)2 HashSet (java.util.HashSet)2 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)1 InvitationActionWithTokenDTO (com.odysseusinc.arachne.portal.api.v1.dto.InvitationActionWithTokenDTO)1 UserLinkDTO (com.odysseusinc.arachne.portal.api.v1.dto.UserLinkDTO)1 UserProfileGeneralDTO (com.odysseusinc.arachne.portal.api.v1.dto.UserProfileGeneralDTO)1 UserPublicationDTO (com.odysseusinc.arachne.portal.api.v1.dto.UserPublicationDTO)1 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1 UserLink (com.odysseusinc.arachne.portal.model.UserLink)1 UserPublication (com.odysseusinc.arachne.portal.model.UserPublication)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1