1. Deployment process (define process)
1 New fileinputstream (file); 2 New Zipinputstream (in); 3 processengine. This . Getrepositoryservice () 4 . Createdeployment ()5 . Name (processName)6 . Addzipinputstream (zipinputstream)7 . Deploy ();
View Code2. Start the process (one instance of the defined process)
1 processengine (). Getruntimeservice () 2 /** */3 . Startprocessinstancebykey ("Leave", "Leavebill", variables);
View Code
In this way, the business table is associated with the Activiti table (generally for convenience, a ProcessID is also stored in the business tables)
The correlation between its internal tables is as follows
3. View a person's task
1 /**2 * Tasks to be performed by the current login in the system (including personal tasks + group tasks)3 */4 PublicList<task>Gettasksbyassignee (String userId) {5List<task> Assigneetasks = This. Gettaskservice ()6 . Createtaskquery ()7. Taskassignee (UserId)//Participant, personal task query8 . Orderbytaskcreatetime ()9 . Desc ()Ten . List (); OneList<task> Candidatetasks = This. Gettaskservice () A . Createtaskquery () -. Taskcandidateuser (UserId)//contributor, group task query - . Orderbytaskcreatetime () the . Desc () - . List (); - Assigneetasks.addall (candidatetasks); - returnAssigneetasks; +}
View Code4. According to task-"processinstance-" businesskey-"business table
1 /**2 * Find Businesskey according to TaskID3 */4 Publicstring Getbusinesskeybytaskid (String taskId) {5Task task = This. Processengine6 . Gettaskservice ()7 . Createtaskquery ()8 . TaskId (taskId)9 . Singleresult ();TenProcessInstance pi = This. Getruntimeservice () One . Createprocessinstancequery () A . Processinstanceid (Task.getprocessinstanceid ()) - . Singleresult (); - returnPi.getbusinesskey (); the}
View Code
Activiti (Workflow) How to correlate business tables