首页 javaWEB java学习jbpm-jbpm”Hello word”简单例子

java学习jbpm-jbpm”Hello word”简单例子

学习jbpm 根据是视频敲的代码, jbpm 版本是4.4 如果代码有侵权的话 联系作者。。 嘿嘿。。   先…

学习jbpm

根据是视频敲的代码,

jbpm 版本是4.4

如果代码有侵权的话 联系作者。。

嘿嘿。。

 

先来张 jpdl的图片

这个就是我们要实现的小流程

jbpm 4.4 的环境的配置我 就不截图了

这个就是test.jpdl.xml

代码如下

<?xml version="1.0" encoding="UTF-8"?>

<process name="test"  key="test" xmlns="http://jbpm.org/4.4/jpdl">
   <start name="start1" g="227,67,48,48">
      <transition name="提交的科长" to="科长审批" g="-52,-22"/>
   </start>
   <task  assignee="张三" name="科长审批" g="210,169,92,52">
      <transition name="提交到主任" to="主任审批" g="-52,-22"/>
   </task>
   <task  assignee="李四" name="主任审批" g="207,294,92,52">
      <transition name="通过" to="end1" g="-58,-21"/>
   </task>
    <end name="end1" g="233,407,48,48"/>

</process>

默认的配置:jbpm.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration>

  <import resource="jbpm.default.cfg.xml" />
  <import resource="jbpm.businesscalendar.cfg.xml" />
  <import resource="jbpm.tx.hibernate.cfg.xml" />
  <import resource="jbpm.jpdl.cfg.xml" />
  <import resource="jbpm.bpmn.cfg.xml" />
  <import resource="jbpm.identity.cfg.xml" />

  <!-- Job executor is excluded for running the example test cases. -->
  <!-- To enable timers and messages in production use, this should be included. -->
  <!--
  <import resource="jbpm.jobexecutor.cfg.xml" />
  -->

</jbpm-configuration>

配置与数据库相对应的  jbpm.hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
  <session-factory>

     <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
       <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/jbmp
       ?useUnicode=true&amp;characterEncoding=UTF-8</property>
     <property name="hibernate.connection.username">root</property>
     <property name="hibernate.connection.password">123456</property>
     <property name="hibernate.hbm2ddl.auto">update</property>
     <property name="hibernate.format_sql">true</property>

     <mapping resource="jbpm.repository.hbm.xml" />
     <mapping resource="jbpm.execution.hbm.xml" />
     <mapping resource="jbpm.history.hbm.xml" />
     <mapping resource="jbpm.task.hbm.xml" />
     <mapping resource="jbpm.identity.hbm.xml" />

  </session-factory>
</hibernate-configuration>

helloword 的代码如下

//部署流程
    public  void  deploy(){
         ProcessEngine  proEngine=Configuration.getProcessEngine();
         RepositoryService  repositoryService= proEngine.getRepositoryService();
           repositoryService.createDeployment()
          .addResourceFromClasspath("test.jpdl.xml").deploy();
    }
    //创建流程实例
    public  void createInstance(){
        ProcessEngine processEngine=Configuration.getProcessEngine();
        ExecutionService executionService=processEngine.getExecutionService();
        ProcessInstance processInstance=executionService.startProcessInstanceByKey("test");
        System.out.println("流程实例ID=="+processInstance.getId());
    }
    //获取对应的人员的任务
    public  void  getTask(){
        System.out.println("aaa");
        ProcessEngine processEngine =Configuration.getProcessEngine() ;
        TaskService taskService=processEngine.getTaskService();
        List<Task> tasks=taskService.findPersonalTasks("张三");
        //List<Task> tasks=taskService.findPersonalTasks("李四");
        Task task= tasks.get(0);
        System.out.println("任务数量==="+tasks.size());
        System.out.println("任务名词==="+task.getActivityName());
        System.out.println("任务人员==="+task.getAssignee()+"任务id=="+task.getId());
    }
    //查询流程实例当前所在的节点
    public void getCurrectActivity(){
        ProcessEngine processEngine = Configuration.getProcessEngine();
        ExecutionService executionService=processEngine.getExecutionService();
          String activityName=executionService.createProcessInstanceQuery()
         .processInstanceId("test.10001").uniqueResult()
         .findActiveActivityNames().toString();
        System.out.println("当前任务所在节点id"+activityName);
    }
    //完成任务
    public  void completeTask(){
        ProcessEngine processEngine= Configuration.getProcessEngine();
        TaskService taskService=processEngine.getTaskService();
       // taskService.completeTask("10002"); 对李三
        taskService.completeTask("20001");//对李四

    }

 

 

免责声明:文章内容不代表本站立场,本站不对其内容的真实性、完整性、准确性给予任何担保、暗示和承诺,仅供读者参考,文章版权归原作者所有。如本文内容影响到您的合法权益(内容、图片等),请及时联系本站,我们会及时删除处理。

为您推荐

nodejs 整理记录

nodejs 整理记录

下载包 https://blog.csdn.net/m0_59878114/article/details/120274...
websocket测试html

websocket测试html

<!DOCTYPE html> <html> <head> <meta cha...
bigdemical两个数比较大小

bigdemical两个数比较大小

/*int result = bigdemical1.compareTo(bigdemical2) result = -...
Beetl2.7 中文文档

Beetl2.7 中文文档

Beetl目前版本是2.7.23,相对于其他java模板引擎,具有功能齐全,语法直观,性能超高,以及编写的模板容易维护等...
纯CSS实现多个便签在一行展示,拖动滚动

纯CSS实现多个便签在一行展示,拖动滚动

div <h2>请注意需要在移动端预览,PC端拖拽无效果</h2> <div class=...
返回顶部