Search in sources :

Example 21 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 sendUnlockRequest.

@ApiOperation("Send analysis unlock request")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/unlock-request", method = POST)
public JsonResult<FileDTO> sendUnlockRequest(Principal principal, @PathVariable("analysisId") Long analysisId, @RequestBody AnalysisUnlockRequestDTO analysisUnlockRequestDTO) throws NotExistException, PermissionDeniedException, AlreadyExistException {
    JsonResult result;
    final IUser user = getUser(principal);
    final AnalysisUnlockRequest unlockRequest = new AnalysisUnlockRequest();
    unlockRequest.setUser(user);
    unlockRequest.setStatus(AnalysisUnlockRequestStatus.PENDING);
    unlockRequest.setCreated(new Date());
    unlockRequest.setToken(UUID.randomUUID().toString().replace("-", ""));
    unlockRequest.setDescription(analysisUnlockRequestDTO.getDescription());
    try {
        final AnalysisUnlockRequest analysisUnlockRequest = analysisService.sendAnalysisUnlockRequest(analysisId, unlockRequest);
        analysisService.findLeads((T) analysisUnlockRequest.getAnalysis()).forEach(lead -> wsTemplate.convertAndSendToUser(lead.getUsername(), "/topic/invitations", new UpdateNotificationDTO()));
        result = new JsonResult<>(NO_ERROR);
    } catch (AlreadyExistException ex) {
        result = new JsonResult<>(VALIDATION_ERROR);
        result.setErrorMessage("Unlock request for the analysis was already created");
    }
    return result;
}
Also used : UpdateNotificationDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateNotificationDTO) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) GET(org.springframework.web.bind.annotation.RequestMethod.GET) POST(org.springframework.web.bind.annotation.RequestMethod.POST) IUser(com.odysseusinc.arachne.portal.model.IUser) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) AnalysisUnlockRequest(com.odysseusinc.arachne.portal.model.AnalysisUnlockRequest) Date(java.util.Date) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 22 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 updateSubmissionInsight.

@ApiOperation("Update submission insight")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/insight", method = PUT)
public JsonResult<SubmissionInsightDTO> updateSubmissionInsight(@PathVariable("submissionId") Long submissionId, @RequestBody SubmissionInsightUpdateDTO insightDTO) throws NotExistException {
    final SubmissionInsight insight = conversionService.convert(insightDTO, SubmissionInsight.class);
    final SubmissionInsight updatedInsight = submissionInsightService.updateSubmissionInsight(submissionId, insight);
    final SubmissionInsightDTO updatedInsightDTO = conversionService.convert(updatedInsight, SubmissionInsightDTO.class);
    final JsonResult<SubmissionInsightDTO> result = new JsonResult<>(NO_ERROR);
    result.setResult(updatedInsightDTO);
    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 23 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 putFileContent.

@ApiOperation("Write content of the code file.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/code-files/{fileUuid}", method = PUT)
public JsonResult<Boolean> putFileContent(Principal principal, @RequestBody FileDTO fileContentDTO, @PathVariable("analysisId") Long analysisId, @PathVariable("fileUuid") String uuid) throws PermissionDeniedException, NotExistException, IOException, URISyntaxException {
    final IUser user = getUser(principal);
    AnalysisFile analysisFile = analysisService.getAnalysisFile(analysisId, uuid);
    analysisService.writeToFile(analysisFile, fileContentDTO, user);
    JsonResult<Boolean> result = new JsonResult<>(NO_ERROR);
    result.setResult(Boolean.TRUE);
    return result;
}
Also used : AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) IUser(com.odysseusinc.arachne.portal.model.IUser) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 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 get.

@ApiOperation("Get analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}", method = GET)
public JsonResult<D> get(@PathVariable("analysisId") Long id) throws NotExistException, PermissionDeniedException {
    JsonResult<D> result;
    T analysis = analysisService.getById(id);
    result = new JsonResult<>(NO_ERROR);
    D analysisDTO = conversionService.convert(analysis, getAnalysisDTOClass());
    result.setResult(analysisDTO);
    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) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with NO_ERROR

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

the class BaseDataSourceController method suggestDataSource.

@RequestMapping(value = "/api/v1/data-sources/search-data-source", method = RequestMethod.GET)
public JsonResult<Page<DS_DTO>> suggestDataSource(Principal principal, @RequestParam("studyId") Long studyId, @RequestParam("query") String query, @ModelAttribute PageDTO pageDTO) throws PermissionDeniedException {
    if (studyId == null || query == null) {
        throw new javax.validation.ValidationException();
    }
    final IUser user = getUser(principal);
    PageRequest pageRequest = getPageRequest(pageDTO);
    Page<DS> dataSources = dataSourceService.suggestDataSource(query, studyId, user.getId(), pageRequest);
    List<DS_DTO> dataSourceDTOs = converterUtils.convertList(dataSources.getContent(), getDataSourceDTOClass());
    CustomPageImpl<DS_DTO> resultPage = new CustomPageImpl<>(dataSourceDTOs, pageRequest, dataSources.getTotalElements());
    return new JsonResult<>(NO_ERROR, resultPage);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) ValidationException(com.odysseusinc.arachne.portal.exception.ValidationException) IUser(com.odysseusinc.arachne.portal.model.IUser) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) 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