首页 > 其他分享 >使用flowable部署流程定义

使用flowable部署流程定义

时间:2024-03-11 21:16:05浏览次数:21  
标签:engine 定义 deploy flowable 流程 import org log4j

效果图

 会操作的表

 

 pom文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.java</groupId>
    <artifactId>flowable -service</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>flowable-test</module>
    </modules>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-engine</artifactId>
            <version>6.7.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.21</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.21</version>
        </dependency>
        <!--mysql驱动5.6.17-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>

  配置文件holiday-request.bpmn20.xml

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
             xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
             xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
             xmlns:flowable="http://flowable.org/bpmn"
             typeLanguage="http://www.w3.org/2001/XMLSchema"
             expressionLanguage="http://www.w3.org/1999/XPath"
             targetNamespace="http://www.flowable.org/processdef">

    <process id="holidayRequest" name="Holiday Request" isExecutable="true">

        <startEvent id="startEvent"/>
        <sequenceFlow sourceRef="startEvent" targetRef="approveTask"/>

        <userTask id="approveTask" name="Approve or reject request"/>
        <sequenceFlow sourceRef="approveTask" targetRef="decision"/>

        <exclusiveGateway id="decision"/>
        <sequenceFlow sourceRef="decision" targetRef="externalSystemCall">
            <conditionExpression xsi:type="tFormalExpression">
                <![CDATA[
          ${approved}
        ]]>
            </conditionExpression>
        </sequenceFlow>
        <sequenceFlow  sourceRef="decision" targetRef="sendRejectionMail">
            <conditionExpression xsi:type="tFormalExpression">
                <![CDATA[
          ${!approved}
        ]]>
            </conditionExpression>
        </sequenceFlow>

        <serviceTask id="externalSystemCall" name="Enter holidays in external system"
                     flowable:class="org.flowable.CallExternalSystemDelegate"/>
        <sequenceFlow sourceRef="externalSystemCall" targetRef="holidayApprovedTask"/>

        <userTask id="holidayApprovedTask" name="Holiday approved"/>
        <sequenceFlow sourceRef="holidayApprovedTask" targetRef="approveEnd"/>

        <serviceTask id="sendRejectionMail" name="Send out rejection email"
                     flowable:class="org.flowable.SendRejectionMail"/>
        <sequenceFlow sourceRef="sendRejectionMail" targetRef="rejectEnd"/>

        <endEvent id="approveEnd"/>

        <endEvent id="rejectEnd"/>

    </process>

</definitions>

  配置文件log4j.properties

log4j.rootLogger=DEBUG, CA

log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern= %d{hh:mm:ss,SSS} [%t] %-5p %c %x - %m%n

  代码部分

package com.java;

import org.flowable.engine.ProcessEngine;
import org.flowable.engine.ProcessEngineConfiguration;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration;
import org.flowable.engine.repository.Deployment;
import org.junit.Before;
import org.junit.Test;

/**
 * @Description:
 * @Author: 喵星人
 * @Create: 2024/3/11 9:50
 */
public class HolidayRequest {

    ProcessEngineConfiguration cfg=null;

    @Before
    public void processTest(){
         cfg = new StandaloneProcessEngineConfiguration()
                .setJdbcUrl("jdbc:mysql://127.0.0.1:3307/public_workflow?useUnicode=true&characterEncoding=utf-8&useSSL=false")
                .setJdbcUsername("root")
                .setJdbcPassword("qweiop1992")
                .setJdbcDriver("com.mysql.jdbc.Driver")
                //表结构不存在就创建
                .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    }

    /**
     * 部署流程
     */
    @Test
    public void test001(){
        /**
         * 获取对象
         */
        ProcessEngine processEngine = cfg.buildProcessEngine();
        RepositoryService service = processEngine.getRepositoryService();
        /**
         * 完成流程部署
         */
        Deployment deploy = service.createDeployment()
                .addClasspathResource("holiday-request.bpmn20.xml")
                .deploy();
        System.out.println("deploy.getId() = " + deploy.getId());
        System.out.println("deploy.getName() = " + deploy.getName());
    }


}

  

 

标签:engine,定义,deploy,flowable,流程,import,org,log4j
From: https://www.cnblogs.com/q202105271618/p/18065493

相关文章

  • flowable的查询操作和删除操作
    效果图 pom文件<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http......
  • Flowable查询历史任务
    效果图 历史任务主要是为了统计使用代码部分/***查询历史任务*/@Testpublicvoidtest007(){ProcessEngineengine=cfg.buildProcessEngine();HistoryServiceservice=engine.getHistoryService();List<HistoricActi......
  • Flowable启动流程实例和查询任务以及完成任务
    效果图 因为流程删除,所以需要  代码部分packagecom.java;importorg.flowable.engine.ProcessEngine;importorg.flowable.engine.ProcessEngineConfiguration;importorg.flowable.engine.RepositoryService;importorg.flowable.engine.RuntimeService;import......
  • 使用flowable创建工作引擎
    pom依赖<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven......
  • Qt 自定义控件
    参考:https://blog.csdn.net/danshiming/article/details/134383612https://blog.csdn.net/u011832219/article/details/128531359 1、创建自定义控件新建qt项目(项目1),选择其他项目中的“Qt设计师自定义控件”,构建套件的版本类型需要与'帮助'列表中'AboutQtCreator'弹窗的......
  • 组件的定义
    定义组件: 1.函数式定义:<divid="test"></div><scripttype="text/babel">//创建函数式组件functionDemo(){return<h2>定义的简单组件</h2>}ReactDom.render(<Demo/>,document.getElementByI......
  • uniapp自定义导航栏
    uniapp项目自定义顶部导航栏1.创建组件完整代码navigation.vue<template><viewclass="navbar-header":style="isfixed?'padding-top'+navHeight+'px':'padding-top:0px'"><viewclass="navbarcustom......
  • RAG实战5-自定义prompt
    RAG实战5-自定义prompt在阅读本文之前,先阅读RAG实战4。在RAG实战4中我们分析了LlamaIndex中RAG的执行过程,同时留下了一个尚待解决的问题:LlamaIndex中提供的prompttemplate都是英文的,该如何使用中文的prompttemplate呢?直接看以下代码:importloggingimportsysimporttorchf......
  • C语言基础-2、函数的定义与使用
    一、函数的定义和使用函数是一块代码,接受零个或多个参数,做一件事情,并返回零个或一个值函数定义:voidsum(intbegin,inend)//函数头;void:返回类型;sum:函数名,intbegin:参数表{ .......//函数体}1、调用函数函数名(参数值);ex1:#include<stdio.h>voidcheer(){ pr......
  • 生信流程全自动化方案
    分享一下当前接触和应用的生信流程自动化分析的实现经验一前言19年底刚到厦门的时候,接触了一家跟临床医院合作,提供罕见病基因检测服务的公司,生信主要对二代DNA杂交捕获的测序数据进行分析,人工操作步骤大致如下:拿到实验室做好的样本信息待测序公司返回数据后,需要第一时间进......