Search in sources :

Example 1 with NO_ERROR

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR 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 NO_ERROR

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR 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 NO_ERROR

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.

the class BaseAnalysisController method getFileContent.

@ApiOperation("Get analysis code file.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/code-files/{fileUuid}", method = GET)
public JsonResult<AnalysisFileDTO> getFileContent(@PathVariable("analysisId") Long analysisId, @RequestParam(defaultValue = "true") Boolean withContent, @PathVariable("fileUuid") String uuid) throws PermissionDeniedException, NotExistException, IOException {
    AnalysisFile analysisFile = analysisService.getAnalysisFile(analysisId, uuid);
    AnalysisFileDTO analysisFileDTO = conversionService.convert(analysisFile, AnalysisFileDTO.class);
    if (withContent) {
        analysisFileDTO = (AnalysisFileDTO) FileDtoContentHandler.getInstance(analysisFileDTO, analysisService.getPath(analysisFile).toFile()).withPdfConverter(toPdfConverter::convert).handle();
    }
    return new JsonResult<>(NO_ERROR, analysisFileDTO);
}
Also used : AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) AnalysisFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO) 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 NO_ERROR

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.

the class BaseAnalysisController method update.

@ApiOperation("Update analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}", method = PUT)
public JsonResult<D> update(@PathVariable("analysisId") Long id, @RequestBody @Valid AnalysisUpdateDTO analysisDTO, BindingResult binding) throws NotExistException, NotUniqueException, ValidationException {
    JsonResult<D> result;
    if (binding.hasErrors()) {
        result = new JsonResult<>(VALIDATION_ERROR);
        for (FieldError fieldError : binding.getFieldErrors()) {
            result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
        }
    } else {
        T analysis = conversionService.convert(analysisDTO, getAnalysisClass());
        analysis.setId(id);
        analysis = analysisService.update(analysis);
        result = new JsonResult<>(NO_ERROR);
        result.setResult(conversionService.convert(analysis, getAnalysisDTOClass()));
    }
    return result;
}
Also used : PERMISSION_DENIED(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.PERMISSION_DENIED) UUID(java.util.UUID) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) GET(org.springframework.web.bind.annotation.RequestMethod.GET) POST(org.springframework.web.bind.annotation.RequestMethod.POST) FieldError(org.springframework.validation.FieldError) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with NO_ERROR

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.

the class BaseAnalysisController method addCommonEntityToAnalysis.

@ApiOperation("Add common entity to analysis")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/entities", method = POST)
public JsonResult addCommonEntityToAnalysis(@PathVariable("analysisId") Long analysisId, @RequestBody @Valid DataReferenceDTO entityReference, @RequestParam(value = "type", required = false, defaultValue = "COHORT") CommonAnalysisType analysisType, Principal principal) throws NotExistException, JMSException, IOException, PermissionDeniedException, URISyntaxException {
    final IUser user = getUser(principal);
    final DataNode dataNode = dataNodeService.getById(entityReference.getDataNodeId());
    final T analysis = analysisService.getById(analysisId);
    final DataReference dataReference = dataReferenceService.addOrUpdate(entityReference.getEntityGuid(), dataNode);
    final List<MultipartFile> entityFiles = getEntityFiles(entityReference, dataNode, analysisType);
    doAddCommonEntityToAnalysis(analysis, dataReference, user, analysisType, entityFiles);
    return new JsonResult(NO_ERROR);
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MultipartFile(org.springframework.web.multipart.MultipartFile) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) GET(org.springframework.web.bind.annotation.RequestMethod.GET) POST(org.springframework.web.bind.annotation.RequestMethod.POST) DataNode(com.odysseusinc.arachne.portal.model.DataNode) IUser(com.odysseusinc.arachne.portal.model.IUser) DataReference(com.odysseusinc.arachne.portal.model.DataReference) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)34 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)33 ApiOperation (io.swagger.annotations.ApiOperation)31 IUser (com.odysseusinc.arachne.portal.model.IUser)18 GET (org.springframework.web.bind.annotation.RequestMethod.GET)10 POST (org.springframework.web.bind.annotation.RequestMethod.POST)10 PUT (org.springframework.web.bind.annotation.RequestMethod.PUT)10 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)6 FileDTO (com.odysseusinc.arachne.portal.api.v1.dto.FileDTO)5 SubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)5 UploadFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO)5 AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)5 PERMISSION_DENIED (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.PERMISSION_DENIED)4 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)4 ResultFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO)4 SubmissionInsightDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO)4 SubmissionStatusHistoryElementDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO)4 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)4 DataNode (com.odysseusinc.arachne.portal.model.DataNode)4 Submission (com.odysseusinc.arachne.portal.model.Submission)4