Search in sources :

Example 1 with DataSourceVO

use of com.dtstack.taier.develop.dto.devlop.DataSourceVO in project Taier by DTStack.

the class AddDatasourceController method getPrincipalsWithConf.

@ApiOperation(value = "解析kerberos文件获取principal列表")
@PostMapping("/getPrincipalsWithConf")
@FileUpload
public R<List<String>> getPrincipalsWithConf(@RequestParam(value = "file", required = false) MultipartFile file, Map<String, Object> params) {
    Pair<String, String> resource = (Pair<String, String>) params.get("resource");
    params.remove(RESOURCE);
    DataSourceVO dataSourceVo = PublicUtil.mapToObject(params, DataSourceVO.class);
    params.put(RESOURCE, resource);
    return R.ok(datasourceService.getPrincipalsWithConf(dataSourceVo, resource, dataSourceVo.getUserId()));
}
Also used : DataSourceVO(com.dtstack.taier.develop.dto.devlop.DataSourceVO) Pair(org.apache.commons.lang3.tuple.Pair) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation) FileUpload(com.dtstack.taier.develop.annotation.FileUpload)

Example 2 with DataSourceVO

use of com.dtstack.taier.develop.dto.devlop.DataSourceVO in project Taier by DTStack.

the class DatasourceService method convertParamToVO.

/**
 * 转换成datasourceVo
 * @param tenantId
 * @param userId
 * @param dscJson
 * @param dataName
 * @param dataSourceType
 * @param dbName
 * @return
 */
private DataSourceVO convertParamToVO(Long tenantId, Long userId, String dscJson, String dataName, Integer dataSourceType, String dbName) {
    DataSourceVO dataSourceVO = new DataSourceVO();
    dataSourceVO.setUserId(userId);
    dataSourceVO.setTenantId(tenantId);
    dataSourceVO.setGmtCreate(new Date());
    dataSourceVO.setGmtModified(new Date());
    dataSourceVO.setDataName(dataName);
    dataSourceVO.setType(dataSourceType);
    dataSourceVO.setSchemaName(dbName);
    DataSourceTypeEnum typeEnum = DataSourceTypeEnum.valOf(dataSourceType);
    Asserts.notNull(typeEnum, ErrorCode.CAN_NOT_FITABLE_SOURCE_TYPE);
    dataSourceVO.setDataType(typeEnum.getDataType());
    dataSourceVO.setDataVersion(typeEnum.getDataVersion());
    if (Strings.isNotBlank(dscJson)) {
        dataSourceVO.setDataJson(DataSourceUtils.getDataSourceJson(dscJson));
    }
    dataSourceVO.setIsMeta(1);
    return dataSourceVO;
}
Also used : DataSourceVO(com.dtstack.taier.develop.dto.devlop.DataSourceVO) DataSourceTypeEnum(com.dtstack.taier.common.enums.DataSourceTypeEnum) Date(java.util.Date)

Example 3 with DataSourceVO

use of com.dtstack.taier.develop.dto.devlop.DataSourceVO in project Taier by DTStack.

the class DataSourceParam2SourceVOConverter method doConvert.

@Override
protected DataSourceVO doConvert(AddDataSourceParam source) {
    DataSourceVO returnVo = new DataSourceVO();
    returnVo.setId(source.getId());
    returnVo.setUserId(source.getUserId());
    returnVo.setTenantId(source.getTenantId());
    returnVo.setTenantId(source.getTenantId());
    returnVo.setDataName(source.getDataName());
    returnVo.setDataDesc(source.getDataDesc());
    returnVo.setDataType(source.getDataType());
    returnVo.setDataVersion(source.getDataVersion());
    returnVo.setDataJsonString(source.getDataJsonString());
    if (Strings.isNotBlank(source.getDataJsonString())) {
        returnVo.setDataJson(DataSourceUtils.getDataSourceJson(source.getDataJsonString()));
    }
    return returnVo;
}
Also used : DataSourceVO(com.dtstack.taier.develop.dto.devlop.DataSourceVO)

Example 4 with DataSourceVO

use of com.dtstack.taier.develop.dto.devlop.DataSourceVO in project Taier by DTStack.

the class DatasourceService method initDefaultSource.

public void initDefaultSource(Long clusterId, EComponentType eComponentType, Long tenantId, String dataSourceName, String dataSourceDesc, Long userId) {
    JdbcInfo jdbcInfo = Engine2DTOService.getJdbcInfoByClusterId(clusterId, eComponentType);
    JSONObject dataJson = buildDataSourceDataJson(clusterId, eComponentType, jdbcInfo, dataSourceName);
    DataSourceVO dataSourceVO = new DataSourceVO();
    dataSourceVO.setDataDesc(org.apache.commons.lang3.StringUtils.isNotEmpty(dataSourceDesc) ? dataSourceDesc : "");
    dataSourceVO.setDataJson(dataJson);
    dataSourceVO.setCreateUserId(userId);
    dataSourceVO.setActive(1);
    dataSourceVO.setDataName(String.format("%s_%s", dataSourceName, eComponentType.getName().toUpperCase(Locale.ROOT)));
    dataSourceVO.setTenantId(tenantId);
    dataSourceVO.setDataType(getDatasourceTypeByComponent(eComponentType, jdbcInfo).getDataType());
    dataSourceVO.setIsMeta(1);
    addOrUpdate(dataSourceVO, userId);
}
Also used : DataSourceVO(com.dtstack.taier.develop.dto.devlop.DataSourceVO) JSONObject(com.alibaba.fastjson.JSONObject) JdbcInfo(com.dtstack.taier.common.engine.JdbcInfo)

Example 5 with DataSourceVO

use of com.dtstack.taier.develop.dto.devlop.DataSourceVO in project Taier by DTStack.

the class DatasourceService method checkConnectionById.

/**
 * 测试联通性
 * @param id
 * @return
 */
public Boolean checkConnectionById(Long id) {
    BatchDataSource dataSource = getOne(id);
    DataSourceVO dataSourceVO = new DataSourceVO();
    BeanUtils.copyProperties(dataSource, dataSourceVO);
    dataSourceVO.setDataJson(JSONObject.parseObject(dataSource.getDataJson()));
    return checkConnectionWithConf(dataSourceVO, null, null);
}
Also used : BatchDataSource(com.dtstack.taier.dao.domain.BatchDataSource) DataSourceVO(com.dtstack.taier.develop.dto.devlop.DataSourceVO)

Aggregations

DataSourceVO (com.dtstack.taier.develop.dto.devlop.DataSourceVO)6 JSONObject (com.alibaba.fastjson.JSONObject)1 JdbcInfo (com.dtstack.taier.common.engine.JdbcInfo)1 DataSourceTypeEnum (com.dtstack.taier.common.enums.DataSourceTypeEnum)1 BatchDataSource (com.dtstack.taier.dao.domain.BatchDataSource)1 FileUpload (com.dtstack.taier.develop.annotation.FileUpload)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Date (java.util.Date)1 Pair (org.apache.commons.lang3.tuple.Pair)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1