use of com.odysseusinc.arachne.portal.model.CommentTopic in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method getSubmissionInsight.
@ApiOperation("Get submission insight")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/insight", method = GET)
public JsonResult<SubmissionInsightDTO> getSubmissionInsight(@PathVariable("submissionId") Long submissionId, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "order", required = false) Sort.Direction order) throws NotExistException {
if (size == null) {
size = Integer.MAX_VALUE;
}
if (order == null) {
order = Sort.Direction.ASC;
}
final SubmissionInsight insight = submissionInsightService.getSubmissionInsight(submissionId);
final SubmissionInsightDTO insightDTO = conversionService.convert(insight, SubmissionInsightDTO.class);
final Set<CommentTopic> recentTopics = submissionInsightService.getInsightComments(insight, size, Sort.by(order, "id"));
final List<Commentable> recentCommentables = getRecentCommentables(conversionService, recentTopics, insightDTO);
insightDTO.setRecentCommentEntities(recentCommentables);
final JsonResult<SubmissionInsightDTO> result = new JsonResult<>(NO_ERROR);
result.setResult(insightDTO);
return result;
}
use of com.odysseusinc.arachne.portal.model.CommentTopic in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method getStudyInsights.
@ApiOperation("Get recent Insights of Study")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/insights", method = GET)
public List<SubmissionInsightDTO> getStudyInsights(@PathVariable("studyId") Long studyId, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "commentsPerInsight", required = false) Integer commentsPerInsight, @RequestParam(value = "order", required = false) Sort.Direction order) {
if (size == null) {
size = Integer.MAX_VALUE;
}
if (commentsPerInsight == null) {
commentsPerInsight = Integer.MAX_VALUE;
}
if (order == null) {
order = Sort.Direction.DESC;
}
List<SubmissionInsightDTO> submissionInsightDTOS = new ArrayList<>();
Pageable pageRequest = PageRequest.of(0, size, Sort.by(order, "created"));
final Page<SubmissionInsight> page = submissionInsightService.getInsightsByStudyId(studyId, pageRequest);
final List<SubmissionInsight> insights = page.getContent();
for (int i = 0; i < insights.size(); i++) {
final SubmissionInsight insight = insights.get(i);
final Set<CommentTopic> recentTopics = submissionInsightService.getInsightComments(insight, commentsPerInsight, Sort.by(Sort.Direction.DESC, "id"));
final SubmissionInsightDTO insightDTO = conversionService.convert(insight, SubmissionInsightDTO.class);
final List<Commentable> recentCommentables = getRecentCommentables(conversionService, recentTopics, insightDTO);
insightDTO.setRecentCommentEntities(recentCommentables);
submissionInsightDTOS.add(insightDTO);
}
if (LOG.isDebugEnabled()) {
submissionInsightDTOS.stream().forEach(submissionInsightDTO -> {
LOG.debug("+" + submissionInsightDTO.getName());
submissionInsightDTO.getRecentCommentEntities().stream().forEach(commentable -> {
LOG.debug("|+" + commentable.getName());
commentable.getTopic().getComments().stream().forEach(commentDTO -> {
LOG.debug(" |-" + commentDTO.getAuthor().getFirstname() + ":" + commentDTO.getDate() + ":" + commentDTO.getComment());
});
});
});
}
return submissionInsightDTOS;
}
use of com.odysseusinc.arachne.portal.model.CommentTopic in project ArachneCentralAPI by OHDSI.
the class CommentController method get.
@ApiOperation(value = "Get topic with all comments")
@RequestMapping(value = "/api/v1/comments/{topicId}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = RequestMethod.GET)
public JsonResult<CommentTopicDTO> get(@PathVariable("topicId") Long topicId) throws NotExistException {
final CommentTopic topic = commentService.getTopic(topicId);
JsonResult<CommentTopicDTO> result = new JsonResult<>(NO_ERROR);
result.setResult(conversionService.convert(topic, CommentTopicDTO.class));
return result;
}
use of com.odysseusinc.arachne.portal.model.CommentTopic in project ArachneCentralAPI by OHDSI.
the class CommentServiceImpl method getTopic.
// @Cacheable("comments") broken code here
@Override
public CommentTopic getTopic(Long id) throws NotExistException {
final CommentTopic commentTopic = commentTopicRepository.getOne(id);
if (commentTopic == null) {
final String message = String.format(TOPIC_NOT_EXIST_EXCEPTION, id);
throw new NotExistException(message, CommentTopic.class);
}
final List<Comment> comments = commentRepository.getAllByTopicIdAndParentIsNull(id);
comments.forEach(c -> Hibernate.initialize(c.getAuthor().getRoles()));
commentTopic.setComments(comments);
return commentTopic;
}
use of com.odysseusinc.arachne.portal.model.CommentTopic 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());
}
Aggregations