Search in sources :

Example 1 with Submission

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

the class BaseSubmissionController method getStatusHistory.

@ApiOperation("Get status history of the submission")
@GetMapping("/api/v1/analysis-management/submissions/{submissionId}/status-history")
public JsonResult<List<SubmissionStatusHistoryElementDTO>> getStatusHistory(@PathVariable("submissionId") Long submissionId) throws NotExistException {
    Submission submission = submissionService.getSubmissionById(submissionId);
    List<SubmissionStatusHistoryElement> submissionStatusHistory = submissionService.getSubmissionStatusHistory(submission.getSubmissionGroup().getAnalysis().getId(), submissionId);
    List<SubmissionStatusHistoryElementDTO> convert = new LinkedList<>();
    for (SubmissionStatusHistoryElement submissionStatusHistoryElement : submissionStatusHistory) {
        convert.add(conversionService.convert(submissionStatusHistoryElement, SubmissionStatusHistoryElementDTO.class));
    }
    JsonResult<List<SubmissionStatusHistoryElementDTO>> result = new JsonResult<>(NO_ERROR);
    result.setResult(convert);
    return result;
}
Also used : SubmissionStatusHistoryElementDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO) Submission(com.odysseusinc.arachne.portal.model.Submission) SubmissionStatusHistoryElement(com.odysseusinc.arachne.portal.model.SubmissionStatusHistoryElement) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with Submission

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

the class BaseSubmissionController method getResultFile.

private ArachneFileMeta getResultFile(Principal principal, Long submissionId, String fileUuid) throws NotExistException, PermissionDeniedException {
    Submission submission = submissionService.getSubmissionById(submissionId);
    IUser user = userService.getByUsername(principal.getName());
    return submissionService.getResultFileAndCheckPermission(user, submission, submission.getSubmissionGroup().getAnalysis().getId(), fileUuid);
}
Also used : Submission(com.odysseusinc.arachne.portal.model.Submission) IUser(com.odysseusinc.arachne.portal.model.IUser)

Example 3 with Submission

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

the class BaseSubmissionController method createSubmission.

@ApiOperation("Create and send submission.")
@PostMapping("/api/v1/analysis-management/{analysisId}/submissions")
public JsonResult<List<DTO>> createSubmission(Principal principal, @RequestBody @Validated CreateSubmissionsDTO createSubmissionsDTO, @PathVariable("analysisId") Long analysisId) throws PermissionDeniedException, NotExistException, IOException, NoExecutableFileException, ValidationException {
    final JsonResult<List<DTO>> result;
    if (principal == null) {
        throw new PermissionDeniedException();
    }
    IUser user = userService.getByUsername(principal.getName());
    if (user == null) {
        throw new PermissionDeniedException();
    }
    Analysis analysis = analysisService.getById(analysisId);
    final List<Submission> submissions = AnalysisHelper.createSubmission(submissionService, createSubmissionsDTO.getDataSources(), user, analysis);
    final List<DTO> submissionDTOs = submissions.stream().map(s -> conversionService.convert(s, getSubmissionDTOClass())).collect(Collectors.toList());
    result = new JsonResult<>(NO_ERROR);
    result.setResult(submissionDTOs);
    return result;
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) AnalysisHelper(com.odysseusinc.arachne.portal.util.AnalysisHelper) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) Valid(javax.validation.Valid) ApiOperation(io.swagger.annotations.ApiOperation) PutMapping(org.springframework.web.bind.annotation.PutMapping) Analysis(com.odysseusinc.arachne.portal.model.Analysis) ResultFileSearch(com.odysseusinc.arachne.portal.model.search.ResultFileSearch) SubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionFile) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) 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) PostMapping(org.springframework.web.bind.annotation.PostMapping) 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) MediaType(org.springframework.http.MediaType) ArachneFileMeta(com.odysseusinc.arachne.storage.model.ArachneFileMeta) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) StandardCharsets(java.nio.charset.StandardCharsets) IUser(com.odysseusinc.arachne.portal.model.IUser) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) IOUtils(org.apache.commons.io.IOUtils) Principal(java.security.Principal) BaseSubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionDTO) SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) FilenameUtils(org.apache.commons.io.FilenameUtils) java.util(java.util) FileDtoContentHandler(com.odysseusinc.arachne.portal.api.v1.dto.converters.FileDtoContentHandler) ZipInputStream(java.util.zip.ZipInputStream) StringUtils.getFilename(org.springframework.util.StringUtils.getFilename) ArrayUtils(org.apache.commons.lang3.ArrayUtils) Submission(com.odysseusinc.arachne.portal.model.Submission) ValidationException(com.odysseusinc.arachne.portal.exception.ValidationException) 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) ZipUtil(com.odysseusinc.arachne.portal.util.ZipUtil) Files(com.google.common.io.Files) ObjectUtils(org.apache.commons.lang3.ObjectUtils) SubmissionStatusHistoryElementDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO) NO_ERROR(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR) GetMapping(org.springframework.web.bind.annotation.GetMapping) 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) HttpServletResponse(javax.servlet.http.HttpServletResponse) FileUtils(org.apache.commons.io.FileUtils) 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) File(java.io.File) 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) MultipartFile(org.springframework.web.multipart.MultipartFile) 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) Submission(com.odysseusinc.arachne.portal.model.Submission) Analysis(com.odysseusinc.arachne.portal.model.Analysis) IUser(com.odysseusinc.arachne.portal.model.IUser) PermissionDeniedException(com.odysseusinc.arachne.portal.exception.PermissionDeniedException) 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) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with Submission

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

the class ArachnePermissionEvaluator method addPermissions.

public boolean addPermissions(ArachneUser user, HasArachnePermissions hasPermissionsObj) {
    Set<ArachnePermission> allPermissions = getAllPermissions(hasPermissionsObj, user);
    hasPermissionsObj.setPermissions(allPermissions);
    if (hasPermissionsObj instanceof Analysis) {
        final Analysis analysis = (Analysis) hasPermissionsObj;
        final List<SubmissionGroup> submissionGroups = analysis.getSubmissionGroups();
        if (!CollectionUtils.isEmpty(submissionGroups)) {
            submissionGroups.forEach(submissionGroup -> submissionGroup.getSubmissions().forEach(submission -> {
                final Set<ArachnePermission> submissionPermissions = getAllPermissions(submission, user);
                submission.setPermissions(submissionPermissions);
            }));
        }
        final List<AnalysisFile> files = analysis.getFiles();
        if (!CollectionUtils.isEmpty(files)) {
            files.forEach(file -> {
                final Set<ArachnePermission> filePermissions = getAllPermissions(file, user);
                file.setPermissions(filePermissions);
            });
        }
    } else if (hasPermissionsObj instanceof Study) {
        final Study study = (Study) hasPermissionsObj;
        for (final Analysis analysis : study.getAnalyses()) {
            analysis.setPermissions(getAllPermissions(analysis, user));
        }
    }
    return true;
}
Also used : Arrays(java.util.Arrays) PermissionDslPredicates(com.odysseusinc.arachne.portal.component.PermissionDslPredicates) AnalysisPredicates.analysisAuthorIs(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.AnalysisPredicates.analysisAuthorIs) DomainObjectLoaderFactory(com.odysseusinc.arachne.portal.service.domain.DomainObjectLoaderFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Paper(com.odysseusinc.arachne.portal.model.Paper) IDataSource(com.odysseusinc.arachne.portal.model.IDataSource) BaseArachneSecureService(com.odysseusinc.arachne.portal.service.BaseArachneSecureService) Analysis(com.odysseusinc.arachne.portal.model.Analysis) Map(java.util.Map) DELETE_ANALYSIS_FILES(com.odysseusinc.arachne.portal.security.ArachnePermission.DELETE_ANALYSIS_FILES) User(com.odysseusinc.arachne.portal.model.User) AnalysisFilePredicates.analysisFileAuthorIs(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.AnalysisFilePredicates.analysisFileAuthorIs) PublishState(com.odysseusinc.arachne.portal.model.PublishState) Set(java.util.Set) DELETE_DATASOURCE(com.odysseusinc.arachne.portal.security.ArachnePermission.DELETE_DATASOURCE) RawUser(com.odysseusinc.arachne.portal.model.RawUser) Page(org.springframework.data.domain.Page) IUser(com.odysseusinc.arachne.portal.model.IUser) Serializable(java.io.Serializable) Objects(java.util.Objects) List(java.util.List) RawDataSource(com.odysseusinc.arachne.portal.model.RawDataSource) CollectionUtils(org.springframework.util.CollectionUtils) Authentication(org.springframework.security.core.Authentication) Study(com.odysseusinc.arachne.portal.model.Study) HashMap(java.util.HashMap) PermissionDsl.domainObject(com.odysseusinc.arachne.portal.component.PermissionDsl.domainObject) Organization(com.odysseusinc.arachne.portal.model.Organization) Submission(com.odysseusinc.arachne.portal.model.Submission) HashSet(java.util.HashSet) DataSource(com.odysseusinc.arachne.portal.model.DataSource) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole) ObjectUtils(org.apache.commons.lang3.ObjectUtils) ArachneUser(com.odysseusinc.arachne.portal.model.security.ArachneUser) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) LinkedList(java.util.LinkedList) HasArachnePermissions(com.odysseusinc.arachne.portal.security.HasArachnePermissions) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) UserStudyGrouped(com.odysseusinc.arachne.portal.model.UserStudyGrouped) PermissionEvaluator(org.springframework.security.access.PermissionEvaluator) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) Component(org.springframework.stereotype.Component) DataNode(com.odysseusinc.arachne.portal.model.DataNode) PermissionDslPredicates.hasRole(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.hasRole) PermissionDslPredicates.instanceOf(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.instanceOf) SubmissionGroup(com.odysseusinc.arachne.portal.model.SubmissionGroup) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission) Collections(java.util.Collections) Study(com.odysseusinc.arachne.portal.model.Study) Set(java.util.Set) HashSet(java.util.HashSet) SubmissionGroup(com.odysseusinc.arachne.portal.model.SubmissionGroup) Analysis(com.odysseusinc.arachne.portal.model.Analysis) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission)

Example 5 with Submission

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

the class BaseSubmissionServiceImpl method getResultFiles.

@Override
public List<ArachneFileMeta> getResultFiles(IUser user, Long submissionId, ResultFileSearch resultFileSearch) throws PermissionDeniedException {
    Submission submission = submissionRepository.findById(submissionId, EntityUtils.fromAttributePaths("dataSource", "dataSource.dataNode")).get();
    checkSubmissionPermission(user, submission);
    String resultFilesPath = contentStorageHelper.getResultFilesDir(submission, resultFileSearch.getPath());
    QuerySpec querySpec = new QuerySpec();
    querySpec.setName(resultFileSearch.getRealName());
    querySpec.setPath(resultFilesPath);
    return contentStorageService.searchFiles(querySpec);
}
Also used : Submission(com.odysseusinc.arachne.portal.model.Submission) QuerySpec(com.odysseusinc.arachne.storage.model.QuerySpec)

Aggregations

Submission (com.odysseusinc.arachne.portal.model.Submission)22 IUser (com.odysseusinc.arachne.portal.model.IUser)8 ResultFile (com.odysseusinc.arachne.portal.model.ResultFile)7 ApiOperation (io.swagger.annotations.ApiOperation)7 Analysis (com.odysseusinc.arachne.portal.model.Analysis)6 Collectors (java.util.stream.Collectors)6 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)5 SubmissionStatus (com.odysseusinc.arachne.portal.model.SubmissionStatus)5 Path (java.nio.file.Path)5 LinkedList (java.util.LinkedList)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 GetMapping (org.springframework.web.bind.annotation.GetMapping)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 SubmissionInsightService (com.odysseusinc.arachne.portal.service.submission.SubmissionInsightService)4 CommonAnalysisExecutionStatusDTO (com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisExecutionStatusDTO)3