org.activiti.engine.repository.ProcessDefinitionQuery Java Examples

The following examples show how to use org.activiti.engine.repository.ProcessDefinitionQuery. 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: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程资源
 *
 * @param processDefinitionId 流程定义ID
 * @param resourceName        资源名称
 */
@RequestMapping(value = "/read-resource")
public void readResource(@RequestParam("pdid") String processDefinitionId,
                         @RequestParam("resourceName") String resourceName, HttpServletResponse response)
        throws Exception {
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult();

    // 通过接口读取
    InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len;
    while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example #2
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程资源
 *
 * @param processDefinitionId 流程定义ID
 * @param resourceName        资源名称
 */
@RequestMapping(value = "/read-resource")
public void readResource(@RequestParam("pdid") String processDefinitionId, @RequestParam("resourceName") String resourceName, HttpServletResponse response)
        throws Exception {
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult();

    // 通过接口读取
    InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len = -1;
    while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example #3
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程资源
 *
 * @param processDefinitionId 流程定义ID
 * @param resourceName        资源名称
 */
@RequestMapping(value = "/read-resource")
public void readResource(@RequestParam("pdid") String processDefinitionId, @RequestParam("resourceName") String resourceName, HttpServletResponse response)
        throws Exception {
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult();

    // 通过接口读取
    InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len = -1;
    while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example #4
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 #5
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程资源
 *
 * @param processDefinitionId 流程定义ID
 * @param resourceName        资源名称
 */
@RequestMapping(value = "/read-resource")
public void readResource(@RequestParam("pdid") String processDefinitionId, @RequestParam("resourceName") String resourceName, HttpServletResponse response)
        throws Exception {
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult();

    // 通过接口读取
    InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len = -1;
    while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example #6
Source File: InputStreamDeploymentTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 从具体的文件中读取输入流部署
 */
@Test
public void testInputStreamFromAbsoluteFilePath() throws Exception {

    // 注意:读者根据自己的实际项目路径更改后验证
    String filePath = "/Users/henryyan/work/books/activiti-in-action-codes/bpmn20-example/src/test/resources/chapter5/userAndGroupInUserTask.bpmn";

    // 读取classpath的资源为一个输入流
    FileInputStream fileInputStream = new FileInputStream(filePath);
    repositoryService.createDeployment().addInputStream("userAndGroupInUserTask.bpmn", fileInputStream).deploy();

    // 验证是否部署成功
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    long count = pdq.processDefinitionKey("userAndGroupInUserTask").count();
    assertEquals(1, count);
}
 
Example #7
Source File: ActTaskService.java    From Shop-for-JavaWeb with MIT License 6 votes vote down vote up
/**
 * 获取流程列表
 * @param category 流程分类
 */
public Page<Object[]> processList(Page<Object[]> page, String category) {
	/*
	 * 保存两个对象,一个是ProcessDefinition(流程定义),一个是Deployment(流程部署)
	 */
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
    		.latestVersion().active().orderByProcessDefinitionKey().asc();
    
    if (StringUtils.isNotEmpty(category)){
    	processDefinitionQuery.processDefinitionCategory(category);
	}
    
    page.setCount(processDefinitionQuery.count());
    
    List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(page.getFirstResult(), page.getMaxResults());
    for (ProcessDefinition processDefinition : processDefinitionList) {
      String deploymentId = processDefinition.getDeploymentId();
      Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
      page.getList().add(new Object[]{processDefinition, deployment});
    }
	return page;
}
 
Example #8
Source File: FlowableDeploymentController.java    From hsweb-framework with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程资源
 *
 * @param processDefinitionId 流程定义ID
 * @param resourceName        资源名称
 */
@GetMapping(value = "/{processDefinitionId}/resource/{resourceName}")
@ApiOperation("读取流程资源")
@Authorize(action = Permission.ACTION_QUERY)
@SneakyThrows
public void readResource(@PathVariable String processDefinitionId
        , @PathVariable String resourceName, HttpServletResponse response) {
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult();

    // 通过接口读取
    try (InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName)) {
        StreamUtils.copy(resourceAsStream, response.getOutputStream());
    }

}
 
Example #9
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程资源
 *
 * @param processDefinitionId 流程定义ID
 * @param resourceName        资源名称
 */
@RequestMapping(value = "/read-resource")
public void readResource(@RequestParam("pdid") String processDefinitionId,
                         @RequestParam("resourceName") String resourceName, HttpServletResponse response)
        throws Exception {
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult();

    // 通过接口读取
    InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len = -1;
    while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example #10
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程资源
 *
 * @param processDefinitionId 流程定义ID
 * @param resourceName        资源名称
 */
@RequestMapping(value = "/read-resource")
public void readResource(@RequestParam("pdid") String processDefinitionId,
                         @RequestParam("resourceName") String resourceName, HttpServletResponse response)
        throws Exception {
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult();

    // 通过接口读取
    InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len;
    while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example #11
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程资源
 *
 * @param processDefinitionId 流程定义ID
 * @param resourceName        资源名称
 */
@RequestMapping(value = "/read-resource")
public void readResource(@RequestParam("pdid") String processDefinitionId,
                         @RequestParam("resourceName") String resourceName, HttpServletResponse response)
        throws Exception {
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult();

    // 通过接口读取
    InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len;
    while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example #12
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 #13
Source File: ActProcessService.java    From Shop-for-JavaWeb with MIT License 6 votes vote down vote up
/**
 * 流程定义列表
 */
public Page<Object[]> processList(Page<Object[]> page, String category) {

    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
    		.latestVersion().orderByProcessDefinitionKey().asc();
    
    if (StringUtils.isNotEmpty(category)){
    	processDefinitionQuery.processDefinitionCategory(category);
	}
    
    page.setCount(processDefinitionQuery.count());
    
    List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(page.getFirstResult(), page.getMaxResults());
    for (ProcessDefinition processDefinition : processDefinitionList) {
      String deploymentId = processDefinition.getDeploymentId();
      Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
      page.getList().add(new Object[]{processDefinition, deployment});
    }

	return page;
}
 
Example #14
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 #15
Source File: ProcessDefinitionQueryEscapeClauseTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testQueryByTenantIdLike() {
  ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionTenantIdLike("%\\%%");
  assertEquals("One%", query.singleResult().getTenantId());
  assertEquals(1, query.list().size());
  assertEquals(1, query.count());
  
  query = repositoryService.createProcessDefinitionQuery().processDefinitionTenantIdLike("%\\_%");
  assertEquals("Two_", query.singleResult().getTenantId());
  assertEquals(1, query.list().size());
  assertEquals(1, query.count());
  
  query = repositoryService.createProcessDefinitionQuery().latestVersion().processDefinitionTenantIdLike("%\\%%");
  assertEquals("One%", query.singleResult().getTenantId());
  assertEquals(1, query.list().size());
  assertEquals(1, query.count());
  
  query = repositoryService.createProcessDefinitionQuery().latestVersion().processDefinitionTenantIdLike("%\\_%");
  assertEquals("Two_", query.singleResult().getTenantId());
  assertEquals(1, query.list().size());
  assertEquals(1, query.count());
}
 
Example #16
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 #17
Source File: ActivitiServiceTest.java    From herd with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetProcessDefinitionsByIds()
{
    Set<String> processDefinitionIds = new HashSet<>();
    ProcessDefinitionQuery processDefinitionQuery = mock(ProcessDefinitionQuery.class);
    when(activitiRepositoryService.createProcessDefinitionQuery()).thenReturn(processDefinitionQuery);
    when(processDefinitionQuery.processDefinitionIds(processDefinitionIds)).thenReturn(processDefinitionQuery);
    List<ProcessDefinition> expectedProcessDefinitions = new ArrayList<>();
    when(processDefinitionQuery.list()).thenReturn(expectedProcessDefinitions);
    List<ProcessDefinition> actualProcessDefinitions = activitiService.getProcessDefinitionsByIds(processDefinitionIds);
    assertSame(expectedProcessDefinitions, actualProcessDefinitions);
    InOrder inOrder = inOrder(processDefinitionQuery);
    inOrder.verify(processDefinitionQuery).processDefinitionIds(processDefinitionIds);
    inOrder.verify(processDefinitionQuery).list();
    inOrder.verifyNoMoreInteractions();
}
 
Example #18
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取流程资源
 *
 * @param processDefinitionId 流程定义ID
 * @param resourceName        资源名称
 */
@RequestMapping(value = "/read-resource")
public void readResource(@RequestParam("pdid") String processDefinitionId,
                         @RequestParam("resourceName") String resourceName, HttpServletResponse response)
        throws Exception {
    ProcessDefinitionQuery pdq = repositoryService.createProcessDefinitionQuery();
    ProcessDefinition pd = pdq.processDefinitionId(processDefinitionId).singleResult();

    // 通过接口读取
    InputStream resourceAsStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName);

    // 输出资源内容到相应对象
    byte[] b = new byte[1024];
    int len;
    while ((len = resourceAsStream.read(b, 0, 1024)) != -1) {
        response.getOutputStream().write(b, 0, len);
    }
}
 
Example #19
Source File: ProcessDefinitionQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByInvalidName() {
  ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionName("invalid");
  verifyQueryResults(query, 0);
  
  try {
    repositoryService.createProcessDefinitionQuery().processDefinitionName(null);
    fail();
  } catch (ActivitiIllegalArgumentException e) {}
}
 
Example #20
Source File: ProcessDefinitionQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByInvalidKey() {
  ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionKey("invalid");
  verifyQueryResults(query, 0);
  
  try {
    repositoryService.createProcessDefinitionQuery().processDefinitionKey(null);
    fail();
  } catch (ActivitiIllegalArgumentException e) {}
}
 
Example #21
Source File: ProcessDefinitionsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public CollectionWithPagingInfo<FormModelElement> getStartFormModel(String definitionId, Paging paging)
{
    // first validate if user is allowed to access the process definition if workflows are deployed per tenant
    if (tenantService.isEnabled() && deployWorkflowsInTenant) 
    {
        ProcessDefinitionQuery query = activitiProcessEngine
                .getRepositoryService()
                .createProcessDefinitionQuery()
                .processDefinitionId(definitionId);
    
        query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%");
        org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult();
        
        if (processDefinition == null) 
        {
            throw new EntityNotFoundException(definitionId); 
        }
    }
    
    StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(definitionId);
    if (startFormData == null)
    {
        throw new EntityNotFoundException(definitionId);
    }
    
    if (qNameConverter == null)
    {
        qNameConverter = new WorkflowQNameConverter(namespaceService);
    }
    if (workflowFactory == null) 
    {
        workflowFactory = new WorkflowObjectFactory(qNameConverter, tenantService, messageService, dictionaryService, engineId, defaultStartTaskType);
    }
    
    // Lookup type definition for the startTask
    TypeDefinition startTaskType = workflowFactory.getTaskFullTypeDefinition(startFormData.getFormKey(), true);
    return getFormModelElements(startTaskType, paging);
}
 
Example #22
Source File: ProcessDefinitionQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void verifySingleResultFails(ProcessDefinitionQuery query) {
  try {
    query.singleResult();
    fail();
  } catch (ActivitiException e) {
  }
}
 
Example #23
Source File: ProcessDefinitionQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void verifyQueryResults(ProcessDefinitionQuery query, int countExpected) {
  assertEquals(countExpected, query.list().size());
  assertEquals(countExpected, query.count());

  if (countExpected == 1) {
    assertNotNull(query.singleResult());
  } else if (countExpected > 1) {
    verifySingleResultFails(query);
  } else if (countExpected == 0) {
    assertNull(query.singleResult());
  }
}
 
Example #24
Source File: ProcessDefinitionQueryEscapeClauseTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByNameLike() {
  ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionNameLike("%\\%%");
  assertEquals("One%", query.singleResult().getName());
  assertEquals(1, query.list().size());
  assertEquals(1, query.count());
  
  query = repositoryService.createProcessDefinitionQuery().processDefinitionNameLike("%\\_%");
  assertEquals("Two_", query.singleResult().getName());
  assertEquals(1, query.list().size());
  assertEquals(1, query.count());
}
 
Example #25
Source File: ProcessDefinitionQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByLatest() {
  ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().latestVersion();
  verifyQueryResults(query, 2);

  query = repositoryService.createProcessDefinitionQuery().processDefinitionKey("one").latestVersion();
  verifyQueryResults(query, 1);

  query = repositoryService.createProcessDefinitionQuery().processDefinitionKey("two").latestVersion();
  verifyQueryResults(query, 1);
}
 
Example #26
Source File: WorkController.java    From ehousechina with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/read")
public void readResource(@RequestParam("pdid") String pdid,@RequestParam("resourceName") String resourceName,HttpServletResponse response) throws IOException {
	ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
	ProcessDefinition pd=processDefinitionQuery.processDefinitionId(pdid).singleResult();
	InputStream resourceAsStream=repositoryService.getResourceAsStream(pd.getDeploymentId(), resourceName);
	byte [] b =new byte[1024];
	int len= -1;
	while((len=resourceAsStream.read(b,0,1024))!=-1){
		response.getOutputStream().write(b,0,len);
	}
}
 
Example #27
Source File: ProcessDefinitionQueryTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryByVersion() {
  ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(2);
  verifyQueryResults(query, 1);

  query = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(1);
  verifyQueryResults(query, 2);
}
 
Example #28
Source File: FlowableDeploymentController.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
/**
 * 流程定义列表
 */
@GetMapping
@ApiOperation("查询流程定义列表")
@Authorize(action = Permission.ACTION_QUERY)
public ResponseMessage<PagerResult<ProcessDefinitionInfo>> queryProcessList(QueryParamEntity param) {
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();

    return ResponseMessage.ok(QueryUtils.doQuery(processDefinitionQuery, param, ProcessDefinitionInfo::of));
}
 
Example #29
Source File: ExecutionController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 流程定义对象缓存
 *
 * @param definitionMap
 * @param processDefinitionId
 */
private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) {
    if (definitionMap.get(processDefinitionId) == null) {
        ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
        processDefinitionQuery.processDefinitionId(processDefinitionId);
        ProcessDefinition processDefinition = processDefinitionQuery.singleResult();

        // 放入缓存
        definitionMap.put(processDefinitionId, processDefinition);
    }
}
 
Example #30
Source File: ProcessInstanceManagerController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 流程定义对象缓存
 *
 * @param definitionMap
 * @param processDefinitionId
 */
private void definitionCache(Map<String, ProcessDefinition> definitionMap, String processDefinitionId) {
    if (definitionMap.get(processDefinitionId) == null) {
        ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
        processDefinitionQuery.processDefinitionId(processDefinitionId);
        ProcessDefinition processDefinition = processDefinitionQuery.singleResult();

        // 放入缓存
        definitionMap.put(processDefinitionId, processDefinition);
    }
}