Search in sources :

Example 1 with SubmissionInsight

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

the class BaseAnalysisController method addSubmissionInsight.

@ApiOperation("Create submission insight")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/insight", method = POST)
public JsonResult<SubmissionInsightDTO> addSubmissionInsight(@PathVariable("submissionId") Long submissionId, @RequestBody @Valid SubmissionInsightDTO insightDTO) throws AlreadyExistException, NotExistException {
    final SubmissionInsight insight = conversionService.convert(insightDTO, SubmissionInsight.class);
    final SubmissionInsight savedInsight = submissionInsightService.createSubmissionInsight(submissionId, insight);
    final SubmissionInsightDTO savedInsightDTO = conversionService.convert(savedInsight, SubmissionInsightDTO.class);
    final JsonResult<SubmissionInsightDTO> result = new JsonResult<>(NO_ERROR);
    result.setResult(savedInsightDTO);
    return result;
}
Also used : SubmissionInsightDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO) 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 SubmissionInsight

use of com.odysseusinc.arachne.portal.model.SubmissionInsight 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 3 with SubmissionInsight

use of com.odysseusinc.arachne.portal.model.SubmissionInsight 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 4 with SubmissionInsight

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

the class BaseSubmissionInsightServiceImpl method updateSubmissionInsight.

@Override
@PreAuthorize("hasPermission(#submissionId, 'Submission', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).EDIT_INSIGHT)")
public SubmissionInsight updateSubmissionInsight(Long submissionId, SubmissionInsight insight) throws NotExistException {
    LOGGER.info(UPDATING_INSIGHT_LOG, submissionId);
    final SubmissionInsight exist = submissionInsightRepository.findOneBySubmissionId(submissionId);
    throwNotExistExceptionIfNull(exist, submissionId);
    if (insight.getName() != null) {
        exist.setName(insight.getName());
    }
    if (insight.getDescription() != null) {
        exist.setDescription(insight.getDescription());
    }
    return submissionInsightRepository.save(exist);
}
Also used : SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 5 with SubmissionInsight

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

the class BaseSubmissionInsightServiceImpl method getSubmissionInsight.

@Override
@PostAuthorize("@ArachnePermissionEvaluator.addPermissions(principal, returnObject )")
public SubmissionInsight getSubmissionInsight(Long submissionId) throws NotExistException {
    final SubmissionInsight insight = submissionInsightRepository.findOneBySubmissionId(submissionId);
    throwNotExistExceptionIfNull(insight, submissionId);
    return insight;
}
Also used : SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) PostAuthorize(org.springframework.security.access.prepost.PostAuthorize)

Aggregations

SubmissionInsight (com.odysseusinc.arachne.portal.model.SubmissionInsight)12 SubmissionInsightDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO)5 CommentTopic (com.odysseusinc.arachne.portal.model.CommentTopic)5 SubmissionInsightSubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile)4 ApiOperation (io.swagger.annotations.ApiOperation)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)3 Commentable (com.odysseusinc.arachne.portal.api.v1.dto.Commentable)3 ResultFile (com.odysseusinc.arachne.portal.model.ResultFile)3 Submission (com.odysseusinc.arachne.portal.model.Submission)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 PostAuthorize (org.springframework.security.access.prepost.PostAuthorize)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 EntityGraphUtils (com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils)2 AlreadyExistException (com.odysseusinc.arachne.portal.exception.AlreadyExistException)2 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)2 SubmissionStatus (com.odysseusinc.arachne.portal.model.SubmissionStatus)2