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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations