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

The following examples show how to use org.activiti.engine.repository.ProcessDefinitionQuery#processDefinitionKeyLike() . 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: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
* {@inheritDoc}
*/
public List<WorkflowDefinition> getAllDefinitions()
{
    try 
    {
        ProcessDefinitionQuery query = repoService.createProcessDefinitionQuery();
        if(activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && !TenantUtil.isCurrentDomainDefault()) 
        {
            query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "%");
        }
        return getValidWorkflowDefinitions(query.list());
    } 
    catch (ActivitiException ae)
    {
        String msg = messageService.getMessage(ERR_GET_WORKFLOW_DEF);
        if(logger.isDebugEnabled())
        {
        	logger.debug(msg, ae);
        }
        throw new WorkflowException(msg, ae);
    }
}
 
Example 2
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
* {@inheritDoc}
*/
public List<WorkflowDefinition> getDefinitions()
{
    try 
    {
        ProcessDefinitionQuery query = repoService.createProcessDefinitionQuery().latestVersion();
        if(activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && !TenantUtil.isCurrentDomainDefault()) 
        {
            query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "%");
        }
        return getValidWorkflowDefinitions(query.list());
    }
    catch (ActivitiException ae)
    {
        String msg = messageService.getMessage(ERR_GET_WORKFLOW_DEF);
        if(logger.isDebugEnabled())
        {
        	logger.debug(msg, ae);
        }
        throw new WorkflowException(msg, ae);
    }
}
 
Example 3
Source File: ProcessDefinitionsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ProcessDefinition getProcessDefinition(String definitionId)
{
    ProcessDefinitionQuery query = activitiProcessEngine
            .getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionId(definitionId);
    
    if (tenantService.isEnabled() && deployWorkflowsInTenant) 
    {
        query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%");
    }
    
    org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult();
    
    if (processDefinition == null) 
    {
        throw new EntityNotFoundException(definitionId); 
    }

    ProcessDefinition deploymentRest = createProcessDefinitionRest((ProcessDefinitionEntity) processDefinition);
    return deploymentRest;
}
 
Example 4
Source File: ProcessEngineService.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 查询流程定义列表
 *
 * @return
 */
public IPage<ProcessDefinition> findProcessDefinition(String key, int firstResult, int maxResults) {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
    // 只查询最新版本
    query.latestVersion();
    if (StringUtils.isNotBlank(key)) {
        String processKey = "%" + key + "%";
        query.processDefinitionKeyLike(processKey);
    }
    List<ProcessDefinition> list = query.listPage(firstResult, maxResults);
    IPage page = new Page();
    page.setRecords(list);
    page.setTotal(query.count());
    return page;
}
 
Example 5
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 6
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);
}
 
Example 7
Source File: ProcessDefinitionsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public BinaryResource getProcessDefinitionImage(String definitionId)
{
	ProcessDefinitionQuery query = activitiProcessEngine
            .getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionId(definitionId);
    
    if (tenantService.isEnabled() && deployWorkflowsInTenant) 
    {
        query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%");
    }
    
    org.activiti.engine.repository.ProcessDefinition processDefinition = query.singleResult();
    
    if (processDefinition == null) 
    {
        throw new EntityNotFoundException(definitionId); 
    }
    
    try
    {
    	InputStream processDiagram = activitiProcessEngine.getRepositoryService().getProcessDiagram(definitionId);
    	if (processDiagram != null) 
    	{
         File file = TempFileProvider.createTempFile(definitionId + UUID.randomUUID(), ".png");
         FileOutputStream fos = new FileOutputStream(file);
         IOUtils.copy(processDiagram, fos);
         fos.close();
             
         return new FileBinaryResource(file);
    	}
    	else
    	{
    		throw new ApiException("No image available for definitionId " + definitionId); 
    	}
    }
    catch (IOException error)
    {
        throw new ApiException("Error while getting process definition image.");
    }
}