Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for extending the implementation of ID generators and expression parsers through SPI #54

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ All notable changes to this project will be documented in this file.
### Bugfix
- Fix v1.1.0 release issues


## [1.1.0] - 2023-03-15

Support CallActivity configuration and execution.
Expand All @@ -22,15 +21,11 @@ Add CallActivity Node

1. Optimize Maven dependency management

-Remove httpclient dependency

-Remove individual jsr250 API dependencies

-Remove individual junit dependencies

-Commons collections 3.2.2-->commons collections 4

-Commons lang3 3.4-->3.12.0
- Remove httpclient dependency
- Remove individual jsr250 API dependencies
- Remove individual junit dependencies
- Commons collections 3.2.2-->commons collections 4
- Commons lang3 3.4-->3.12.0

2. Optimize hook function, change HTTP mode to internal call mode, reduce dependence on HTTP packages, and improve performance

Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Turbo 简介

[![License](https://img.shields.io/github/license/didi/turbo.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![Maven](https://img.shields.io/maven-central/v/com.didiglobal.turbo/turbo.svg)](https://github.com/didi/turbo/releases)


Turbo是一款Java实现的轻量级流程引擎,是公司内多个低代码平台的核心后端服务。

# 特性
Expand Down Expand Up @@ -199,7 +203,7 @@ Turbo的定位是兼容BPMN2.0的轻量级流程引擎(而非平台),支
</dependency>
```

## 3. 配置必要信息
## 2. 配置必要信息

执行[建表语句](engine/src/main/resources/turbo.db.create/turbo.mysql.sql),在属性文件中配置属性信息

Expand All @@ -214,7 +218,7 @@ spring.datasource.dynamic.datasource.engine.url=jdbc:mysql://127.0.0.1:3306/db_e

```

## 4. 根据demo开始你的Turbo之旅吧
## 3. 根据demo开始你的Turbo之旅吧

根据上文提到的turbo支持的特性,给出了两个例子,其中整体的流程如下图所示:

Expand All @@ -232,7 +236,7 @@ Demo2:<a href="#demo2">请假流程</a>

注:例子使用两个service是为了封装sop,在实际开发中sop是有前端页面传递进入,并非是必须再次开发。

## 5. Turbo与LogicFlow交互demo
## 4. Turbo与LogicFlow交互demo

LogicFlow 是一款流程图编辑框架,提供了一系列流程图交互、编辑所必需的功能和灵活的节点自定义、插件等拓展机制。使用LogicFlow与Turbo接口交互可实现流程图创建,编辑,保存,发布功能,发布完成流程图即可参考第四部分文档,执行流程。

Expand All @@ -246,12 +250,12 @@ LogicFlow 是一款流程图编辑框架,提供了一系列流程图交互、

代码提供基本用法示例,使用方可以根据自己的业务场景参考使用

## 6. 新的节点类型CallActivity上线啦
## 5. 新的节点类型CallActivity上线啦

千呼万唤的子流程它来了,着眼于内外部需求,我们新增了调用子流程节点,支持了同步单实例调用子流程

使用文档:[CallActivityGuide](docs/CallActivityGuide.md)

## 7. 联系我们
## 6. 联系我们
### 加入微信群
添加微信号:logic-flow 加入turbo用户群
8 changes: 3 additions & 5 deletions demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
<parent>
<groupId>com.didiglobal.turbo</groupId>
<artifactId>turbo</artifactId>
<version>1.1.1</version>
<version>1.1.2-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>

<artifactId>demo</artifactId>
<version>1.1.1</version>
<version>1.1.2-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>

<spring-boot.version>1.5.10.RELEASE</spring-boot.version>
<turbo.engine.version>1.1.1</turbo.engine.version>
<h2.version>1.4.200</h2.version>
<turbo.engine.version>1.1.2-SNAPSHOT</turbo.engine.version>
</properties>

<dependencies>
Expand All @@ -44,7 +43,6 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.didiglobal.turbo.engine.annotation.EnableTurboEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.didiglobal.turbo.demo.service;

import com.didiglobal.turbo.engine.model.InstanceData;
import com.didiglobal.turbo.engine.spi.HookService;
import com.didiglobal.turbo.engine.hook.HookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.didiglobal.turbo.demo.spi;

import com.didiglobal.turbo.engine.exception.ProcessException;
import com.didiglobal.turbo.engine.spi.calculator.ExpressionCalculator;
import com.didiglobal.turbo.engine.spi.calculator.ExpressionCalculatorFactory;
import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;

import java.util.Map;

public class TestExpressionCalculator implements ExpressionCalculator {

private static final Logger LOGGER = LoggerFactory.getLogger(TestExpressionCalculator.class);

@Override
public String getType() {
return "test";
}

@Override
public Boolean calculate(String expression, Map<String, Object> dataMap) throws ProcessException {
// You can customize the implementation,
// and the code here serves as an example of extending the calculation expression
// Because all calculations in the demo use groovy, the groovy method will also be used here
LOGGER.info("enter TestExpressionCalculator, but use groovy for test");
return ExpressionCalculatorFactory.getExpressionCalculator("groovy").calculate(expression, dataMap);
}

/**
* test
*
* @param args
*/
public static void main(String[] args) {
TestExpressionCalculator testExpressionCalculator = new TestExpressionCalculator();
String expression = "[0-9]";
Map<String, Object> dataMap = Maps.newHashMap();
dataMap.put("data", "1");
try {
Boolean result = testExpressionCalculator.calculate(expression, dataMap);
Assert.isTrue(result, "test fail");
} catch (ProcessException e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.didiglobal.turbo.demo.spi;

import com.didiglobal.turbo.engine.spi.generator.IdGenerator;
import org.apache.commons.lang3.RandomStringUtils;

public class TestIdGenerator implements IdGenerator {

@Override
public String getNextId() {
// Expand your ID generator in this way
return RandomStringUtils.randomAlphabetic(20);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.didiglobal.turbo.demo.spi.TestExpressionCalculator
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.didiglobal.turbo.demo.spi.TestIdGenerator
6 changes: 3 additions & 3 deletions demo/src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ?????
# h2
spring.datasource.url=jdbc:h2:mem:test
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=root
Expand All @@ -12,10 +12,10 @@ spring.datasource.dynamic.datasource.engine.driver-class-name=org.h2.Driver
spring.datasource.dynamic.datasource.engine.url=jdbc:h2:mem:t_engine;MODE=MYSQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE


# DDL??
# DDL SQL
spring.datasource.schema=classpath:script/turbo-mysql-h2-ddl.sql

# DML??
# DML SQL
spring.datasource.data=classpath:script/turbo-mysql-h2-dml.sql

logging.config=classpath:logback-spring.xml
Expand Down
Loading