The user dynamically setting a reference to the process, see the flowchart shown:
Is set here $ {user1}, a first user
Demo code:
@RequestMapping ( "single_assignee" ) public void setSingleAssignee () { // deployment process according bpmn file repositoryService.createDeployment () addClasspathResource ( "Processes / single_assignee.bpmn." ) The .deploy (); // Set User Task1 assignee variable Map <String, Object> = variables new new the HashMap <> (. 8 ); variables.put ( "user1", "007" ); // use key set to start the process definitions and process variables, the process returns instance ProcessInstance pi = runtimeService.startProcessInstanceByKey ( "single_assignee" , the Variables); String processId = pi.getId (); System.out.println("Creating a successful process, the current process instance ID:" + processId); // note that here need to get 007 inquiries, key-value value needs to take to get the task List <Task> list = taskService.createTaskQuery ( ) taskAssignee ( "007. " ) .list (); IF (List =! null && list.size ()> 0 ) { for (org.activiti.engine.task.Task task: List) { System.out.println ( " task ID: " + task.getId ()); System.out.println ( "task of handling people:" + task.getAssignee ()); System.out.println ( "task name:" + task.getName ()); System. Out.println ( println ( "Created task:" +task.getCreateTime ()); System.out.println ( "Process Instance ID:" + task.getProcessInstanceId ()); System.out.println ( "####################### ########### " ); } } // set the assignee variable User Task2 the Map <String, Object> = variables1 new new the HashMap <> (. 8 ); variables1.put ( " user2 "," Kevin " ); // because the task is only a charge d'affaires of the 007 directly to complete the task, and assign the next node user2 accept people as Kevin handled taskService.complete (list.get (0 ) .getId (), variables1); System. Out.println ( "the User Task1 is completed, then the process flow has Task2 to the User" ); }
访问:http://localhost:8080/activti/single_assignee