JBPM4.4業務流程管理框架詳細解讀
阿新 • • 發佈:2019-01-05
如需轉載;請註明原文出處謝謝合作!public class ProcessTest { private static ProcessEngine processEngine = Configuration.getProcessEngine(); @Test public void testProcess() throws Exception { // 部署流程定義 InputStream in = this.getClass().getResourceAsStream("test.jpdl.xml"); String deploymentId = processEngine.getRepositoryService()// .createDeployment()// .addResourceFromInputStream("test.jpdl.xml", in)// .deploy(); System.out.println("部署流程定義完畢:deploymentId = " + deploymentId); // 啟動流程例項 Map<String, Object> variables = new HashMap<String, Object>(); variables.put("manager", "王經理"); variables.put("userIds", "小A,小B,小C,小D"); ProcessInstance pi = processEngine.getExecutionService().startProcessInstanceByKey("test", variables); System.out.println("流程例項啟動完畢:processInstanceId = " + pi.getId()); } // 查詢組任務列表 @Test public void testFindMyGroupTaskList() throws Exception { String userId = "王工程師"; // String userId = "趙工程師"; // 查詢 // List<Task> list = processEngine.getTaskService().findGroupTasks(userId); // 分頁 List<Task> list = processEngine.getTaskService()// .createTaskQuery()// .candidate(userId)// 指定候選人,這是查詢組任務 .page(0, 100)// 分頁 .list(); // 顯示 System.out.println("====== " + userId + "的個人任務列表 ======"); for (Task task : list) { System.out.println("id=" + task.getId()// + ", name=" + task.getName()// + ", assignee=" + task.getAssignee()// + ", createTime=" + task.getCreateTime()// + ", executionId=" + task.getExecutionId()); } } // 拾取任務 @Test public void testTakeTask() throws Exception { String taskId = "310009"; String userId = "王工程師"; processEngine.getTaskService().takeTask(taskId, userId); } // 查詢個人任務列表 @Test public void testFindMyPersonalTaskList() throws Exception { String userId = "王工程師"; // 查詢 // List<Task> list = processEngine.getTaskService().findPersonalTasks(userId); // 分頁 List<Task> list = processEngine.getTaskService()// .createTaskQuery()// .assignee(userId)// 指定辦理人條件 .page(0, 100)// 分頁 .list(); // 顯示 System.out.println("====== " + userId + "的個人任務列表 ======"); for (Task task : list) { System.out.println("id=" + task.getId()// + ", name=" + task.getName()// + ", assignee=" + task.getAssignee()// + ", createTime=" + task.getCreateTime()// + ", executionId=" + task.getExecutionId()); } } // 直接指定任務的辦理人 @Test public void testAssignTask() throws Exception { String taskId = "310009"; // String userId = null; // 退回到組任務列表 String userId = "趙工程師"; processEngine.getTaskService().assignTask(taskId, userId); } }