JBPM4.4会签问题
abin888
2012-02-27
现在又有了新的问题。我是用jbpm4.4建立会签任务,使用
taskService.completeTask(subtask.getId());无法结束子任务。 报错: org.hibernate.ObjectNotFoundException:now rows given org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl#11 请问如何修改 代码 package com.ht.util; import java.util.HashMap; 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; public class Huiqian implements ExternalActivityBehaviour { private String form; private static final long serialVersionUID = 1L; private static int count = 0;// 同意人数 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(); TaskImpl parentTask =(TaskImpl)tasks.get(0); // 获得子任务 List<Task> subTask_list = taskService.getSubTasks(tasks.get(0).getId()); Iterator<Task> iter = subTask_list.iterator(); // 循环所有子任务 while (iter.hasNext()) { Task subtask = iter.next(); System.out.println(subtask.getId()); if (parms.get("name").equals(subtask.getAssignee())) { if (parms.get("RESULT").equals("同意")) { count++; } [b]taskService.completeTask(subtask.getId());[/b] // 完成当前会签人子任务 } } // 剩余子任务数量为1个时,则直接跳转下一个流程节点 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); // 获得将跳转到的transition } else { transition = activity.findOutgoingTransition(signalName); } Map<String, Object> map = new HashMap<String, Object>(); if (count == 2) { count = 0; map.put("RESULT", "PASS"); } else { count = 0; map.put("RESULT", "NOPASS"); // System.out.print("会签不通过"); } taskService.completeTask(tasks.get(0).getId(), map); // 结束父任务 executionImpl.take(transition); // 流程继续 } else { executionImpl.waitForSignal(); } } public void execute(ActivityExecution activityExecution) throws Exception { ExecutionImpl executionimpl = (ExecutionImpl) activityExecution; DbSession dbsession = EnvironmentImpl.getFromCurrent(DbSession.class); TaskImpl taskimpl = dbsession.createTask(); taskimpl.setName("领导会签"); taskimpl.setExecution(executionimpl); taskimpl.setProcessInstance(executionimpl.getProcessInstance()); taskimpl.setSignalling(false); taskimpl.setExecutionDbid(executionimpl.getDbid()); dbsession.save(taskimpl); HistoryEvent.fire(new TaskActivityStart(taskimpl), executionimpl); // 从原任务中分出两个子任务 //子任务1分配给manager TaskImpl subtask1 = taskimpl.createSubTask(); subtask1.setAssignee("manager"); subtask1.setFormResourceName(form); subtask1.setName("领导会签,操作角色:" + "manager"); subtask1.setSignalling(false); subtask1.setExecution(executionimpl); subtask1.setExecutionDbid(executionimpl.getDbid()); dbsession.save(subtask1); HistoryEvent.fire(new TaskActivityStart(subtask1), executionimpl); //子任务2分配给boss TaskImpl subtask2 = taskimpl.createSubTask(); subtask2.setAssignee("boss"); subtask2.setFormResourceName(form); subtask2.setName("领导会签,操作角色:" + "boss"); subtask2.setSignalling(false); subtask2.setExecution(executionimpl); subtask2.setExecutionDbid(executionimpl.getDbid()); dbsession.save(subtask2); HistoryEvent.fire(new TaskActivityStart(subtask2), executionimpl); // 流程等待 executionimpl.waitForSignal(); } public String getForm() { return form; } public void setForm(String form) { this.form = form; } } |
|
dawnlong2000
2012-02-28
工作流这么写,就没有通用性了。以上代码显然只是针对特定的流程定义
|
相关讨论
相关资源推荐
- javaee7-scaffold:使用 Gradle 和 Wildfly 开发 Java EE 7 应用程序的样板
- java中的jpa_JPA教程–在Java SE环境中设置JPA
- JPA教程–在Java SE环境中设置JPA
- Java的三大体系架构:深入剖析Java的三大体系架构,包括Java SE、Java ME和Java EE等
- Java SE、Java EE、Java ME三者之间的区别
- 在Java SE环境下使用JPA1.0
- JPA企业开发视频教程
- openjpa mysql_java – 使用openJPA MySQL进行运行时优化的例外
- 在Java SE环境下使用JPA1.0(Java EE 5.0 中的主要组成部分,TopLink配置
- Java 和微服务,第 4 部分: 处理数据 JPA 反射