JPdl:jbpm流程定义文件,下面是一个简单的流程定义文件:
下面对JPdl中各个Element进行介绍
(1) process
attribution:1.name:这个流程的名字,是必须的
2.key
3.version
(2)start
1.name:这个activity的名称,开始activity是每个流程的第一个执行的activity所以可以没有name
[2]transition
(3)states
(4)带分支的states
ProcessInstance processInstance = executionService .startProcessInstanceByKey("StateChoice");
通过process的name来得到这个process的instance,然后使用这个instance来做一些操作
String executionId = processInstance .findActiveExecutionIn("wait for response") .getId();得到name等于wwait for response的statesprocessInstance = executionService.signalExecutionById(executionId, "accept");这个states接受一个外界为accept的信号,然后根据transition的name来选择转向下一个states
(5) decision:takes one path of many alternatives outgoings,只能转向其中的一个节点
de cision.transition.condit
Mapvariables = new HashMap ();variables.put("content", "good");ProcessInstance processInstance = executionService.startProcessInstanceByKey("DecisionConditions", variables);
通过对varibles的设置可以控制流程下一个节点的转向
(6)decision expr
通过在执行流程的过程中设置content的值可以控制"evaluate document"下一个节点转向
Mapvariables = new HashMap ();variables.put("content", "good");ProcessInstance processInstance = executionService.startProcessInstanceByKey("DecisionExpression", variables);
(7)decisiton handler:通过自定义的程序来控制转向
接下来创建 ContentEvaluation这个类,实现DecisionHandler这个接口
public class ContentEvaluation implements DecisionHandler { 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"; }}
(8)fork and join(同时)
1.fork activity allows a single path of execution to be of split into two or more branches which can execute
activities concurrently(所有这些分支会被同时执行)
2.join actvity allows multipart paths of execution to join into one path which execute when all path execute
success(join是由多个分支流入,一个活动流出,必须等到前面流入的分支都执行完成再会留到下一个节点,他们之间的关系相当于"与"的关系)
(9)end 流程的结束,一个流程可以定义多个不同的结束节点
返回到名称为completed的states
(10)task:create a task for a person in the task component
你也可以assignee = "jeck",把这个task分配给了jeck这个人
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; }}
Mapvariables = new HashMap ();variables.put("order", new Order("johndoe")); //order相当于指向这个Order对象的一个引用,order.owner来获取Order对象的owner这个属性ProcessInstance processInstance = executionService .startProcessInstanceByKey("TaskAssignee", variables);
ListtaskList = taskService.findPersonalTasks("johndoe");
上面的代码可以根据某个人的Id来得到这个用户所有相关的task
(11)可以将一个task分配给一个用户组,只要用户在这个组里面就要去完成这个task,like follow code:
identityService.createGroup("sales-dept"); //创建一个用户组identityService.createUser("johndoe", "johndoe", "John", "Doe"); //创建一个用户identityService.createMembership("johndoe", "sales-dept"); //将这个用户和这个组相关联identityService.createUser("joesmoe", "joesmoe", "Joe", "Smoe");identityService.createMembership("joesmoe", "sales-dept");
(12)task assignment handler
public class AssignTask implements AssignmentHandler { String assignee; public void assign(Assignable assignable, OpenExecution execution) { assignable.setAssignee(assignee); }}
(13)task swimlanes:可以将多个task定义为一个swimlanes,然后将这个泳道分配给用户或者用户组
(1)name(requerid)
(2)assignee
(3)candidate-groups
(4)candidate-users
(14)java 和 script自动执行的活动
(15)mail发邮件的活动