• 1. Jbpm 相关编程接口李亚南
  • 2. JbpmContext类负责了对所有功能模块的管理在Jbpm应用中,只需要: JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance(); JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(); 两条语句就可以配置好一切。
  • 3. 查找所有ProcessInstances public void findAllProcessInstance() throws Exception { List processDefinitions = jbpmContext.getGraphSession().findAllProcessDefinitions(); for(int i = 0 ; i < processDefinitions.size();i++){ ProcessDefinition processDefinition = (ProcessDefinition)processDefinitions.get(i); long processDefinitionId = processDefinition.getId(); List processInstances = jbpmContext.getGraphSession().findProcessInstances(processDefinitionId); for(int j =0;j
  • 4. 查找特定用户得任务列表public void findByActorId(String actorId){ List processDefinitions = jbpmContext.getGraphSession().findAllProcessDefinitions(); for(int i = 0;i
  • 5. 删除一个processInstancepublic void deleteProcessInstance(long processInstanceId){ //boolean flag = false; jbpmContext.getGraphSession().deleteProcessInstance(processInstanceId); System.out.println("delete processInstance Id is : " + processInstanceId); //return flag; }
  • 6. 判定用户登陆 public boolean checkUserValidate(String userName,String password) throws Exception{ boolean flag = false; Connection conn = jbpmContext.getConnection(); Statement stmt = conn.createStatement(); String sql = "select name_,password_ from jbpm_id_user where name_='"+userName+"'"; ResultSet rs = stmt.executeQuery(sql); while(rs.next()){ if(rs.getObject("password_").equals("password")){ flag = true; }else{ flag = false; } } rs.close(); stmt.close(); conn.close(); return flag; }
  • 7. 挂起一个实例processInstancepublic void userCancleProcessInstance(long processDefinitionId ) throws Exception { ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition(processDefinitionId); ProcessInstance processInstance = new ProcessInstance(processDefinition); /* * 挂起一个实例 */ processInstance.suspend(); Date end = new Date(); processInstance.setEnd(end); }
  • 8. 使用TaskController 原理介绍
  • 9. 实现方式public Map useTaskController(long processDefinitionId){ Map parameters = new HashMap(); ProcessDefinition processDefinition = jbpmContext.getGraphSession().loadProcessDefinition(processDefinitionId); ProcessInstance processInstance = new ProcessInstance(processDefinition); TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance(); TaskController taskController = taskInstance.getTask().getTaskController(); if (taskController!=null) { List variableAccesses = taskController.getVariableAccesses(); Iterator iter = variableAccesses.iterator(); while (iter.hasNext()) { VariableAccess variableAccess = (VariableAccess) iter.next(); String mappedName = variableAccess.getMappedName(); Object value = taskInstance.getVariable(mappedName); parameters.put(mappedName, value); } } return parameters; }