Search in sources :

Example 26 with ProcessDefinitionQuery

use of org.activiti.engine.repository.ProcessDefinitionQuery in project Activiti by Activiti.

the class ProcessDefinitionQueryTest method testQueryByNameLike.

public void testQueryByNameLike() {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionNameLike("%w%");
    verifyQueryResults(query, 1);
}
Also used : ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery)

Example 27 with ProcessDefinitionQuery

use of org.activiti.engine.repository.ProcessDefinitionQuery in project Activiti by Activiti.

the class ProcessDefinitionQueryTest method testQuerySorting.

public void testQuerySorting() {
    // asc 
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionId().asc();
    verifyQueryResults(query, 3);
    query = repositoryService.createProcessDefinitionQuery().orderByDeploymentId().asc();
    verifyQueryResults(query, 3);
    query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionKey().asc();
    verifyQueryResults(query, 3);
    query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().asc();
    verifyQueryResults(query, 3);
    // desc
    query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionId().desc();
    verifyQueryResults(query, 3);
    query = repositoryService.createProcessDefinitionQuery().orderByDeploymentId().desc();
    verifyQueryResults(query, 3);
    query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionKey().desc();
    verifyQueryResults(query, 3);
    query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionVersion().desc();
    verifyQueryResults(query, 3);
    // Typical use case
    query = repositoryService.createProcessDefinitionQuery().orderByProcessDefinitionKey().asc().orderByProcessDefinitionVersion().desc();
    List<ProcessDefinition> processDefinitions = query.list();
    assertEquals(3, processDefinitions.size());
    assertEquals("one", processDefinitions.get(0).getKey());
    assertEquals(2, processDefinitions.get(0).getVersion());
    assertEquals("one", processDefinitions.get(1).getKey());
    assertEquals(1, processDefinitions.get(1).getVersion());
    assertEquals("two", processDefinitions.get(2).getKey());
    assertEquals(1, processDefinitions.get(2).getVersion());
}
Also used : ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 28 with ProcessDefinitionQuery

use of org.activiti.engine.repository.ProcessDefinitionQuery in project Activiti by Activiti.

the class ProcessDefinitionQueryByLatestTest method testQueryByLatestAndName.

public void testQueryByLatestAndName() throws Exception {
    // Deploy
    List<String> xmlFileNameList = Arrays.asList("name_testProcess1_one.bpmn20.xml", "name_testProcess1_two.bpmn20.xml", "name_testProcess2_one.bpmn20.xml");
    List<String> deploymentIdList = deploy(xmlFileNameList);
    // name
    ProcessDefinitionQuery nameQuery = repositoryService.createProcessDefinitionQuery().processDefinitionName("one").latestVersion();
    List<ProcessDefinition> processDefinitions = nameQuery.list();
    assertEquals(1, processDefinitions.size());
    assertEquals(1, processDefinitions.get(0).getVersion());
    assertEquals("testProcess2", processDefinitions.get(0).getKey());
    // nameLike
    ProcessDefinitionQuery nameLikeQuery = repositoryService.createProcessDefinitionQuery().processDefinitionName("one").latestVersion();
    processDefinitions = nameLikeQuery.list();
    assertEquals(1, processDefinitions.size());
    assertEquals(1, processDefinitions.get(0).getVersion());
    assertEquals("testProcess2", processDefinitions.get(0).getKey());
    // Undeploy
    unDeploy(deploymentIdList);
}
Also used : ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 29 with ProcessDefinitionQuery

use of org.activiti.engine.repository.ProcessDefinitionQuery in project Activiti by Activiti.

the class ProcessDefinitionQueryEscapeClauseTest method testQueryByCategoryLike.

public void testQueryByCategoryLike() {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionCategoryLike("%\\_%");
    assertEquals("Examples_", query.singleResult().getCategory());
    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
}
Also used : ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery)

Aggregations

ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)29 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)7 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)5 SysBpmnResourceVO (com.netsteadfast.greenstep.vo.SysBpmnResourceVO)1 ArrayList (java.util.ArrayList)1 RepositoryService (org.activiti.engine.RepositoryService)1 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)1 DeploymentQuery (org.activiti.engine.repository.DeploymentQuery)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Task (org.activiti.engine.task.Task)1 Test (org.junit.Test)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1