One, from the CREATE table to the processing to complete the task
public class Leaveactiontest {private Processengine processengine = Processengines.getdefaultprocessengine (); 1.1. CREATE table public static void Createtabelauto () {//Create object Processengineconfiguration conf = processengine
Configuration.createstandaloneprocessengineconfiguration ();
String Driver = Propertiesutil.getvalue ("Jdbc_driver", "conf/jdbc.properties");
String url = propertiesutil.getvalue ("Jdbc_url", "conf/jdbc.properties");
String username = propertiesutil.getvalue ("Jdbc_username", "conf/jdbc.properties");
String Password = propertiesutil.getvalue ("Jdbc_password", "conf/jdbc.properties");
Set up Database Conf.setjdbcdriver (driver);
Conf.setjdbcurl (URL);
Conf.setjdbcusername (username);
Conf.setjdbcpassword (password);
Auto-Build Table Conf.setdatabaseschemaupdate ("true");
Create engine Processengine Processengine = Conf.buildprocessengine (); //1.2, CREATE TABLE, ProcessengineconfigUration the database entity bean public static void Createtabelbyxml () {//Create object String resource = "activiti-context2.x
ML ";
String beanname = "Processengineconfiguration"; Processengineconfiguration conf = Processengineconfiguration.createprocessengineconfigurationfromresource (
Resource, beanname);
Create engine Processengine Processengine = Conf.buildprocessengine (); }//2, deployment process definition @Test public void Deployleave () throws Exception {Deploymentbuilder builder = Processe
Ngine.getrepositoryservice (). Createdeployment ();
Builder.addclasspathresource ("FLOW/LEAVE.BPMN");
Builder.addclasspathresource ("Flow/leave.png");
Deployment deploy = Builder.deploy ();
System.out.println ("deploy.getid () = =" + Deploy.getid ()); }//3, obtain the process-defined ID @Test public void queryfinition () throws Exception {processdefinitionquery query = P
Rocessengine.getrepositoryservice (). Createprocessdefinitionquery (); //Add Filter condition Query.processdefinitionkey ("Leaveflow");
Add sort query.orderbyprocessdefinitionversion (). DESC ();
Paging query.listpage (0, 10);
list<processdefinition> processdefinitions = Query.list ();
for (ProcessDefinition p:processdefinitions) {System.out.println ("p.getid () = =" +p.getid ()); @Test public void Querys () throws Exception {list<processdefinition> processdefinitions =
Processengine.getrepositoryservice (). Createprocessdefinitionquery (). List ();
list<deployment> deployments = Processengine.getrepositoryservice (). Createdeploymentquery (). List (); list<processinstance> processinstances = Processengine.getruntimeservice (). Createprocessinstancequery ().
List ();
list<task> tasks = Processengine.gettaskservice (). Createtaskquery (). List ();
//4 The ID of the process instance is obtained based on the ID of the process definition @Test public void getprocessinstance () throws Exception { String Processdefinitionid = "Leaveflow:1:4"; ProcessInstance processinstance = Processengine.getruntimeservice (). Startprocessinstancebyid (ProcessDefinitionId)
;
System.out.println ("processinstance.getid () = =" + Processinstance.getid ());
//5, according to the process example, Query task list, explain a process definition corresponding to multiple process instances, a process instance corresponding to multiple task lists @Test public void Getprocesstask () throws Exception {
String Processinstanceid = "5001";
1//string assignee = "Tom";
2//string assignee = "Jack";
3 String Assignee = "Smith";
Task List Taskquery taskquery = Processengine.gettaskservice (). Createtaskquery ();
Query Tom's Task List Taskquery.taskassignee (assignee);
list<task> tasks = Taskquery.list ();
for (Task task:tasks) {System.out.println (Task.getid () + ":" + task.getname ()); }//6, processing tasks, processing completed, the third step will not find the task of Tom, ran to the next Jack's task, 5 and 6 are mutually repeated @Test public void Dealprocesstask ()Throws Exception {String taskId = "";
Processengine.gettaskservice (). complete (taskId); }
}
Second, the database configuration
Jdbc_driver=com.microsoft.sqlserver.jdbc.sqlserverdriver
Jdbc_url=jdbc:sqlserver://localhost:1433;d Atabasename=activiti
Jdbc_username=sa
Jdbc_password=sa
Third, the process document Leave.xml
<?xml version= "1.0" encoding= "UTF-8" standalone= "yes"?> <definitions "xmlns=" 20100524/model "xmlns:activiti=" HTTP://ACTIVITI.ORG/BPMN "xmlns:bpmndi=" Http://www.omg.org/spec/BPMN/20100524/DI "Xmlns:omgdc=" Http://www.omg.org/spec/DD/20100524/DC "xmlns:omgdi=" Http://www.omg.org/spec/DD/20100524/DI "xmlns : tns= "Http://www.activiti.org/test" xmlns:xsd= "Http://www.w3.org/2001/XMLSchema" xmlns:xsi= "http://www.w3.org/" 2001/xmlschema-instance "expressionlanguage=" Http://www.w3.org/1999/XPath "id=" m1505312057485 "Name=" " Targetnamespace= "Http://www.activiti.org/test" typelanguage= "Http://www.w3.org/2001/XMLSchema" > <process ID = "Leaveflow" isclosed= "false" isexecutable= "true" Name= "Leaveflow" processtype= "None" > <startevent id= "Startid" "Name=" "Start"/> <endevent id= "Endid" name= "End"/> <usertask "Tom" activiti:assignee= "F Alse "activiti:exclusive=" true "id=" Processsubmitid "name=" Submit request for Leave "/> <usertask acTiviti:assignee= "Jack" activiti:exclusive= "true" id= "Processsupervisorid" name= "project manager approval"/> <sequenceflow id= "_ 6 "sourceref=" Startid "targetref=" Processsubmitid "/> <sequenceflow id=" _7 "sourceref=" ProcessSubmitId " targetref= "Processsupervisorid"/> <usertask activiti:assignee= "Smith" activiti:exclusive= "true" id= " Processmanagerid "name=" department manager approval "/> <sequenceflow id=" _10 "sourceref=" Processsupervisorid "targetRef=" Processmanagerid "/> <sequenceflow id=" _11 sourceref= "Processmanagerid" targetref= "EndId"/> <sequenceF Low sourceref= "Startid" targetref= "Processsubmitid" id= "Startid-processsubmitid"/> </process> <bpmndi: Bpmndiagram documentation= "background= #FFFFFF; count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2 ; imageablewidth=832.4;imageableheight=1185.2;imageablex=5.0;imageabley=5.0 "id=" Diagram-_1 "name=" New Diagram " > <bpmndi:bpmnplane bpmnelement= "Leaveflow" > <bpmndi:bpmnshape bpMnelement= "Startid" id= "Shape-startid" > <omgdc:bounds height= "32.0" width= "32.0" x= "390.0" y= "115.0"/> <bpmndi:BPMNLabel> <omgdc:bounds height= "32.0" width= "32.0" x= "0.0" y= "0.0"/> </bpm
ndi:bpmnlabel> </bpmndi:BPMNShape> <bpmndi:bpmnshape bpmnelement= "Endid" id= "Shape-endid" > <omgdc:bounds height= "32.0" width= "32.0" x= "400.0" y= "495.0"/> <bpmndi:BPMNLabel> <om Gdc:bounds height= "32.0" width= "32.0" x= "0.0" y= "0.0"/> </bpmndi:BPMNLabel> </BPMNDI:BPMNSHAPE&G
T <bpmndi:bpmnshape bpmnelement= "Processsubmitid" id= "Shape-processsubmitid" > <omgdc:bounds height= "55.0" W Idth= "85.0" x= "370.0" y= "215.0"/> <bpmndi:BPMNLabel> <omgdc:bounds height= "55.0" width= "85.0 "x=" 0.0 "y=" 0.0 "/> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:bpmnshape bpmnel Ement= "ProcesssUpervisorid "id=" Shape-processsupervisorid "> <omgdc:bounds height=" 55.0 "width=" 85.0 "x=" 365.0 "y=" 305.0 "/&G"
T <bpmndi:BPMNLabel> <omgdc:bounds height= "55.0" width= "85.0" x= "0.0" y= "0.0"/> </bpmndi:bp mnlabel> </bpmndi:BPMNShape> <bpmndi:bpmnshape bpmnelement= "Processmanagerid" id= "Shape-processman"
Agerid "> <omgdc:bounds height=" 55.0 width= "85.0" x= "370.0" y= "405.0"/> <bpmndi:BPMNLabel> <omgdc:bounds height= "55.0" width= "85.0" x= "0.0" y= "0.0"/> </bpmndi:BPMNLabel> </bp mndi:bpmnshape> <bpmndi:bpmnedge bpmnelement= "_6 id=" Bpmnedge__6 "sourceelement=" StartId "targetElement=" pro
Cesssubmitid "> <omgdi:waypoint x=" 406.0 "y=" 147.0 "/> <omgdi:waypoint" x= "406.0" y= "215.0"/> " <bpmndi:BPMNLabel> <omgdc:bounds height= "0.0" width= "0.0" x= "0.0" y= "0.0"/> </bpm ndi:bpmnlabel&Gt </bpmndi:BPMNEdge> <bpmndi:bpmnedge bpmnelement= "_7" id= "bpmnedge__7" sourceelement= "Processsubmitid" Targ Etelement= "Processsupervisorid" > <omgdi:waypoint x= "410.0" y= "270.0"/> <omgdi:waypoint "the x=" 410. 0 "y=" 305.0 "/> <bpmndi:BPMNLabel> <omgdc:bounds height=" 0.0 "width=" 0.0 "x=" 0.0 "y=" 0.0 "/>"
; </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:bpmnedge bpmnelement= "_11" id= "Bpmnedge__11" sou Rceelement= "Processmanagerid" targetelement= "Endid" > <omgdi:waypoint x= "416.0" y= "460.0"/> <om Gdi:waypoint x= "416.0" y= "495.0"/> <bpmndi:BPMNLabel> <omgdc:bounds height= "0.0" width= "0.0" x= "0.0" y= "0.0"/> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:bpmnedge bpmneleme Nt= "_10" id= "bpmnedge__10" sourceelement= "Processsupervisorid" targetelement= "Processmanagerid" > <omgdi:wayp Ointx= "410.0" y= "360.0"/> <omgdi:waypoint x= "410.0" y= "405.0"/> <bpmndi:BPMNLabel> &l T;omgdc:bounds height= "0.0" width= "0.0" x= "0.0" y= "0.0"/> </bpmndi:BPMNLabel> </bpmndi:bpmnedge&
Gt
<bpmndi:bpmnedge bpmnelement= "Startid-processsubmitid" > <omgdi:waypoint x= "406.0" y= "131.0"/> <omgdi:waypoint x= "412.5" y= "242.5"/> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:bpm Ndiagram> </definitions>
————————————————————————————————————————————————— – Java Architect Project Combat, high concurrency cluster distributed, large data high availability video tutorials, total 760G
Download Address:
https://item.taobao.com/item.htm?id=555888526201
01. High-level architect 42 Phases
02.Java Advanced System Training Architecture Course 148 hours
03.Java Senior Internet Architect Course
04.Java Internet Architecture Netty, Nio, Mina, etc.-Video tutorials
05.Java Advanced Architecture Design 2016 finishing-video tutorials
06. Architect Foundation, advanced film
07.Java Architect Required Linux Operation series courses
08.Java Advanced System Training Architecture Course 116 hours
+
Hadoop series tutorials, Java design patterns and data structures, Spring Cloud Micro service, Springboot Primer
—————————————————————————————————————————————————–