Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
njgzx
dataease
Commits
e3e25501
提交
e3e25501
authored
10月 11, 2021
作者:
taojinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 规范类名
上级
04156d08
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
157 行增加
和
164 行删除
+157
-164
CHConfiguration.java
...main/java/io/dataease/datasource/dto/CHConfiguration.java
+1
-1
DorisConfiguration.java
...n/java/io/dataease/datasource/dto/DorisConfiguration.java
+1
-1
EsConfiguration.java
...main/java/io/dataease/datasource/dto/EsConfiguration.java
+1
-1
JdbcConfiguration.java
...in/java/io/dataease/datasource/dto/JdbcConfiguration.java
+1
-1
MysqlConfiguration.java
...n/java/io/dataease/datasource/dto/MysqlConfiguration.java
+1
-1
OracleConfiguration.java
.../java/io/dataease/datasource/dto/OracleConfiguration.java
+1
-1
PgConfiguration.java
...main/java/io/dataease/datasource/dto/PgConfiguration.java
+1
-1
SqlServerConfiguration.java
...va/io/dataease/datasource/dto/SqlServerConfiguration.java
+1
-1
EsProvider.java
...main/java/io/dataease/datasource/provider/EsProvider.java
+17
-18
JdbcProvider.java
...in/java/io/dataease/datasource/provider/JdbcProvider.java
+94
-94
DatasourceService.java
...ava/io/dataease/datasource/service/DatasourceService.java
+5
-5
QueryProvider.java
...end/src/main/java/io/dataease/provider/QueryProvider.java
+2
-2
OracleQueryProvider.java
...java/io/dataease/provider/oracle/OracleQueryProvider.java
+7
-8
PgQueryProvider.java
...rc/main/java/io/dataease/provider/pg/PgQueryProvider.java
+3
-5
SqlserverQueryProvider.java
...o/dataease/provider/sqlserver/SqlserverQueryProvider.java
+4
-7
ExtractDataService.java
.../java/io/dataease/service/dataset/ExtractDataService.java
+17
-17
没有找到文件。
backend/src/main/java/io/dataease/datasource/dto/CHConfigration.java
→
backend/src/main/java/io/dataease/datasource/dto/CHConfig
u
ration.java
浏览文件 @
e3e25501
...
...
@@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils;
@Getter
@Setter
public
class
CHConfig
ration
extends
JdbcDTO
{
public
class
CHConfig
uration
extends
JdbcConfiguration
{
private
String
driver
=
"ru.yandex.clickhouse.ClickHouseDriver"
;
private
String
extraParams
=
""
;
...
...
backend/src/main/java/io/dataease/datasource/dto/DorisConfigration.java
→
backend/src/main/java/io/dataease/datasource/dto/DorisConfig
u
ration.java
浏览文件 @
e3e25501
...
...
@@ -5,7 +5,7 @@ import lombok.Setter;
@Getter
@Setter
public
class
DorisConfig
ration
extends
MysqlConfig
ration
{
public
class
DorisConfig
uration
extends
MysqlConfigu
ration
{
private
Integer
httpPort
;
}
backend/src/main/java/io/dataease/datasource/dto/EsConfig
DTO
.java
→
backend/src/main/java/io/dataease/datasource/dto/EsConfig
uration
.java
浏览文件 @
e3e25501
...
...
@@ -6,7 +6,7 @@ import lombok.Setter;
@Getter
@Setter
public
class
EsConfig
DTO
{
public
class
EsConfig
uration
{
private
String
url
;
private
String
esUsername
;
private
String
esPassword
;
...
...
backend/src/main/java/io/dataease/datasource/dto/Jdbc
DTO
.java
→
backend/src/main/java/io/dataease/datasource/dto/Jdbc
Configuration
.java
浏览文件 @
e3e25501
...
...
@@ -6,7 +6,7 @@ import lombok.Setter;
@Getter
@Setter
public
class
Jdbc
DTO
{
public
class
Jdbc
Configuration
{
private
String
host
;
private
Integer
port
;
private
String
username
;
...
...
backend/src/main/java/io/dataease/datasource/dto/MysqlConfigration.java
→
backend/src/main/java/io/dataease/datasource/dto/MysqlConfig
u
ration.java
浏览文件 @
e3e25501
...
...
@@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils;
@Getter
@Setter
public
class
MysqlConfig
ration
extends
JdbcDTO
{
public
class
MysqlConfig
uration
extends
JdbcConfiguration
{
private
String
driver
=
"com.mysql.cj.jdbc.Driver"
;
private
String
extraParams
=
"characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true"
;
...
...
backend/src/main/java/io/dataease/datasource/dto/OracleConfigration.java
→
backend/src/main/java/io/dataease/datasource/dto/OracleConfig
u
ration.java
浏览文件 @
e3e25501
...
...
@@ -5,7 +5,7 @@ import lombok.Setter;
@Getter
@Setter
public
class
OracleConfig
ration
extends
JdbcDTO
{
public
class
OracleConfig
uration
extends
JdbcConfiguration
{
private
String
driver
=
"oracle.jdbc.driver.OracleDriver"
;
private
String
connectionType
;
...
...
backend/src/main/java/io/dataease/datasource/dto/PgConfigration.java
→
backend/src/main/java/io/dataease/datasource/dto/PgConfig
u
ration.java
浏览文件 @
e3e25501
...
...
@@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils;
@Getter
@Setter
public
class
PgConfig
ration
extends
JdbcDTO
{
public
class
PgConfig
uration
extends
JdbcConfiguration
{
private
String
driver
=
"org.postgresql.Driver"
;
private
String
extraParams
=
""
;
...
...
backend/src/main/java/io/dataease/datasource/dto/SqlServerConfigration.java
→
backend/src/main/java/io/dataease/datasource/dto/SqlServerConfig
u
ration.java
浏览文件 @
e3e25501
...
...
@@ -7,7 +7,7 @@ import org.apache.commons.lang3.StringUtils;
@Getter
@Setter
public
class
SqlServerConfig
ration
extends
JdbcDTO
{
public
class
SqlServerConfig
uration
extends
JdbcConfiguration
{
private
String
driver
=
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
;
private
String
extraParams
=
""
;
public
String
getJdbc
(){
...
...
backend/src/main/java/io/dataease/datasource/provider/EsProvider.java
浏览文件 @
e3e25501
package
io
.
dataease
.
datasource
.
provider
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
com.mchange.v2.c3p0.ComboPooledDataSource
;
...
...
@@ -48,17 +47,17 @@ public class EsProvider extends DatasourceProvider {
public
List
<
String
[]>
getData
(
DatasourceRequest
dsr
)
throws
Exception
{
List
<
String
[]>
list
=
new
LinkedList
<>();
try
{
EsConfig
DTO
esConfigDTO
=
new
Gson
().
fromJson
(
dsr
.
getDatasource
().
getConfiguration
(),
EsConfigDTO
.
class
);
EsConfig
uration
esConfiguration
=
new
Gson
().
fromJson
(
dsr
.
getDatasource
().
getConfiguration
(),
EsConfiguration
.
class
);
HttpClientConfig
httpClientConfig
=
new
HttpClientConfig
();
if
(
StringUtils
.
isNotEmpty
(
esConfig
DTO
.
getEsUsername
())){
String
auth
=
esConfig
DTO
.
getEsUsername
()
+
":"
+
esConfigDTO
.
getEsPassword
();
if
(
StringUtils
.
isNotEmpty
(
esConfig
uration
.
getEsUsername
())){
String
auth
=
esConfig
uration
.
getEsUsername
()
+
":"
+
esConfiguration
.
getEsPassword
();
byte
[]
encodedAuth
=
Base64
.
encodeBase64
(
auth
.
getBytes
(
StandardCharsets
.
UTF_8
));
httpClientConfig
.
addHeader
(
HttpHeaders
.
AUTHORIZATION
,
"Basic "
+
new
String
(
encodedAuth
));
}
Requst
requst
=
new
Requst
();
requst
.
setQuery
(
dsr
.
getQuery
());
requst
.
setFetch_size
(
dsr
.
getFetchSize
());
String
url
=
esConfig
DTO
.
getUrl
().
endsWith
(
"/"
)
?
esConfigDTO
.
getUrl
()
+
esConfigDTO
.
getUri
()
+
"?format=json"
:
esConfigDTO
.
getUrl
()
+
"/"
+
esConfigDTO
.
getUri
()
+
"?format=json"
;
String
url
=
esConfig
uration
.
getUrl
().
endsWith
(
"/"
)
?
esConfiguration
.
getUrl
()
+
esConfiguration
.
getUri
()
+
"?format=json"
:
esConfiguration
.
getUrl
()
+
"/"
+
esConfiguration
.
getUri
()
+
"?format=json"
;
String
response
=
HttpClientUtil
.
post
(
url
,
new
Gson
().
toJson
(
requst
),
httpClientConfig
);
EsReponse
esReponse
=
new
Gson
().
fromJson
(
response
,
EsReponse
.
class
);
...
...
@@ -225,7 +224,7 @@ public class EsProvider extends DatasourceProvider {
@Override
public
void
checkStatus
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
EsConfig
DTO
esConfigDTO
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
EsConfigDTO
.
class
);
EsConfig
uration
esConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
EsConfiguration
.
class
);
String
response
=
exexGetQuery
(
datasourceRequest
);
if
(
JSONObject
.
parseObject
(
response
).
getJSONObject
(
"error"
)
!=
null
){
...
...
@@ -239,21 +238,21 @@ public class EsProvider extends DatasourceProvider {
throw
new
Exception
(
Translator
.
get
(
"i18n_es_limit"
));
}
if
(
Integer
.
valueOf
(
version
.
substring
(
0
,
1
))
==
6
)
{
esConfig
DTO
.
setUri
(
"_xpack/sql"
);
esConfig
uration
.
setUri
(
"_xpack/sql"
);
}
if
(
Integer
.
valueOf
(
version
.
substring
(
0
,
1
))
==
7
)
{
esConfig
DTO
.
setUri
(
"_sql"
);
esConfig
uration
.
setUri
(
"_sql"
);
}
datasourceRequest
.
getDatasource
().
setConfiguration
(
new
Gson
().
toJson
(
esConfig
DTO
));
datasourceRequest
.
getDatasource
().
setConfiguration
(
new
Gson
().
toJson
(
esConfig
uration
));
getTables
(
datasourceRequest
);
}
private
String
exexQuery
(
DatasourceRequest
datasourceRequest
,
String
sql
,
String
uri
){
EsConfig
DTO
esConfigDTO
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
EsConfigDTO
.
class
);
uri
=
esConfig
DTO
.
getUri
()+
uri
;
EsConfig
uration
esConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
EsConfiguration
.
class
);
uri
=
esConfig
uration
.
getUri
()+
uri
;
HttpClientConfig
httpClientConfig
=
new
HttpClientConfig
();
if
(
StringUtils
.
isNotEmpty
(
esConfig
DTO
.
getEsUsername
())
&&
StringUtils
.
isNotEmpty
(
esConfigDTO
.
getEsPassword
())){
String
auth
=
esConfig
DTO
.
getEsUsername
()
+
":"
+
esConfigDTO
.
getEsPassword
();
if
(
StringUtils
.
isNotEmpty
(
esConfig
uration
.
getEsUsername
())
&&
StringUtils
.
isNotEmpty
(
esConfiguration
.
getEsPassword
())){
String
auth
=
esConfig
uration
.
getEsUsername
()
+
":"
+
esConfiguration
.
getEsPassword
();
byte
[]
encodedAuth
=
Base64
.
encodeBase64
(
auth
.
getBytes
(
StandardCharsets
.
UTF_8
));
httpClientConfig
.
addHeader
(
HttpHeaders
.
AUTHORIZATION
,
"Basic "
+
new
String
(
encodedAuth
));
}
...
...
@@ -261,21 +260,21 @@ public class EsProvider extends DatasourceProvider {
Requst
requst
=
new
Requst
();
requst
.
setQuery
(
sql
);
requst
.
setFetch_size
(
datasourceRequest
.
getFetchSize
());
String
url
=
esConfig
DTO
.
getUrl
().
endsWith
(
"/"
)
?
esConfigDTO
.
getUrl
()
+
uri
:
esConfigDTO
.
getUrl
()
+
"/"
+
uri
;
String
url
=
esConfig
uration
.
getUrl
().
endsWith
(
"/"
)
?
esConfiguration
.
getUrl
()
+
uri
:
esConfiguration
.
getUrl
()
+
"/"
+
uri
;
String
response
=
HttpClientUtil
.
post
(
url
,
new
Gson
().
toJson
(
requst
),
httpClientConfig
);
return
response
;
}
private
String
exexGetQuery
(
DatasourceRequest
datasourceRequest
){
EsConfig
DTO
esConfigDTO
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
EsConfigDTO
.
class
);
EsConfig
uration
esConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
EsConfiguration
.
class
);
HttpClientConfig
httpClientConfig
=
new
HttpClientConfig
();
if
(
StringUtils
.
isNotEmpty
(
esConfig
DTO
.
getEsUsername
())
&&
StringUtils
.
isNotEmpty
(
esConfigDTO
.
getEsPassword
())){
String
auth
=
esConfig
DTO
.
getEsUsername
()
+
":"
+
esConfigDTO
.
getEsPassword
();
if
(
StringUtils
.
isNotEmpty
(
esConfig
uration
.
getEsUsername
())
&&
StringUtils
.
isNotEmpty
(
esConfiguration
.
getEsPassword
())){
String
auth
=
esConfig
uration
.
getEsUsername
()
+
":"
+
esConfiguration
.
getEsPassword
();
byte
[]
encodedAuth
=
Base64
.
encodeBase64
(
auth
.
getBytes
(
StandardCharsets
.
UTF_8
));
httpClientConfig
.
addHeader
(
HttpHeaders
.
AUTHORIZATION
,
"Basic "
+
new
String
(
encodedAuth
));
}
String
response
=
HttpClientUtil
.
get
(
esConfig
DTO
.
getUrl
(),
httpClientConfig
);
String
response
=
HttpClientUtil
.
get
(
esConfig
uration
.
getUrl
(),
httpClientConfig
);
return
response
;
}
...
...
backend/src/main/java/io/dataease/datasource/provider/JdbcProvider.java
浏览文件 @
e3e25501
...
...
@@ -420,12 +420,12 @@ public class JdbcProvider extends DatasourceProvider {
private
void
addToPool
(
DatasourceRequest
datasourceRequest
)
throws
PropertyVetoException
{
ComboPooledDataSource
dataSource
;
dataSource
=
new
ComboPooledDataSource
();
Jdbc
DTO
jdbcDTO
=
setCredential
(
datasourceRequest
,
dataSource
);
dataSource
.
setMaxIdleTime
(
jdbc
DTO
.
getMaxIdleTime
());
// 最大空闲时间
dataSource
.
setAcquireIncrement
(
jdbc
DTO
.
getAcquireIncrement
());
// 增长数
dataSource
.
setInitialPoolSize
(
jdbc
DTO
.
getInitialPoolSize
());
// 初始连接数
dataSource
.
setMinPoolSize
(
jdbc
DTO
.
getMinPoolSize
());
// 最小连接数
dataSource
.
setMaxPoolSize
(
jdbc
DTO
.
getMaxPoolSize
());
// 最大连接数
Jdbc
Configuration
jdbcConfiguration
=
setCredential
(
datasourceRequest
,
dataSource
);
dataSource
.
setMaxIdleTime
(
jdbc
Configuration
.
getMaxIdleTime
());
// 最大空闲时间
dataSource
.
setAcquireIncrement
(
jdbc
Configuration
.
getAcquireIncrement
());
// 增长数
dataSource
.
setInitialPoolSize
(
jdbc
Configuration
.
getInitialPoolSize
());
// 初始连接数
dataSource
.
setMinPoolSize
(
jdbc
Configuration
.
getMinPoolSize
());
// 最小连接数
dataSource
.
setMaxPoolSize
(
jdbc
Configuration
.
getMaxPoolSize
());
// 最大连接数
dataSource
.
setAcquireRetryAttempts
(
30
);
// 获取连接重试次数
dataSource
.
setIdleConnectionTestPeriod
(
60
);
// 每60s检查数据库空闲连接
dataSource
.
setMaxStatements
(
0
);
// c3p0全局的PreparedStatements缓存的大小
...
...
@@ -451,41 +451,41 @@ public class JdbcProvider extends DatasourceProvider {
case
mariadb:
case
de_doris:
case
ds_doris:
MysqlConfig
ration
mysqlConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
MysqlConfig
ration
.
class
);
username
=
mysqlConfigration
.
getUsername
();
password
=
mysqlConfigration
.
getPassword
();
driver
=
mysqlConfigration
.
getDriver
();
jdbcurl
=
mysqlConfigration
.
getJdbc
();
MysqlConfig
uration
mysqlConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
MysqlConfigu
ration
.
class
);
username
=
mysqlConfig
u
ration
.
getUsername
();
password
=
mysqlConfig
u
ration
.
getPassword
();
driver
=
mysqlConfig
u
ration
.
getDriver
();
jdbcurl
=
mysqlConfig
u
ration
.
getJdbc
();
break
;
case
sqlServer:
SqlServerConfig
ration
sqlServerConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfig
ration
.
class
);
username
=
sqlServerConfigration
.
getUsername
();
password
=
sqlServerConfigration
.
getPassword
();
driver
=
sqlServerConfigration
.
getDriver
();
jdbcurl
=
sqlServerConfigration
.
getJdbc
();
SqlServerConfig
uration
sqlServerConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfigu
ration
.
class
);
username
=
sqlServerConfig
u
ration
.
getUsername
();
password
=
sqlServerConfig
u
ration
.
getPassword
();
driver
=
sqlServerConfig
u
ration
.
getDriver
();
jdbcurl
=
sqlServerConfig
u
ration
.
getJdbc
();
break
;
case
oracle:
OracleConfig
ration
oracleConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
OracleConfig
ration
.
class
);
username
=
oracleConfigration
.
getUsername
();
password
=
oracleConfigration
.
getPassword
();
driver
=
oracleConfigration
.
getDriver
();
jdbcurl
=
oracleConfigration
.
getJdbc
();
OracleConfig
uration
oracleConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
OracleConfigu
ration
.
class
);
username
=
oracleConfig
u
ration
.
getUsername
();
password
=
oracleConfig
u
ration
.
getPassword
();
driver
=
oracleConfig
u
ration
.
getDriver
();
jdbcurl
=
oracleConfig
u
ration
.
getJdbc
();
props
.
put
(
"oracle.net.CONNECT_TIMEOUT"
,
"5000"
)
;
// props.put( "oracle.jdbc.ReadTimeout" , "5000" ) ;
break
;
case
pg:
PgConfig
ration
pgConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfig
ration
.
class
);
username
=
pgConfigration
.
getUsername
();
password
=
pgConfigration
.
getPassword
();
driver
=
pgConfigration
.
getDriver
();
jdbcurl
=
pgConfigration
.
getJdbc
();
PgConfig
uration
pgConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfigu
ration
.
class
);
username
=
pgConfig
u
ration
.
getUsername
();
password
=
pgConfig
u
ration
.
getPassword
();
driver
=
pgConfig
u
ration
.
getDriver
();
jdbcurl
=
pgConfig
u
ration
.
getJdbc
();
break
;
case
ck:
CHConfig
ration
chConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
CHConfig
ration
.
class
);
username
=
chConfigration
.
getUsername
();
password
=
chConfigration
.
getPassword
();
driver
=
chConfigration
.
getDriver
();
jdbcurl
=
chConfigration
.
getJdbc
();
CHConfig
uration
chConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
CHConfigu
ration
.
class
);
username
=
chConfig
u
ration
.
getUsername
();
password
=
chConfig
u
ration
.
getPassword
();
driver
=
chConfig
u
ration
.
getDriver
();
jdbcurl
=
chConfig
u
ration
.
getJdbc
();
break
;
default
:
break
;
...
...
@@ -500,57 +500,57 @@ public class JdbcProvider extends DatasourceProvider {
}
private
Jdbc
DTO
setCredential
(
DatasourceRequest
datasourceRequest
,
ComboPooledDataSource
dataSource
)
throws
PropertyVetoException
{
private
Jdbc
Configuration
setCredential
(
DatasourceRequest
datasourceRequest
,
ComboPooledDataSource
dataSource
)
throws
PropertyVetoException
{
DatasourceTypes
datasourceType
=
DatasourceTypes
.
valueOf
(
datasourceRequest
.
getDatasource
().
getType
());
Jdbc
DTO
jdbcDTO
=
new
JdbcDTO
();
Jdbc
Configuration
jdbcConfiguration
=
new
JdbcConfiguration
();
switch
(
datasourceType
)
{
case
mysql:
case
mariadb:
case
de_doris:
case
ds_doris:
MysqlConfig
ration
mysqlConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
MysqlConfig
ration
.
class
);
dataSource
.
setUser
(
mysqlConfigration
.
getUsername
());
dataSource
.
setDriverClass
(
mysqlConfigration
.
getDriver
());
dataSource
.
setPassword
(
mysqlConfigration
.
getPassword
());
dataSource
.
setJdbcUrl
(
mysqlConfigration
.
getJdbc
());
jdbc
DTO
=
mysqlConfig
ration
;
MysqlConfig
uration
mysqlConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
MysqlConfigu
ration
.
class
);
dataSource
.
setUser
(
mysqlConfig
u
ration
.
getUsername
());
dataSource
.
setDriverClass
(
mysqlConfig
u
ration
.
getDriver
());
dataSource
.
setPassword
(
mysqlConfig
u
ration
.
getPassword
());
dataSource
.
setJdbcUrl
(
mysqlConfig
u
ration
.
getJdbc
());
jdbc
Configuration
=
mysqlConfigu
ration
;
break
;
case
sqlServer:
SqlServerConfig
ration
sqlServerConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfig
ration
.
class
);
dataSource
.
setUser
(
sqlServerConfigration
.
getUsername
());
dataSource
.
setDriverClass
(
sqlServerConfigration
.
getDriver
());
dataSource
.
setPassword
(
sqlServerConfigration
.
getPassword
());
dataSource
.
setJdbcUrl
(
sqlServerConfigration
.
getJdbc
());
jdbc
DTO
=
sqlServerConfig
ration
;
SqlServerConfig
uration
sqlServerConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfigu
ration
.
class
);
dataSource
.
setUser
(
sqlServerConfig
u
ration
.
getUsername
());
dataSource
.
setDriverClass
(
sqlServerConfig
u
ration
.
getDriver
());
dataSource
.
setPassword
(
sqlServerConfig
u
ration
.
getPassword
());
dataSource
.
setJdbcUrl
(
sqlServerConfig
u
ration
.
getJdbc
());
jdbc
Configuration
=
sqlServerConfigu
ration
;
break
;
case
oracle:
OracleConfig
ration
oracleConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
OracleConfig
ration
.
class
);
dataSource
.
setUser
(
oracleConfigration
.
getUsername
());
dataSource
.
setDriverClass
(
oracleConfigration
.
getDriver
());
dataSource
.
setPassword
(
oracleConfigration
.
getPassword
());
dataSource
.
setJdbcUrl
(
oracleConfigration
.
getJdbc
());
jdbc
DTO
=
oracleConfig
ration
;
OracleConfig
uration
oracleConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
OracleConfigu
ration
.
class
);
dataSource
.
setUser
(
oracleConfig
u
ration
.
getUsername
());
dataSource
.
setDriverClass
(
oracleConfig
u
ration
.
getDriver
());
dataSource
.
setPassword
(
oracleConfig
u
ration
.
getPassword
());
dataSource
.
setJdbcUrl
(
oracleConfig
u
ration
.
getJdbc
());
jdbc
Configuration
=
oracleConfigu
ration
;
break
;
case
pg:
PgConfig
ration
pgConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfig
ration
.
class
);
dataSource
.
setUser
(
pgConfigration
.
getUsername
());
dataSource
.
setDriverClass
(
pgConfigration
.
getDriver
());
dataSource
.
setPassword
(
pgConfigration
.
getPassword
());
dataSource
.
setJdbcUrl
(
pgConfigration
.
getJdbc
());
jdbc
DTO
=
pgConfig
ration
;
PgConfig
uration
pgConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfigu
ration
.
class
);
dataSource
.
setUser
(
pgConfig
u
ration
.
getUsername
());
dataSource
.
setDriverClass
(
pgConfig
u
ration
.
getDriver
());
dataSource
.
setPassword
(
pgConfig
u
ration
.
getPassword
());
dataSource
.
setJdbcUrl
(
pgConfig
u
ration
.
getJdbc
());
jdbc
Configuration
=
pgConfigu
ration
;
break
;
case
ck:
CHConfig
ration
chConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
CHConfig
ration
.
class
);
dataSource
.
setUser
(
chConfigration
.
getUsername
());
dataSource
.
setDriverClass
(
chConfigration
.
getDriver
());
dataSource
.
setPassword
(
chConfigration
.
getPassword
());
dataSource
.
setJdbcUrl
(
chConfigration
.
getJdbc
());
jdbc
DTO
=
chConfig
ration
;
CHConfig
uration
chConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
CHConfigu
ration
.
class
);
dataSource
.
setUser
(
chConfig
u
ration
.
getUsername
());
dataSource
.
setDriverClass
(
chConfig
u
ration
.
getDriver
());
dataSource
.
setPassword
(
chConfig
u
ration
.
getPassword
());
dataSource
.
setJdbcUrl
(
chConfig
u
ration
.
getJdbc
());
jdbc
Configuration
=
chConfigu
ration
;
break
;
default
:
break
;
}
return
jdbc
DTO
;
return
jdbc
Configuration
;
}
private
String
getDatabase
(
DatasourceRequest
datasourceRequest
)
{
...
...
@@ -560,17 +560,17 @@ public class JdbcProvider extends DatasourceProvider {
case
de_doris:
case
ds_doris:
case
mariadb:
MysqlConfig
ration
mysqlConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
MysqlConfig
ration
.
class
);
return
mysqlConfigration
.
getDataBase
();
MysqlConfig
uration
mysqlConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
MysqlConfigu
ration
.
class
);
return
mysqlConfig
u
ration
.
getDataBase
();
case
sqlServer:
SqlServerConfig
ration
sqlServerConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfig
ration
.
class
);
return
sqlServerConfigration
.
getDataBase
();
SqlServerConfig
uration
sqlServerConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfigu
ration
.
class
);
return
sqlServerConfig
u
ration
.
getDataBase
();
case
pg:
PgConfig
ration
pgConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfig
ration
.
class
);
return
pgConfigration
.
getDataBase
();
PgConfig
uration
pgConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfigu
ration
.
class
);
return
pgConfig
u
ration
.
getDataBase
();
default
:
Jdbc
DTO
jdbcDTO
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
JdbcDTO
.
class
);
return
jdbc
DTO
.
getDataBase
();
Jdbc
Configuration
jdbcConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
JdbcConfiguration
.
class
);
return
jdbc
Configuration
.
getDataBase
();
}
}
...
...
@@ -583,28 +583,28 @@ public class JdbcProvider extends DatasourceProvider {
case
ds_doris:
return
"show tables;"
;
case
sqlServer:
SqlServerConfig
ration
sqlServerConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfig
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
sqlServerConfigration
.
getSchema
())){
SqlServerConfig
uration
sqlServerConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfigu
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
sqlServerConfig
u
ration
.
getSchema
())){
throw
new
Exception
(
Translator
.
get
(
"i18n_schema_is_empty"
));
}
return
"SELECT TABLE_NAME FROM DATABASE.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'DS_SCHEMA' ;"
.
replace
(
"DATABASE"
,
sqlServerConfigration
.
getDataBase
())
.
replace
(
"DS_SCHEMA"
,
sqlServerConfigration
.
getSchema
());
.
replace
(
"DATABASE"
,
sqlServerConfig
u
ration
.
getDataBase
())
.
replace
(
"DS_SCHEMA"
,
sqlServerConfig
u
ration
.
getSchema
());
case
oracle:
OracleConfig
ration
oracleConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
OracleConfig
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
oracleConfigration
.
getSchema
())){
OracleConfig
uration
oracleConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
OracleConfigu
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
oracleConfig
u
ration
.
getSchema
())){
throw
new
Exception
(
Translator
.
get
(
"i18n_schema_is_empty"
));
}
return
"select table_name, owner from all_tables where owner='"
+
oracleConfigration
.
getSchema
()
+
"'"
;
return
"select table_name, owner from all_tables where owner='"
+
oracleConfig
u
ration
.
getSchema
()
+
"'"
;
case
pg:
PgConfig
ration
pgConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfig
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
pgConfigration
.
getSchema
())){
PgConfig
uration
pgConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfigu
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
pgConfig
u
ration
.
getSchema
())){
throw
new
Exception
(
Translator
.
get
(
"i18n_schema_is_empty"
));
}
return
"SELECT tablename FROM pg_tables WHERE schemaname='SCHEMA' ;"
.
replace
(
"SCHEMA"
,
pgConfigration
.
getSchema
());
return
"SELECT tablename FROM pg_tables WHERE schemaname='SCHEMA' ;"
.
replace
(
"SCHEMA"
,
pgConfig
u
ration
.
getSchema
());
case
ck:
CHConfig
ration
chConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
CHConfig
ration
.
class
);
return
"SELECT name FROM system.tables where database='DATABASE';"
.
replace
(
"DATABASE"
,
chConfigration
.
getDataBase
());
CHConfig
uration
chConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
CHConfigu
ration
.
class
);
return
"SELECT name FROM system.tables where database='DATABASE';"
.
replace
(
"DATABASE"
,
chConfig
u
ration
.
getDataBase
());
default
:
return
"show tables;"
;
}
...
...
@@ -620,25 +620,25 @@ public class JdbcProvider extends DatasourceProvider {
case
ck:
return
null
;
case
sqlServer:
SqlServerConfig
ration
sqlServerConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfig
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
sqlServerConfigration
.
getSchema
())){
SqlServerConfig
uration
sqlServerConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
SqlServerConfigu
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
sqlServerConfig
u
ration
.
getSchema
())){
throw
new
Exception
(
Translator
.
get
(
"i18n_schema_is_empty"
));
}
return
"SELECT TABLE_NAME FROM DATABASE.INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'DS_SCHEMA' ;"
.
replace
(
"DATABASE"
,
sqlServerConfigration
.
getDataBase
())
.
replace
(
"DS_SCHEMA"
,
sqlServerConfigration
.
getSchema
());
.
replace
(
"DATABASE"
,
sqlServerConfig
u
ration
.
getDataBase
())
.
replace
(
"DS_SCHEMA"
,
sqlServerConfig
u
ration
.
getSchema
());
case
oracle:
OracleConfig
ration
oracleConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
OracleConfig
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
oracleConfigration
.
getSchema
())){
OracleConfig
uration
oracleConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
OracleConfigu
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
oracleConfig
u
ration
.
getSchema
())){
throw
new
Exception
(
Translator
.
get
(
"i18n_schema_is_empty"
));
}
return
"select VIEW_NAME from all_views where owner='"
+
oracleConfigration
.
getSchema
()
+
"'"
;
return
"select VIEW_NAME from all_views where owner='"
+
oracleConfig
u
ration
.
getSchema
()
+
"'"
;
case
pg:
PgConfig
ration
pgConfigration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfig
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
pgConfigration
.
getSchema
())){
PgConfig
uration
pgConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
PgConfigu
ration
.
class
);
if
(
StringUtils
.
isEmpty
(
pgConfig
u
ration
.
getSchema
())){
throw
new
Exception
(
Translator
.
get
(
"i18n_schema_is_empty"
));
}
return
"SELECT viewname FROM pg_views WHERE schemaname='SCHEMA' ;"
.
replace
(
"SCHEMA"
,
pgConfigration
.
getSchema
());
return
"SELECT viewname FROM pg_views WHERE schemaname='SCHEMA' ;"
.
replace
(
"SCHEMA"
,
pgConfig
u
ration
.
getSchema
());
default
:
return
null
;
}
...
...
backend/src/main/java/io/dataease/datasource/service/DatasourceService.java
浏览文件 @
e3e25501
...
...
@@ -96,19 +96,19 @@ public class DatasourceService {
case
mariadb:
case
de_doris:
case
ds_doris:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
MysqlConfigration
.
class
))
);
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
MysqlConfig
u
ration
.
class
))
);
break
;
case
sqlServer:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
SqlServerConfigration
.
class
))
);
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
SqlServerConfig
u
ration
.
class
))
);
break
;
case
oracle:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
OracleConfigration
.
class
))
);
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
OracleConfig
u
ration
.
class
))
);
break
;
case
pg:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
PgConfigration
.
class
))
);
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
PgConfig
u
ration
.
class
))
);
break
;
case
ck:
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
CHConfigration
.
class
))
);
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
CHConfig
u
ration
.
class
))
);
break
;
default
:
break
;
...
...
backend/src/main/java/io/dataease/provider/QueryProvider.java
浏览文件 @
e3e25501
...
...
@@ -4,7 +4,7 @@ import com.google.gson.Gson;
import
io.dataease.base.domain.DatasetTableField
;
import
io.dataease.base.domain.Datasource
;
import
io.dataease.controller.request.chart.ChartExtFilterRequest
;
import
io.dataease.datasource.dto.Jdbc
DTO
;
import
io.dataease.datasource.dto.Jdbc
Configuration
;
import
io.dataease.dto.chart.ChartCustomFilterDTO
;
import
io.dataease.dto.chart.ChartViewFieldDTO
;
import
io.dataease.dto.sqlObj.SQLObj
;
...
...
@@ -76,7 +76,7 @@ public abstract class QueryProvider {
public
void
setSchema
(
SQLObj
tableObj
,
Datasource
ds
){
if
(
ds
!=
null
&&
!
tableObj
.
getTableName
().
startsWith
(
"("
)
&&
!
tableObj
.
getTableName
().
endsWith
(
")"
)){
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
DTO
.
class
).
getSchema
();
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
Configuration
.
class
).
getSchema
();
schema
=
String
.
format
(
PgConstants
.
KEYWORD_TABLE
,
schema
);
tableObj
.
setTableName
(
schema
+
"."
+
tableObj
.
getTableName
());
}
...
...
backend/src/main/java/io/dataease/provider/oracle/OracleQueryProvider.java
浏览文件 @
e3e25501
...
...
@@ -6,14 +6,13 @@ import io.dataease.base.domain.DatasetTableFieldExample;
import
io.dataease.base.domain.Datasource
;
import
io.dataease.base.mapper.DatasetTableFieldMapper
;
import
io.dataease.controller.request.chart.ChartExtFilterRequest
;
import
io.dataease.datasource.dto.Jdbc
DTO
;
import
io.dataease.datasource.dto.OracleConfigration
;
import
io.dataease.datasource.dto.Jdbc
Configuration
;
import
io.dataease.datasource.dto.OracleConfig
u
ration
;
import
io.dataease.dto.chart.ChartCustomFilterDTO
;
import
io.dataease.dto.chart.ChartViewFieldDTO
;
import
io.dataease.dto.sqlObj.SQLObj
;
import
io.dataease.provider.QueryProvider
;
import
io.dataease.provider.SQLConstants
;
import
io.dataease.provider.mysql.MySQLConstants
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -112,7 +111,7 @@ public class OracleQueryProvider extends QueryProvider {
public
void
setSchema
(
SQLObj
tableObj
,
Datasource
ds
){
if
(
ds
!=
null
&&
!
tableObj
.
getTableName
().
startsWith
(
"("
)
&&
!
tableObj
.
getTableName
().
endsWith
(
")"
)){
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
DTO
.
class
).
getSchema
();
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
Configuration
.
class
).
getSchema
();
schema
=
String
.
format
(
OracleConstants
.
KEYWORD_TABLE
,
schema
);
tableObj
.
setTableName
(
schema
+
"."
+
tableObj
.
getTableName
());
}
...
...
@@ -203,7 +202,7 @@ public class OracleQueryProvider extends QueryProvider {
@Override
public
String
createQueryTableWithLimit
(
String
table
,
List
<
DatasetTableField
>
fields
,
Integer
limit
,
boolean
isGroup
,
Datasource
ds
)
{
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
DTO
.
class
).
getSchema
();
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
Configuration
.
class
).
getSchema
();
return
String
.
format
(
"SELECT * from %s WHERE rownum <= %s "
,
schema
+
"."
+
String
.
format
(
OracleConstants
.
KEYWORD_TABLE
,
table
),
limit
.
toString
());
}
...
...
@@ -730,8 +729,8 @@ public class OracleQueryProvider extends QueryProvider {
stringBuilder
.
append
(
" \""
).
append
(
f
.
getOriginName
()).
append
(
"\""
);
return
stringBuilder
.
toString
();
}).
toArray
(
String
[]::
new
);
OracleConfig
ration
oracleConfigration
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
OracleConfig
ration
.
class
);
return
MessageFormat
.
format
(
"SELECT {0} FROM {1}"
,
StringUtils
.
join
(
array
,
","
),
oracleConfigration
.
getSchema
()
+
".\""
+
table
+
"\""
);
OracleConfig
uration
oracleConfiguration
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
OracleConfigu
ration
.
class
);
return
MessageFormat
.
format
(
"SELECT {0} FROM {1}"
,
StringUtils
.
join
(
array
,
","
),
oracleConfig
u
ration
.
getSchema
()
+
".\""
+
table
+
"\""
);
}
@Override
...
...
@@ -746,7 +745,7 @@ public class OracleQueryProvider extends QueryProvider {
@Override
public
String
convertTableToSql
(
String
tableName
,
Datasource
ds
){
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
DTO
.
class
).
getSchema
();
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
Configuration
.
class
).
getSchema
();
schema
=
String
.
format
(
OracleConstants
.
KEYWORD_TABLE
,
schema
);
return
createSQLPreview
(
"SELECT * FROM "
+
schema
+
"."
+
String
.
format
(
OracleConstants
.
KEYWORD_TABLE
,
tableName
),
null
);
}
...
...
backend/src/main/java/io/dataease/provider/pg/PgQueryProvider.java
浏览文件 @
e3e25501
...
...
@@ -7,14 +7,12 @@ import io.dataease.base.domain.Datasource;
import
io.dataease.base.mapper.DatasetTableFieldMapper
;
import
io.dataease.commons.constants.DeTypeConstants
;
import
io.dataease.controller.request.chart.ChartExtFilterRequest
;
import
io.dataease.datasource.dto.Jdbc
DTO
;
import
io.dataease.datasource.dto.Jdbc
Configuration
;
import
io.dataease.dto.chart.ChartCustomFilterDTO
;
import
io.dataease.dto.chart.ChartViewFieldDTO
;
import
io.dataease.dto.sqlObj.SQLObj
;
import
io.dataease.provider.QueryProvider
;
import
io.dataease.provider.SQLConstants
;
import
io.dataease.provider.mysql.MySQLConstants
;
import
io.dataease.provider.oracle.OracleConstants
;
import
io.dataease.provider.sqlserver.SqlServerSQLConstants
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
...
...
@@ -709,7 +707,7 @@ public class PgQueryProvider extends QueryProvider {
return
stringBuilder
.
toString
();
}).
toArray
(
String
[]::
new
);
if
(
ds
!=
null
)
{
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
DTO
.
class
).
getSchema
();
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
Configuration
.
class
).
getSchema
();
String
tableWithSchema
=
String
.
format
(
SqlServerSQLConstants
.
KEYWORD_TABLE
,
schema
)
+
"."
+
String
.
format
(
SqlServerSQLConstants
.
KEYWORD_TABLE
,
table
);
return
MessageFormat
.
format
(
"SELECT {0} FROM {1} "
,
StringUtils
.
join
(
array
,
","
),
tableWithSchema
);
}
else
{
...
...
@@ -724,7 +722,7 @@ public class PgQueryProvider extends QueryProvider {
@Override
public
String
convertTableToSql
(
String
tableName
,
Datasource
ds
){
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
DTO
.
class
).
getSchema
();
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
Configuration
.
class
).
getSchema
();
schema
=
String
.
format
(
PgConstants
.
KEYWORD_TABLE
,
schema
);
return
createSQLPreview
(
"SELECT * FROM "
+
schema
+
"."
+
String
.
format
(
PgConstants
.
KEYWORD_TABLE
,
tableName
),
null
);
}
...
...
backend/src/main/java/io/dataease/provider/sqlserver/SqlserverQueryProvider.java
浏览文件 @
e3e25501
...
...
@@ -7,15 +7,12 @@ import io.dataease.base.domain.Datasource;
import
io.dataease.base.mapper.DatasetTableFieldMapper
;
import
io.dataease.commons.constants.DeTypeConstants
;
import
io.dataease.controller.request.chart.ChartExtFilterRequest
;
import
io.dataease.datasource.dto.JdbcDTO
;
import
io.dataease.datasource.dto.SqlServerConfigration
;
import
io.dataease.datasource.dto.JdbcConfiguration
;
import
io.dataease.dto.chart.ChartCustomFilterDTO
;
import
io.dataease.dto.chart.ChartViewFieldDTO
;
import
io.dataease.dto.sqlObj.SQLObj
;
import
io.dataease.provider.QueryProvider
;
import
io.dataease.provider.SQLConstants
;
import
io.dataease.provider.oracle.OracleConstants
;
import
io.dataease.provider.pg.PgConstants
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -159,7 +156,7 @@ public class SqlserverQueryProvider extends QueryProvider {
@Override
public
String
createQueryTableWithLimit
(
String
table
,
List
<
DatasetTableField
>
fields
,
Integer
limit
,
boolean
isGroup
,
Datasource
ds
)
{
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
DTO
.
class
).
getSchema
();
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
Configuration
.
class
).
getSchema
();
return
String
.
format
(
"SELECT top %s * from %s "
,
limit
.
toString
(),
schema
+
"."
+
table
);
}
...
...
@@ -666,7 +663,7 @@ public class SqlserverQueryProvider extends QueryProvider {
return
stringBuilder
.
toString
();
}).
toArray
(
String
[]::
new
);
if
(
ds
!=
null
)
{
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
DTO
.
class
).
getSchema
();
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
Configuration
.
class
).
getSchema
();
String
tableWithSchema
=
String
.
format
(
SqlServerSQLConstants
.
KEYWORD_TABLE
,
schema
)
+
"."
+
String
.
format
(
SqlServerSQLConstants
.
KEYWORD_TABLE
,
table
);
return
MessageFormat
.
format
(
"SELECT {0} FROM {1} "
,
StringUtils
.
join
(
array
,
","
),
tableWithSchema
);
}
else
{
...
...
@@ -681,7 +678,7 @@ public class SqlserverQueryProvider extends QueryProvider {
@Override
public
String
convertTableToSql
(
String
tableName
,
Datasource
ds
){
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
DTO
.
class
).
getSchema
();
String
schema
=
new
Gson
().
fromJson
(
ds
.
getConfiguration
(),
Jdbc
Configuration
.
class
).
getSchema
();
schema
=
String
.
format
(
SqlServerSQLConstants
.
KEYWORD_TABLE
,
schema
);
return
createSQLPreview
(
"SELECT * FROM "
+
schema
+
"."
+
String
.
format
(
SqlServerSQLConstants
.
KEYWORD_TABLE
,
tableName
),
null
);
}
...
...
backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java
浏览文件 @
e3e25501
...
...
@@ -653,7 +653,7 @@ public class ExtractDataService {
String
jobName
=
null
;
String
script
=
null
;
Datasource
dorisDatasource
=
(
Datasource
)
CommonBeanFactory
.
getBean
(
"DorisDatasource"
);
DorisConfig
ration
dorisConfigration
=
new
Gson
().
fromJson
(
dorisDatasource
.
getConfiguration
(),
DorisConfig
ration
.
class
);
DorisConfig
uration
dorisConfiguration
=
new
Gson
().
fromJson
(
dorisDatasource
.
getConfiguration
(),
DorisConfigu
ration
.
class
);
String
columns
=
columnFeilds
+
",dataease_uuid"
;
String
transName
=
null
;
switch
(
extractType
)
{
...
...
@@ -661,18 +661,18 @@ public class ExtractDataService {
transName
=
"trans_"
+
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
());
outFile
=
DorisTableUtils
.
dorisTmpName
(
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
()));
jobName
=
"job_"
+
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
());
script
=
String
.
format
(
shellScript
,
dorisConfig
ration
.
getUsername
(),
dorisConfigration
.
getPassword
(),
String
.
valueOf
(
System
.
currentTimeMillis
()),
separator
,
columns
,
"APPEND"
,
root_path
+
outFile
+
"."
+
extention
,
dorisConfigration
.
getHost
(),
dorisConfigration
.
getHttpPort
(),
dorisConfig
ration
.
getDataBase
(),
DorisTableUtils
.
dorisTmpName
(
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
())),
root_path
+
outFile
+
"."
+
extention
);
script
=
String
.
format
(
shellScript
,
dorisConfig
uration
.
getUsername
(),
dorisConfiguration
.
getPassword
(),
String
.
valueOf
(
System
.
currentTimeMillis
()),
separator
,
columns
,
"APPEND"
,
root_path
+
outFile
+
"."
+
extention
,
dorisConfiguration
.
getHost
(),
dorisConfiguration
.
getHttpPort
(),
dorisConfigu
ration
.
getDataBase
(),
DorisTableUtils
.
dorisTmpName
(
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
())),
root_path
+
outFile
+
"."
+
extention
);
break
;
case
"incremental_add"
:
transName
=
"trans_add_"
+
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
());
outFile
=
DorisTableUtils
.
dorisAddName
(
datasetTable
.
getId
());
jobName
=
"job_add_"
+
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
());
script
=
String
.
format
(
shellScript
,
dorisConfig
ration
.
getUsername
(),
dorisConfigration
.
getPassword
(),
String
.
valueOf
(
System
.
currentTimeMillis
()),
separator
,
columns
,
"APPEND"
,
root_path
+
outFile
+
"."
+
extention
,
dorisConfigration
.
getHost
(),
dorisConfigration
.
getHttpPort
(),
dorisConfig
ration
.
getDataBase
(),
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
()),
root_path
+
outFile
+
"."
+
extention
);
script
=
String
.
format
(
shellScript
,
dorisConfig
uration
.
getUsername
(),
dorisConfiguration
.
getPassword
(),
String
.
valueOf
(
System
.
currentTimeMillis
()),
separator
,
columns
,
"APPEND"
,
root_path
+
outFile
+
"."
+
extention
,
dorisConfiguration
.
getHost
(),
dorisConfiguration
.
getHttpPort
(),
dorisConfigu
ration
.
getDataBase
(),
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
()),
root_path
+
outFile
+
"."
+
extention
);
break
;
case
"incremental_delete"
:
transName
=
"trans_delete_"
+
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
());
outFile
=
DorisTableUtils
.
dorisDeleteName
(
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
()));
script
=
String
.
format
(
shellScript
,
dorisConfig
ration
.
getUsername
(),
dorisConfigration
.
getPassword
(),
String
.
valueOf
(
System
.
currentTimeMillis
()),
separator
,
columns
,
"DELETE"
,
root_path
+
outFile
+
"."
+
extention
,
dorisConfigration
.
getHost
(),
dorisConfigration
.
getHttpPort
(),
dorisConfig
ration
.
getDataBase
(),
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
()),
root_path
+
outFile
+
"."
+
extention
);
script
=
String
.
format
(
shellScript
,
dorisConfig
uration
.
getUsername
(),
dorisConfiguration
.
getPassword
(),
String
.
valueOf
(
System
.
currentTimeMillis
()),
separator
,
columns
,
"DELETE"
,
root_path
+
outFile
+
"."
+
extention
,
dorisConfiguration
.
getHost
(),
dorisConfiguration
.
getHttpPort
(),
dorisConfigu
ration
.
getDataBase
(),
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
()),
root_path
+
outFile
+
"."
+
extention
);
jobName
=
"job_delete_"
+
DorisTableUtils
.
dorisName
(
datasetTable
.
getId
());
break
;
default
:
...
...
@@ -766,8 +766,8 @@ public class ExtractDataService {
case
ds_doris:
case
mariadb:
case
mysql:
MysqlConfig
ration
mysqlConfigration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
MysqlConfig
ration
.
class
);
dataMeta
=
new
DatabaseMeta
(
"db"
,
"MYSQL"
,
"Native"
,
mysqlConfig
ration
.
getHost
().
trim
(),
mysqlConfigration
.
getDataBase
().
trim
(),
mysqlConfigration
.
getPort
().
toString
(),
mysqlConfigration
.
getUsername
(),
mysqlConfig
ration
.
getPassword
());
MysqlConfig
uration
mysqlConfiguration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
MysqlConfigu
ration
.
class
);
dataMeta
=
new
DatabaseMeta
(
"db"
,
"MYSQL"
,
"Native"
,
mysqlConfig
uration
.
getHost
().
trim
(),
mysqlConfiguration
.
getDataBase
().
trim
(),
mysqlConfiguration
.
getPort
().
toString
(),
mysqlConfiguration
.
getUsername
(),
mysqlConfigu
ration
.
getPassword
());
dataMeta
.
addExtraOption
(
"MYSQL"
,
"characterEncoding"
,
"UTF-8"
);
transMeta
.
addDatabase
(
dataMeta
);
selectSQL
=
getSelectSQL
(
extractType
,
datasetTable
,
datasource
,
datasetTableFields
,
selectSQL
);
...
...
@@ -775,28 +775,28 @@ public class ExtractDataService {
udjcStep
=
udjc
(
datasetTableFields
,
DatasourceTypes
.
mysql
);
break
;
case
sqlServer:
SqlServerConfig
ration
sqlServerConfigration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
SqlServerConfig
ration
.
class
);
dataMeta
=
new
DatabaseMeta
(
"db"
,
"MSSQLNATIVE"
,
"Native"
,
sqlServerConfig
ration
.
getHost
().
trim
(),
sqlServerConfigration
.
getDataBase
(),
sqlServerConfigration
.
getPort
().
toString
(),
sqlServerConfigration
.
getUsername
(),
sqlServerConfig
ration
.
getPassword
());
SqlServerConfig
uration
sqlServerConfiguration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
SqlServerConfigu
ration
.
class
);
dataMeta
=
new
DatabaseMeta
(
"db"
,
"MSSQLNATIVE"
,
"Native"
,
sqlServerConfig
uration
.
getHost
().
trim
(),
sqlServerConfiguration
.
getDataBase
(),
sqlServerConfiguration
.
getPort
().
toString
(),
sqlServerConfiguration
.
getUsername
(),
sqlServerConfigu
ration
.
getPassword
());
transMeta
.
addDatabase
(
dataMeta
);
selectSQL
=
getSelectSQL
(
extractType
,
datasetTable
,
datasource
,
datasetTableFields
,
selectSQL
);
inputStep
=
inputStep
(
transMeta
,
selectSQL
);
udjcStep
=
udjc
(
datasetTableFields
,
DatasourceTypes
.
sqlServer
);
break
;
case
pg:
PgConfig
ration
pgConfigration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
PgConfig
ration
.
class
);
dataMeta
=
new
DatabaseMeta
(
"db"
,
"POSTGRESQL"
,
"Native"
,
pgConfig
ration
.
getHost
().
trim
(),
pgConfigration
.
getDataBase
(),
pgConfigration
.
getPort
().
toString
(),
pgConfigration
.
getUsername
(),
pgConfig
ration
.
getPassword
());
PgConfig
uration
pgConfiguration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
PgConfigu
ration
.
class
);
dataMeta
=
new
DatabaseMeta
(
"db"
,
"POSTGRESQL"
,
"Native"
,
pgConfig
uration
.
getHost
().
trim
(),
pgConfiguration
.
getDataBase
(),
pgConfiguration
.
getPort
().
toString
(),
pgConfiguration
.
getUsername
(),
pgConfigu
ration
.
getPassword
());
transMeta
.
addDatabase
(
dataMeta
);
selectSQL
=
getSelectSQL
(
extractType
,
datasetTable
,
datasource
,
datasetTableFields
,
selectSQL
);
inputStep
=
inputStep
(
transMeta
,
selectSQL
);
udjcStep
=
udjc
(
datasetTableFields
,
DatasourceTypes
.
pg
);
break
;
case
oracle:
OracleConfig
ration
oracleConfigration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
OracleConfig
ration
.
class
);
if
(
oracleConfigration
.
getConnectionType
().
equalsIgnoreCase
(
"serviceName"
))
{
String
database
=
"(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE_HOSTNAME)(PORT = ORACLE_PORT))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = ORACLE_SERVICE_NAME )))"
.
replace
(
"ORACLE_HOSTNAME"
,
oracleConfig
ration
.
getHost
()).
replace
(
"ORACLE_PORT"
,
oracleConfigration
.
getPort
().
toString
()).
replace
(
"ORACLE_SERVICE_NAME"
,
oracleConfig
ration
.
getDataBase
());
dataMeta
=
new
DatabaseMeta
(
"db"
,
"ORACLE"
,
"Native"
,
""
,
database
,
"-1"
,
oracleConfig
ration
.
getUsername
(),
oracleConfig
ration
.
getPassword
());
OracleConfig
uration
oracleConfiguration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
OracleConfigu
ration
.
class
);
if
(
oracleConfig
u
ration
.
getConnectionType
().
equalsIgnoreCase
(
"serviceName"
))
{
String
database
=
"(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = ORACLE_HOSTNAME)(PORT = ORACLE_PORT))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = ORACLE_SERVICE_NAME )))"
.
replace
(
"ORACLE_HOSTNAME"
,
oracleConfig
uration
.
getHost
()).
replace
(
"ORACLE_PORT"
,
oracleConfiguration
.
getPort
().
toString
()).
replace
(
"ORACLE_SERVICE_NAME"
,
oracleConfigu
ration
.
getDataBase
());
dataMeta
=
new
DatabaseMeta
(
"db"
,
"ORACLE"
,
"Native"
,
""
,
database
,
"-1"
,
oracleConfig
uration
.
getUsername
(),
oracleConfigu
ration
.
getPassword
());
}
else
{
dataMeta
=
new
DatabaseMeta
(
"db"
,
"ORACLE"
,
"Native"
,
oracleConfig
ration
.
getHost
().
trim
(),
oracleConfigration
.
getDataBase
(),
oracleConfigration
.
getPort
().
toString
(),
oracleConfigration
.
getUsername
(),
oracleConfig
ration
.
getPassword
());
dataMeta
=
new
DatabaseMeta
(
"db"
,
"ORACLE"
,
"Native"
,
oracleConfig
uration
.
getHost
().
trim
(),
oracleConfiguration
.
getDataBase
(),
oracleConfiguration
.
getPort
().
toString
(),
oracleConfiguration
.
getUsername
(),
oracleConfigu
ration
.
getPassword
());
}
transMeta
.
addDatabase
(
dataMeta
);
...
...
@@ -805,8 +805,8 @@ public class ExtractDataService {
udjcStep
=
udjc
(
datasetTableFields
,
DatasourceTypes
.
oracle
);
break
;
case
ck:
CHConfig
ration
chConfigration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
CHConfig
ration
.
class
);
dataMeta
=
new
DatabaseMeta
(
"db"
,
"ORACLE"
,
"Native"
,
chConfig
ration
.
getHost
().
trim
(),
chConfigration
.
getDataBase
().
trim
(),
chConfigration
.
getPort
().
toString
(),
chConfigration
.
getUsername
(),
chConfig
ration
.
getPassword
());
CHConfig
uration
chConfiguration
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
CHConfigu
ration
.
class
);
dataMeta
=
new
DatabaseMeta
(
"db"
,
"ORACLE"
,
"Native"
,
chConfig
uration
.
getHost
().
trim
(),
chConfiguration
.
getDataBase
().
trim
(),
chConfiguration
.
getPort
().
toString
(),
chConfiguration
.
getUsername
(),
chConfigu
ration
.
getPassword
());
// dataMeta.addExtraOption("MYSQL", "characterEncoding", "UTF-8");
dataMeta
.
setDatabaseType
(
"Clickhouse"
);
transMeta
.
addDatabase
(
dataMeta
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论