Skip to content

Commit

Permalink
Merge pull request #548 from scottsut/master
Browse files Browse the repository at this point in the history
feat: 1.0.0-beta.0 release
  • Loading branch information
scottsut authored Jan 4, 2022
2 parents f35069c + 6f9821a commit 79f83eb
Show file tree
Hide file tree
Showing 583 changed files with 19,923 additions and 6,178 deletions.
8 changes: 4 additions & 4 deletions Deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ title: 部署

- JDK 1.8+
- MySql5.7+
- datart安装包(datart-server-1.0.0-alpha.3-install.zip)
- datart安装包(datart-server-1.0.0-beta.x-install.zip)
- Mail Server (可选)
- [ChromeWebDriver](https://chromedriver.chromium.org/) (可选)
- Redis (可选)

方式1 :解压安装包 (官方提供的包)

```bash
unzip datart-server-1.0.0-alpha.3-install.zip
unzip datart-server-1.0.0-beta.x-install.zip
```

方式2 :自行编译
Expand All @@ -32,11 +32,11 @@ cd datart

mvn clean package -Dmaven.test.skip=true

cp ./datart-server-1.0.0-alpha.3-install.zip ${deployment_basedir}
cp ./datart-server-1.0.0-beta.x-install.zip ${deployment_basedir}

cd ${deployment_basedir}

unzip datart-server-1.0.0-alpha.3-install.zip
unzip datart-server-1.0.0-beta.x-install.zip

```

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ datart 可作为独立平台使用,但不仅限于此,为了更好支持快
![](https://running-elephant.github.io/datart-docs/images/about/wechat-group.jpeg)

#### 插件示例仓库
[示例仓库 v1.0.0](https://github.com/Cuiyansong/datart-extension-charts)
[示例仓库 v1.0.0](https://github.com/running-elephan/datart-extension-charts)

### 参与贡献 Contributing
非常欢迎和感谢参与贡献,如何参与可参见 [Contributing]()
Expand Down
2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ datart 是新一代数据可视化开放平台,支持各类企业数据可视
参见 [User Guide](http://running-elephant.gitee.io/datart-docs/docs/source.html)

### 最新版本 Latest Release
参见 [Latest Release](https://gitee.com/running-elephant/datart/releases/1.0.0-alpha.3)
参见 [Latest Release](https://gitee.com/running-elephant/datart/releases)

## Community
### 社区支持 Support
Expand Down
Binary file modified bin/h2/datart.demo.mv.db
Binary file not shown.
2 changes: 2 additions & 0 deletions bin/migrations/migration.1.0.0-beta.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `datachart`
MODIFY COLUMN `config` mediumtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER `org_id`;
66 changes: 36 additions & 30 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>datart-parent</artifactId>
<groupId>datart</groupId>
<version>1.0.0-alpha.3</version>
<version>1.0.0-beta.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -157,39 +157,45 @@
<build>
<plugins>
<!--MyBatis generator-->
<!-- <plugin>-->
<!-- <groupId>org.mybatis.generator</groupId>-->
<!-- <artifactId>mybatis-generator-maven-plugin</artifactId>-->
<!-- <version>1.4.0</version>-->
<!-- <configuration>-->
<!-- <configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile>-->
<!-- <verbose>true</verbose>-->
<!-- <overwrite>true</overwrite>-->
<!-- <includeAllDependencies>true</includeAllDependencies>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>Generate MyBatis Artifacts</id>-->
<!-- <goals>-->
<!-- <goal>generate</goal>-->
<!-- </goals>-->
<!-- <phase>install</phase>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- <version>5.1.49</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>datart</groupId>-->
<!-- <artifactId>datart-core</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- </plugin>-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.4.0</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
<includeAllDependencies>true</includeAllDependencies>
<parameters>true</parameters>
</configuration>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<goals>
<goal>generate</goal>
</goals>
<phase>install</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
</dependency>
<dependency>
<groupId>datart</groupId>
<artifactId>datart-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>

</plugins>

</build>
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/datart/core/base/consts/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Const {
* 正则表达式
*/

public static final String REG_EMAIL = "^[a-z_0-9.-]{1,64}@([a-z0-9-]{1,200}.){1,5}[a-z]{1,6}$";
public static final String REG_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";

public static final String REG_USER_PASSWORD = ".{6,20}";

Expand All @@ -45,7 +45,8 @@ public class Const {
*/
//默认的变量引用符号
public static final String DEFAULT_VARIABLE_QUOTE = "$";

//变量匹配符
public static final String VARIABLE_EXP = "\\$\\w+\\$";
/**
* 权限变量
*/
Expand Down
36 changes: 1 addition & 35 deletions core/src/main/java/datart/core/common/CSVParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
*/
package datart.core.common;

import datart.core.base.consts.Const;
import datart.core.base.consts.ValueType;
import datart.core.base.exception.BaseException;
import datart.core.base.exception.Exceptions;
import lombok.Data;
import org.apache.commons.csv.CSVFormat;
Expand All @@ -31,7 +29,6 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.LinkedList;
Expand All @@ -40,32 +37,22 @@

public class CSVParse {

public static final ParseConfig DEFAULT_CONFIG = new ParseConfig();

static {
DEFAULT_CONFIG.setDateFormat(Const.DEFAULT_DATE_FORMAT);
}

private String path;

private ParseConfig parseConfig;

private ValueType[] types;

private SimpleDateFormat simpleDateFormat;

public static CSVParse create(String path, ParseConfig parseConfig) {
CSVParse csvParse = new CSVParse();
csvParse.path = path;
csvParse.parseConfig = parseConfig;
csvParse.simpleDateFormat = new SimpleDateFormat(parseConfig.getDateFormat());
return csvParse;
}

public static CSVParse create(String path) {
CSVParse csvParse = new CSVParse();
csvParse.path = path;
csvParse.parseConfig = DEFAULT_CONFIG;
return csvParse;
}

Expand Down Expand Up @@ -111,32 +98,11 @@ private List<Object> extractValues(CSVRecord record) {
}
LinkedList<Object> values = new LinkedList<>();
for (int i = 0; i < record.size(); i++) {
Object val;
try {
val = parseValue(record.get(i), types[i]);
} catch (Exception e) {
val = record.get(i);
}
values.add(val);
values.add(record.get(i));
}
return values;
}

private Object parseValue(String val, ValueType valueType) throws ParseException {
switch (valueType) {
case DATE:
return simpleDateFormat.parse(val);
case NUMERIC:
if (NumberUtils.isDigits(val)) {
return Long.parseLong(val);
} else {
return Double.parseDouble(val);
}
default:
return val;
}
}

@Data
public static class ParseConfig {
private String dateFormat;
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/datart/core/common/CacheFactory.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package datart.core.common;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

@Slf4j
public class CacheFactory {

private static final String CACHE_IMPL_CLASS_NAME = "cacheImpl";

private static final String DEFAULT_CACHE = "datart.server.service.impl.RedisCacheImpl";

private static Cache cache;

public static Cache getCache() {
Expand All @@ -15,6 +18,9 @@ public static Cache getCache() {
}
try {
String className = Application.getProperty(CACHE_IMPL_CLASS_NAME);
if (StringUtils.isBlank(className)) {
className = DEFAULT_CACHE;
}
cache = (Cache) Application.getBean(Class.forName(className));
return cache;
} catch (Exception e) {
Expand Down
49 changes: 49 additions & 0 deletions core/src/main/java/datart/core/common/DateUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Datart
* <p>
* Copyright 2021
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package datart.core.common;

public class DateUtils {

private static final String[] FMT = {"y", "M", "d", "H", "m", "s", "S"};

public static String inferDateFormat(String src) {
int fmtIdx = 0;
boolean findMatch = false;
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < src.length(); i++) {
char chr = src.charAt(i);
if (Character.isDigit(chr)) {
findMatch = true;
stringBuilder.append(FMT[fmtIdx]);
} else {
if (findMatch) {
fmtIdx++;
findMatch = false;
}
stringBuilder.append(chr);
}
if (fmtIdx == FMT.length - 1 && i < src.length() - 1) {
stringBuilder.append(src.substring(i + 1));
break;
}
}
return stringBuilder.toString();
}

}
16 changes: 12 additions & 4 deletions core/src/main/java/datart/core/common/JavascriptUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@

package datart.core.common;

import datart.core.base.exception.BaseException;
import datart.core.base.exception.Exceptions;
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

Expand All @@ -36,7 +37,14 @@ public class JavascriptUtils {
engineFactory = new NashornScriptEngineFactory();
}

public static Object invoke(String path, String functionName, Object... args) throws Exception {
public static Object invoke(Invocable invocable, String functionName, Object... args) throws Exception {
if (invocable != null) {
return invocable.invokeFunction(functionName, args);
}
return null;
}

public static Invocable load(String path) throws IOException, ScriptException {
InputStream stream = JavascriptUtils.class.getClassLoader().getResourceAsStream(path);
if (stream == null) {
Exceptions.notFound(path);
Expand All @@ -45,10 +53,10 @@ public static Object invoke(String path, String functionName, Object... args) th
ScriptEngine engine = engineFactory.getScriptEngine();
engine.eval(reader);
if (engine instanceof Invocable) {
Invocable invocable = (Invocable) engine;
return invocable.invokeFunction(functionName, args);
return (Invocable) engine;
}
return null;
}
}

}
12 changes: 6 additions & 6 deletions core/src/main/java/datart/core/common/WebUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ public static <T> T screenShot(String url, OutputType<T> outputType, int imageWi
ExpectedCondition<WebElement> ConditionOfHeight = ExpectedConditions.presenceOfElementLocated(By.id("height"));
wait.until(ExpectedConditions.and(ConditionOfSign, ConditionOfWidth, ConditionOfHeight));

int contentWidth = Integer.parseInt(webDriver.findElement(By.id("width")).getAttribute("value"));
Double contentWidth = Double.parseDouble(webDriver.findElement(By.id("width")).getAttribute("value"));

int contentHeight = Integer.parseInt(webDriver.findElement(By.id("height")).getAttribute("value"));
Double contentHeight = Double.parseDouble(webDriver.findElement(By.id("height")).getAttribute("value"));

if (imageWidth != contentWidth) {
// scale the window
webDriver.manage().window().setSize(new Dimension(imageWidth, contentHeight));
webDriver.manage().window().setSize(new Dimension(imageWidth, contentHeight.intValue()));
Thread.sleep(1000);
}
// scale the window again
contentWidth = Integer.parseInt(webDriver.findElement(By.id("width")).getAttribute("value"));
contentHeight = Integer.parseInt(webDriver.findElement(By.id("height")).getAttribute("value"));
webDriver.manage().window().setSize(new Dimension(contentWidth, contentHeight));
contentWidth = Double.parseDouble(webDriver.findElement(By.id("width")).getAttribute("value"));
contentHeight = Double.parseDouble(webDriver.findElement(By.id("height")).getAttribute("value"));
webDriver.manage().window().setSize(new Dimension(contentWidth.intValue(), contentHeight.intValue()));
Thread.sleep(1000);

TakesScreenshot screenshot = (TakesScreenshot) webDriver;
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/datart/core/data/provider/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class Column implements Serializable {
private String name;

private ValueType type;

private String fmt;

public Column(String name, ValueType type) {
this.name = name;
Expand Down
Loading

0 comments on commit 79f83eb

Please sign in to comment.