Search in sources :

Example 1 with JsonResult

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

the class BaseAnalysisController method uploadFile.

@ApiOperation("Upload file to attach to analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/upload", method = POST)
public JsonResult<List<AnalysisFileDTO>> uploadFile(Principal principal, @Valid UploadFileDTO uploadFileDTO, @PathVariable("analysisId") Long id) throws PermissionDeniedException, NotExistException, IOException {
    IUser user = getUser(principal);
    T analysis = analysisService.getById(id);
    JsonResult<List<AnalysisFileDTO>> result = new JsonResult<>(NO_ERROR);
    List<AnalysisFileDTO> createdFiles = new ArrayList<>();
    if (uploadFileDTO.getFile() != null) {
        AnalysisFile createdFile = analysisService.saveFile(uploadFileDTO.getFile(), user, analysis, uploadFileDTO.getLabel(), uploadFileDTO.getExecutable(), null);
        createdFiles.add(conversionService.convert(createdFile, AnalysisFileDTO.class));
    } else {
        if (StringUtils.hasText(uploadFileDTO.getLink())) {
            AnalysisFile createdFile = analysisService.saveFile(uploadFileDTO.getLink(), user, analysis, uploadFileDTO.getLabel(), uploadFileDTO.getExecutable());
            createdFiles.add(conversionService.convert(createdFile, AnalysisFileDTO.class));
        } else {
            result.setErrorCode(VALIDATION_ERROR.getCode());
        }
    }
    result.setResult(createdFiles);
    return result;
}
Also used : PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) GET(org.springframework.web.bind.annotation.RequestMethod.GET) POST(org.springframework.web.bind.annotation.RequestMethod.POST) ArrayList(java.util.ArrayList) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) IUser(com.odysseusinc.arachne.portal.model.IUser) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) 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 2 with JsonResult

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

the class BaseDataNodeController method updateDataNode.

@ApiOperation("Update data node info")
@RequestMapping(value = "/api/v1/data-nodes/{dataNodeId}", method = RequestMethod.PUT)
public JsonResult<CommonDataNodeDTO> updateDataNode(@PathVariable("dataNodeId") Long dataNodeId, @RequestBody @Valid CommonDataNodeRegisterDTO commonDataNodeRegisterDTO, Principal principal) throws PermissionDeniedException, NotExistException {
    final IUser user = getUser(principal);
    final DN dataNode = conversionService.convert(commonDataNodeRegisterDTO, getDataNodeDNClass());
    dataNode.setId(dataNodeId);
    final DN updatedDataNode = baseDataNodeService.update(dataNode);
    final CommonDataNodeDTO dataNodeRegisterResponseDTO = conversionService.convert(updatedDataNode, CommonDataNodeDTO.class);
    final JsonResult<CommonDataNodeDTO> result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
    result.setResult(dataNodeRegisterResponseDTO);
    return result;
}
Also used : CommonDataNodeDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonDataNodeDTO) 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 3 with JsonResult

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

the class BaseExpertFinderController method get.

@ApiOperation("Get user by id")
@RequestMapping(value = "/api/v1/user-management/users/{id}", method = GET)
public JsonResult<CommonUserDTO> get(@PathVariable("id") Long id) {
    JsonResult<CommonUserDTO> result;
    U user = userService.getByIdInAnyTenant(id);
    CommonUserDTO userDTO = conversionService.convert(user, CommonUserDTO.class);
    result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
    result.setResult(userDTO);
    return result;
}
Also used : CommonUserDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with JsonResult

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

the class BaseDataSourceController method updateDataSource.

private JsonResult<DTO> updateDataSource(Principal principal, Long dataSourceId, DTO commonDataSourceDTO, BindingResult bindingResult) throws PermissionDeniedException, IllegalAccessException, IOException, NoSuchFieldException, SolrServerException, ValidationException {
    JsonResult result;
    if (bindingResult.hasErrors()) {
        result = setValidationErrors(bindingResult);
    } else {
        final DS exist = dataSourceService.getByIdInAnyTenant(dataSourceId);
        DS dataSource = convertDTOToDataSource(commonDataSourceDTO);
        dataSource.setId(dataSourceId);
        dataSource.setDataNode(exist.getDataNode());
        dataSource.setPublished(true);
        dataSourceService.makeLinksWithTenantsNotDeleted(dataSourceId);
        dataSource = dataSourceService.updateInAnyTenant(dataSource);
        result = new JsonResult<>(NO_ERROR);
        result.setResult(convertDataSourceToDTO(dataSource));
    }
    return result;
}
Also used : JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)

Example 5 with JsonResult

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

the class BaseDataNodeController method createDataNode.

@ApiOperation("Create new data node.")
@RequestMapping(value = "/api/v1/data-nodes", method = RequestMethod.POST)
public JsonResult<CommonDataNodeCreationResponseDTO> createDataNode(Principal principal) throws PermissionDeniedException, AlreadyExistException {
    final IUser user = getUser(principal);
    final DN dataNode = buildEmptyDN();
    CommonDataNodeCreationResponseDTO responseDTO = createDataNode(dataNode, principal);
    final JsonResult<CommonDataNodeCreationResponseDTO> result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
    result.setResult(responseDTO);
    return result;
}
Also used : CommonDataNodeCreationResponseDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonDataNodeCreationResponseDTO) 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)

Aggregations

JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)77 ApiOperation (io.swagger.annotations.ApiOperation)59 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)44 IUser (com.odysseusinc.arachne.portal.model.IUser)22 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)21 ResponseEntity (org.springframework.http.ResponseEntity)20 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)17 GET (org.springframework.web.bind.annotation.RequestMethod.GET)8 POST (org.springframework.web.bind.annotation.RequestMethod.POST)8 PUT (org.springframework.web.bind.annotation.RequestMethod.PUT)8 FileDTO (com.odysseusinc.arachne.portal.api.v1.dto.FileDTO)6 SubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)6 UploadFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO)6 NotUniqueException (com.odysseusinc.arachne.portal.exception.NotUniqueException)6 FieldError (org.springframework.validation.FieldError)6 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 ResultFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO)5 PermissionDeniedException (com.odysseusinc.arachne.portal.exception.PermissionDeniedException)5 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)5 AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)5