/**
* Process Example
* * START Process instance
* * Complete tasks
* * Enquiry
* * Query Process Example
* * Query Task
* * Query the task that is being performed
* * Query all the tasks that are being performed
* * According to the task's executor to query the task being performed
* * Query the tasks being performed according to Executionid
* * Query the tasks being performed according to PIID
* * Query the tasks being performed according to Pdid
* * Query Task Taskservice.gettask (String taskId) according to TaskId; not the same as other queries
* * Query Completed Tasks
* * Check All
* * According to the mandate of the Executive person
* * According to Executionid
* * .......
* * End Process Instance
* @author Administrator
*
*/
public class Pitest extends basejbpm{
/**
* The table involved
* * Jbpm4_execution
* * Indicates a process instance that is currently executing
* * Field
* Dbid_: Primary key
* ID_: Process instance ID
* Activityname_: Active node of current process instance
* PROCDEFID_: Process definition ID
* * Jbpm4_hist_procinst
* * Represents a history of process instances, but the currently running process instances are also here
* * Field
* Dbid_: Primary key
* ID_: Process instance ID
* Start_: The start time of the entire process instance
* End_: The end time of the process instance, or null if the process instance is the currently running process
* State: Indicates the status of the process instance if it is running, for active if the process instance ends as ended
* * Jbpm4_task
* * Indicates the currently executing task
* Description: The task is a node of the JBPM flowchart
* * Field
* Dbid_: Primary key, Task ID
* Name_: Task Name
* Assignee_: The executor of the task
* * Jbpm4_hist_task
* * indicates historical tasks, but the tasks currently being performed are also here
* * Field
* State_: If a task is completed, the value is completed
* End_: The end time of the task is value
* * Jbpm4_hist_actinst
* * nodes representing history
* * Field
* Type_: Node type
Description
* * When the process instance is started, it automatically leaves the start node and flows to the next node
* * Jbpm4_task is a temporary table, when the current task is completed, the data is deleted
*/
@Test
public void Teststartpibypdid () {
ProcessInstance pi= Processengine.getexecutionservice (). Startprocessinstancebyid ("Qingjia1-1");
System.out.println (Pi.getid ());
System.out.println (Pi.getstate ());
}
/**
* Starting the process instance according to Pdkey, is the highest version under that key
*/
@Test
public void Teststartpibypdkey () {
Processengine.getexecutionservice ()
. Startprocessinstancebykey ("Qingjia1");
}
/**
* Complete Tasks
*/
@Test
public void Testfinishtask () {
Processengine.gettaskservice ()
. Completetask ("60002");
}
/**
* Query All process instances
*/
@Test
public void Testqueryallpi () {
list<processinstance> pilist = Processengine.getexecutionservice ()
. Createprocessinstancequery ()
/.processdefinitionid ("")//Can be based on Pdid query process instances, a number of
. List ();
for (ProcessInstance pi:pilist) {
/**
* Can inquire piid,pdid,state etc.
*/
System.err.println ();
System.err.print ("InstanceID" +pi.getid ());
System.err.print ("\t\t\tinstancekey" +pi.getkey ());
System.err.print ("\t\t\tinstancename" +pi.getname ());
System.err.println ("\t\t\tinstancestate" +pi.getstate ());
}
}
/**
* Query all the tasks that are being performed
*/
@Test
public void Testqueryalltask () {
list<task> taskList = Processengine.gettaskservice ()
. Createtaskquery ()
. Processdefinitionid ("")
. List ();
for (Task task:tasklist) {
System.out.println ("Assignee:" +task.getassignee ());
System.out.println ("Name:" +task.getname ());
System.out.println ("Createtime:" +task.getcreatetime ());
}
}
/**
* You can query the currently executing task according to the task's executor.
* The currently executing task can be queried according to Pdid
*/
@Test
public void Testquerytaskbypdid () {
list<task> taskList = Processengine.gettaskservice ()
. Createtaskquery ()
. Processdefinitionid ("Qingjia1-4")
. List ();
System.out.println (Tasklist.size ());
}
/**
* Execution
* * If there is no concurrency, then exection and process instance are the same
* * If concurrency is present, execution represents the branch, and process instance represents the main line
* * Based on the Executionid Query task, there is only one
*/
@Test
public void Testquerytaskbytaskid () {
Task task = Processengine.gettaskservice ()
. Gettask ("60002");
System.out.println (Task.getname ());
}
/**
* Query All tasks that have been completed
*/
@Test
public void Testqueryallhisttask () {
list. Createhistorytaskquery ()
. Assignee ("") can query the completed task according to the task's executor
. Executionid ("") can query the completed task according to Executionid
. State ("completed")
. List ();
for (Historytask histtask:histtasklist) {
System.out.println (Histtask.getendtime ());
System.out.println (Histtask.getassignee ());
}
}
/**
* Direct End Process Instance
*/
@Test
public void testendpi () {
Processengine.getexecutionservice ()
. Endprocessinstance ("qingjia1.20001", "error");
}
/**
* According to the PIID query process instance, if the result of the query is null, it means that the process instance is over.
*/
@Test
public void testisendpi () {
ProcessInstance pi = Processengine.getexecutionservice ()
. Createprocessinstancequery ()
. Processinstanceid ("qingjia1.60001")
. Uniqueresult ();
System.out.println (pi);//If the value is null, it means that the process instance has ended
}
}
JBPM Process Instance (PI) process Instance