1. How to get Processengine:
A) method one
Private Processengine Processengine = new Configuration (). Setresource ("Jbpm.cfg.xml"). Buildprocessengine ();
b) Method Two
Gets the singleton Processengine object, using the default configuration file (Jbpm.cfg.xml)
Private Processengine Processengine = Configuration.getprocessengine ();
2. Common service API (JBPM All operations are done by service)
A) processengine.getrepositoryservice ();//Manage Process definition related operations (deployment, query, delete, etc.)
b) Processengine.getexecutionservice ();//management execution, process instance management operations, a specific execution of information, including start, push, delete execution operations
c) Processengine.gettaskservice ();//management tasks (query tasks, handling Tasks)
d) processengine.gethistoryservice ();//management of historical data (execution of data management, mainly query)
3.API style
A) method call chain.
b) Each method is a business operation related to the process, which is a separate transaction by default.
4. Inquiries about the API
Function description |
The corresponding query API |
Query "Process definition" |
Processdefinitionquery Processdefinitionquery = Processengine.getrepositoryservice () . Createprocessdefinitionquery (); |
Query "Execute Object" (Process instance) |
Processinstancequery Processinstancequery = Processengine.getexecutionservice ()// . Createprocessinstancequery (); |
Query "Tasks" |
Taskquery taskquery =// Processengine.gettaskservice ()// . Createtaskquery (); |
Query "Execution History" (Process instance history) |
Historyprocessinstancequery Historyprocessinstancequery = Processengine.gethistoryservice () . Createhistoryprocessinstancequery (); |
Query "Task History" |
Historytaskquery Historytaskquery = Processengine.gethistoryservice () . Createhistorytaskquery (); |
The query objects listed above are:
1. Processdefinitionquery
2. Processinstancequery
3. Taskquery
4. Historyprocessinstancequery
5. Historytaskquery
These query objects are used in a consistent manner, as follows:
1, add Filter: Call the relevant method in which the conditions can be specified. Such as:
A) Processdefinitionquery.processdefinitionkey ("Leave") is a process definition that specifies that the query key is "leave";
b) Taskquery.assignee ("Zhang San") is a task designated for "Zhang San".
2, add sorting criteria:
A) Call Xxquery.orderasc (property), which indicates the ascending order of an attribute
b) Call Xxquery.orderdesc (property), which indicates descending order by an attribute
c) Multiple ordering criteria can be specified, which means the 1th order, the 2nd order ... such as
D) Attribute names have constant definitions in their respective query objects (interfaces), such as:
I. processdefinitionquery.property_id
II. Processdefinitionquery.property_key
III. Taskquery.property_name
Iv. Taskquery.property_assignee
3, specify paging information:
A) Call method Xxquery.page (Firstresult, maxResults);
b) This is the value of the specified first and Max (that is, Query.setfirstresult () and Query.setmaxresults () in Hibernate)
c) If this method is not called, the representative is to query all records that match the criteria.
4, the query results are as follows:
A) Call method Xxquery.list (); Represents a query list
b) Call method Xxquery.uniqueresult (); Represents the only result of a query called Method Xxquery.count (); Indicates the number of records for which the query meets the criteria
JBPM Workflow (iii)--processengine and service API