Java Code Examples for org.activiti.engine.repository.ProcessDefinitionQuery#list()

The following examples show how to use org.activiti.engine.repository.ProcessDefinitionQuery#list() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BxlcTaskListeningImpl.java    From gem with MIT License 6 votes vote down vote up
/**
 * @Description:流程列表
 * @author: Ryan
 * @date 2018年11月18日
 */
public List<ProcessVersion> findProcessList() {
	List<ProcessVersion> arrayList = new ArrayList<ProcessVersion>();
	ProcessDefinitionQuery createProcessDefinitionQuery = repositoryService.createProcessDefinitionQuery();
	createProcessDefinitionQuery.latestVersion();
	List<ProcessDefinition> list = createProcessDefinitionQuery.list();
	if(list!=null && list.size()>0) {
		for (ProcessDefinition processDefinition : list) {
			ProcessVersion processVersion = new ProcessVersion();
			processVersion.setId(processDefinition.getId());
			processVersion.setName(processDefinition.getName());
			processVersion.setKey(processDefinition.getKey());
			arrayList.add(processVersion);
		}
	}
	return arrayList;
}
 
Example 2
Source File: AbstractProcessDefinitionsResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public ResultListDataRepresentation getProcessDefinitions(Boolean latest, String deploymentKey) {

    ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery();

    if (deploymentKey != null) {
      Deployment deployment = repositoryService.createDeploymentQuery().deploymentKey(deploymentKey).latest().singleResult();
      
      if (deployment != null) {
        definitionQuery.deploymentId(deployment.getId());
      } else {
        return new ResultListDataRepresentation(new ArrayList<ProcessDefinitionRepresentation>());
      }

    } else {

      if (latest != null && latest) {
        definitionQuery.latestVersion();
      }
    }

    List<ProcessDefinition> definitions = definitionQuery.list();
    ResultListDataRepresentation result = new ResultListDataRepresentation(convertDefinitionList(definitions));
    return result;
  }
 
Example 3
Source File: ProcessDefinitionQueryByLatestTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 4
Source File: ProcessDefinitionQueryByLatestTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByLatestAndDeploymentId() 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);

	// deploymentId
	ProcessDefinitionQuery deploymentQuery1 = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentIdList.get(0)).latestVersion();
	List<ProcessDefinition> processDefinitions = deploymentQuery1.list();
	assertEquals(0, processDefinitions.size());

	ProcessDefinitionQuery deploymentQuery2 = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentIdList.get(1)).latestVersion();
	processDefinitions = deploymentQuery2.list();
	assertEquals(1, processDefinitions.size());
	assertEquals("testProcess1", processDefinitions.get(0).getKey());

	// Undeploy
	unDeploy(deploymentIdList);
}
 
Example 5
Source File: ProcessDefinitionQueryByLatestTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 6
Source File: ProcessDefinitionQueryByLatestTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByLatestAndDeploymentId() 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);

	// deploymentId
	ProcessDefinitionQuery deploymentQuery1 = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentIdList.get(0)).latestVersion();
	List<ProcessDefinition> processDefinitions = deploymentQuery1.list();
	assertEquals(0, processDefinitions.size());

	ProcessDefinitionQuery deploymentQuery2 = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentIdList.get(1)).latestVersion();
	processDefinitions = deploymentQuery2.list();
	assertEquals(1, processDefinitions.size());
	assertEquals("testProcess1", processDefinitions.get(0).getKey());

	// Undeploy
	unDeploy(deploymentIdList);
}
 
Example 7
Source File: ProcessDefinitionQueryByLatestTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByLatestAndId() 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);
	
	List<String> processDefinitionIdList = new ArrayList<String>();
	for(String deploymentId : deploymentIdList){
		String processDefinitionId = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).list().get(0).getId();
		processDefinitionIdList.add(processDefinitionId);
	}

	ProcessDefinitionQuery idQuery1 = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdList.get(0)).latestVersion();
	List<ProcessDefinition>  processDefinitions = idQuery1.list();
	assertEquals(0, processDefinitions.size());

	ProcessDefinitionQuery idQuery2 = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdList.get(1)).latestVersion();
	processDefinitions = idQuery2.list();
	assertEquals(1, processDefinitions.size());
	assertEquals("testProcess1", processDefinitions.get(0).getKey());

	ProcessDefinitionQuery idQuery3 = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdList.get(2)).latestVersion();
	processDefinitions = idQuery3.list();
	assertEquals(1, processDefinitions.size());
	assertEquals("testProcess2", processDefinitions.get(0).getKey());

	// Undeploy
	unDeploy(deploymentIdList);
}
 
Example 8
Source File: ProcessDefinitionQueryByLatestTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByLatestAndVersion() throws Exception {
	// Deploy
	List<String> xmlFileNameList = Arrays.asList("version_testProcess1_one.bpmn20.xml",
			"version_testProcess1_two.bpmn20.xml", "version_testProcess2_one.bpmn20.xml");
	List<String> deploymentIdList = deploy(xmlFileNameList);

	// version
	ProcessDefinitionQuery nameQuery = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(1).latestVersion();
	List<ProcessDefinition> processDefinitions = nameQuery.list();
	assertEquals(1, processDefinitions.size());
	assertEquals("testProcess2", processDefinitions.get(0).getKey());

	// Undeploy
	unDeploy(deploymentIdList);
}
 
Example 9
Source File: ProcessDefinitionQueryByLatestTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByLatestAndId() 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);
	
	List<String> processDefinitionIdList = new ArrayList<String>();
	for(String deploymentId : deploymentIdList){
		String processDefinitionId = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).list().get(0).getId();
		processDefinitionIdList.add(processDefinitionId);
	}

	ProcessDefinitionQuery idQuery1 = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdList.get(0)).latestVersion();
	List<ProcessDefinition>  processDefinitions = idQuery1.list();
	assertEquals(0, processDefinitions.size());

	ProcessDefinitionQuery idQuery2 = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdList.get(1)).latestVersion();
	processDefinitions = idQuery2.list();
	assertEquals(1, processDefinitions.size());
	assertEquals("testProcess1", processDefinitions.get(0).getKey());

	ProcessDefinitionQuery idQuery3 = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionIdList.get(2)).latestVersion();
	processDefinitions = idQuery3.list();
	assertEquals(1, processDefinitions.size());
	assertEquals("testProcess2", processDefinitions.get(0).getKey());

	// Undeploy
	unDeploy(deploymentIdList);
}
 
Example 10
Source File: ProcessDefinitionQueryByLatestTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByLatestAndVersion() throws Exception {
	// Deploy
	List<String> xmlFileNameList = Arrays.asList("version_testProcess1_one.bpmn20.xml",
			"version_testProcess1_two.bpmn20.xml", "version_testProcess2_one.bpmn20.xml");
	List<String> deploymentIdList = deploy(xmlFileNameList);

	// version
	ProcessDefinitionQuery nameQuery = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(1).latestVersion();
	List<ProcessDefinition> processDefinitions = nameQuery.list();
	assertEquals(1, processDefinitions.size());
	assertEquals("testProcess2", processDefinitions.get(0).getKey());

	// Undeploy
	unDeploy(deploymentIdList);
}
 
Example 11
Source File: ProcessDefinitionQueryTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
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());
  }
 
Example 12
Source File: ProcessDefinitionQueryTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
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());
}