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