use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR 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.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method updateSubmissionInsight.
@ApiOperation("Update submission insight")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/insight", method = PUT)
public JsonResult<SubmissionInsightDTO> updateSubmissionInsight(@PathVariable("submissionId") Long submissionId, @RequestBody SubmissionInsightUpdateDTO insightDTO) throws NotExistException {
final SubmissionInsight insight = conversionService.convert(insightDTO, SubmissionInsight.class);
final SubmissionInsight updatedInsight = submissionInsightService.updateSubmissionInsight(submissionId, insight);
final SubmissionInsightDTO updatedInsightDTO = conversionService.convert(updatedInsight, SubmissionInsightDTO.class);
final JsonResult<SubmissionInsightDTO> result = new JsonResult<>(NO_ERROR);
result.setResult(updatedInsightDTO);
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method putFileContent.
@ApiOperation("Write content of the code file.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/code-files/{fileUuid}", method = PUT)
public JsonResult<Boolean> putFileContent(Principal principal, @RequestBody FileDTO fileContentDTO, @PathVariable("analysisId") Long analysisId, @PathVariable("fileUuid") String uuid) throws PermissionDeniedException, NotExistException, IOException, URISyntaxException {
final IUser user = getUser(principal);
AnalysisFile analysisFile = analysisService.getAnalysisFile(analysisId, uuid);
analysisService.writeToFile(analysisFile, fileContentDTO, user);
JsonResult<Boolean> result = new JsonResult<>(NO_ERROR);
result.setResult(Boolean.TRUE);
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method get.
@ApiOperation("Get analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}", method = GET)
public JsonResult<D> get(@PathVariable("analysisId") Long id) throws NotExistException, PermissionDeniedException {
JsonResult<D> result;
T analysis = analysisService.getById(id);
result = new JsonResult<>(NO_ERROR);
D analysisDTO = conversionService.convert(analysis, getAnalysisDTOClass());
result.setResult(analysisDTO);
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseDataSourceController method suggestDataSource.
@RequestMapping(value = "/api/v1/data-sources/search-data-source", method = RequestMethod.GET)
public JsonResult<Page<DS_DTO>> suggestDataSource(Principal principal, @RequestParam("studyId") Long studyId, @RequestParam("query") String query, @ModelAttribute PageDTO pageDTO) throws PermissionDeniedException {
if (studyId == null || query == null) {
throw new javax.validation.ValidationException();
}
final IUser user = getUser(principal);
PageRequest pageRequest = getPageRequest(pageDTO);
Page<DS> dataSources = dataSourceService.suggestDataSource(query, studyId, user.getId(), pageRequest);
List<DS_DTO> dataSourceDTOs = converterUtils.convertList(dataSources.getContent(), getDataSourceDTOClass());
CustomPageImpl<DS_DTO> resultPage = new CustomPageImpl<>(dataSourceDTOs, pageRequest, dataSources.getTotalElements());
return new JsonResult<>(NO_ERROR, resultPage);
}
Aggregations