use of com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile in project ArachneCentralAPI by OHDSI.
the class SubmissionInsightSubmissionFileToCommentableSubmissionFileDTOConverter method convert.
@Override
public CommentableSubmissionFileDTO convert(SubmissionInsightSubmissionFile submissionInsightSubmissionFile) {
final CommentableSubmissionFileDTO dto = new CommentableSubmissionFileDTO();
final SubmissionFile submissionFile = submissionInsightSubmissionFile.getSubmissionFile();
dto.setLabel(submissionFile.getLabel());
dto.setUuid(submissionFile.getUuid());
dto.setName(submissionFile.getRealName());
dto.setCreated(submissionFile.getCreated());
dto.setCommentTopicId(submissionInsightSubmissionFile.getCommentTopic().getId());
dto.setCommentCount(submissionInsightSubmissionFile.getCommentTopic().getCount());
dto.setAuthor(conversionService.convert(submissionFile.getAuthor(), UserInfoDTO.class));
dto.setDocType(submissionInsightSubmissionFile.getSubmissionFile().getContentType());
dto.setFileId(submissionFile.getId());
return dto;
}
use of com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionInsightServiceImpl method extractCommentTopics.
private Set<CommentTopic> extractCommentTopics(SubmissionInsight insight) {
final Stream<CommentTopic> submissionFilesTopics = insight.getSubmissionInsightSubmissionFiles().stream().map(SubmissionInsightSubmissionFile::getCommentTopic);
final Submission submission = insight.getSubmission();
final Stream<CommentTopic> resultFileTopics = submission.getResultFiles().stream().map(ResultFile::getCommentTopic);
return Stream.concat(submissionFilesTopics, resultFileTopics).map(commentTopic -> {
commentTopic.setComments(new LinkedList<>());
return commentTopic;
}).collect(Collectors.toSet());
}
use of com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile in project ArachneCentralAPI by OHDSI.
the class BaseAdminServiceImpl method deleteSubmissionInsight.
private void deleteSubmissionInsight(SB submission) {
SubmissionInsight insight = submission.getSubmissionInsight();
if (insight == null) {
return;
}
List<SubmissionInsightSubmissionFile> submissionInsightSubmissionFiles = insight.getSubmissionInsightSubmissionFiles();
for (SubmissionInsightSubmissionFile link : submissionInsightSubmissionFiles) {
CommentTopic topic = link.getCommentTopic();
List<Comment> comments = topic.getComments();
commentService.deleteComments(comments);
commentService.deleteTopic(topic);
}
submissionInsightService.deleteSubmissionInsightSubmissionFileLinks(submissionInsightSubmissionFiles);
submissionInsightService.tryDeleteSubmissionInsight(insight.getId());
}
use of com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile in project ArachneCentralAPI by OHDSI.
the class BaseArachneSecureServiceImpl method getRolesByCommentTopic.
@Override
public List<ParticipantRole> getRolesByCommentTopic(ArachneUser user, CommentTopic topic) {
SubmissionInsightSubmissionFile submissionInsightLink = submissionInsightSubmissionFileRepository.findByCommentTopic(topic);
SubmissionInsight insight;
if (submissionInsightLink == null) {
ResultFile resultFile = resultFileRepository.findByCommentTopic(topic);
insight = resultFile.getSubmission().getSubmissionInsight();
} else {
insight = submissionInsightLink.getSubmissionInsight();
}
return getRolesByInsight(user, insight);
}
use of com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile 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;
}
Aggregations