jbpm4.3中会签的实现主要思路也是从网上找的。新接触jbpm简单的实现下,如果有什么疑问或错误,请指正。
jpdl.xml文件见附件,这里只贴出java代码
package com.zhangrun.custom;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.TaskService;
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.activity.ExternalActivityBehaviour;
import org.jbpm.api.task.Task;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.TaskActivityStart;
import org.jbpm.pvm.internal.model.Activity;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.Transition;
import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.task.TaskImpl;
/**
* @author zr
*
*/
public class Custom implements ExternalActivityBehaviour {
private static final long serialVersionUID = 1L;
public void execute(ActivityExecution activityExecution) throws Exception {
ExecutionImpl executionimpl = (ExecutionImpl) activityExecution;
DbSession dbsession = EnvironmentImpl.getFromCurrent(DbSession.class);
TaskImpl taskimpl = dbsession.createTask();
taskimpl.setName("customTem");
taskimpl.setExecution(executionimpl);
taskimpl.setProcessInstance(executionimpl.getProcessInstance());
taskimpl.setSignalling(false);
taskimpl.setExecutionDbid(executionimpl.getDbid());
dbsession.save(taskimpl);
HistoryEvent.fire(new TaskActivityStart(taskimpl), executionimpl);
// 子任务
TaskImpl subtaskimpl1 = taskimpl.createSubTask();
subtaskimpl1.setName("huigao1");
subtaskimpl1.setAssignee("huigao1");
subtaskimpl1.setSignalling(false);
subtaskimpl1.setExecutionDbid(executionimpl.getDbid());
dbsession.save(subtaskimpl1);
HistoryEvent.fire(new TaskActivityStart(subtaskimpl1), executionimpl);
TaskImpl subtaskimpl2 = taskimpl.createSubTask();
subtaskimpl2.setName("huigao2");
subtaskimpl2.setAssignee("huigao2");
subtaskimpl2.setExecutionDbid(executionimpl.getDbid());
subtaskimpl2.setSignalling(false);
dbsession.save(subtaskimpl2);
HistoryEvent.fire(new TaskActivityStart(subtaskimpl2), executionimpl);
// 流程等待
executionimpl.waitForSignal();
}
public void signal(ActivityExecution activityExecution, String signalName,
Map<String, ?> parms) throws Exception {
ExecutionImpl executionImpl = (ExecutionImpl) activityExecution;
ProcessInstance pi = (ProcessInstance) executionImpl
.getProcessInstance();
TaskService taskService = Configuration.getProcessEngine()
.getTaskService();
Activity activity = executionImpl.getActivity();
List<Task> tasks = taskService.createTaskQuery().processInstanceId(
pi.getId()).list();
List<Task> subTask_list = taskService.getSubTasks(tasks.get(0).getId());
Iterator<Task> iter = subTask_list.iterator();
while (iter.hasNext()) {
Task subtask = iter.next();
if (parms.get("username").equals(subtask.getAssignee())) {
taskService.completeTask(subtask.getId());
}
}
if (subTask_list == null || subTask_list.size() == 1) {
Transition transition = null;
if ((signalName == null)
|| ((Task.STATE_COMPLETED.equals(signalName))
&& (activity.getOutgoingTransitions() != null) && (activity
.getOutgoingTransitions().size() == 1))) {
transition = activity.getOutgoingTransitions().get(0);
} else {
transition = activity.findOutgoingTransition(signalName);
}
taskService.completeTask(tasks.get(0).getId());
executionImpl.take(transition);
} else {
executionImpl.waitForSignal();
}
}
}
分享到:
相关推荐
在这个实例中,我们将探讨如何在JBPM4.3中实现基于Spring的会签功能。会签是一种常见的业务流程操作,需要多个参与者依次或同时对同一文档或任务进行审批,所有参与者的签名都得到确认后,流程才能继续进行。这通常...
【jbpm4.3 会签的实现】 在企业级工作流管理系统中,会签(Concurrence Signature)是一种常见的审批流程模式,它允许多个审批人同时参与同一个任务的处理,只有当所有指定的审批人都完成他们的操作后,任务才会被...
4.3安装流程设计器(MyEclipse插件) 11 4.4在MyEclipse中添加jpdl4.4 xsd文件 11 4.5准备jbpm4.4开发环境 13 4.5.1添加jbpm4.4的jar包 13 4.5.2添加并制定配置文件 13 4.6 JBPM在MyEclipse画流程图时出现乱码: 14 5 ...
BPM4工作流应用开发指南 《jBPM4工作流应用开发指南》是2010...306 第20章 中国特色工作流的jBPM实现 307 20.1 退回 308 20.2 取回 313 20.3 会签 318 20.4 委派 326 20.5 自由流 331 20.6 小结 332 附录A jBPM术语 334
.............................116 4.2.4 Pooled Actors方式.......................117 4.2.5 Actor方式....................................117 4.3 任务事件....................................................
.............................116 4.2.4 Pooled Actors方式.......................117 4.2.5 Actor方式....................................117 4.3 任务事件....................................................
综上所述,流程引擎在业务流程自动化中起到关键作用,而Activiti以其强大的功能和灵活性,成为实现高效流程管理的优秀工具。通过理解并运用上述概念,开发者能够更好地设计和管理复杂的业务流程。
会签功能通过设置task的performType实现。参与者可以静态设定(assignee属性),动态传递(运行时变量),或通过自定义Assignment类。 #### 使用Web设计器 Web设计器基于raphael技术开发,其代码位于`snaker-web`...