Process Variables in jbpm

Source: Internet
Author: User
Tags jbpm
Package COM. njupt. jbpm; import Java. util. map; import Java. util. set; import Org. jbpm. API. configuration; import Org. jbpm. API. executionservice; import Org. jbpm. API. processengine; import Org. jbpm. API. processinstance; import Org. jbpm. API. taskservice; import Org. JUnit. test; public class processvariabletest {private processengine = configuration. getprocessengine (); Private executionservice = processengine. getexecutionservice (); Private taskservice = processengine. gettaskservice (); // start process instance @ testpublic void teststartprocessinstance () throws exception {processinstance Pi = processengine. getexecutionservice (). startprocessinstancebykey ("test"); system. out. println ("ID =" + pi. GETID () + ", processdefinitionid =" + pi. getprocessdefinitionid ();} // set the process variable @ testpublic void testsetvariable () throws exception {string executionid = "test.110001"; // processengine. getexecutionservice (). setvariable (executionid, "days for leave", new INTEGER (3); Form = new form (); form. setid (1l); // set the ID to correspond to the record whose ID is 1 in the database. settitle ("three days for leave"); processengine. getexecutionservice (). setvariable (executionid, "form", form); // use execution to set the process variable // executionservice. setvariable (executionid, name, value); // sets a // executionservice. setvariables (executionid, variablesmap); // you can specify multiple executionids. setvariables (taskid, variablesmap); // you can specify multiple variables when starting a process instance. startprocessinstancebykey (key); // executionservice. startprocessinstancebykey (Key, variablesmap); // when the task is completed, set some process variables. // taskservice. completetask (taskid); // taskservice. completetask (taskid, variablesmap);} // obtain the process variable @ testpublic void testgetvariable () throws exception {string executionid = "test.110001"; // integer days = (integer) processengine. getexecutionservice (). getvariable (executionid, "days for leave"); // system. out. println ("leave days =" + days); Form = (form) processengine. getexecutionservice (). getvariable (executionid, "form"); system. out. println (form); // obtain the process variable through execution // object value = executionservice. getvariable (executionid, variablename); // get a // set <string> namesset = executionservice. getvariablenames (executionid); // obtain the names of all variables // Map <string, Object> map = executionservice. getvariables (executionid, variablenamesset); // obtain multiple executionids // obtain process variables using tasks // taskservice. getvariable (taskid, variablename); // taskservice. getvariablenames (taskid); // taskservice. getvariables (taskid, variablenames );}}

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.