jbpm4.4 Demo3

Source: Internet
Author: User
Tags jbpm

Package Cn.itcast.c_processinstance;import Java.util.list;import Org.jbpm.api.configuration;import Org.jbpm.api.processengine;import Org.jbpm.api.processinstance;import Org.jbpm.api.taskquery;import Org.jbpm.api.task.task;import org.junit.test;/** * Perform process instance related actions * * <pre> * START Process instance * Query my task list * handling tasks * Take a step backwards * &L t;/pre> * * @author Tyg * */public class Processinstancetest {private Processengine processengine = Configuration.get Processengine ();//START process instance @testpublic void Teststartprocessinstance () throws Exception {// Starts the process instance using the specified process definition (specify the name and is the specified version)//Processengine.getexecutionservice (). Startprocessinstancebyid ("helloworld-3 ");//Start a process instance processinstance pi = Processengine.getexecutionservice () using the latest version of the process definition for the specified key. Startprocessinstancebykey ( "HelloWorld"); SYSTEM.OUT.PRINTLN ("Process instance started successfully, processinstanceid=" + pi.getid () + ", processdefinitionid=" + Pi.getprocessdefinitionid ( ));} Query my (unfinished) task List @testpublic void Testfindmytasklist () throws Exception {//prepare String userId = "employee";//String UserID = "department manager";//string userId = "General manager";///query All//list<task> List = Processengine.gettaskservice (). Findpersona Ltasks (userId);//paged query list<task> list = Processengine.gettaskservice ()//.createtaskquery ()////filter condition. Assignee (userId)//Specify who the person is, and if you do not specify a person, you will find out the tasks for everyone//Sort conditions//. ORDERASC (taskquery.property_createdate)//execute the query to get results//. Count ();/. Page (Firstresult, maxResults). List ();//Display for (Task t:list) {System.out.println ("id=" + t.getid ()//+ ", name=" + T.getna Me ()//Task Name + ", assignee=" + t.getassignee ()//Transact-man + ", createtime=" + t.getcreatetime ()//creation time of this task + ", executionid=" + t.g Etexecutionid ()); The id}}//handle task of the owning execution object @testpublic void Testcompletetask () throws Exception {String taskId = "320002"; Processengine.gettaskservice (). Completetask (taskId);} Skip a node and take a step backwards to assume: the process to the department manager, when you need to jump to the general manager, Operation: Get department manager executionid@testpublic void Testsignal () throws Exception {String Executionid = "helloworld.320001";p rocessengine.getexecutionservice (). Signalexecutionbyid (ExecutionId, "to General Manager [Audit](Batch] ");}} 
<?xml version= "1.0" encoding= "UTF-8"? ><process name= "Hellokey" key= "Hellokey" xmlns= "http://jbpm.org/4.4/ JPDL ">   <start g=" 115,21,48,48 "name=" Start1 ">      <transition g=" -71,-17 "name=" to submit Application "to=" Submit Application "/ >   </start>   <end g= "115,353,48,48" name= "End1"/> <task   assignee= "Employees" g= "81,101,117,52 "Name=" Submit Application ">      <transition g=" -78,-15 "name=" to department manager [approval] "to=" department manager [approval] "/>   </task>   < Task assignee= "department manager" g= "81,185,117,52" name= "department manager [approval]" >      <transition g= " -95,-17" Name= "to General manager [approval]" to= "General manager [ Approval] "/>   </task>   <task assignee=" general manager "g=" 81,269,117,52 "Name=" general Manager [approval] >      <transition G= " -47,-17" name= "to End1" to= "End1"/>   </task></process>

Download Demo

jbpm4.4 Demo3

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.