use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseUserController method linkUserToDataNode.
@ApiOperation("Link U to DataNode")
@RequestMapping(value = "/api/v1/user-management/datanodes/{datanodeSid}/users", method = POST)
public JsonResult linkUserToDataNode(@PathVariable("datanodeSid") Long datanodeId, @RequestBody CommonLinkUserToDataNodeDTO linkUserToDataNode) throws NotExistException, AlreadyExistException {
final DN dataNode = Optional.ofNullable(baseDataNodeService.getById(datanodeId)).orElseThrow(() -> new NotExistException(String.format(DATA_NODE_NOT_FOUND_EXCEPTION, datanodeId), DataNode.class));
final U user = userService.getByUnverifiedEmailInAnyTenant(linkUserToDataNode.getUserName());
baseDataNodeService.linkUserToDataNode(dataNode, user);
return new JsonResult(NO_ERROR);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method getResultFileInfo.
@ApiOperation("Get result file of the submission.")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/results/{fileUuid}", method = GET)
public JsonResult<ResultFileDTO> getResultFileInfo(Principal principal, @PathVariable("submissionId") Long submissionId, @RequestParam(defaultValue = "true") Boolean withContent, @PathVariable("fileUuid") String fileUuid) throws PermissionDeniedException, NotExistException, IOException {
ArachneFileMeta file = getResultFile(principal, submissionId, fileUuid);
String resultFilesPath = contentStorageHelper.getResultFilesDir(Submission.class, submissionId, null);
ResultFileDTO resultFileDTO = new ResultFileDTO(conversionService.convert(file, FileDTO.class));
resultFileDTO.setRelativePath(contentStorageHelper.getRelativePath(resultFilesPath, resultFileDTO.getPath()));
if (withContent) {
byte[] content = IOUtils.toByteArray(contentStorageService.getContentByFilepath(file.getPath()));
resultFileDTO = (ResultFileDTO) FileDtoContentHandler.getInstance(resultFileDTO, content).withPdfConverter(toPdfConverter::convert).handle();
}
return new JsonResult<>(NO_ERROR, resultFileDTO);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method getSubmissionGroupFileInfo.
@ApiOperation("Get query file of the submission group.")
@RequestMapping(value = "/api/v1/analysis-management/submission-groups/{submissionGroupId}/files/{fileId}", method = GET)
public JsonResult<SubmissionFileDTO> getSubmissionGroupFileInfo(@PathVariable("submissionGroupId") Long submissionGroupId, @PathVariable("fileId") Long fileId, @RequestParam(defaultValue = "true") Boolean withContent) throws NotExistException, IOException {
final SubmissionFile submissionFile = submissionService.getSubmissionFile(submissionGroupId, fileId);
SubmissionFileDTO fileDto = conversionService.convert(submissionFile, SubmissionFileDTO.class);
if (withContent) {
fileDto = (SubmissionFileDTO) FileDtoContentHandler.getInstance(fileDto, analysisService.getPath(submissionFile).toFile()).withPdfConverter(toPdfConverter::convert).handle();
}
return new JsonResult<>(NO_ERROR, fileDto);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method approveSubmissionResult.
@ApiOperation("Approve submission results for show to owner")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/approveresult", method = POST)
public JsonResult<DTO> approveSubmissionResult(Principal principal, @PathVariable("submissionId") Long submissionId, @RequestBody @Valid ApproveDTO approveDTO) throws PermissionDeniedException, NotExistException {
// ToDo remove after front will be changed
approveDTO.setIsSuccess(true);
Submission updatedSubmission = submissionService.approveSubmissionResult(submissionId, approveDTO, userService.getByEmail(principal.getName()));
DTO submissionDTO = conversionService.convert(updatedSubmission, getSubmissionDTOClass());
return new JsonResult<>(NO_ERROR, submissionDTO);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method approveSubmission.
@ApiOperation("Approve submission for execute")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/approve", method = POST)
public JsonResult<DTO> approveSubmission(Principal principal, @PathVariable("submissionId") Long id, @RequestBody @Valid ApproveDTO approveDTO) throws PermissionDeniedException, NotExistException, IOException {
Boolean isApproved = approveDTO.getIsApproved();
IUser user = getUser(principal);
T updatedSubmission = submissionService.approveSubmission(id, isApproved, approveDTO.getComment(), user);
DTO updatedSubmissionDTO = conversionService.convert(updatedSubmission, getSubmissionDTOClass());
return new JsonResult<>(NO_ERROR, updatedSubmissionDTO);
}
Aggregations