Specify Group tasks in jbpm

Source: Internet
Author: User
Tags jbpm

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.