Search in sources :

Example 1 with SubmissionInsightDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO 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, new Sort(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) Sort(org.springframework.data.domain.Sort) 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 SubmissionInsightDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO 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 3 with SubmissionInsightDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO 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 = new PageRequest(0, size, new Sort(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, new Sort(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) 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) PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with SubmissionInsightDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO in project ArachneCentralAPI by OHDSI.

the class BaseSubmissionToSubmissionDTOConverter method insightDTO.

private SubmissionInsightDTO insightDTO(SubmissionInsight insight) {
    SubmissionInsightDTO insightDTO = null;
    if (insight != null) {
        insightDTO = new SubmissionInsightDTO();
        insightDTO.setName(insight.getName());
        insightDTO.setCreated(insight.getCreated());
    }
    return insightDTO;
}
Also used : SubmissionInsightDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO)

Example 5 with SubmissionInsightDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO in project ArachneCentralAPI by OHDSI.

the class SubmissionInsightToSubmissionInsightDTOConverter method convert.

@Override
public SubmissionInsightDTO convert(SubmissionInsight source) {
    final Submission submission = source.getSubmission();
    final SubmissionInsightDTO dto = new SubmissionInsightDTO();
    SubmissionDTO shortSubmissionDTO = new SubmissionDTO();
    shortSubmissionDTO.setId(submission.getId());
    shortSubmissionDTO.setCreatedAt(submission.getCreated());
    shortSubmissionDTO.setStatus(conversionService.convert(submission.getStatus(), SubmissionStatusDTO.class));
    shortSubmissionDTO.setAuthor(conversionService.convert(submission.getAuthor(), ShortUserDTO.class));
    dto.setCreated(source.getCreated());
    dto.setName(source.getName());
    dto.setDescription(source.getDescription());
    dto.setSubmission(shortSubmissionDTO);
    final List<Commentable> submissionFileDTOS = source.getSubmissionInsightSubmissionFiles().stream().map(submissionFile -> conversionService.convert(submissionFile, CommentableSubmissionFileDTO.class)).collect(Collectors.toList());
    dto.setCodeFiles(submissionFileDTOS);
    final List<Commentable> resultFileDTOS = submission.getResultFiles().stream().map(resultFile -> conversionService.convert(resultFile, CommentableResultFileDTO.class)).collect(Collectors.toList());
    dto.setResultFiles(resultFileDTOS);
    dto.setDataSource(conversionService.convert(submission.getDataSource(), DataSourceDTO.class));
    final AnalysisDTO analysisDTO = analysisConverter(source.getSubmission().getAnalysis());
    dto.setAnalysis(analysisDTO);
    dto.setCommentsCount(source.getCommentsCount());
    dto.setPermissions(conversionService.convert(source, PermissionsDTO.class));
    return dto;
}
Also used : SubmissionInsightDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO) AnalysisDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisDTO) Autowired(org.springframework.beans.factory.annotation.Autowired) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) CommentableSubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentableSubmissionFileDTO) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) Submission(com.odysseusinc.arachne.portal.model.Submission) Collectors(java.util.stream.Collectors) SubmissionStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusDTO) StudyShortDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyShortDTO) List(java.util.List) Component(org.springframework.stereotype.Component) ShortUserDTO(com.odysseusinc.arachne.portal.api.v1.dto.ShortUserDTO) SubmissionInsightDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO) Analysis(com.odysseusinc.arachne.portal.model.Analysis) BaseConversionServiceAwareConverter(com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter) Commentable(com.odysseusinc.arachne.portal.api.v1.dto.Commentable) CommentableResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentableResultFileDTO) SubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) Study(com.odysseusinc.arachne.portal.model.Study) DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) Submission(com.odysseusinc.arachne.portal.model.Submission) ShortUserDTO(com.odysseusinc.arachne.portal.api.v1.dto.ShortUserDTO) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) Commentable(com.odysseusinc.arachne.portal.api.v1.dto.Commentable) AnalysisDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisDTO) SubmissionStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusDTO) SubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO)

Aggregations

SubmissionInsightDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO)6 SubmissionInsight (com.odysseusinc.arachne.portal.model.SubmissionInsight)5 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 CommentTopic (com.odysseusinc.arachne.portal.model.CommentTopic)2 Sort (org.springframework.data.domain.Sort)2 AnalysisDTO (com.odysseusinc.arachne.portal.api.v1.dto.AnalysisDTO)1 CommentableResultFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.CommentableResultFileDTO)1 CommentableSubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.CommentableSubmissionFileDTO)1 DataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO)1 PermissionsDTO (com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO)1 ShortUserDTO (com.odysseusinc.arachne.portal.api.v1.dto.ShortUserDTO)1 StudyShortDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyShortDTO)1 SubmissionDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO)1 SubmissionStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusDTO)1 BaseConversionServiceAwareConverter (com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter)1 Analysis (com.odysseusinc.arachne.portal.model.Analysis)1 Study (com.odysseusinc.arachne.portal.model.Study)1