forked from github/dataease
feat: 支持ES
This commit is contained in:
parent
dc116ee00c
commit
93a94cccfe
@ -110,7 +110,6 @@ public class ChartDataManage {
|
||||
}
|
||||
|
||||
var dillAxis = new ArrayList<ChartViewFieldDTO>();
|
||||
|
||||
DatasetGroupInfoDTO table = datasetGroupManage.getDatasetGroupInfoDTO(view.getTableId(), null);
|
||||
if (table == null) {
|
||||
DEException.throwException(ResultCode.DATA_IS_WRONG.code(), Translator.get("i18n_no_ds"));
|
||||
|
@ -6,4 +6,5 @@ package io.dataease.dataset.constant;
|
||||
public class DatasetTableType {
|
||||
public static String DB = "db";
|
||||
public static String SQL = "sql";
|
||||
public static String Es = "es";
|
||||
}
|
||||
|
@ -129,6 +129,15 @@ public class DatasetDataManage {
|
||||
datasourceRequest.setTable(tableInfoDTO.getTable());
|
||||
}
|
||||
|
||||
tableFields = provider.fetchTableField(datasourceRequest);
|
||||
} else if (StringUtils.equalsIgnoreCase(type, DatasetTableType.Es)) {
|
||||
CoreDatasource coreDatasource = coreDatasourceMapper.selectById(datasetTableDTO.getDatasourceId());
|
||||
Provider provider = ProviderFactory.getProvider(type);
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO();
|
||||
BeanUtils.copyBean(datasourceSchemaDTO, coreDatasource);
|
||||
datasourceRequest.setDatasource(datasourceSchemaDTO);
|
||||
datasourceRequest.setTable(datasetTableDTO.getTableName());
|
||||
tableFields = provider.fetchTableField(datasourceRequest);
|
||||
} else {
|
||||
// excel,api
|
||||
@ -185,9 +194,7 @@ public class DatasetDataManage {
|
||||
DEException.throwException(Translator.get("i18n_no_column_permission"));
|
||||
}
|
||||
}
|
||||
|
||||
buildFieldName(sqlMap, fields);
|
||||
|
||||
Map<Long, DatasourceSchemaDTO> dsMap = (Map<Long, DatasourceSchemaDTO>) sqlMap.get("dsMap");
|
||||
DatasourceUtils.checkDsStatus(dsMap);
|
||||
List<String> dsList = new ArrayList<>();
|
||||
@ -202,13 +209,11 @@ public class DatasetDataManage {
|
||||
}
|
||||
sql = Utils.replaceSchemaAlias(sql, dsMap);
|
||||
}
|
||||
|
||||
List<DataSetRowPermissionsTreeDTO> rowPermissionsTree = new ArrayList<>();
|
||||
TokenUserBO user = AuthUtils.getUser();
|
||||
if (user != null && checkPermission) {
|
||||
rowPermissionsTree = permissionManage.getRowPermissionsTree(datasetGroupInfoDTO.getId(), user.getUserId());
|
||||
}
|
||||
|
||||
Provider provider;
|
||||
if (crossDs) {
|
||||
provider = ProviderFactory.getDefaultProvider();
|
||||
@ -236,7 +241,6 @@ public class DatasetDataManage {
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setQuery(querySQL);
|
||||
datasourceRequest.setDsList(dsMap);
|
||||
|
||||
Map<String, Object> data = provider.fetchResultField(datasourceRequest);
|
||||
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
|
@ -494,7 +494,16 @@ public class DatasetSQLManage {
|
||||
datasourceSchemaDTO.setSchemaAlias(schemaAlias);
|
||||
dsMap.put(coreDatasource.getId(), datasourceSchemaDTO);
|
||||
}
|
||||
} else {
|
||||
} else if (StringUtils.equalsIgnoreCase(ds.getType(), DatasetTableType.Es)){
|
||||
CoreDatasource coreDatasource = coreDatasourceMapper.selectById(ds.getDatasourceId());
|
||||
schemaAlias = String.format(SQLConstants.SCHEMA, coreDatasource.getId());
|
||||
if (!dsMap.containsKey(coreDatasource.getId())) {
|
||||
DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO();
|
||||
BeanUtils.copyBean(datasourceSchemaDTO, coreDatasource);
|
||||
datasourceSchemaDTO.setSchemaAlias(schemaAlias);
|
||||
dsMap.put(coreDatasource.getId(), datasourceSchemaDTO);
|
||||
}
|
||||
}else {
|
||||
CoreDatasource coreDatasource = engineManage.getDeEngine();
|
||||
schemaAlias = String.format(SQLConstants.SCHEMA, coreDatasource.getId());
|
||||
if (!dsMap.containsKey(coreDatasource.getId())) {
|
||||
|
@ -1274,7 +1274,6 @@ public class CalciteProvider extends Provider {
|
||||
try {
|
||||
connection = initConnection(dsMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -911,7 +911,7 @@ defineExpose({
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="notapiexcelconfig">
|
||||
<el-form-item label="连接方式" prop="type">
|
||||
<el-form-item label="连接方式" prop="type" v-if="form.type !== 'es'">
|
||||
<el-radio-group v-model="form.configuration.urlType">
|
||||
<el-radio label="hostName">主机名</el-radio>
|
||||
<el-radio label="jdbcUrl">JDBC 连接</el-radio>
|
||||
@ -933,7 +933,7 @@ defineExpose({
|
||||
<el-form-item
|
||||
:label="t('datasource.host')"
|
||||
prop="configuration.host"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl'"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl' && form.type !== 'es'"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.configuration.host"
|
||||
@ -944,7 +944,7 @@ defineExpose({
|
||||
<el-form-item
|
||||
:label="t('datasource.port')"
|
||||
prop="configuration.port"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl'"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl' && form.type !== 'es'"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="form.configuration.port"
|
||||
@ -960,7 +960,7 @@ defineExpose({
|
||||
<el-form-item
|
||||
:label="t('datasource.data_base')"
|
||||
prop="configuration.dataBase"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl'"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl' && form.type !== 'es'"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.configuration.dataBase"
|
||||
@ -1012,6 +1012,17 @@ defineExpose({
|
||||
{{ t('datasource.kerbers_info') }}
|
||||
</p>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.type == 'es'"
|
||||
:label="$t('datasource.datasource_url')"
|
||||
prop="configuration.url"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.configuration.url"
|
||||
:placeholder="$t('datasource.please_input_datasource_url')"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('datasource.user_name')" v-if="form.type !== 'presto'">
|
||||
<el-input
|
||||
:placeholder="t('common.inputText') + t('datasource.user_name')"
|
||||
@ -1066,7 +1077,7 @@ defineExpose({
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="t('datasource.extra_params')"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl'"
|
||||
v-if="form.configuration.urlType !== 'jdbcUrl' && form.type !== 'es'"
|
||||
>
|
||||
<el-input
|
||||
:placeholder="t('common.inputText') + t('datasource.extra_params')"
|
||||
|
@ -42,6 +42,12 @@ export const dsTypes = [
|
||||
extraParams:
|
||||
'characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true'
|
||||
},
|
||||
{
|
||||
type: 'es',
|
||||
name: 'Elasticsearch',
|
||||
catalog: 'OLAP',
|
||||
extraParams: ''
|
||||
},
|
||||
{
|
||||
type: 'StarRocks',
|
||||
name: 'StarRocks',
|
||||
|
@ -352,6 +352,7 @@ const initSearch = () => {
|
||||
state.filterTable = tableData.value.filter(ele =>
|
||||
ele.tableName.toLowerCase().includes(nickName.value.toLowerCase())
|
||||
)
|
||||
console.log(tableData.value)
|
||||
state.paginationConfig.total = state.filterTable.length
|
||||
}
|
||||
|
||||
@ -836,6 +837,7 @@ const operation = (cmd: string, data: Tree, nodeType: string) => {
|
||||
}
|
||||
|
||||
const handleClick = (tabName: TabPaneName) => {
|
||||
console.log(tabName)
|
||||
switch (tabName) {
|
||||
case 'config':
|
||||
listDatasourceTables({ datasourceId: nodeInfo.id }).then(res => {
|
||||
|
@ -21,6 +21,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class ProviderFactory {
|
||||
|
||||
public static Provider getProvider(String type) throws DEException {
|
||||
if (type.equalsIgnoreCase("es")) {
|
||||
return SpringContextUtil.getApplicationContext().getBean("esProvider", Provider.class);
|
||||
}
|
||||
List<String> list = Arrays.stream(DatasourceConfiguration.DatasourceType.values()).map(DatasourceConfiguration.DatasourceType::getType).toList();
|
||||
if (list.contains(type)) {
|
||||
return SpringContextUtil.getApplicationContext().getBean("calciteProvider", Provider.class);
|
||||
|
@ -18,6 +18,7 @@ public class DatasourceConfiguration extends Configuration {
|
||||
impala("impala", "Apache Impala", "OLAP", "`", "`"),
|
||||
mariadb("mariadb", "Mariadb", "OLTP", "`", "`"),
|
||||
StarRocks("StarRocks", "StarRocks", "OLAP", "`", "`"),
|
||||
es("es", "Elasticsearch", "OLAP", "\"", "\""),
|
||||
doris("doris", "Apache Doris", "OLAP", "`", "`"),
|
||||
TiDB("TiDB", "TiDB", "OLTP", "`", "`"),
|
||||
oracle("oracle", "ORACLE", "OLTP", "\"", "\""),
|
||||
|
Loading…
Reference in New Issue
Block a user