Skip to content

Commit 32735ca

Browse files
committed
fix(chart): merge conflicts
2 parents dffbacb + 92c593e commit 32735ca

File tree

118 files changed

+1507
-1204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1507
-1204
lines changed

README_zh.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ datart 是新一代数据可视化开放平台,支持各类企业数据可视
6464

6565
## License
6666
datart is under the Apache 2.0 license. See the [LICENSE](https://gitee.com/running-elephant/datart/blob/master/LICENSE) file for details.
67+
68+
**(在使用上遇到的任何问题,以及对 datart 的建议,欢迎创建 issue 提问和讨论)**

config/datart.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ datart.user.register=true
2020
datart.register.expire-hours=
2121
# 邀请邮件有效期/小时, 默认48小时
2222
datart.invite.expire-hours=
23-
# 系统运行模式: normal-正常(默认),single-单组织
24-
datart.mode=normal
25-
# 用户名/密码: 仅单组织模式且两者都不为空时重置
23+
# 租户管理模式:platform-平台(默认),team-团队
24+
datart.tenant-management-mode=platform
25+
# 团队管理员用户名/密码: 仅team模式且两者都不为空时重置
2626
datart.admin.username=
2727
datart.admin.password=

config/profiles/application-config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ datart:
6767
server:
6868
address: ${datart.address:http://127.0.0.1:8080}
6969

70-
# 系统运行模式:normal-正常(默认),single-单组织
71-
mode: normal
72-
# 用户名/密码: 仅单组织模式且两者都不为空时重置
70+
# 租户管理模式:plateform-平台(默认),team-团队
71+
tenant-management-mode: platform
72+
# 团队管理员用户名/密码: 仅team模式且两者都不为空时重置
7373
admin:
7474
username:
7575
password:

core/src/main/java/datart/core/base/consts/SystemMode.java

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package datart.core.base.consts;
2+
3+
public enum TenantManagementMode {
4+
/** 团队模式 */
5+
TEAM,
6+
/** 平台模式 */
7+
PLATFORM;
8+
9+
}

core/src/main/java/datart/core/common/Application.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package datart.core.common;
2020

21-
import datart.core.base.consts.SystemMode;
21+
import datart.core.base.consts.TenantManagementMode;
2222
import lombok.extern.slf4j.Slf4j;
2323
import org.apache.commons.lang3.BooleanUtils;
2424
import org.apache.commons.lang3.StringUtils;
@@ -28,15 +28,15 @@
2828
import org.springframework.lang.NonNull;
2929
import org.springframework.stereotype.Component;
3030

31-
import static datart.core.base.consts.SystemMode.NORMAL;
31+
import static datart.core.base.consts.TenantManagementMode.PLATFORM;
3232

3333
@Component
3434
@Slf4j
3535
public class Application implements ApplicationContextAware {
3636

3737
private static ApplicationContext context;
3838

39-
private static SystemMode currMode;
39+
private static TenantManagementMode currMode;
4040

4141
@Override
4242
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
@@ -99,21 +99,21 @@ public static boolean canRegister() {
9999
}
100100

101101
public static String getAdminId() {
102-
if (getCurrMode().equals(SystemMode.SINGLE)){
102+
if (getCurrMode().equals(TenantManagementMode.TEAM)){
103103
return getProperty("datart.admin-id", "datart-admin");
104104
}
105105
return "";
106106
}
107107

108-
public static SystemMode getCurrMode() {
108+
public static TenantManagementMode getCurrMode() {
109109
if (currMode == null) {
110-
String mode = Application.getProperty("datart.mode");
110+
String mode = Application.getProperty("datart.tenant-management-mode");
111111
try {
112-
return SystemMode.valueOf(mode.toUpperCase());
112+
return TenantManagementMode.valueOf(mode.toUpperCase());
113113
} catch (Exception e) {
114-
log.warn("Unrecognized mode: '{}', and this will run in normal mode", mode);
114+
log.warn("Unrecognized tenant-management-mode: '{}', and this will run in platform tenant-management-mode", mode);
115115
}
116-
currMode = NORMAL;
116+
currMode = PLATFORM;
117117
}
118118
return currMode;
119119
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Datart
3+
* <p>
4+
* Copyright 2021
5+
* <p>
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package datart.core.common;
20+
21+
import org.apache.ibatis.javassist.ClassPool;
22+
import org.apache.ibatis.javassist.CtClass;
23+
import org.apache.ibatis.javassist.CtMethod;
24+
25+
public class ClassTransformer {
26+
27+
public static void transform() {
28+
transformSqlWriter();
29+
transformFlyway();
30+
}
31+
32+
private static void transformSqlWriter() {
33+
try {
34+
ClassPool classPool = ClassPool.getDefault();
35+
CtClass ctClass = classPool.get("org.apache.calcite.sql.pretty.SqlPrettyWriter");
36+
CtMethod keyword = ctClass.getDeclaredMethod("keyword");
37+
keyword.setBody("{ maybeWhitespace($1);" +
38+
" buf.append($1);" +
39+
" if (!$1.equals(\"\")) {" +
40+
" setNeedWhitespace(needWhitespaceAfter($1));" +
41+
" } " +
42+
"return;} ");
43+
ctClass.toClass();
44+
} catch (Exception e) {
45+
e.printStackTrace();
46+
}
47+
}
48+
49+
private static void transformFlyway() {
50+
try {
51+
ClassPool classPool = ClassPool.getDefault();
52+
CtClass ctClass = classPool.get("org.flywaydb.core.internal.database.mysql.MySQLConnection");
53+
CtMethod getIntVariableValue = ctClass.getDeclaredMethod("getIntVariableValue");
54+
getIntVariableValue.setBody("return 0;");
55+
56+
CtMethod doRestoreOriginalState = ctClass.getDeclaredMethod("doRestoreOriginalState");
57+
doRestoreOriginalState.setBody("return;");
58+
59+
CtMethod hasUserVariableResetCapability = ctClass.getDeclaredMethod("hasUserVariableResetCapability");
60+
hasUserVariableResetCapability.setBody("{return false;}");
61+
ctClass.toClass();
62+
} catch (Exception e) {
63+
e.printStackTrace();
64+
}
65+
}
66+
}

core/src/main/java/datart/core/common/WebUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,16 @@ public static <T> T screenShot(String url, OutputType<T> outputType, int imageWi
7373

7474
Double contentHeight = Double.parseDouble(webDriver.findElement(By.id("height")).getAttribute("value"));
7575

76-
if (imageWidth != contentWidth) {
76+
if (imageWidth>0 && imageWidth != contentWidth) {
7777
// scale the window
7878
webDriver.manage().window().setSize(new Dimension(imageWidth, contentHeight.intValue()));
79-
Thread.sleep(1000);
8079
}
80+
Thread.sleep(1500);
8181
// scale the window again
8282
contentWidth = Double.parseDouble(webDriver.findElement(By.id("width")).getAttribute("value"));
83+
contentWidth = contentWidth>0 ? contentWidth : 1920;
8384
contentHeight = Double.parseDouble(webDriver.findElement(By.id("height")).getAttribute("value"));
85+
contentHeight = contentHeight>0 ? contentHeight : 600;
8486
webDriver.manage().window().setSize(new Dimension(contentWidth.intValue(), contentHeight.intValue()));
8587
Thread.sleep(1000);
8688

@@ -124,6 +126,7 @@ private static WebDriver createChromeWebDriver(String driverPath) throws Excepti
124126
options.addArguments("disable-web-security");
125127
options.addArguments("no-proxy-server");
126128
options.addArguments("disable-dev-shm-usage");
129+
options.addArguments("window-size=2048,1536");
127130

128131
if (isRemoteDriver(driverPath)) {
129132
return new RemoteWebDriver(new URL(driverPath), options);

data-providers/http-data-provider/src/main/java/datart/data/provider/HttpDataFetcher.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package datart.data.provider;
1919

2020
import datart.core.data.provider.Dataframe;
21+
import lombok.extern.slf4j.Slf4j;
2122
import org.apache.commons.codec.binary.Base64;
2223
import org.apache.commons.lang3.StringUtils;
2324
import org.apache.http.HttpEntity;
@@ -27,9 +28,13 @@
2728
import org.apache.http.client.config.RequestConfig;
2829
import org.apache.http.client.methods.*;
2930
import org.apache.http.client.utils.URIBuilder;
31+
import org.apache.http.conn.ssl.NoopHostnameVerifier;
32+
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
33+
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
3034
import org.apache.http.entity.ContentType;
3135
import org.apache.http.entity.StringEntity;
3236
import org.apache.http.impl.client.HttpClientBuilder;
37+
import org.apache.http.ssl.SSLContexts;
3338
import org.springframework.util.CollectionUtils;
3439

3540
import java.io.IOException;
@@ -38,14 +43,25 @@
3843
import java.nio.charset.StandardCharsets;
3944
import java.util.Map;
4045

46+
@Slf4j
4147
public class HttpDataFetcher {
4248

4349
private static final HttpClient httpClient;
4450

4551
private final HttpRequestParam param;
4652

4753
static {
48-
httpClient = HttpClientBuilder.create().build();
54+
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
55+
try {
56+
// trust self-signed certificate and ignore hostname verification
57+
SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(
58+
SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(),
59+
NoopHostnameVerifier.INSTANCE);
60+
httpClientBuilder.setSSLSocketFactory(scsf);
61+
} catch (Exception e) {
62+
log.warn("HttpClient config ssl failed, and used default config.");
63+
}
64+
httpClient = httpClientBuilder.build();
4965
}
5066

5167
public HttpDataFetcher(HttpRequestParam param) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package datart.data.provider.jdbc.adapters;
2+
3+
import org.apache.commons.lang3.StringUtils;
4+
5+
import java.sql.Connection;
6+
import java.sql.DatabaseMetaData;
7+
import java.sql.ResultSet;
8+
import java.sql.SQLException;
9+
import java.util.Collections;
10+
import java.util.HashSet;
11+
import java.util.Set;
12+
13+
public class HiveDataProviderAdapter extends JdbcDataProviderAdapter {
14+
15+
@Override
16+
public Set<String> readAllDatabases() throws SQLException {
17+
Set<String> schemas = new HashSet<>();
18+
try (Connection conn = getConn()) {
19+
String schema = conn.getSchema();
20+
if (StringUtils.isNotBlank(schema)) {
21+
return Collections.singleton(schema);
22+
}
23+
DatabaseMetaData metadata = conn.getMetaData();
24+
try (ResultSet rs = metadata.getSchemas()) {
25+
while (rs.next()) {
26+
String schemaName = rs.getString(1);
27+
schemas.add(schemaName);
28+
}
29+
}
30+
return schemas;
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)