Search in sources :

Example 1 with CommentTopic

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;
}
Also used : SubmissionInsightDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO) Commentable(com.odysseusinc.arachne.portal.api.v1.dto.Commentable) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with CommentTopic

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;
}
Also used : SubmissionInsightDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO) Pageable(org.springframework.data.domain.Pageable) ArrayList(java.util.ArrayList) Commentable(com.odysseusinc.arachne.portal.api.v1.dto.Commentable) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with CommentTopic

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;
}
Also used : CommentTopicDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentTopicDTO) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with CommentTopic

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;
}
Also used : Comment(com.odysseusinc.arachne.portal.model.Comment) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException)

Example 5 with 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());
}
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) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) LinkedList(java.util.LinkedList)

Aggregations

CommentTopic (com.odysseusinc.arachne.portal.model.CommentTopic)9 SubmissionInsight (com.odysseusinc.arachne.portal.model.SubmissionInsight)5 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)3 Comment (com.odysseusinc.arachne.portal.model.Comment)3 SubmissionInsightSubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile)3 ApiOperation (io.swagger.annotations.ApiOperation)3 Date (java.util.Date)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Pageable (org.springframework.data.domain.Pageable)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 EntityGraphUtils (com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils)2 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)2 CommentTopicDTO (com.odysseusinc.arachne.portal.api.v1.dto.CommentTopicDTO)2 Commentable (com.odysseusinc.arachne.portal.api.v1.dto.Commentable)2 SubmissionInsightDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO)2 AlreadyExistException (com.odysseusinc.arachne.portal.exception.AlreadyExistException)2 ResultFile (com.odysseusinc.arachne.portal.model.ResultFile)2 Submission (com.odysseusinc.arachne.portal.model.Submission)2