Skip to content

Commit 86f0f05

Browse files
authored
Merge pull request #150 from codingapi/dev
Dev
2 parents c683127 + 46f9830 commit 86f0f05

98 files changed

Lines changed: 1655 additions & 914 deletions

File tree

Some content is hidden

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

docs/components/flow-engine-framework_FlowScriptContext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ description: Groovy 脚本运行时的 $bind 上下文对象,为脚本提供
2222
<dependency>
2323
<groupId>com.codingapi.flow</groupId>
2424
<artifactId>flow-engine-framework</artifactId>
25-
<version>0.0.40</version>
25+
<version>0.0.42</version>
2626
</dependency>
2727
```
2828

docs/components/flow-engine-framework_GatewayContext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ GatewayContext 是框架内部获取流程操作人(IFlowOperator)数据的
2222
<dependency>
2323
<groupId>com.codingapi.flow</groupId>
2424
<artifactId>flow-engine-framework</artifactId>
25-
<version>0.0.40</version>
25+
<version>0.0.42</version>
2626
</dependency>
2727
```
2828

docs/components/flow-engine-framework_GroovyScriptBind.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ GroovyScriptBind 是脚本编写者在流程 Groovy 脚本中通过 `$bind` 变
2222
<dependency>
2323
<groupId>com.codingapi.flow</groupId>
2424
<artifactId>flow-engine-framework</artifactId>
25-
<version>0.0.40</version>
25+
<version>0.0.42</version>
2626
</dependency>
2727
```
2828

docs/components/flow-engine-framework_GroovyScriptRequest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ GroovyScriptRequest 是流程 Groovy 脚本中 `request` 参数的实际类型
2222
<dependency>
2323
<groupId>com.codingapi.flow</groupId>
2424
<artifactId>flow-engine-framework</artifactId>
25-
<version>0.0.40</version>
25+
<version>0.0.42</version>
2626
</dependency>
2727
```
2828

docs/components/flow-engine-framework_GroovyWorkflowRequest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ GroovyWorkflowRequest 用于工作流级别(非会话级别)的脚本场景
2222
<dependency>
2323
<groupId>com.codingapi.flow</groupId>
2424
<artifactId>flow-engine-framework</artifactId>
25-
<version>0.0.40</version>
25+
<version>0.0.42</version>
2626
</dependency>
2727
```
2828

docs/components/flow-engine-framework_IFlowOperator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ IFlowOperator 是流程引擎中对参与流程的用户(审批人、创建者
2222
<dependency>
2323
<groupId>com.codingapi.flow</groupId>
2424
<artifactId>flow-engine-framework</artifactId>
25-
<version>0.0.40</version>
25+
<version>0.0.42</version>
2626
</dependency>
2727
```
2828

docs/components/flow-engine-framework_RepositoryHolderContext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RepositoryHolderContext 是流程引擎运行时的基础设施注册中心。
2222
<dependency>
2323
<groupId>com.codingapi.flow</groupId>
2424
<artifactId>flow-engine-framework</artifactId>
25-
<version>0.0.40</version>
25+
<version>0.0.42</version>
2626
</dependency>
2727
```
2828

docs/components/flow-engine-framework_ScriptRegistryContext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ScriptRegistryContext 是流程引擎中所有默认 Groovy 脚本的注册中
2222
<dependency>
2323
<groupId>com.codingapi.flow</groupId>
2424
<artifactId>flow-engine-framework</artifactId>
25-
<version>0.0.40</version>
25+
<version>0.0.42</version>
2626
</dependency>
2727
```
2828

flow-engine-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.flow</groupId>
88
<artifactId>flow-engine-parent</artifactId>
9-
<version>0.0.40</version>
9+
<version>0.0.42</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.codingapi.example.convertor;
2+
3+
import com.alibaba.fastjson.JSON;
4+
import com.codingapi.example.entity.GroovyScriptEntity;
5+
import com.codingapi.springboot.script.GroovyScript;
6+
import lombok.SneakyThrows;
7+
import org.springframework.util.StringUtils;
8+
9+
import java.util.HashMap;
10+
import java.util.Map;
11+
12+
public class GroovyScriptConvertor {
13+
14+
public static GroovyScriptEntity convert(GroovyScript groovyScript) {
15+
if (groovyScript == null) {
16+
return null;
17+
}
18+
GroovyScriptEntity entity = new GroovyScriptEntity();
19+
entity.setKey(groovyScript.getKey());
20+
entity.setScript(groovyScript.getScript());
21+
entity.setDescription(groovyScript.getDescription());
22+
entity.setMethod(groovyScript.getMethod());
23+
entity.setReturnType(groovyScript.getReturnType() != null ? groovyScript.getReturnType().getName() : null);
24+
entity.setBinds(groovyScript.getBinds() != null ? JSON.toJSONString(groovyScript.getBinds()) : null);
25+
entity.setRequests(groovyScript.getRequests() != null ? JSON.toJSONString(groovyScript.getRequests()) : null);
26+
entity.setTypeOne(groovyScript.getTypeOne());
27+
entity.setTypeTwo(groovyScript.getTypeTwo());
28+
entity.setRemark(groovyScript.getRemark());
29+
entity.setTag(groovyScript.getTag());
30+
entity.setCreateTime(groovyScript.getCreateTime());
31+
entity.setUpdateTime(groovyScript.getUpdateTime());
32+
return entity;
33+
}
34+
35+
@SneakyThrows
36+
public static Map<String, Class<?>> toClassMap(String content) {
37+
if (!StringUtils.hasText(content)) {
38+
return null;
39+
}
40+
Map<String, Object> value = JSON.parseObject(content, Map.class);
41+
if (value == null || value.isEmpty()) {
42+
return null;
43+
}
44+
Map<String, Class<?>> data = new HashMap<>();
45+
46+
for (String key : value.keySet()) {
47+
Object clazzValue = value.get(key);
48+
if (clazzValue instanceof String) {
49+
data.put(key, Class.forName((String) clazzValue));
50+
}
51+
if (clazzValue instanceof Class<?>) {
52+
data.put(key, (Class) clazzValue);
53+
}
54+
}
55+
56+
return data;
57+
}
58+
59+
@SneakyThrows
60+
public static GroovyScript convert(GroovyScriptEntity entity) {
61+
if (entity == null) {
62+
return null;
63+
}
64+
return new GroovyScript(entity.getKey(),
65+
entity.getScript(),
66+
entity.getDescription(),
67+
entity.getMethod(),
68+
entity.getReturnType() != null ? Class.forName(entity.getReturnType()) : null,
69+
toClassMap(entity.getBinds()),
70+
toClassMap(entity.getRequests()),
71+
entity.getTypeOne(),
72+
entity.getTypeTwo(),
73+
entity.getTag(),
74+
entity.getRemark(),
75+
entity.getCreateTime(),
76+
entity.getUpdateTime());
77+
}
78+
}

0 commit comments

Comments
 (0)