Search in sources :

Example 11 with UserProfileDTO

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

the class BaseUserController method addPublication.

@ApiOperation("Add user's publication.")
@RequestMapping(value = "/api/v1/user-management/users/publications", method = POST)
public JsonResult<UserProfileDTO> addPublication(Principal principal, @Valid @RequestBody UserPublicationDTO userPublicationDTO, 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.addPublicationToUser(user.getId(), conversionService.convert(userPublicationDTO, UserPublication.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 12 with UserProfileDTO

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

the class BaseUserController method removeSkill.

@ApiOperation("Remove skill from user profile.")
@RequestMapping(value = "/api/v1/user-management/users/skills/{skillId}", method = RequestMethod.DELETE)
public JsonResult<UserProfileDTO> removeSkill(Principal principal, @PathVariable("skillId") Long skillId) throws NotExistException, IllegalAccessException, SolrServerException, IOException, NoSuchFieldException {
    JsonResult<UserProfileDTO> result;
    U user = userService.getByEmail(principal.getName());
    user = userService.removeSkillFromUser(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 13 with UserProfileDTO

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

the class UserProfileDTOToUserConverter method convert.

@Override
public User convert(UserProfileDTO dto) {
    User user = new User();
    HashSet<Skill> skills = new HashSet<>();
    if (dto.getSkills() != null) {
        for (SkillDTO skillDTO : dto.getSkills()) {
            skills.add(conversionService.convert(skillDTO, Skill.class));
        }
    }
    user.setSkills(skills);
    return user;
}
Also used : Skill(com.odysseusinc.arachne.portal.model.Skill) User(com.odysseusinc.arachne.portal.model.User) SkillDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO) HashSet(java.util.HashSet)

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