Search in sources :

Example 31 with NO_ERROR

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);
}
Also used : DataNode(com.odysseusinc.arachne.portal.model.DataNode) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with 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);
}
Also used : ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) SubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO) ArachneFileMeta(com.odysseusinc.arachne.storage.model.ArachneFileMeta) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 33 with 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 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);
}
Also used : SubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) SubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionFile) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 34 with 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 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);
}
Also used : Submission(com.odysseusinc.arachne.portal.model.Submission) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) BaseSubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionDTO) ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) SubmissionStatusHistoryElementDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) CommonAnalysisExecutionStatusDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisExecutionStatusDTO) CreateSubmissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateSubmissionsDTO) SubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO) SubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO) BaseSubmissionAndAnalysisTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionAndAnalysisTypeDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 35 with 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 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);
}
Also used : PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) GET(org.springframework.web.bind.annotation.RequestMethod.GET) POST(org.springframework.web.bind.annotation.RequestMethod.POST) IUser(com.odysseusinc.arachne.portal.model.IUser) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) BaseSubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionDTO) ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) SubmissionStatusHistoryElementDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) CommonAnalysisExecutionStatusDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisExecutionStatusDTO) CreateSubmissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateSubmissionsDTO) SubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO) SubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO) BaseSubmissionAndAnalysisTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionAndAnalysisTypeDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)34 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)33 ApiOperation (io.swagger.annotations.ApiOperation)31 IUser (com.odysseusinc.arachne.portal.model.IUser)18 GET (org.springframework.web.bind.annotation.RequestMethod.GET)10 POST (org.springframework.web.bind.annotation.RequestMethod.POST)10 PUT (org.springframework.web.bind.annotation.RequestMethod.PUT)10 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)6 FileDTO (com.odysseusinc.arachne.portal.api.v1.dto.FileDTO)5 SubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)5 UploadFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO)5 AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)5 PERMISSION_DENIED (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.PERMISSION_DENIED)4 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)4 ResultFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO)4 SubmissionInsightDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO)4 SubmissionStatusHistoryElementDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO)4 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)4 DataNode (com.odysseusinc.arachne.portal.model.DataNode)4 Submission (com.odysseusinc.arachne.portal.model.Submission)4