mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 05:22:13 +08:00
fix:抽取数据类型
This commit is contained in:
committed by
xuwei-fit2cloud
parent
bc4f8d7d43
commit
0af52e1963
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import io.dataease.commons.constants.OptConstants;
|
||||
import io.dataease.commons.constants.TaskStatus;
|
||||
import io.dataease.constant.DataSourceType;
|
||||
import io.dataease.datasource.dao.auto.entity.CoreDatasource;
|
||||
import io.dataease.datasource.dao.auto.mapper.CoreDatasourceMapper;
|
||||
import io.dataease.datasource.dao.ext.mapper.CoreDatasourceExtMapper;
|
||||
@@ -13,7 +12,10 @@ import io.dataease.datasource.dao.ext.po.DataSourceNodePO;
|
||||
import io.dataease.datasource.dao.ext.po.DsItem;
|
||||
import io.dataease.datasource.dto.DatasourceNodeBO;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.extensions.datasource.api.PluginManageApi;
|
||||
import io.dataease.extensions.datasource.dto.DatasourceDTO;
|
||||
import io.dataease.extensions.datasource.vo.DatasourceConfiguration;
|
||||
import io.dataease.extensions.datasource.vo.XpackPluginsDatasourceVO;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.license.config.XpackInteract;
|
||||
import io.dataease.license.utils.LicenseUtil;
|
||||
@@ -28,6 +30,7 @@ import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -52,18 +55,57 @@ public class DataSourceManage {
|
||||
@Resource
|
||||
private EngineManage engineManage;
|
||||
|
||||
@Autowired(required = false)
|
||||
private PluginManageApi pluginManage;
|
||||
|
||||
private DatasourceNodeBO rootNode() {
|
||||
return new DatasourceNodeBO(0L, "root", false, 7, -1L, 0, "mysql");
|
||||
}
|
||||
|
||||
private DatasourceNodeBO convert(DataSourceNodePO po) {
|
||||
DataSourceType dataSourceType = DataSourceType.valueOf(po.getType());
|
||||
if (ObjectUtils.isEmpty(dataSourceType)) {
|
||||
dataSourceType = DataSourceType.mysql;
|
||||
private Integer getFlag(String type) {
|
||||
Integer flag = null;
|
||||
for (DatasourceConfiguration.DatasourceType datasourceType : DatasourceConfiguration.DatasourceType.values()) {
|
||||
if (datasourceType.getType().equals(type)) {
|
||||
flag = datasourceType.getFlag();
|
||||
}
|
||||
}
|
||||
Integer flag = dataSourceType.getFlag();
|
||||
if (ObjectUtils.isEmpty(flag)) {
|
||||
List<XpackPluginsDatasourceVO> xpackPluginsDatasourceVOS = pluginManage.queryPluginDs();
|
||||
List<XpackPluginsDatasourceVO> list = xpackPluginsDatasourceVOS.stream().filter(ele -> StringUtils.equals(ele.getType(), type)).toList();
|
||||
if (ObjectUtils.isNotEmpty(list)) {
|
||||
XpackPluginsDatasourceVO first = list.getFirst();
|
||||
flag = first.getFlag();
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isEmpty(flag)) {
|
||||
flag = 27;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private String getName(String type) {
|
||||
String name = null;
|
||||
for (DatasourceConfiguration.DatasourceType datasourceType : DatasourceConfiguration.DatasourceType.values()) {
|
||||
if (datasourceType.getType().equals(type)) {
|
||||
name = datasourceType.getName();
|
||||
}
|
||||
|
||||
}
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
List<XpackPluginsDatasourceVO> xpackPluginsDatasourceVOS = pluginManage.queryPluginDs();
|
||||
List<XpackPluginsDatasourceVO> list = xpackPluginsDatasourceVOS.stream().filter(ele -> StringUtils.equals(ele.getType(), type)).toList();
|
||||
if (ObjectUtils.isNotEmpty(list)) {
|
||||
XpackPluginsDatasourceVO first = list.getFirst();
|
||||
name = first.getName();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private DatasourceNodeBO convert(DataSourceNodePO po) {
|
||||
Integer flag = getFlag(po.getType());
|
||||
int extraFlag = StringUtils.equalsIgnoreCase("error", po.getStatus()) ? Math.negateExact(flag) : flag;
|
||||
return new DatasourceNodeBO(po.getId(), po.getName(), !StringUtils.equals(po.getType(), "folder"), 9, po.getPid(), extraFlag, dataSourceType.name());
|
||||
return new DatasourceNodeBO(po.getId(), po.getName(), !StringUtils.equals(po.getType(), "folder"), 9, po.getPid(), extraFlag, getName(po.getType()));
|
||||
}
|
||||
|
||||
@XpackInteract(value = "datasourceResourceTree", replace = true, invalid = true)
|
||||
|
||||
@@ -12,7 +12,6 @@ import io.dataease.api.ds.DatasourceApi;
|
||||
import io.dataease.api.ds.vo.*;
|
||||
import io.dataease.api.permissions.relation.api.RelationApi;
|
||||
import io.dataease.commons.constants.TaskStatus;
|
||||
import io.dataease.constant.DataSourceType;
|
||||
import io.dataease.constant.LogOT;
|
||||
import io.dataease.constant.LogST;
|
||||
import io.dataease.constant.SQLConstants;
|
||||
@@ -1446,7 +1445,7 @@ public class DatasourceServer implements DatasourceApi {
|
||||
Object resObj = null;
|
||||
try {
|
||||
Method method = getMethod(dsType, methodName, classes);
|
||||
if (object instanceof DatasourceRequest && dsType.equals(DataSourceType.APILark.name())) {
|
||||
if (object instanceof DatasourceRequest && dsType.equals("APILark")) {
|
||||
Class<?> clazz = Class.forName(DatasourceRequest.class.getName());
|
||||
Method setToken = clazz.getMethod("setToken", String.class);
|
||||
setToken.invoke(object, dataSourceManage.getTenantAccessToken());
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package io.dataease.constant;
|
||||
|
||||
public enum DataSourceType {oracle(1), sqlServer(2), TiDB(3), hive(4), impala(5), mariadb(6), StarRocks(7), ds_doris(8), pg(9), mongo(10), ck(11), db2(12), redshift(13), es(14), API(15),
|
||||
Excel(16), influxdb(17), sls(18), kingbase(19), mongobi(20), maxcompute(21), presto(22),
|
||||
dm(23), kylin(24), folder(25), doris(26), mysql(27), APILark(28), ExcelRemote(29);
|
||||
|
||||
private final Integer flag;
|
||||
|
||||
DataSourceType(Integer flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public Integer getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static DataSourceType fromFlag(int flag) {
|
||||
DataSourceType[] values = DataSourceType.values();
|
||||
for (DataSourceType value : values) {
|
||||
if (value.flag == flag) return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -11,39 +11,40 @@ public class DatasourceConfiguration extends Configuration {
|
||||
|
||||
|
||||
static public enum DatasourceType {
|
||||
folder("folder", "folder", "folder", null, null),
|
||||
API("API", "API", "API", "`", "`"),
|
||||
Excel("Excel", "Excel", "LOCALFILE", "`", "`"),
|
||||
ExcelRemote("ExcelRemote", "ExcelRemote", "LOCALFILE", "`", "`"),
|
||||
mysql("mysql", "Mysql", "OLTP", "`", "`"),
|
||||
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", "\"", "\""),
|
||||
pg("pg", "PostgreSQL", "OLTP", "\"", "\""),
|
||||
redshift("redshift", "AWS Redshift", "OLTP", "\"", "\""),
|
||||
db2("db2", "Db2", "OLTP", "", ""),
|
||||
ck("ck", "Clickhouse", "OLAP", "`", "`"),
|
||||
h2("h2", "H2", "OLAP", "\"", "\""),
|
||||
sqlServer("sqlServer", "Sqlserver", "DL", "[", "]"),
|
||||
mongo("mongo", "MongoDB", "DL", "`", "`");
|
||||
folder("folder", "folder", "folder", null, null, 25),
|
||||
API("API", "API", "API", "`", "`", 15),
|
||||
Excel("Excel", "Excel", "LOCALFILE", "`", "`", 16),
|
||||
ExcelRemote("ExcelRemote", "ExcelRemote", "LOCALFILE", "`", "`", 29),
|
||||
mysql("mysql", "Mysql", "OLTP", "`", "`", 27),
|
||||
impala("impala", "Apache Impala", "OLAP", "`", "`", 5),
|
||||
mariadb("mariadb", "Mariadb", "OLTP", "`", "`", 6),
|
||||
StarRocks("StarRocks", "StarRocks", "OLAP", "`", "`", 7),
|
||||
es("es", "Elasticsearch", "OLAP", "\"", "\"", 14),
|
||||
doris("doris", "Apache Doris", "OLAP", "`", "`", 26),
|
||||
TiDB("TiDB", "TiDB", "OLTP", "`", "`", 3),
|
||||
oracle("oracle", "ORACLE", "OLTP", "\"", "\"", 1),
|
||||
pg("pg", "PostgreSQL", "OLTP", "\"", "\"", 9),
|
||||
redshift("redshift", "AWS Redshift", "OLTP", "\"", "\"", 13),
|
||||
db2("db2", "Db2", "OLTP", "", "", 12),
|
||||
ck("ck", "Clickhouse", "OLAP", "`", "`", 11),
|
||||
h2("h2", "H2", "OLAP", "\"", "\"", null),
|
||||
sqlServer("sqlServer", "Sqlserver", "DL", "[", "]", 2),
|
||||
mongo("mongo", "MongoDB", "DL", "`", "`", 10);
|
||||
|
||||
private String type;
|
||||
private String name;
|
||||
|
||||
private Integer flag;
|
||||
private String catalog;
|
||||
private String prefix;
|
||||
private String suffix;
|
||||
|
||||
DatasourceType(String type, String name, String catalog, String prefix, String suffix) {
|
||||
DatasourceType(String type, String name, String catalog, String prefix, String suffix, Integer flag) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.catalog = catalog;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
@@ -65,5 +66,9 @@ public class DatasourceConfiguration extends Configuration {
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public Integer getFlag() {
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user