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

The following examples show how to use org.activiti.engine.repository.ProcessDefinitionQuery#processDefinitionCategory() . 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: 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 2
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 3
Source File: ProcessDefinitionCollectionResource.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@ApiOperation(value = "List of process definitions", tags = {"Process Definitions"})
@ApiImplicitParams({
  @ApiImplicitParam(name = "version", dataType = "integer", value = "Only return process definitions with the given version.", paramType = "query"),
  @ApiImplicitParam(name = "name", dataType = "string", value = "Only return process definitions with the given name.", paramType = "query"),
  @ApiImplicitParam(name = "nameLike", dataType = "string", value = "Only return process definitions with a name like the given name.", paramType = "query"),
  @ApiImplicitParam(name = "key", dataType = "string", value = "Only return process definitions with the given key.", paramType = "query"),
  @ApiImplicitParam(name = "keyLike", dataType = "string", value = "Only return process definitions with a name like the given key.", paramType = "query"),
  @ApiImplicitParam(name = "resourceName", dataType = "string", value = "Only return process definitions with the given resource name.", paramType = "query"),
  @ApiImplicitParam(name = "resourceNameLike", dataType = "string", value = "Only return process definitions with a name like the given resource name.", paramType = "query"),
  @ApiImplicitParam(name = "category", dataType = "string", value = "Only return process definitions with the given category.", paramType = "query"),
  @ApiImplicitParam(name = "categoryLike", dataType = "string", value = "Only return process definitions with a category like the given name.", paramType = "query"),
  @ApiImplicitParam(name = "categoryNotEquals", dataType = "string", value = "Only return process definitions which don’t have the given category.", paramType = "query"),
  @ApiImplicitParam(name = "deploymentId", dataType = "string", value = "Only return process definitions with the given category.", paramType = "query"),
  @ApiImplicitParam(name = "startableByUser", dataType = "string", value = "Only return process definitions which are part of a deployment with the given id.", paramType = "query"),
  @ApiImplicitParam(name = "latest", dataType = "boolean", value = "Only return the latest process definition versions. Can only be used together with key and keyLike parameters, using any other parameter will result in a 400-response.", paramType = "query"),
  @ApiImplicitParam(name = "suspended", dataType = "boolean", value = "If true, only returns process definitions which are suspended. If false, only active process definitions (which are not suspended) are returned.", paramType = "query"),
  @ApiImplicitParam(name = "sort", dataType = "string", value = "Property to sort on, to be used together with the order.", allowableValues ="name,id,key,category,deploymentId,version", paramType = "query"),
})
@ApiResponses(value = {
    @ApiResponse(code = 200, message = "Indicates request was successful and the process-definitions are returned"),
    @ApiResponse(code = 400, message = "Indicates a parameter was passed in the wrong format or that latest is used with other parameters other than key and keyLike. The status-message contains additional information.")
})
@RequestMapping(value = "/repository/process-definitions", method = RequestMethod.GET, produces = "application/json")
public DataResponse getProcessDefinitions(@ApiParam(hidden = true) @RequestParam Map<String, String> allRequestParams, HttpServletRequest request) {
  ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();

  // Populate filter-parameters
  if (allRequestParams.containsKey("category")) {
    processDefinitionQuery.processDefinitionCategory(allRequestParams.get("category"));
  }
  if (allRequestParams.containsKey("categoryLike")) {
    processDefinitionQuery.processDefinitionCategoryLike(allRequestParams.get("categoryLike"));
  }
  if (allRequestParams.containsKey("categoryNotEquals")) {
    processDefinitionQuery.processDefinitionCategoryNotEquals(allRequestParams.get("categoryNotEquals"));
  }
  if (allRequestParams.containsKey("key")) {
    processDefinitionQuery.processDefinitionKey(allRequestParams.get("key"));
  }
  if (allRequestParams.containsKey("keyLike")) {
    processDefinitionQuery.processDefinitionKeyLike(allRequestParams.get("keyLike"));
  }
  if (allRequestParams.containsKey("name")) {
    processDefinitionQuery.processDefinitionName(allRequestParams.get("name"));
  }
  if (allRequestParams.containsKey("nameLike")) {
    processDefinitionQuery.processDefinitionNameLike(allRequestParams.get("nameLike"));
  }
  if (allRequestParams.containsKey("resourceName")) {
    processDefinitionQuery.processDefinitionResourceName(allRequestParams.get("resourceName"));
  }
  if (allRequestParams.containsKey("resourceNameLike")) {
    processDefinitionQuery.processDefinitionResourceNameLike(allRequestParams.get("resourceNameLike"));
  }
  if (allRequestParams.containsKey("version")) {
    processDefinitionQuery.processDefinitionVersion(Integer.valueOf(allRequestParams.get("version")));
  }
  if (allRequestParams.containsKey("suspended")) {
    Boolean suspended = Boolean.valueOf(allRequestParams.get("suspended"));
    if (suspended != null) {
      if (suspended) {
        processDefinitionQuery.suspended();
      } else {
        processDefinitionQuery.active();
      }
    }
  }
  if (allRequestParams.containsKey("latest")) {
    Boolean latest = Boolean.valueOf(allRequestParams.get("latest"));
    if (latest != null && latest) {
      processDefinitionQuery.latestVersion();
    }
  }
  if (allRequestParams.containsKey("deploymentId")) {
    processDefinitionQuery.deploymentId(allRequestParams.get("deploymentId"));
  }
  if (allRequestParams.containsKey("startableByUser")) {
    processDefinitionQuery.startableByUser(allRequestParams.get("startableByUser"));
  }
  if (allRequestParams.containsKey("tenantId")) {
    processDefinitionQuery.processDefinitionTenantId(allRequestParams.get("tenantId"));
  }
  if (allRequestParams.containsKey("tenantIdLike")) {
    processDefinitionQuery.processDefinitionTenantIdLike(allRequestParams.get("tenantIdLike"));
  }

  return new ProcessDefinitionsPaginateList(restResponseFactory).paginateList(allRequestParams, processDefinitionQuery, "name", properties);
}