Search in sources :

Example 1 with SubmissionSpecification

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

the class BaseSubmissionServiceImpl method getSubmissionGroups.

@Override
@PreAuthorize("hasPermission(#submissoinGroupSearch.analysisId,  'Analysis', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).ACCESS_STUDY)")
@PostAuthorize("@ArachnePermissionEvaluator.addPermissionsToSubmissions(principal, returnObject )")
public Page<SubmissionGroup> getSubmissionGroups(SubmissionGroupSearch submissoinGroupSearch) {
    final SubmissionGroupSpecification submissionGroupSpecification = new SubmissionGroupSpecification(submissoinGroupSearch);
    final Integer page = submissoinGroupSearch.getPage();
    final PageRequest pageRequest = new PageRequest(page == null ? 0 : page - 1, submissoinGroupSearch.getPageSize(), new Sort(Sort.Direction.DESC, "created"));
    final Page<SubmissionGroup> submissionGroups = submissionGroupRepository.findAll(submissionGroupSpecification, pageRequest);
    final List<SubmissionGroup> content = submissionGroups.getContent();
    final Map<Long, SubmissionGroup> submissionGroupMap = content.stream().collect(Collectors.toMap(SubmissionGroup::getId, sg -> {
        sg.setSubmissions(new ArrayList<>());
        return sg;
    }));
    final Set<Long> submissionGroupIds = submissionGroupMap.keySet();
    if (!CollectionUtils.isEmpty(submissionGroupIds)) {
        final SubmissionSpecification<T> submissionSpecification = SubmissionSpecification.<T>builder(submissionGroupIds).withStatuses(submissoinGroupSearch.getSubmissionStatuses()).withDataSourceIds(submissoinGroupSearch.getDataSourceIds()).hasInsight(submissoinGroupSearch.getHasInsight()).showHidden(submissoinGroupSearch.getShowHidden()).build();
        submissionRepository.findAll(submissionSpecification).forEach(s -> submissionGroupMap.get(s.getSubmissionGroup().getId()).getSubmissions().add(s));
    }
    return submissionGroups;
}
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) SubmissionGroup(com.odysseusinc.arachne.portal.model.SubmissionGroup) ArrayList(java.util.ArrayList) PageRequest(org.springframework.data.domain.PageRequest) SubmissionGroupSpecification(com.odysseusinc.arachne.portal.model.search.SubmissionGroupSpecification) Sort(org.springframework.data.domain.Sort) PostAuthorize(org.springframework.security.access.prepost.PostAuthorize) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

EntityGraph (com.cosium.spring.data.jpa.entity.graph.domain.EntityGraph)1 EntityGraphUtils (com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils)1 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)1 UpdateNotificationDTO (com.odysseusinc.arachne.portal.api.v1.dto.UpdateNotificationDTO)1 WebSecurityConfig (com.odysseusinc.arachne.portal.config.WebSecurityConfig)1 NoExecutableFileException (com.odysseusinc.arachne.portal.exception.NoExecutableFileException)1 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1 PermissionDeniedException (com.odysseusinc.arachne.portal.exception.PermissionDeniedException)1 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)1 Analysis (com.odysseusinc.arachne.portal.model.Analysis)1 AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)1 IDataSource (com.odysseusinc.arachne.portal.model.IDataSource)1 IUser (com.odysseusinc.arachne.portal.model.IUser)1 ResultFile (com.odysseusinc.arachne.portal.model.ResultFile)1 Submission (com.odysseusinc.arachne.portal.model.Submission)1 SubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionFile)1 SubmissionGroup (com.odysseusinc.arachne.portal.model.SubmissionGroup)1 SubmissionStatus (com.odysseusinc.arachne.portal.model.SubmissionStatus)1 EXECUTED (com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED)1 EXECUTED_PUBLISHED (com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED_PUBLISHED)1