Search in sources :

Example 16 with Submission

use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.

the class BaseSubmissionServiceImpl method getSubmissionArchiveChunk.

@Override
public Path getSubmissionArchiveChunk(Long id, String updatePassword, String fileName) throws FileNotFoundException {
    Path file;
    Submission submission = submissionRepository.findByIdAndUpdatePassword(id, updatePassword);
    if (submission != null) {
        file = analysisHelper.getSplittedFolder(submission.getSubmissionGroup()).resolve(fileName);
        if (Files.notExists(file)) {
            throw new FileNotFoundException();
        }
    } else {
        throw new FileNotFoundException();
    }
    return file;
}
Also used : Path(java.nio.file.Path) Submission(com.odysseusinc.arachne.portal.model.Submission) FileNotFoundException(java.io.FileNotFoundException)

Example 17 with Submission

use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.

the class BaseSubmissionServiceImpl method createResultFilesBatch.

@Override
@Transactional
public List<ResultFile> createResultFilesBatch(List<FileSaveRequest> fileSaveRequests, Submission submission, Long createById) throws IOException {
    fileSaveRequests.forEach(entry -> entry.setDestinationFilepath(contentStorageHelper.getResultFilesDir(submission, entry.getDestinationFilepath())));
    List<ArachneFileMeta> metaList = contentStorageService.saveBatch(fileSaveRequests, createById);
    return metaList.stream().map(fm -> {
        ResultFile resultFile = new ResultFile();
        resultFile.setSubmission(submission);
        resultFile.setPath(fm.getPath());
        return resultFile;
    }).collect(Collectors.toList());
}
Also used : Arrays(java.util.Arrays) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) FileSaveRequest(com.odysseusinc.arachne.storage.util.FileSaveRequest) FAILED_PUBLISHED(com.odysseusinc.arachne.portal.model.SubmissionStatus.FAILED_PUBLISHED) BaseDataSourceService(com.odysseusinc.arachne.portal.service.BaseDataSourceService) Analysis(com.odysseusinc.arachne.portal.model.Analysis) Map(java.util.Map) Sort(org.springframework.data.domain.Sort) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) Path(java.nio.file.Path) SubmissionStatusHistoryElement(com.odysseusinc.arachne.portal.model.SubmissionStatusHistoryElement) SubmissionHelper(com.odysseusinc.arachne.portal.util.SubmissionHelper) EXECUTE(com.odysseusinc.arachne.portal.service.impl.submission.SubmissionActionType.EXECUTE) ArachneMailSender(com.odysseusinc.arachne.portal.service.mail.ArachneMailSender) BaseSubmissionRepository(com.odysseusinc.arachne.portal.repository.submission.BaseSubmissionRepository) Transactional(javax.transaction.Transactional) SubmissionGroupRepository(com.odysseusinc.arachne.portal.repository.SubmissionGroupRepository) Set(java.util.Set) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) IUser(com.odysseusinc.arachne.portal.model.IUser) SubmissionInsightRepository(com.odysseusinc.arachne.portal.repository.SubmissionInsightRepository) SimpMessagingTemplate(org.springframework.messaging.simp.SimpMessagingTemplate) Stream(java.util.stream.Stream) CollectionUtils(org.springframework.util.CollectionUtils) SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) ZipOutputStream(java.util.zip.ZipOutputStream) PENDING(com.odysseusinc.arachne.portal.model.SubmissionStatus.PENDING) FAILED_REJECTED(com.odysseusinc.arachne.portal.model.SubmissionStatus.FAILED_REJECTED) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) InvitationApprovalSubmissionArachneMailMessage(com.odysseusinc.arachne.portal.service.mail.InvitationApprovalSubmissionArachneMailMessage) ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) ZipUtil(com.odysseusinc.arachne.portal.util.ZipUtil) UserService(com.odysseusinc.arachne.portal.service.UserService) SubmissionFileRepository(com.odysseusinc.arachne.portal.repository.SubmissionFileRepository) Files(java.nio.file.Files) SubmissionGroupSpecification(com.odysseusinc.arachne.portal.model.search.SubmissionGroupSpecification) IOException(java.io.IOException) EntityManager(javax.persistence.EntityManager) DataNodeUtils(com.odysseusinc.arachne.portal.util.DataNodeUtils) File(java.io.File) ContentStorageHelper(com.odysseusinc.arachne.portal.util.ContentStorageHelper) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) QuerySpec(com.odysseusinc.arachne.storage.model.QuerySpec) Paths(java.nio.file.Paths) FAILED(com.odysseusinc.arachne.portal.model.SubmissionStatus.FAILED) PUBLISH(com.odysseusinc.arachne.portal.service.impl.submission.SubmissionActionType.PUBLISH) DataNodeUtils.isDataNodeOwner(com.odysseusinc.arachne.portal.util.DataNodeUtils.isDataNodeOwner) UpdateNotificationDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateNotificationDTO) AnalysisHelper(com.odysseusinc.arachne.portal.util.AnalysisHelper) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) EXECUTED_PUBLISHED(com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED_PUBLISHED) IDataSource(com.odysseusinc.arachne.portal.model.IDataSource) ResultFileSearch(com.odysseusinc.arachne.portal.model.search.ResultFileSearch) SubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionFile) SubmissionStatusHistoryRepository(com.odysseusinc.arachne.portal.repository.SubmissionStatusHistoryRepository) BaseSubmissionService(com.odysseusinc.arachne.portal.service.submission.BaseSubmissionService) ContentStorageService(com.odysseusinc.arachne.storage.service.ContentStorageService) ArachneFileMeta(com.odysseusinc.arachne.storage.model.ArachneFileMeta) PostAuthorize(org.springframework.security.access.prepost.PostAuthorize) UUIDGenerator(com.odysseusinc.arachne.portal.util.UUIDGenerator) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) Objects(java.util.Objects) SubmissionSpecification(com.odysseusinc.arachne.portal.model.search.SubmissionSpecification) List(java.util.List) Optional(java.util.Optional) SubmissionActionType(com.odysseusinc.arachne.portal.service.impl.submission.SubmissionActionType) NOT_APPROVED(com.odysseusinc.arachne.portal.model.SubmissionStatus.NOT_APPROVED) EntityGraph(com.cosium.spring.data.jpa.entity.graph.domain.EntityGraph) SubmissionStatus.valueOf(com.odysseusinc.arachne.portal.model.SubmissionStatus.valueOf) DigestUtils(org.springframework.util.DigestUtils) EntityGraphUtils(com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils) LegacyAnalysisHelper(com.odysseusinc.arachne.portal.util.LegacyAnalysisHelper) Submission(com.odysseusinc.arachne.portal.model.Submission) SubmissionGroupSearch(com.odysseusinc.arachne.portal.model.search.SubmissionGroupSearch) ResultFileRepository(com.odysseusinc.arachne.portal.repository.ResultFileRepository) ValidationException(com.odysseusinc.arachne.portal.exception.ValidationException) EXECUTED_REJECTED(com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED_REJECTED) NoExecutableFileException(com.odysseusinc.arachne.portal.exception.NoExecutableFileException) ObjectUtils(org.apache.commons.lang3.ObjectUtils) EXECUTED(com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED) UserDetails(org.springframework.security.core.userdetails.UserDetails) LinkedList(java.util.LinkedList) OutputStream(java.io.OutputStream) Logger(org.slf4j.Logger) SubmissionResultFileRepository(com.odysseusinc.arachne.portal.repository.SubmissionResultFileRepository) SequenceInputStream(java.io.SequenceInputStream) SubmissionAction(com.odysseusinc.arachne.portal.service.impl.submission.SubmissionAction) PermissionDeniedException(com.odysseusinc.arachne.portal.exception.PermissionDeniedException) WebSecurityConfig(com.odysseusinc.arachne.portal.config.WebSecurityConfig) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) EntityUtils(com.odysseusinc.arachne.portal.util.EntityUtils) MultipartFile(org.springframework.web.multipart.MultipartFile) IN_PROGRESS(com.odysseusinc.arachne.portal.model.SubmissionStatus.IN_PROGRESS) SubmissionGroup(com.odysseusinc.arachne.portal.model.SubmissionGroup) Collections(java.util.Collections) InputStream(java.io.InputStream) ArachneFileMeta(com.odysseusinc.arachne.storage.model.ArachneFileMeta) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) Transactional(javax.transaction.Transactional)

Example 18 with Submission

use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.

the class BaseSubmissionServiceImpl method getSubmissionResultAllFiles.

@Override
public void getSubmissionResultAllFiles(IUser user, Long analysisId, Long submissionId, String archiveName, OutputStream os) throws IOException, PermissionDeniedException {
    Submission submission = submissionRepository.findOne(submissionId);
    checkSubmissionPermission(user, submission);
    Path resultFilesPath = Paths.get(contentStorageHelper.getResultFilesDir(submission));
    try (ZipOutputStream zos = new ZipOutputStream(os)) {
        for (ResultFile resultFile : submission.getResultFiles()) {
            Path relativePath = resultFilesPath.relativize(Paths.get(resultFile.getPath()));
            ZipUtil.addZipEntry(zos, relativePath.toString(), contentStorageService.getContentByFilepath(resultFile.getPath()));
        }
    }
}
Also used : Path(java.nio.file.Path) Submission(com.odysseusinc.arachne.portal.model.Submission) ZipOutputStream(java.util.zip.ZipOutputStream) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile)

Example 19 with Submission

use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.

the class AnalysisSubmissionControllerTests method getResultFilePath.

/*private void prepareResultFile(Long studyId, Long analysisId, Long submissionGroupId, Long submissionId) throws IOException {

        Path dir = Paths.get(analysisHelper.getStoreFilesPath(), studyId.toString(), analysisId.toString(), "sg_" + submissionGroupId, submissionId.toString(), AnalysisPaths.RESULT_DIR);
        Files.createDirectories(dir);
        Path path = dir.resolve("9934135d-07f0-4c6a-afd2-b705a1c8d948");
        Files.write(path, "SELECT * FROM death LIMIT 10".getBytes());
    }*/
private String getResultFilePath(Long submissionId) {
    Submission submission = new Submission();
    submission.setId(submissionId);
    return contentStorageHelper.getResultFilesDir(submission, "test.sql");
}
Also used : Submission(com.odysseusinc.arachne.portal.model.Submission)

Example 20 with Submission

use of com.odysseusinc.arachne.portal.model.Submission 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)

Aggregations

Submission (com.odysseusinc.arachne.portal.model.Submission)21 LinkedList (java.util.LinkedList)8 List (java.util.List)8 ResultFile (com.odysseusinc.arachne.portal.model.ResultFile)7 ApiOperation (io.swagger.annotations.ApiOperation)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 Analysis (com.odysseusinc.arachne.portal.model.Analysis)6 IUser (com.odysseusinc.arachne.portal.model.IUser)6 Collectors (java.util.stream.Collectors)6 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)5 SubmissionStatus (com.odysseusinc.arachne.portal.model.SubmissionStatus)5 Date (java.util.Date)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)4 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)4 SubmissionDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO)4 SubmissionStatusHistoryElementDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO)4 SubmissionStatusHistoryElement (com.odysseusinc.arachne.portal.model.SubmissionStatusHistoryElement)4 Path (java.nio.file.Path)4