Assignment of Group tasks:
1. Specify directly: candidate-users = "Manager A, Manager B, Manager C"
2. Use process variables:
Code: Variables. Put ("userids", "Manager AAA, Manager BBB, Manager CCC ");
Definition: candidate-users = "# {userids }"
3. Use assignmenthandler to write the code:
Assignable. addcandidateuser ("Manager AA ");
Assignable. addcandidateuser ("Manager BB ");
Assignable. addcandidateuser ("Manager cc ");
I. Flowchart
Ii. Code Implementation (mainly for method 2) and method 3) refer to the individual task designation)
Package COM. njupt. task; import Java. io. inputstream; import Java. util. hashmap; import Java. util. list; import Java. util. map; import Org. jbpm. API. configuration; import Org. jbpm. API. processengine; import Org. jbpm. API. processinstance; import Org. jbpm. API. task. task; import Org. JUnit. test; public class processtest {private processengine = configuration. getprocessengine (); @ testpublic void test () throws exception {// 1. the deployment process defines inputstream in = getclass (). getresourceasstream ("test. jpdl. XML "); processengine. getrepositoryservice ()//. createdeployment ()//. addresourcefrominputstream ("test. jpdl. XML ", in )//. deploy (); // 2. Start the process instance Map <string, Object> variables = new hashmap <string, Object> (); variables. put ("userids", "Manager AAA, Manager BBB, Manager CCC"); processinstance Pi = processengine. getexecutionservice (). startprocessinstancebykey ("test", variables);} // query my task list @ testpublic void testfindmytask () throws exception {string userid = "Manager C "; //> Query personal tasks // list <task> tasklist = processengine. gettaskservice (). findpersonaltasks (userid); // list <task> tasklist = processengine. gettaskservice ()////. createtaskquery ()////. assignee (userid) // specify the condition for the handler //. list (); // query list //> query group task list <task> tasklist = processengine. gettaskservice (). findgrouptasks (userid); // list <task> tasklist = processengine. gettaskservice ()////. createtaskquery ()////. candidate (userid) // specify the candidate's condition //. list (); // query the list // display system. out. println ("=========== [" + userid + "] task list ============= "); for (Task task: tasklist) {system. out. println ("ID =" + task. GETID () // task id + ", name =" + task. getname () // Task Name + ", assignee =" + task. getassignee () // task handler + ", createtime =" + task. getcreatetime () // task creation time + ", executionid =" + task. getexecutionid (); // the ID of the execution object to which it belongs} // The picking task @ testpublic void testtaketask () throws exception {string taskid = "300008 "; string userid = "Manager C"; processengine. gettaskservice (). taketask (taskid, userid);} // re-allocate the task (re-specify the handler) @ testpublic void testassigntask () throws exception {string taskid = "300008 "; // string userid = "Manager A"; string userid = NULL; processengine. gettaskservice (). assigntask (taskid, userid );}}
3. You can view the corresponding information in _ participant ipation.