flowable6.4.1+springboot使用dmn

resources/dmn/strings_1.dmn

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd"
             id="simple" name="Simple" namespace="http://activiti.org/dmn">
    <decision id="decision" name="Simple decision">
        <decisionTable id="decisionTable">
            <input>
                <inputExpression id="inputExpression1" typeRef="string">
                    <text>input1</text>
                </inputExpression>
            </input>
            <output id="output1" label="Output 1" name="output1" typeRef="string" />
            <rule>
                <inputEntry id="inputEntry1">
                    <text><![CDATA[.startsWith('test')]]></text>
                </inputEntry>
                <outputEntry id="outputEntry1">
                    <text>'shareniu1'</text>
                </outputEntry>
            </rule>
            <rule>
                <inputEntry id="inputEntry2">
                    <text><![CDATA[.endsWith('test')]]></text>
                </inputEntry>
                <outputEntry id="outputEntry2">
                    <text>'shareniu2'</text>
                </outputEntry>
            </rule>
        </decisionTable>
    </decision>
</definitions>

Service.java

import org.flowable.dmn.api.DmnRepositoryService;
import org.flowable.dmn.api.DmnRuleService;
import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TimerRedPacketService {

    @Autowired
    private DmnRuleService dmnRuleService;

    @Autowired
    private DmnRepositoryService dmnRepositoryService;

    public void redPacket(DelegateExecution execution) {
        dmnRepositoryService.createDeployment().name("secondDeployment").disableSchemaValidation()
                .addClasspathResource("dmn/strings_1.dmn").tenantId("testTenant")
                .deploy();

        Map<String, Object> processVariablesInput = new HashMap<>();
        processVariablesInput.put("input1", "Stringtest");
        List<Map<String, Object>> result = dmnRuleService.executeDecisionByKey("decision", processVariablesInput);
        System.out.println(result.get(0).get("output1"));
    }

}

resources/flowable.dmn.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="dmnEngineConfiguration" class="org.flowable.dmn.engine.impl.cfg.StandaloneDmnEngineConfiguration">
        <property name="jdbcUrl" value="jdbc:mysql://130.51.23.249:3306/flowable" />
        <property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
        <property name="jdbcUsername" value="flowable" />
        <property name="jdbcPassword" value="flowable" />
    </bean>

</beans>

pom.xml

<!--一般已引入flowable-spring-boot-starter,因此下面也可以不需要-->
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-spring-boot-starter-dmn</artifactId>
			<version>${flowable.version}</version>
		</dependency>

转载于:https://my.oschina.net/u/2464371/blog/3033904

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值