Search in sources :

Example 6 with SubmissionStatus

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

the class BaseSubmissionServiceImpl method changeSubmissionState.

@Override
public T changeSubmissionState(Long id, String status) {
    T submission = submissionRepository.findOne(id);
    SubmissionStatus submissionStatus = valueOf(status);
    List<SubmissionStatusHistoryElement> statusHistory = submission.getStatusHistory();
    statusHistory.add(new SubmissionStatusHistoryElement(new Date(), submissionStatus, null, submission, null));
    submission.setStatusHistory(statusHistory);
    return saveSubmission(submission);
}
Also used : SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) SubmissionStatusHistoryElement(com.odysseusinc.arachne.portal.model.SubmissionStatusHistoryElement) Date(java.util.Date)

Example 7 with SubmissionStatus

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

the class SubmissionStatusHistoryToSubmissionStatusHistoryDTOConverter method convert.

@Override
public SubmissionStatusHistoryElementDTO convert(SubmissionStatusHistoryElement source) {
    Date date = source.getDate();
    SubmissionStatus status = source.getStatus();
    SubmissionStatusDTO submissionStatusDTO = null;
    if (status != null) {
        submissionStatusDTO = new SubmissionStatusDTO(status);
    }
    IUser author = source.getAuthor();
    ShortUserDTO shortUser = null;
    if (author != null) {
        shortUser = conversionService.convert(author, ShortUserDTO.class);
    }
    return new SubmissionStatusHistoryElementDTO(date, submissionStatusDTO, shortUser, source.getComment());
}
Also used : SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) SubmissionStatusHistoryElementDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO) ShortUserDTO(com.odysseusinc.arachne.portal.api.v1.dto.ShortUserDTO) IUser(com.odysseusinc.arachne.portal.model.IUser) SubmissionStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusDTO) Date(java.util.Date)

Example 8 with SubmissionStatus

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

the class BaseSubmissionServiceImpl method createSubmission.

@Override
public T createSubmission(IUser user, A analysis, Long datasourceId, SubmissionGroup submissionGroup) throws NotExistException, IOException {
    DS dataSource = dataSourceService.getByIdUnsecured(datasourceId);
    T submission = newSubmission();
    submission.setAuthor(user);
    Date created = new Date();
    submission.setCreated(created);
    submission.setUpdated(created);
    submission.setAnalysis(analysis);
    submission.setDataSource(dataSource);
    SubmissionStatus status = calculateSubmissionStatusAccordingToDatasourceOwnership(dataSource, user);
    List<SubmissionStatusHistoryElement> statusHistory = new LinkedList<>();
    SubmissionStatusHistoryElement statusHistoryElement = new SubmissionStatusHistoryElement(created, status, user, submission, null);
    statusHistory.add(statusHistoryElement);
    submission.setStatusHistory(statusHistory);
    submission.setSubmissionGroup(submissionGroup);
    submission.setToken(UUIDGenerator.generateUUID());
    submission.setUpdatePassword(UUIDGenerator.generateUUID());
    beforeCreateSubmission(submission);
    submission = saveSubmissionAndFlush(submission);
    afterCreateSubmission(submission);
    return submission;
}
Also used : SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) SubmissionStatusHistoryElement(com.odysseusinc.arachne.portal.model.SubmissionStatusHistoryElement) Date(java.util.Date) LinkedList(java.util.LinkedList)

Example 9 with SubmissionStatus

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

the class BaseSubmissionServiceImpl method approveSubmission.

@Override
public T approveSubmission(Long submissionId, Boolean isApproved, String comment, IUser user) throws IOException, NotExistException {
    T submission = getSubmissionByIdAndStatus(submissionId, PENDING);
    SubmissionStatus status = getApproveForExecutionSubmissionStatus(submission, isApproved);
    submission = moveSubmissionToNewStatus(submission, status, user, comment);
    notifyOwnersAboutSubmissionUpdateViaSocket(submission);
    return submission;
}
Also used : SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus)

Example 10 with SubmissionStatus

use of com.odysseusinc.arachne.portal.model.SubmissionStatus 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.saveAll(submissionInsightSubmissionFiles);
    final List<ResultFile> resultFiles = submission.getResultFiles();
    resultFiles.forEach(resultFile -> resultFile.setCommentTopic(new CommentTopic()));
    submissionResultFileRepository.saveAll(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)

Aggregations

SubmissionStatus (com.odysseusinc.arachne.portal.model.SubmissionStatus)10 Date (java.util.Date)6 SubmissionStatusHistoryElement (com.odysseusinc.arachne.portal.model.SubmissionStatusHistoryElement)3 LinkedList (java.util.LinkedList)2 EntityGraphUtils (com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils)1 ShortUserDTO (com.odysseusinc.arachne.portal.api.v1.dto.ShortUserDTO)1 SubmissionStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusDTO)1 SubmissionStatusHistoryElementDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO)1 AlreadyExistException (com.odysseusinc.arachne.portal.exception.AlreadyExistException)1 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1 CommentTopic (com.odysseusinc.arachne.portal.model.CommentTopic)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 SubmissionInsight (com.odysseusinc.arachne.portal.model.SubmissionInsight)1 SubmissionInsightSubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile)1 EXECUTED_PUBLISHED (com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED_PUBLISHED)1 FAILED_PUBLISHED (com.odysseusinc.arachne.portal.model.SubmissionStatus.FAILED_PUBLISHED)1 SubmissionInsightRepository (com.odysseusinc.arachne.portal.repository.SubmissionInsightRepository)1 SubmissionInsightSubmissionFileRepository (com.odysseusinc.arachne.portal.repository.SubmissionInsightSubmissionFileRepository)1