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