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;
}
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;
}
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;
}
Aggregations