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