jbpm实践2

 <c:choose>

<c:when test="${flag.status eq '新建'}">
<a>提交</a>
</c:when>
<c:otherwise>
审核中...
</c:otherwise>
</c:choose>
提交公文---》显示流程下的路由 用于用户提交公文交给谁审批----》提交公文(提交申请)
 
  
  
  
  
  1. /** 
  2. *显示流程下的路由 用于用户提交公文交给谁审批 
  3. **/ 
  4. //显示流程下的路由 
  5. public List<String> findNextStepTransition(long processInstanceId) { 
  6.     JbpmContext context = getContext(); 
  7.     List<String> transitions = new ArrayList<String>(); 
  8.     ProcessInstance pe = context.getProcessInstance(processInstanceId); 
  9.     List<Transition> nextSteps = pe.getRootToken().getNode().getLeavingTransitions(); 
  10.     for(Transition transition : nextSteps) { 
  11.         transitions.add(transition.getName()); 
  12.     } 
  13.     return transitions; 
  14.  
  15. //提交公文(提交申请) 
  16. //提交公文 
  17. //uname 得到当前用户的工作列表 
  18. //dom_id 取得Doc对象 得到流程实例ID 得到流程实例 
  19. //transitionName 路由名称 
  20. public void applyDoc(String uname,Document doc,String transitionName) { 
  21.     String status = getStatus(uname, doc.getProcessInstanceId(), transitionName); 
  22.     doc.setStatus(status); 
  23.     update(doc); 
  24. //辅助方法 提交公文后得到对应的公文状态 
  25. private String getStatus(String uname,long processInstanceId,String transitionName) { 
  26.     JbpmContext context = getContext(); 
  27.     String status = null
  28.     //得到流程实例 
  29.     ProcessInstance pi = context.getProcessInstance(processInstanceId); 
  30.     //得到当前的节点 
  31.     String currentNodeName = pi.getRootToken().getNode().getName(); 
  32.     //得到起始节点 
  33.     String startNodeName = pi.getProcessDefinition().getStartState().getName(); 
  34.      
  35.     if(currentNodeName.equals(startNodeName)) { 
  36.         //是开始节点 通过signal()来触发流程向下一步流动 
  37.         pi.getRootToken().signal(transitionName); 
  38.     } else { 
  39.         //首先找出当前用户的当前任务 
  40.         List<TaskInstance> tasks = context.getTaskMgmtSession().findTaskInstances(uname); 
  41.         for(TaskInstance task : tasks) { 
  42.             if(task.getProcessInstance().getId()==processInstanceId) { 
  43.                 task.end(transitionName); 
  44.                 break
  45.             } 
  46.         } 
  47.     } 
  48.     //将公文当前所处的节点作为状态信息返回 
  49.     status = pi.getRootToken().getNode().getName(); 
  50.     //判断当前的状态是否结束 
  51.     if(pi.hasEnded()) { 
  52.         status = Document.STATUS_END; 
  53.     } 
  54.     return status; 

你可能感兴趣的:(新建,eq,审核,otherwise)