use of com.odysseusinc.arachne.portal.api.v1.dto.AnalysisUnlockRequestDTO 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;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.AnalysisUnlockRequestDTO in project ArachneCentralAPI by OHDSI.
the class AnalysisLockingControllerTests method testUnlockRequest.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-with-contributor-and-leader-before.xml"), @DatabaseSetup("/data/analysis/analysis-after-locking.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-with-contributor-and-leader-before.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-after-locking.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-unlock-requests.xml", assertionMode = NON_STRICT) })
public void testUnlockRequest() throws Exception {
AnalysisUnlockRequestDTO requestDTO = new AnalysisUnlockRequestDTO();
requestDTO.setDescription("please unlock");
mvc.perform(post("/api/v1/analysis-management/analyses/{analysisId}/unlock-request", ANALYSIS_ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(requestDTO))).andExpect(NO_ERROR_CODE);
}
Aggregations