"Activiti" Process execution with node judgment

Source: Internet
Author: User

1. Deployment Rules

2. Open process

3. Get the first Excution execution object

4. According to the conditions, the next execution of the Excution execution object, and complete the corresponding logic

Note: There are 3 scenarios where the default flow option in the Judgment node is selected to point to the default node The Sequence Flow connection
 Packagecom.tabchanj.activiti.receive;Importorg.activiti.engine.runtime.Execution;Importorg.activiti.engine.runtime.ProcessInstance;ImportOrg.junit.Assert;Importorg.junit.Test; Public classReceivetestextendsbaseprocess {@Test Public voidTESTPSS ()throwsException {//Deployment RulesDeploy ("PSS.BPMN"); //Open ProcessProcessInstance pi = Runservice.startprocessinstancebykey ("Pssid"); System.out.println ("Process ID:" +Pi.getid ()); //gets the ID of the current process instanceString PID =Pi.getid (); //gets the execution object with the ID name of the sales ID for the current dayExecution e1=runservice.createexecutionquery (). Processinstanceid (PID). ActivityID ("Statistics Day sales ID"). Singleresult (); //using assertions, expected results should not be emptyAssert.assertnotnull (E1); Double Money=2888.8d; //set the process variable money as the basis of judgment to the process variableRunservice.setvariable (E1.getid (), "Money", Money); //signals that the current node execution is completerunservice.signal (E1.getid ()); //Process Judgment        if(money<1000) {Execution E2=runservice.createexecutionquery (). Processinstanceid (PID). ActivityID ("Send SMS ID to Boss"). Singleresult ();            Assert.assertnotnull (E2); System.out.println ("SMS: Boss, small profit Today" +runservice.getvariable (E2.getid (), "money") + "Yuan");        Runservice.signal (E2.getid ()); }Else if(money>=10000) {Execution E3=runservice.createexecutionquery (). Processinstanceid (PID). ActivityID ("e-mail ID to the Boss"). Singleresult ();            Assert.assertnotnull (E3); System.out.println ("Mail: Boss, today Hao earn" +money+ "Yuan");        Runservice.signal (E3.getid ()); }Else{execution E4=runservice.createexecutionquery (). Processinstanceid (PID). ActivityID ("Default ID"). Singleresult ();            Assert.assertnotnull (E4); System.out.println ("Default: Boss, earn Today" +money+ "Yuan");        Runservice.signal (E4.getid ()); }        //Check process statusAssert.assertnull (getprocessinstence (PID)); System.out.println ("Process Check Complete"); }    }

"Activiti" Process execution with node judgment

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.