Activiti query Process Definition

Source: Internet
Author: User

 Packagecom.mycom.processDefinition;ImportJava.io.InputStream;Importjava.util.List;ImportJava.util.zip.ZipInputStream;ImportOrg.activiti.engine.ProcessEngine;ImportOrg.activiti.engine.ProcessEngines;Importorg.activiti.engine.repository.Deployment;Importorg.activiti.engine.repository.ProcessDefinition;Importorg.junit.Test; Public classprocessdefinitiontest {processengine processengine=Processengines.getdefaultprocessengine (); /** Deployment process definition (from Classpath)*/@Test Public voidDeploymentprocessdefinition_classpath () {Deployment Deployment= Processengine.getrepositoryservice ()//Service related to process definition and deployment objects. Createdeployment ()//Create a Deployment object. Name ("Process definition")//Add a deployment name. Addclasspathresource ("DIAGRAMS/HELLOWORLD.BPMN")//Load from Classpath resources, only one file can be loaded at a time. Addclasspathresource ("Diagrams/helloworld.png"). deploy ();//Complete DeploymentSYSTEM.OUT.PRINTLN ("Deployment ID:" +Deployment.getid ()); System.out.println ("Deployment Name:" +deployment.getname ()); }        /** Deployment process definition (from Zip)*/@Test Public voidDeploymentprocessdefinition_zip () {InputStream in= This. GetClass (). getClassLoader (). getResourceAsStream ("Diagrams/helloworld.zip"); Zipinputstream Zipinputstream=NewZipinputstream (in); Deployment Deployment= Processengine.getrepositoryservice ()//Service related to process definition and deployment objects. Createdeployment ()//Create a Deployment object. Name ("Process definition")//Add a deployment name. Addzipinputstream (Zipinputstream)//complete the deployment of the zip file. deploy ();//Complete DeploymentSYSTEM.OUT.PRINTLN ("Deployment ID:" +Deployment.getid ()); System.out.println ("Deployment Name:" +deployment.getname ()); }        /** Query Process definition*/@Test Public voidfindprocessdefinition () {List<ProcessDefinition> list = Processengine.getrepositoryservice ()//Service related to process definition and deployment objects. Createprocessdefinitionquery ()//Create a Process definition query                        /*specify query criteria, where condition*/                        //. Deploymentid (Deploymentid)//querying using the Deployment Object ID//. Processdefinitionid (Processdefinitionid)//query using process definition ID//. Processdefinitionkey (Processdefinitionkey)//use process-defined key queries//. Processdefinitionnamelike (processdefinitionnamelike)//fuzzy Query using the name of the process definition                                                /*Sort*/. Orderbyprocessdefinitionversion (). ASC ()//Sorted by version in ascending order//. Orderbyprocessdefinitionname (). DESC ()//Sort by process-defined name in descending order. List ();//returns a collection list that encapsulates the process definition//. Singleresult ();//returns a unique result set//. Count ();//returns the number of result sets//. Listpage (Firstresult, MaxResults)//Paging Query                if(List! =NULL&& list.size () >0){             for(ProcessDefinition processdefinition:list) {System.out.println ("Process definition ID:" +processdefinition.getid ());//key+ version of the process definition + random build numberSYSTEM.OUT.PRINTLN ("Process definition name:" +processdefinition.getname ());//the value of the name attribute in the corresponding HELLOWORLD.BPMN fileSystem.out.println ("Key for process definition:" +processdefinition.getkey ());//the value of the id attribute in the corresponding HELLOWORLD.BPMN fileSystem.out.println ("version of the process definition:" +processdefinition.getversion ());//when the key value of the process definition is the same, the version is upgraded by default starting from 1System.out.println ("Resource Name BPMN file:" +processdefinition.getresourcename ()); System.out.println ("Resource name PNG file:" +processdefinition.getdiagramresourcename ()); System.out.println ("Deployment Object ID:" +Processdefinition.getdeploymentid ()); System.out.println ("################################"); }        }            }    }

Activiti query Process Definition

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.