Activiti process instance Management

Source: Internet
Author: User
1. Start the process
/*** 1 Start Process ** when the process reaches a node, one piece of data will be generated in the act_ru_execution table * if the current node is a user task node, in this case, the act_ru_task table will generate one piece of data (the task handler, the task creation time) */@ test public void startprocess () throws exception {/*** V1 myprocess: 2: 604 * V2 myprocess: 3: 704 * // runtimeservice. startprocessinstancebyid (processdefinitionid) // start the process with the key defined in the process. The process with the highest version processinstance Pi = runtimeservice is started. startprocessinstancebykey ("leaveflow"); system. out. println ("PID:" + pi. GETID () + ", activitiid:" + pi. getactivityid ());}

2. view the process status

Public void queryprocessstate () throws exception {string processinstanceid = "1401"; // query process instance processinstance Pi = runtimeservice by process instance id. createprocessinstancequery (). processinstanceid (processinstanceid ). singleresult (); If (Pi! = NULL) {system. Out. println ("the current process is in:" + pi. getactivityid ();} else {system. Out. println ("the process has ended !! ");}}

3. view public tasks

Public void querycommontask () throws exception {// create a task query object taskquery = taskservice. createtaskquery (); // configure the query object string candidateuser = "zhangsan"; taskquery // filter condition. taskcandidateuser (candidateuser) // paging condition //. listpage (firstresult, maxresults) // sorting condition. orderbytaskcreatetime (). DESC (); // execute the query list <task> tasks = taskquery. list (); system. out. println ("=================================public task list for [" + candidateuser + "] ====== ============== "); for (Task task: tasks) {system. out. print ("ID:" + task. GETID () + ","); system. out. print ("name:" + task. getname () + ","); system. out. print ("createtime:" + task. getcreatetime () + ","); system. out. println ("assignee:" + task. getassignee ());}}

4. view private tasks

Public void querypersonaltask () throws exception {// create a task query object taskquery = taskservice. createtaskquery (); // configure the query object // string assignee = "user"; string assignee = ""; taskquery // filter condition. taskassignee (assignee) // paging condition //. listpage (firstresult, maxresults) // sorting condition. orderbytaskcreatetime (). DESC (); // execute the query list <task> tasks = taskquery. list (); system. out. println ("=============================== [" + assignee + "] ============== "); for (Task task: tasks) {system. out. print ("ID:" + task. GETID () + ","); system. out. print ("name:" + task. getname () + ","); system. out. print ("createtime:" + task. getcreatetime () + ","); system. out. println ("assignee:" + task. getassignee ());}}

5. claim a task

Public void taketask () throws exception {// claim string taskid = "1404"; string userid = ""; // Let the user of the specified userid claim the task taskservice of the specified taskid. claim (taskid, userid); system. out. println ("claim operation completed !! ");}

6. Handle tasks

Public void complete () throws exception {string taskid = "1602"; // complete task taskservice. Complete (taskid );}

 

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.