Search in sources :

Example 6 with UserProfileDTO

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

the class UserToUserProfileDTOConverter method convert.

@Override
public UserProfileDTO convert(IUser user) {
    UserProfileDTO dto = new UserProfileDTO();
    dto.setId(user.getUuid());
    dto.setEnabled(user.getEnabled());
    dto.setCreated(user.getCreated());
    dto.setUpdated(user.getUpdated());
    HashSet<SkillDTO> skills = new HashSet<>();
    for (Skill skill : user.getSkills()) {
        skills.add(conversionService.convert(skill, SkillDTO.class));
    }
    dto.setSkills(skills);
    LinkedList<UserPublicationDTO> publications = new LinkedList<>();
    for (UserPublication userPublication : user.getPublications()) {
        publications.add(conversionService.convert(userPublication, UserPublicationDTO.class));
    }
    dto.setPublications(publications);
    LinkedList<UserLinkDTO> links = new LinkedList<>();
    for (UserLink userLink : user.getLinks()) {
        links.add(conversionService.convert(userLink, UserLinkDTO.class));
    }
    dto.setLinks(links);
    dto.setGeneral(conversionService.convert(user, UserProfileGeneralDTO.class));
    return dto;
}
Also used : SkillDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO) UserLinkDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserLinkDTO) UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) LinkedList(java.util.LinkedList) UserPublication(com.odysseusinc.arachne.portal.model.UserPublication) UserLink(com.odysseusinc.arachne.portal.model.UserLink) Skill(com.odysseusinc.arachne.portal.model.Skill) UserProfileGeneralDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileGeneralDTO) UserPublicationDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserPublicationDTO) HashSet(java.util.HashSet)

Example 7 with UserProfileDTO

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

the class BaseUserController method addSkill.

@ApiOperation("Add skill to user profile.")
@RequestMapping(value = "/api/v1/user-management/users/skills/{skillId}", method = POST)
public JsonResult<UserProfileDTO> addSkill(Principal principal, @PathVariable("skillId") Long skillId) throws NotExistException, IllegalAccessException, SolrServerException, IOException, NoSuchFieldException {
    JsonResult<UserProfileDTO> result;
    U user = userService.getByEmail(principal.getName());
    user = userService.addSkillToUser(user.getId(), skillId);
    UserProfileDTO userProfileDTO = conversionService.convert(user, UserProfileDTO.class);
    result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
    result.setResult(userProfileDTO);
    return result;
}
Also used : UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with UserProfileDTO

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

the class BaseUserController method addLink.

@ApiOperation("Add link to user profile.")
@RequestMapping(value = "/api/v1/user-management/users/links", method = POST)
public JsonResult<UserProfileDTO> addLink(Principal principal, @Valid @RequestBody UserLinkDTO userLinkDTO, BindingResult binding) throws NotExistException, PermissionDeniedException, NotUniqueException {
    JsonResult<UserProfileDTO> result;
    if (binding.hasErrors()) {
        result = new JsonResult<>(VALIDATION_ERROR);
        for (FieldError fieldError : binding.getFieldErrors()) {
            result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
        }
    } else {
        U user = userService.getByEmail(principal.getName());
        user = userService.addLinkToUser(user.getId(), conversionService.convert(userLinkDTO, UserLink.class));
        UserProfileDTO userProfileDTO = conversionService.convert(user, UserProfileDTO.class);
        result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
        result.setResult(userProfileDTO);
    }
    return result;
}
Also used : UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) FieldError(org.springframework.validation.FieldError) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with UserProfileDTO

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

the class BaseUserController method removePublication.

@ApiOperation("Remove user's publication.")
@RequestMapping(value = "/api/v1/user-management/users/publications/{publicationId}", method = RequestMethod.DELETE)
public JsonResult<UserProfileDTO> removePublication(Principal principal, @PathVariable("publicationId") Long publicationId) throws NotExistException {
    JsonResult<UserProfileDTO> result;
    U user = userService.getByEmail(principal.getName());
    user = userService.removePublicationFromUser(user.getId(), publicationId);
    UserProfileDTO userProfileDTO = conversionService.convert(user, UserProfileDTO.class);
    result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
    result.setResult(userProfileDTO);
    return result;
}
Also used : UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with UserProfileDTO

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

the class BaseUserController method removeLink.

@ApiOperation("Remove link from user profile.")
@RequestMapping(value = "/api/v1/user-management/users/links/{linkId}", method = RequestMethod.DELETE)
public JsonResult<UserProfileDTO> removeLink(Principal principal, @PathVariable("linkId") Long linkId) throws NotExistException {
    JsonResult<UserProfileDTO> result;
    U user = userService.getByEmail(principal.getName());
    user = userService.removeLinkFromUser(user.getId(), linkId);
    UserProfileDTO userProfileDTO = conversionService.convert(user, UserProfileDTO.class);
    result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
    result.setResult(userProfileDTO);
    return result;
}
Also used : UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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