use of com.odysseusinc.arachne.commons.api.v1.dto.CommonDataSourceDTO in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeController method createDataSource.
@ApiOperation("Create new data source of datanode.")
@RequestMapping(value = "/api/v1/data-nodes/{dataNodeId}/data-sources", method = RequestMethod.POST)
public JsonResult createDataSource(@PathVariable("dataNodeId") Long id, @RequestBody C_DS_DTO commonDataSourceDTO) throws FieldException, NotExistException, ValidationException, IOException, SolrServerException, NoSuchFieldException, IllegalAccessException, BindException {
// we validate only two fields, because we don't want to validate another fields, because they always are null
validate(commonDataSourceDTO);
JsonResult<CommonDataSourceDTO> result;
DataNode dataNode = baseDataNodeService.getById(id);
if (dataNode == null) {
throw new IllegalArgumentException("Unable to find datanode by ID " + id);
}
DS dataSource = convertCommonDataSourceDtoToDataSource(commonDataSourceDTO);
dataSource.setDataNode(dataNode);
dataSource = dataSourceService.createOrRestoreDataSource(dataSource);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(genericConversionService.convert(dataSource, CommonDataSourceDTO.class));
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonDataSourceDTO 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 {
IUser user = getUser(principal);
final DS exist = dataSourceService.getNotDeletedByIdInAnyTenant(dataSourceId);
DS dataSource = convertDTOToDataSource(commonDataSourceDTO);
dataSource.setId(dataSourceId);
dataSource.setDataNode(exist.getDataNode());
dataSource.setPublished(true);
dataSource = dataSourceService.updateInAnyTenant(dataSource);
result = new JsonResult<>(NO_ERROR);
result.setResult(convertDataSourceToDTO(dataSource));
}
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonDataSourceDTO in project ArachneCentralAPI by OHDSI.
the class BaseDataSourceToCommonDataSourceDTOConverter method convert.
@Override
public DTO convert(DS dataSource) {
if (dataSource == null) {
return null;
}
DTO commonDataSourceDTO = createResultObject();
commonDataSourceDTO.setId(dataSource.getId());
commonDataSourceDTO.setUuid(dataSource.getUuid());
commonDataSourceDTO.setName(dataSource.getName());
commonDataSourceDTO.setModelType(dataSource.getModelType());
commonDataSourceDTO.setCdmVersion(dataSource.getCdmVersion());
commonDataSourceDTO.setOrganization(dataSource.getOrganization());
proceedAdditionalFields(commonDataSourceDTO, dataSource);
commonDataSourceDTO.setPublished(dataSource.getPublished());
commonDataSourceDTO.setDbmsType(dataSource.getDbmsType());
return commonDataSourceDTO;
}
Aggregations