JBPM4.4学习笔记
1、JBPM4表说明:
JBPM4_DEPLOYMENT 流程定义表
JBPM4_DEPLOYPROP 流程定义属性表
JBPM4_EXECUTION 流程实例表
JBPM4_HIST_ACTINST 流程活动( 节点) 实例表
JBPM4_HIST_DETAIL 流程历史详细表
JBPM4_HIST_PROCINST 流程实例历史表
JBPM4_HIST_TASK 流程任务实例历史表
JBPM4_HIST_VAR 流程变量( 上下文) 历史表
JBPM4_ID_GROUP 组表
JBPM4_ID_MEMBERSHIP 用户角色表
JBPM4_ID_USER 用户表
JBPM4_JOB 定时表
JBPM4_LOB 存储表 存放流程定义的xml和png图片文件
JBPM4_PARTICIPATION 参与者表
JBPM4_SWIMLANE 泳道表
JBPM4_TASK 任务表
JBPM4_VARIABLE 上下文表
2、工作流的基本思路:
3、jBPM有什么,简介jBPM的Service API
4、jPDL基础--1
5、流程操作1、如何发布流程
//如果是读取默认的jbpm.cfg.xml文件
ProcessEngine engine = Configuration.getProcessEngine();
//如果不是读取默认的jbpm.cfg.xml文件
ProcessEngine engine = new Configuration()
.setResource("ccjbpm.cfg.xml")
.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment()
.addResourceFromClasspath("cn/javass/jbpm4/hello/hello.jpdl.xml")
.deploy();
2、如何检索流程定义
ProcessEngine processEngine = Configuration.getProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
List<ProcessDefinition> pdList = repositoryService.createProcessDefinitionQuery().list();
for (ProcessDefinition pd:pdList){
System.out.println("id:"+pd.getId());
System.out.println("name:"+pd.getName());
System.out.println("version:"+pd.getVersion());
System.out.println("deploymentId:"+pd.getDeploymentId());
System.out.println("---------------");
}
3、如何启动一个实例
ProcessEngine processEngine = Configuration.getProcessEngine();
ExecutionService executionService = processEngine.getExecutionService();
Map map = new HashMap();
map.put("pm","ProjectManager");
map.put("dm", "DepartmentManager ");
map.put("ceo", "Manager");
executionService.startProcessInstanceByKey("MyProcess",map);
4、如何检索流程实例
ProcessEngine processEngine = Configuration.getProcessEngine();
ExecutionService executionService = processEngine.getExecutionService();
List<ProcessInstance> piList = executionService.createProcessInstanceQuery().list();
for (ProcessInstance pi : piList) {
System.out.println("id:"+pi.getId());
System.out.println("activeActivityNames:“+pi.findActiveActivityNames());
System.out.println("state:"+pi.getState());
System.out.println("-----------------");
5、如何检索出Task
ProcessEngine processEngine = Configuration.getProcessEngine();
TaskService taskService = processEngine.getTaskService();
List<Task> list = taskService.createTaskQuery().list();
for(Task t : list){
System.out.println("activityName="+t.getActivityName()+",user="
+t.getAssignee()+",id="+t.getId());
6、如何完成task
ProcessEngine processEngine = Configuration.getProcessEngine();
TaskService taskService = processEngine.getTaskService();
String taskId = “70003”;//这个是流程运行中生成的任务id Map map = new HashMap();
map.put("dmResult", 1);
map.put("days", 15); taskService.completeTask(taskId,map);
7、如何检索出历史的流程实例
ProcessEngine engine = Configuration.getProcessEngine();
HistoryService hs = engine.getHistoryService();
List<HistoryProcessInstance> list = hs.createHistoryProcessInstanceQuery().list(); for(HistoryProcessInstance hpi : list){
System.out.println("state="+hpi.getState()+" ,pdid=“+hpi.getProcessDefinitionId()+
",piid="+hpi.getProcessInstanceId()+",startTime="+hpi.getStartTime());
}
6、流程的描述
ExecutionService exe = engine.getExecutionService(); Execution e = exe.createProcessInstanceQuery()
.processInstanceId(piid).uniqueResult()
.findActiveExecutionIn(“state活动名称"); exe.signalExecutionById(e.getId());
<decision name="evaluate document">
<handler class="org.jbpm.examples.decision.handler.ContentEvaluation" />
<transition name="good" to="submit document" />
<transition name="bad" to="try again" />
<transition name="ugly" to="give up" />
</decision>
public class ContentEvaluation implements DecisionHand
public String decide(OpenExecution execution) {
String content = (String) execution.getVariable("content");
if (content.equals("you're great")) {
return "good";
}
if (content.equals("you gotta improve")) {
return "bad";
}
return "ugly";
}
}
<decision>
<transition name="good" to="submit document" />
<transition name="bad" to="try again" />
<transition name="ugly" to="give up" />
</decision> Map<String, Object> variables = new HashMap<String, Object>();
variables.put("content", "good");
ProcessInstance processInstance =
executionService.startProcessInstanceByKey("DecisionExpression", variables);
<decision name="evaluate document">
<transition to="submit document">
<condition expr="#{content=="good"}" />
</transition>
<transition to="try again">
<condition expr="#{content=="not so good"}" />
</transition>
<transition to="give up" />
</decision> Map<String, Object> variables = new HashMap<String, Object>();
variables.put("content", "good");
ProcessInstance processInstance =
executionService.startProcessInstanceByKey("DecisionConditions", variables);
<task name="review" assignee="#{order.owner}" > 《或者assignee="johndoe"》
<transition to="wait" />
</task>
public class Order implements Serializable { String owner; public Order(String owner) { this.owner = owner; } public String getOwner() { return owner; } public void setOwner(String owner) { this.owner = owner; } } Map<String, Object> variables = new HashMap<String, Object>();
variables.put("order", new Order("johndoe")); ProcessInstance processInstance = executionService
.startProcessInstanceByKey("TaskAssignee", variables); List<Task> taskList = taskService.findPersonalTasks("johndoe");
};
TaskService taskService = processEngine.getTaskService();
taskService.takeTask(“task的id”, “领取task的人员");
<task name="review" candidate-groups="sales" > <transition to="wait" /> </task> IdentityService identityService = processEngine.getIdentityService();
identityService.createGroup("sales");
identityService.createUser(“zhang", “zhang", “san");
identityService.createUser(“li", “li", “si");
identityService.createMembership(“zhang", "sales");
identityService.createMembership(“li", "sales");
taskService.findGroupTasks("zhang");
taskService.findGroupTasks("li");
注意:为了防止同一个任务被一个分组中的多个人领取,需要将这个任务分配给指定的个人后才能开始执行任务,例如下面taskService.takeTask(task.getDbid(), "zhang");并且任务呗某一个用户领取之后,应该将该任务标识为已领取状态,以避免造成重复。
<task name="review" g="96,16,127,52">
<assignment-handler class="org.jbpm.examples.task.assignmenthandler.AssignTask"> <field name="assignee">
<string value="johndoe" />
</field> </assignment-handler>
<transition to="wait" /> </task>
public class AssignTask implements AssignmentHandler{ private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public void assign(Assignable assignable, OpenExecution execution) throws Exception { assignable.setAssignee(name); } }
注意:Please note that potentially, AssignmentHandler implementations can use the process variables and any other Java API to access resources like your application database to calculate the assignee and candidate users and groups.}
<java g="246,135,92,52" name="java1" class="cn.javass.test.java.MyJava"
method="sayHello" var="manager"> <field name="user1"><object expr="#{user1}"/></field> <field name="user2"><string value="user2"/></field> <arg><string value="xyz"/></arg> <arg><object expr="#{abc}"/></arg> <transition to="task1"/> </java>
public class MyJava{ private String user1; private String user2; …user1和user2的setter public String sayHello(String arg1,String arg2){ System.out.println("user1=="+user1); System.out.println("user2=="+user2); System.out.println("arg1=="+arg1); System.out.println("arg2=="+arg2); return “Hello"; } }
<sql g="192,438,92,52" name="sql1" unique="true" var="sqlV">
<query>
select * from tbl_user where uuid=:uuid
</query> <parameters>
<object name="uuid" expr="#{uuid}"></object>
</parameters> <transition to="hql1"/>
</sql>
<hql name="hql1" g="404,457,92,52" unique="true" var="hqlV">
<query>
select o from Parent o where o.id=:id
</query> <parameters>
<string name="id" value="22"/>
</parameters> <transition to="task2"/>
</hql>
<foreach name="foreach1" in="D1,D2,D3" var="nowDep">
<transition to="task5"/>
</foreach> <task name="task5">
<transition to="join1"/>
</task> <join name="join1" multiplicity="3">
<transition to="task6"/>
</join>
与join活动连用通常情况下,foreach活动后面是多次执行的活动,在这个活动后面应该跟一个join活动,并且把join活动的multiplicity设置成为foreach的数量,这样才会等到foreach的多个task执行完成,流程才继续向下,否则,只要有一个foreach的task完成了,流程就向下流转了。
<on event="start"> <event-listener class="org.jbpm.examples.eventlistener.LogListener">
<field name="msg"><string value="start on process definition"/></field>
</event-listener>
</on> <start>
<transition to="wait"/>
</start> <state name="wait">
<on event="start">
<event-listener class="org.jbpm.examples.eventlistener.LogListener">
<field name="msg"><string value="start on activity wait"/></field>
</event-listener>
</on> <on event="end">
<event-listener class="org.jbpm.examples.eventlistener.LogListener">
<field name="msg"><string value="end on activity wait"/></field>
</event-listener>
</on> <transition to="park">
<event-listener class="org.jbpm.examples.eventlistener.LogListener">
<field name="msg"><string value="take transition"/></field>
</event-listener>
</transition> </state>public class MyEventListener implements EventListener{ public void notify(EventListenerExecution exection) throws Exception { System.out.println("走出Decistion"); }
}
7、tomcat的配置:
JBPM4.4学习笔记的更多相关文章
- js学习笔记:webpack基础入门(一)
之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...
- PHP-自定义模板-学习笔记
1. 开始 这几天,看了李炎恢老师的<PHP第二季度视频>中的“章节7:创建TPL自定义模板”,做一个学习笔记,通过绘制架构图.UML类图和思维导图,来对加深理解. 2. 整体架构图 ...
- PHP-会员登录与注册例子解析-学习笔记
1.开始 最近开始学习李炎恢老师的<PHP第二季度视频>中的“章节5:使用OOP注册会员”,做一个学习笔记,通过绘制基本页面流程和UML类图,来对加深理解. 2.基本页面流程 3.通过UM ...
- 2014年暑假c#学习笔记目录
2014年暑假c#学习笔记 一.C#编程基础 1. c#编程基础之枚举 2. c#编程基础之函数可变参数 3. c#编程基础之字符串基础 4. c#编程基础之字符串函数 5.c#编程基础之ref.ou ...
- JAVA GUI编程学习笔记目录
2014年暑假JAVA GUI编程学习笔记目录 1.JAVA之GUI编程概述 2.JAVA之GUI编程布局 3.JAVA之GUI编程Frame窗口 4.JAVA之GUI编程事件监听机制 5.JAVA之 ...
- seaJs学习笔记2 – seaJs组建库的使用
原文地址:seaJs学习笔记2 – seaJs组建库的使用 我觉得学习新东西并不是会使用它就够了的,会使用仅仅代表你看懂了,理解了,二不代表你深入了,彻悟了它的精髓. 所以不断的学习将是源源不断. 最 ...
- CSS学习笔记
CSS学习笔记 2016年12月15日整理 CSS基础 Chapter1 在console输入escape("宋体") ENTER 就会出现unicode编码 显示"%u ...
- HTML学习笔记
HTML学习笔记 2016年12月15日整理 Chapter1 URL(scheme://host.domain:port/path/filename) scheme: 定义因特网服务的类型,常见的为 ...
- DirectX Graphics Infrastructure(DXGI):最佳范例 学习笔记
今天要学习的这篇文章写的算是比较早的了,大概在DX11时代就写好了,当时龙书11版看得很潦草,并没有注意这篇文章,现在看12,觉得是跳不过去的一篇文章,地址如下: https://msdn.micro ...
随机推荐
- VS2013 tips
1.创建一个connection时会自动产生一个localdb数据库文件,可以通过Server Explorer窗口查看这个localDB,注意,是Server Explorer窗口,而不是SQL S ...
- 每天一个linux命令:【转载】head命令
head 与 tail 就像它的名字一样的浅显易懂,它是用来显示开头或结尾某个数量的文字区块,head 用来显示档案的开头至标准输出中,而 tail 想当然尔就是看档案的结尾. 1.命令格式: hea ...
- pat甲级 1155 Heap Paths (30 分)
In computer science, a heap is a specialized tree-based data structure that satisfies the heap prope ...
- 淘宝npm镜像使用
淘宝NPM镜像使用 镜像使用方法 1.config命令 npm config set registry https://registry.npm.taobao.org npm info undersc ...
- LeetCode 739. Daily Temperatures
原题链接在这里:https://leetcode.com/problems/daily-temperatures/description/ 题目: Given a list of daily temp ...
- tomcat nginx 证书切换
1. 导出公钥 keytool -export -alias tomcat -keystore <you jks>wsriakey.keystore -file <outputfil ...
- 嵌入式linux问题杂锦
tftp 在开发板上不能获取共享文件,出现: Permission denied tftp: can't open 'myTcpTest': Permission denied 是因为,我在/sys目 ...
- PHP如何实现网址伪静态(转)
Apache的 mod_rewrite是比较强大的,在进行网站建设时,可以通过这个模块来实现伪静态.主要步骤如下: 1.检测Apache是否开启mod_rewrite功能 可以通过php提供的 ...
- MyEclipse自动生成Ant Build.xm
关于MyEclipse 自动生成 Ant Build.xml 配置文件,生成的方法很隐蔽,是自己无意中找到的.选择你要生成Build.xml文件的项目,右键. Export-> General ...
- winform Textbox模糊搜索实现下拉显示+提示文字
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...