1. Description:
Process variables play an important role in the entire workflow. For example: The leave process in the absence of days, leave reasons, and other parameters are the scope of the process variable. The scope of a process variable is a process instance. This means that the process variables for each process instance do not interact with each other. Process variables are also saved in the database after the process instance finishes.
2. Sample Process variables:
3. Add Process Variables
1 when the process instance is started
2. Add variable
@Test public
void Startprocessinstancebykey () throws Exception {
String when starting process instance Processdefinitionkey = "Baoxiaoflow";
map<string, object> variable = new hashmap<string, object> ();
Variable.put ("Amount", "300 Yuan");
Variable.put ("Reason", "travel");
ProcessInstance processinstance = Processengine.getruntimeservice (). Startprocessinstancebykey ( Processdefinitionkey, variable);
System.out.println ("processinstance.getid () = =" + Processinstance.getid ());
System.out.println ("processinstance.getprocessdefinitionid () = =" + Processinstance.getprocessdefinitionid ());
}
2 When handling the task
2.2. When handling tasks, add variable
@Test public
void Dealprocesstask () throws Exception {
String taskId = "42511"; Project manager approves
map<string, object> variable = new hashmap<string, object> ();
Variable.put ("Amount", "300 Yuan");
Variable.put ("Reason", "travel");
Processengine.gettaskservice (). Complete (taskId, variable);
3) using the Runtimeservice method setting
2.3. Add variable using runtimeservice
@Test public
void Setvariablebyruntime () throws Exception {
String taskId = " 47504 "; Project manager approves
task task = Processengine.gettaskservice (). Createtaskquery (). TaskId (TaskId). Singleresult ();
Gets the process instance ID
String Processinstanceid = Task.getprocessinstanceid ();
String Executionid = "601";
String variableName = "Amount3";
Object value = "300 yuan";
Processengine.getruntimeservice (). SetVariable (Processinstanceid, variableName, value);
4) using the Taskservice method setting
2.4. Add variable with runtimeservice
@Test public
void Setvariablebytask () throws Exception {
String taskId = "47504 "; The project manager approves
//string Executionid = "601";
String variableName = "Amount4";
Object value = "300 yuan";
Processengine.gettaskservice (). SetVariable (TaskId, variableName, value);
map<string, object> variable = new hashmap<string, object> ();
Variable.put ("Amount4", "300 Yuan");
Variable.put ("Reason4", "Travel");
Processengine.gettaskservice (). Setvariables (taskId, variable);
4. Get Process Variables
1) Using Runtimeservice method to obtain
3.2. Get process variable @Test public void Getvariablebyruntime () throws Exception {String taskId = "47504";
Task task = Processengine.gettaskservice (). Createtaskquery (). TaskId (TaskId). Singleresult ();
Gets the process instance id String Processinstanceid = Task.getprocessinstanceid ();
map<string, object> variables = Processengine.getruntimeservice (). Getvariables (Processinstanceid); For (map.entry<string, object> entry:variables.entrySet ()) {System.out.println ("Key =" + Entry.getke
Y () + ", Value =" + Entry.getvalue ());
Object value = Processengine.getruntimeservice (). GetVariable (Processinstanceid, "user");
System.out.println ("value =" + value); } ' ' 2 uses the Taskservice method to get '//2.4, add variable using runtimeservice @Test public void Getvariablebytask () throws Exceptio n {String taskId = "47504"; Project manager approves map<string, object> variables = Processengine.gettaskservice (). Getvariables (TASKID); For (map.entry<string, object> entry:variables.entrySet ()) {System.out.println ("Key =" + Entry.getke
Y () + ", Value =" + Entry.getvalue ()); }
}
```
*--------------------------------------------------------------------------------------------------------- --------------------------------------------* Java Architect Project Combat, high concurrency cluster distributed, large data high availability video tutorials, a total of 760G----------------------------
----------* * Download Address: * *
https://item.taobao.com/item.htm?id=555888526201
"'
01. High-level architect 42 Phases
02.Java Advanced System Training Architecture Course 148 hours
03.Java Senior Internet Architect Course
04.Java Internet Architecture Netty, Nio, Mina, etc.-Video tutorials
05.Java Advanced Architecture Design 2016 finishing-video tutorials
06. Architect Foundation, advanced film
07.Java Architect Required Linux Operation series courses
08.Java Advanced System Training Architecture Course 116 hours
+
Hadoop series tutorials, Java design patterns and data structures, Spring Cloud Micro service, Springboot Primer
—————————————————————————————————————————————————–