use of com.odysseusinc.arachne.portal.api.v1.dto.UpdateNotificationDTO in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method addParticipant.
@ApiOperation("Add participant to the study.")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/participants", method = POST)
public JsonResult<Boolean> addParticipant(Principal principal, @PathVariable("studyId") Long studyId, @RequestBody @Valid AddStudyParticipantDTO addParticipantDTO, BindingResult binding) throws PermissionDeniedException, NotExistException, AlreadyExistException {
JsonResult<Boolean> result;
if (binding.hasErrors()) {
return setValidationErrors(binding);
}
final IUser createdBy = getUser(principal);
IUser participant = Optional.ofNullable(userService.getByUuid(addParticipantDTO.getUserId())).orElseThrow(() -> new NotExistException(EX_USER_NOT_EXISTS, User.class));
UserStudy userStudy = studyService.addParticipant(createdBy, studyId, participant.getId(), addParticipantDTO.getRole());
wsTemplate.convertAndSendToUser(userStudy.getUser().getUsername(), "/topic/invitations", new UpdateNotificationDTO());
return new JsonResult<>(NO_ERROR, Boolean.TRUE);
}
use of com.odysseusinc.arachne.portal.api.v1.dto.UpdateNotificationDTO in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method sendUnlockRequest.
@ApiOperation("Send analysis unlock request")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/unlock-request", method = POST)
public JsonResult<FileDTO> sendUnlockRequest(Principal principal, @PathVariable("analysisId") Long analysisId, @RequestBody AnalysisUnlockRequestDTO analysisUnlockRequestDTO) throws NotExistException, PermissionDeniedException, AlreadyExistException {
JsonResult result;
final IUser user = getUser(principal);
final AnalysisUnlockRequest unlockRequest = new AnalysisUnlockRequest();
unlockRequest.setUser(user);
unlockRequest.setStatus(AnalysisUnlockRequestStatus.PENDING);
unlockRequest.setCreated(new Date());
unlockRequest.setToken(UUID.randomUUID().toString().replace("-", ""));
unlockRequest.setDescription(analysisUnlockRequestDTO.getDescription());
try {
final AnalysisUnlockRequest analysisUnlockRequest = analysisService.sendAnalysisUnlockRequest(analysisId, unlockRequest);
analysisService.findLeads((T) analysisUnlockRequest.getAnalysis()).forEach(lead -> wsTemplate.convertAndSendToUser(lead.getUsername(), "/topic/invitations", new UpdateNotificationDTO()));
result = new JsonResult<>(NO_ERROR);
} catch (AlreadyExistException ex) {
result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage("Unlock request for the analysis was already created");
}
return result;
}
Aggregations