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