Search in sources :

Example 11 with Submission

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

the class BaseSubmissionController method downloadSubmissionGroupFileBySubmission.

@ApiOperation("Download query file of the submission group by submission.")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/files/{fileId}/download", method = GET)
public void downloadSubmissionGroupFileBySubmission(@PathVariable("submissionId") Long submissionId, @PathVariable("fileId") Long fileId, HttpServletResponse response) throws PermissionDeniedException, NotExistException, IOException {
    Submission submission = submissionService.getSubmissionById(submissionId);
    downloadSubmissionGroupFile(submission.getSubmissionGroup().getId(), fileId, response);
}
Also used : Submission(com.odysseusinc.arachne.portal.model.Submission) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with Submission

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

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

the class BaseSubmissionController method downloadAllSubmissionResultFiles.

@ApiOperation("Download all result files of the submission.")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/results/all", method = GET)
public void downloadAllSubmissionResultFiles(Principal principal, @PathVariable("submissionId") Long submissionId, HttpServletResponse response) throws PermissionDeniedException, NotExistException, IOException {
    String archiveName = "submission_result_" + submissionId + "_" + Long.toString(System.currentTimeMillis()) + ".zip";
    String contentType = "application/zip, application/octet-stream";
    response.setContentType(contentType);
    response.setHeader("Content-type", contentType);
    response.setHeader("Content-Disposition", "attachment; filename=" + archiveName);
    Submission submission = submissionService.getSubmissionById(submissionId);
    IUser user = userService.getByEmail(principal.getName());
    submissionService.getSubmissionResultAllFiles(user, submission.getSubmissionGroup().getAnalysis().getId(), submissionId, archiveName, response.getOutputStream());
    response.flushBuffer();
}
Also used : Submission(com.odysseusinc.arachne.portal.model.Submission) IUser(com.odysseusinc.arachne.portal.model.IUser) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with Submission

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

the class BaseSubmissionInsightServiceImpl method createSubmissionInsight.

@Override
@PreAuthorize("hasPermission(#submissionId,  'Submission', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).EDIT_ANALYSIS)")
public SubmissionInsight createSubmissionInsight(Long submissionId, SubmissionInsight insight) throws AlreadyExistException, NotExistException {
    LOGGER.info(CREATING_INSIGHT_LOG, submissionId);
    final SubmissionInsight submissionInsight = submissionInsightRepository.findOneBySubmissionId(submissionId);
    if (submissionInsight != null) {
        final String message = String.format(INSIGHT_ALREADY_EXISTS_EXCEPTION, submissionId);
        throw new AlreadyExistException(message);
    }
    final List<SubmissionStatus> allowedStatuses = Arrays.asList(EXECUTED_PUBLISHED, FAILED_PUBLISHED);
    final Submission submission = submissionService.getSubmissionByIdAndStatus(submissionId, allowedStatuses);
    throwNotExistExceptionIfNull(submission, submissionId);
    insight.setId(null);
    insight.setCreated(new Date());
    insight.setSubmission(submission);
    final SubmissionInsight savedInsight = submissionInsightRepository.save(insight);
    final List<SubmissionInsightSubmissionFile> submissionInsightSubmissionFiles = submission.getSubmissionGroup().getFiles().stream().map(sf -> new SubmissionInsightSubmissionFile(savedInsight, sf, new CommentTopic())).collect(Collectors.toList());
    submissionInsightSubmissionFileRepository.save(submissionInsightSubmissionFiles);
    final List<ResultFile> resultFiles = submission.getResultFiles();
    resultFiles.forEach(resultFile -> resultFile.setCommentTopic(new CommentTopic()));
    submissionResultFileRepository.save(resultFiles);
    return savedInsight;
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) EntityGraphUtils(com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EXECUTED_PUBLISHED(com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED_PUBLISHED) Submission(com.odysseusinc.arachne.portal.model.Submission) FAILED_PUBLISHED(com.odysseusinc.arachne.portal.model.SubmissionStatus.FAILED_PUBLISHED) Map(java.util.Map) BigInteger(java.math.BigInteger) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) LinkedList(java.util.LinkedList) CommentService(com.odysseusinc.arachne.portal.service.CommentService) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) Logger(org.slf4j.Logger) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) SubmissionResultFileRepository(com.odysseusinc.arachne.portal.repository.SubmissionResultFileRepository) Set(java.util.Set) PostAuthorize(org.springframework.security.access.prepost.PostAuthorize) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) SubmissionInsightRepository(com.odysseusinc.arachne.portal.repository.SubmissionInsightRepository) SubmissionService(com.odysseusinc.arachne.portal.service.submission.SubmissionService) List(java.util.List) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) EntityUtils(com.odysseusinc.arachne.portal.util.EntityUtils) Stream(java.util.stream.Stream) SubmissionInsightService(com.odysseusinc.arachne.portal.service.submission.SubmissionInsightService) SubmissionInsightSubmissionFileRepository(com.odysseusinc.arachne.portal.repository.SubmissionInsightSubmissionFileRepository) SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) Submission(com.odysseusinc.arachne.portal.model.Submission) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) Date(java.util.Date) SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 15 with Submission

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

the class AnalysisHelper method createSubmission.

public static List<Submission> createSubmission(BaseSubmissionService submissionService, List<Long> datasourceIds, IUser user, Analysis analysis) throws IOException, NotExistException, NoExecutableFileException, ValidationException {
    final List<Submission> submissions = new LinkedList<>();
    // removes datasourceId duplicates
    Set<Long> datasourceIdSet = new HashSet<>(datasourceIds);
    SubmissionGroup submissionGroup = submissionService.createSubmissionGroup(user, analysis);
    for (Long datasourceId : datasourceIdSet) {
        submissions.add(submissionService.createSubmission(user, analysis, datasourceId, submissionGroup));
    }
    return submissions;
}
Also used : Submission(com.odysseusinc.arachne.portal.model.Submission) SubmissionGroup(com.odysseusinc.arachne.portal.model.SubmissionGroup) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

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