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);
}
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());
}
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;
}
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;
}
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;
}
Aggregations