How to specify personal tasks in jbpm

Source: Internet
Author: User
Tags jbpm

Method:

1) specify someone directly and write in. jpdl. xml: assignee = "James"
2) use the process variable and write it in. jpdl. xml: assignee = "# {manager }"
3), use the class (at this time, you do not need to set the attribute xuancheng none), write in. jpdl. xml:
<Assignment-handler class = "com. njupt. task. assignmenthandlerimpl"/>
4), processengine. gettaskservice (). assigntask (taskid, userid); // re-specify the Handler

The following points are described:

1. For 2), the source code is as follows:

Package COM. njupt. task; import Java. io. inputstream; import Java. util. hashmap; 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 ("manager", "Manager Li"); // This corresponds to the # {manager} processinstance Pi = processengine. getexecutionservice (). startprocessinstancebykey ("test", variables );}}

2. For 3), 4) the source code is as follows:

1> first, write the handler's processing class

Package COM. njupt. task; import Org. jbpm. API. model. openexecution; import Org. jbpm. API. task. assignable; import Org. jbpm. API. task. assignmenthandler; public class assignmenthandlerimpl implements assignmenthandler {// calculates and specifies the task handler @ overridepublic void assign (assignable, openexecution execution) throws exception {system. out. println ("---> assignmenthandlerimpl. assign () "); // computing handler string userid =" Zhao manager ++ "; // specify handler assignable. setassignee (userid); // assignable. addcandidateuser ("Manager AA"); // assignable. addcandidateuser ("Manager BB"); // assignable. addcandidateuser ("Manager cc ");}}

2> writing test classes for Process Design

Package COM. njupt. task; import Java. io. inputstream; import Org. jbpm. API. configuration; import Org. jbpm. API. processengine; import Org. jbpm. API. processinstance; 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 process instance processinstance Pi = processengine. getexecutionservice (). startprocessinstancebykey ("test");} // re-allocate the task (re-specify the handler) @ testpublic void testassigntask () throws exception {string taskid = "270009 "; string userid = "Manager Zhao ++"; processengine. gettaskservice (). assigntask (taskid, userid );}}

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.