Package com.jiaocaigen002.processinstance;
Import java.util.List;
Import org.jbpm.api.*;
Import Junit.framework.TestCase; /** * Process Instance * @author Leiwei 2012-3-20 * * */public class Processinstancetest extends TestCase {//Process engine Processengine
Processengine;
Public Processinstancetest () {processengine = Configuration.getprocessengine (); /** * Release process definition/protected void setUp () {//Process resource service interface, such as process definition Publishing, query, delete processengine.getrepositoryservice (). CRE
Atedeployment (). Addresourcefromclasspath ("Helloworld.jpdl.xml"). deploy (); /** * NEW Process * * * * public void Newprocessinstance () {//service for the operation of human tasks, can perform task creation, query, acquisition, submission, save, delete, etc. Executionservic
E Executionservice = Processengine.getexecutionservice ();
ProcessInstance processinstance = Executionservice.startprocessinstancebykey ("HelloWorld");
To see if the process has ended System.out.println ("The process has ended:" +processinstance.isended ()); Skip the wait directly and end processinstance = Executionservice.signalexecutionbyid (proceSsinstance.getid ());
System.out.println ("Whether the process is finished:" +processinstance.isended ()); /** * Terminate the process */public void endprocessinstance () {Executionservice Executionservice = Processengine.getexecutio
Nservice ();
ProcessInstance processinstance = Executionservice.startprocessinstancebykey ("HelloWorld");
Executionservice.endprocessinstance (Processinstance.getid (), "cancle"); /** * Delete process * * public void Deleteprocessinstance () {Executionservice Executionservice = Processengine.getexecu
Tionservice ();
ProcessInstance processinstance = Executionservice.startprocessinstancebykey ("HelloWorld");
Executionservice.deleteprocessinstancecascade (Processinstance.getid ()); /** * View Process * * * public void Selectprocessinstance () {Executionservice Executionservice = Processengine.getexecu
Tionservice ();
ProcessInstance ProcessInstance1 = Executionservice.startprocessinstancebykey ("HelloWorld"); ProcessInstance ProcessInstance2 = Executionservice.startprocessinstancebyKey ("HelloWorld"); List<processinstance> processinstancelist= Executionservice. Createprocessinstancequer
Y (). List ();
for (ProcessInstance processinstance:processinstancelist) {System.out.println ("Number of processes:" +processinstance.getid ());
}
}
}