Demo-e of Design Activities in jbpm

Source: Internet
Author: User
Tags jbpm

I. Flowchart

Ii. Code Implementation

1. First, prepare the processing class required by deploy.

Package COM. njupt. demo-; import Org. jbpm. API. jpdl. decisionhandler; import Org. jbpm. API. model. openexecution; public class decisionhandlerimpl implements decisionhandler {// calculate the route name to be used and return @ overridepublic string decide (openexecution execution) {system. out. println ("------> decisionhandlerimpl. decide () "); // get information int money = (integer) execution. getvariable ("reimbursement amount"); // select the route if (money> 1000) {return "approved by the general manager";} else {return "ended ";}}}

2. Write a process processing test

Package COM. njupt. demo-; 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 Map <string, Object> variables = new hashmap <string, Object> (); // variables. put ("reimbursement amount", 200); variables. put ("reimbursement amount", 2000); processinstance Pi = processengine. getexecutionservice (). startprocessinstancebykey ("test", variables); // 3. After the first task is executed ("department manager approval"), use the specified route to exit task = processengine. gettaskservice ()//. createtaskquery () // queries only one task in the current process instance. processinstanceid (Pi. GETID ())//. uniqueresult (); processengine. gettaskservice (). completetask (task. GETID ());}}

3. You can query the corresponding information from the _ execution and _ hist_task tables. _ Execution can be used to query information about an ongoing process. _ Hist_task information of the completed process

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.