Search in sources :

Example 1 with ResultFileDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO 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 2 with ResultFileDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO in project ArachneCentralAPI by OHDSI.

the class BaseSubmissionController method getResultFiles.

@ApiOperation("Get result files of the submission.")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/results", method = GET)
public List<ResultFileDTO> getResultFiles(Principal principal, @PathVariable("submissionId") Long submissionId, @RequestParam(value = "path", required = false, defaultValue = "") String path, @RequestParam(value = "real-name", required = false) String realName) throws PermissionDeniedException, IOException {
    IUser user = userService.getByEmail(principal.getName());
    ResultFileSearch resultFileSearch = new ResultFileSearch();
    resultFileSearch.setPath(path);
    resultFileSearch.setRealName(realName);
    List<? extends ArachneFileMeta> resultFileList = submissionService.getResultFiles(user, submissionId, resultFileSearch);
    String resultFilesPath = contentStorageHelper.getResultFilesDir(Submission.class, submissionId, null);
    return resultFileList.stream().map(rf -> {
        ResultFileDTO rfDto = conversionService.convert(rf, ResultFileDTO.class);
        rfDto.setSubmissionId(submissionId);
        rfDto.setRelativePath(contentStorageHelper.getRelativePath(resultFilesPath, rfDto.getPath()));
        return rfDto;
    }).collect(Collectors.toList());
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) AnalysisHelper(com.odysseusinc.arachne.portal.util.AnalysisHelper) Date(java.util.Date) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) LoggerFactory(org.slf4j.LoggerFactory) Valid(javax.validation.Valid) ApiOperation(io.swagger.annotations.ApiOperation) Analysis(com.odysseusinc.arachne.portal.model.Analysis) ResultFileSearch(com.odysseusinc.arachne.portal.model.search.ResultFileSearch) SubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionFile) Path(java.nio.file.Path) SubmissionStatusHistoryElement(com.odysseusinc.arachne.portal.model.SubmissionStatusHistoryElement) ToPdfConverter(com.odysseusinc.arachne.portal.service.ToPdfConverter) BaseSubmissionService(com.odysseusinc.arachne.portal.service.submission.BaseSubmissionService) BaseAnalysisService(com.odysseusinc.arachne.portal.service.analysis.BaseAnalysisService) ContentStorageService(com.odysseusinc.arachne.storage.service.ContentStorageService) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) HttpUtils(com.odysseusinc.arachne.portal.util.HttpUtils) ArachneFileMeta(com.odysseusinc.arachne.storage.model.ArachneFileMeta) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) IUser(com.odysseusinc.arachne.portal.model.IUser) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Principal(java.security.Principal) BaseSubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionDTO) SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) FileDtoContentHandler(com.odysseusinc.arachne.portal.api.v1.dto.converters.FileDtoContentHandler) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) GET(org.springframework.web.bind.annotation.RequestMethod.GET) Submission(com.odysseusinc.arachne.portal.model.Submission) ValidationException(com.odysseusinc.arachne.portal.exception.ValidationException) ArrayList(java.util.ArrayList) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) RequestBody(org.springframework.web.bind.annotation.RequestBody) NoExecutableFileException(com.odysseusinc.arachne.portal.exception.NoExecutableFileException) ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) NO_ERROR(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR) SubmissionStatusHistoryElementDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO) POST(org.springframework.web.bind.annotation.RequestMethod.POST) LinkedList(java.util.LinkedList) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) BaseController(com.odysseusinc.arachne.portal.api.v1.controller.BaseController) Validated(org.springframework.validation.annotation.Validated) Logger(org.slf4j.Logger) DELETE(org.springframework.web.bind.annotation.RequestMethod.DELETE) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) 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) PermissionDeniedException(com.odysseusinc.arachne.portal.exception.PermissionDeniedException) ContentStorageHelper(com.odysseusinc.arachne.portal.util.ContentStorageHelper) HttpStatus(org.springframework.http.HttpStatus) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) SubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO) BaseSubmissionAndAnalysisTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionAndAnalysisTypeDTO) SubmissionInsightService(com.odysseusinc.arachne.portal.service.submission.SubmissionInsightService) StringUtils(org.springframework.util.StringUtils) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) IUser(com.odysseusinc.arachne.portal.model.IUser) ResultFileSearch(com.odysseusinc.arachne.portal.model.search.ResultFileSearch) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ResultFileDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO in project ArachneCentralAPI by OHDSI.

the class ArachneFileMetaToResultFileDTOConverter method convert.

@Override
public ResultFileDTO convert(ArachneFileMeta source) {
    FileDTO fileDTO = conversionService.convert(source, FileDTO.class);
    ResultFileDTO resultFileDTO = new ResultFileDTO(fileDTO);
    resultFileDTO.setManuallyUploaded(source.getCreatedBy() != null);
    return resultFileDTO;
}
Also used : FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO)

Aggregations

FileDTO (com.odysseusinc.arachne.portal.api.v1.dto.FileDTO)3 ResultFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO)3 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)2 SubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)2 UploadFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO)2 ArachneFileMeta (com.odysseusinc.arachne.storage.model.ArachneFileMeta)2 ApiOperation (io.swagger.annotations.ApiOperation)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 CommonAnalysisExecutionStatusDTO (com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisExecutionStatusDTO)1 NO_ERROR (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR)1 BaseController (com.odysseusinc.arachne.portal.api.v1.controller.BaseController)1 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)1 BaseSubmissionAndAnalysisTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionAndAnalysisTypeDTO)1 BaseSubmissionDTO (com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionDTO)1 CreateSubmissionsDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateSubmissionsDTO)1 SubmissionDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO)1 SubmissionStatusHistoryElementDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO)1 FileDtoContentHandler (com.odysseusinc.arachne.portal.api.v1.dto.converters.FileDtoContentHandler)1 NoExecutableFileException (com.odysseusinc.arachne.portal.exception.NoExecutableFileException)1 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1