JBPM-動態的賦值任務申請人:
<?xml version="1.0" encoding="UTF-8"?>
<process name="task" xmlns="http://jbpm.org/4.4/jpdl">
<start name="start1" g="314,21,48,48">
<transition name="to 申請請假" to="申請請假" g="-71,-17"/>
</start>
<end name="end1" g="330,339,48,48"/>
<task name="申請請假" g="142,103,92,52" assignee="#{applicator}">
<transition name="to 部門經理審批" to="部門經理審批" g="-111,11"/>
</task>
<task name="部門經理審批" g="296,170,92,52">
<assignment-handler class="cn.itcast.jbpm0909.task.MyAssignmentHandler"></assignment-handler>
<transition name="to 總經理審批" to="總經理審批" g="-92,8"/>
</task>
<task name="總經理審批" g="405,261,92,52" assignee="#{boss}">
<transition name="to end1" to="end1" g="-47,-17"/>
</task>
</process>
public class MyAssignmentHandler implements AssignmentHandler{
@Override
public void assign(Assignable assignable, OpenExecution execution)
throws Exception {
String manager = execution.getVariable("manager").toString();//execution的上下文
assignable.setAssignee(manager);
}
}
/**
* 給任務的執行人動態的賦值
* * 在*.jpdl.xml文件中
* 在task元素中
* <task name="部門經理審批" g="296,170,92,52">
* <assignment-handler class="cn.itcast.jbpm0909.task.MyAssignmentHandler">
* </assignment-handler>
* </task>
* 可以在MyAssignmentHandler中給當前的任務賦值執行人,當進入當前節點時,assign方法執行
* * 在*.jpdl.xml文件中
* <task name="申請請假" g="142,103,92,52" assignee="#{applicator}">
* assignee可以通過流程變量的方式進行賦值
* 在執行該任務節點之前,必須給applicator賦值
* * 可以通過taskService.assignTask(String taskId,String userId);給正在執行的任務賦值任務的執行人
* @author Administrator
*
*/
public class TaskTest extends BaseJbpm{
@Test
public void testDeploy(){
processEngine.getRepositoryService()
.createDeployment()
.addResourceFromClasspath("cn/itcast/jbpm0909/task/task.jpdl.xml")
.deploy();
}
@Test
public void testStartPI(){
Map<String, String> variables = new HashMap<String, String>();
variables.put("manager", "王二麻子");
variables.put("applicator", "張三");
processEngine.getExecutionService()
.startProcessInstanceById("task-2",variables);
}
@Test
public void testFinishTask(){
processEngine.getTaskService()
.completeTask("150004");
}
@Test
public void testAssigneeWhenTask(){
/**
* 該API只能給當前的任務賦值
*/
processEngine.getTaskService()
.assignTask("290001", "王二麻子的哥");
}
}
JBPM 的詳細介紹:請點這裡
JBPM 的下載地址:請點這裡
JBPM4.4部署在Tomcat6以上的版本jar包沖突 http://www.linuxidc.com/Linux/2014-04/99476.htm
JBPM流程實例(PV)Process Variables http://www.linuxidc.com/Linux/2014-06/102859.htm
JBPM流程實例(PI)Process Instance http://www.linuxidc.com/Linux/2014-06/102858.htm
JBPM流程部署校驗 http://www.linuxidc.com/Linux/2014-06/102860.htm