Java Code Examples for org.activiti.engine.repository.ProcessDefinition#getDeploymentId()

The following examples show how to use org.activiti.engine.repository.ProcessDefinition#getDeploymentId() . 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: DeploymentManager.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public ProcessDefinitionCacheEntry resolveProcessDefinition(ProcessDefinition processDefinition) {
  String processDefinitionId = processDefinition.getId();
  String deploymentId = processDefinition.getDeploymentId();
  ProcessDefinitionCacheEntry cachedProcessDefinition = processDefinitionCache.get(processDefinitionId);
  if (cachedProcessDefinition==null) {
    DeploymentEntity deployment = Context
      .getCommandContext()
      .getDeploymentEntityManager()
      .findDeploymentById(deploymentId);
    deployment.setNew(false);
    deploy(deployment, null);
    cachedProcessDefinition = processDefinitionCache.get(processDefinitionId);
    
    if (cachedProcessDefinition==null) {
      throw new ActivitiException("deployment '"+deploymentId+"' didn't put process definition '"+processDefinitionId+"' in the cache");
    }
  }
  return cachedProcessDefinition;
}
 
Example 2
Source File: GetDeploymentProcessDiagramCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public InputStream execute(CommandContext commandContext) {
  ProcessDefinition processDefinition = commandContext
          .getProcessEngineConfiguration()
          .getDeploymentManager()
          .findDeployedProcessDefinitionById(processDefinitionId);
  String deploymentId = processDefinition.getDeploymentId();
  String resourceName = processDefinition.getDiagramResourceName();
  if (resourceName == null ) {
    log.info("Resource name is null! No process diagram stream exists.");
    return null;
  } else {
    InputStream processDiagramStream =
            new GetDeploymentResourceCmd(deploymentId, resourceName)
            .execute(commandContext);
    return processDiagramStream;
  }
}
 
Example 3
Source File: DeploymentManager.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * Resolving the process definition will fetch the BPMN 2.0, parse it and store the {@link BpmnModel} in memory.
 */
public ProcessDefinitionCacheEntry resolveProcessDefinition(ProcessDefinition processDefinition) {
  String processDefinitionId = processDefinition.getId();
  String deploymentId = processDefinition.getDeploymentId();

  ProcessDefinitionCacheEntry cachedProcessDefinition = processDefinitionCache.get(processDefinitionId);

  if (cachedProcessDefinition == null) {
    CommandContext commandContext = Context.getCommandContext();
    if (commandContext.getProcessEngineConfiguration().isActiviti5CompatibilityEnabled() && 
        Activiti5Util.isActiviti5ProcessDefinition(Context.getCommandContext(), processDefinition)) {
      
      return Activiti5Util.getActiviti5CompatibilityHandler().resolveProcessDefinition(processDefinition);
    }
    
    DeploymentEntity deployment = deploymentEntityManager.findById(deploymentId);
    deployment.setNew(false);
    deploy(deployment, null);
    cachedProcessDefinition = processDefinitionCache.get(processDefinitionId);

    if (cachedProcessDefinition == null) {
      throw new ActivitiException("deployment '" + deploymentId + "' didn't put process definition '" + processDefinitionId + "' in the cache");
    }
  }
  return cachedProcessDefinition;
}
 
Example 4
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 5
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 6
Source File: WorkFlowController.java    From maven-framework-project with MIT License 6 votes vote down vote up
@RequestMapping(value="/processlist",method={RequestMethod.POST,RequestMethod.GET})
public ModelAndView processlist(HttpServletRequest request, HttpServletResponse response){
	
	ModelAndView modelAndView=new ModelAndView("workflow/processlist");
	
	/*
	 * 保存两个对象,一个是ProcessDefinition(流程定义),一个是Deployment(流程部署)
	 */
	List<Object[]> objects = new ArrayList<Object[]>();
	
	List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().list();
	for (ProcessDefinition processDefinition : list) {
		String deploymentId = processDefinition.getDeploymentId();
		Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
		objects.add(new Object[]{processDefinition,deployment});
	}
	modelAndView.addObject("objects",objects);
	return modelAndView;
}
 
Example 7
Source File: DeploymentManager.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public BpmnModel getBpmnModelById(String processDefinitionId) {
  if (processDefinitionId == null) {
    throw new ActivitiIllegalArgumentException("Invalid process definition id : null");
  }
  
  // first try the cache
  BpmnModel bpmnModel = bpmnModelCache.get(processDefinitionId);
  
  if (bpmnModel == null) {
    ProcessDefinition processDefinition = findDeployedProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
      throw new ActivitiObjectNotFoundException("no deployed process definition found with id '" + processDefinitionId + "'", ProcessDefinition.class);
    }
    
    // Fetch the resource
    String resourceName = processDefinition.getResourceName();
    ResourceEntity resource = Context.getCommandContext().getResourceEntityManager()
            .findResourceByDeploymentIdAndResourceName(processDefinition.getDeploymentId(), resourceName);
    if (resource == null) {
      if (Context.getCommandContext().getDeploymentEntityManager().findDeploymentById(processDefinition.getDeploymentId()) == null) {
        throw new ActivitiObjectNotFoundException("deployment for process definition does not exist: " 
            + processDefinition.getDeploymentId(), Deployment.class);
      } else {
        throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName 
                + "' in deployment '" + processDefinition.getDeploymentId() + "'", InputStream.class);
      }
    }
    
    // Convert the bpmn 2.0 xml to a bpmn model
    BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
    bpmnModel = bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false);
    bpmnModelCache.add(processDefinition.getId(), bpmnModel);
  }
  return bpmnModel;
}
 
Example 8
Source File: GetDeploymentProcessModelCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public InputStream execute(CommandContext commandContext) {
  ProcessDefinition processDefinition = commandContext
          .getProcessEngineConfiguration()
          .getDeploymentManager()
          .findDeployedProcessDefinitionById(processDefinitionId);
  String deploymentId = processDefinition.getDeploymentId();
  String resourceName = processDefinition.getResourceName();
  InputStream processModelStream =
          new GetDeploymentResourceCmd(deploymentId, resourceName)
          .execute(commandContext);
  return processModelStream;
}
 
Example 9
Source File: TaskRepresentation.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public TaskRepresentation(TaskInfo taskInfo, ProcessDefinition processDefinition) {
  this.id = taskInfo.getId();
  this.name = taskInfo.getName();
  this.description = taskInfo.getDescription();
  this.category = taskInfo.getCategory();
  this.created = taskInfo.getCreateTime();
  this.dueDate = taskInfo.getDueDate();
  this.priority = taskInfo.getPriority();
  this.processInstanceId = taskInfo.getProcessInstanceId();
  this.processDefinitionId = taskInfo.getProcessDefinitionId();

  if (taskInfo instanceof HistoricTaskInstance) {
    this.endDate = ((HistoricTaskInstance) taskInfo).getEndTime();
    this.formKey = taskInfo.getFormKey();
    this.duration = ((HistoricTaskInstance) taskInfo).getDurationInMillis();
  } else {
    // Rendering of forms for historic tasks not supported currently
    this.formKey = taskInfo.getFormKey();
  }

  if (processDefinition != null) {
    this.processDefinitionName = processDefinition.getName();
    this.processDefinitionDescription = processDefinition.getDescription();
    this.processDefinitionKey = processDefinition.getKey();
    this.processDefinitionCategory = processDefinition.getCategory();
    this.processDefinitionVersion = processDefinition.getVersion();
    this.processDefinitionDeploymentId = processDefinition.getDeploymentId();
  }
}
 
Example 10
Source File: ProcessDefinitionRepresentation.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public ProcessDefinitionRepresentation(ProcessDefinition processDefinition) {
    this.id = processDefinition.getId();
    this.name = processDefinition.getName();
    this.description = processDefinition.getDescription();
    this.key = processDefinition.getKey();
    this.category = processDefinition.getCategory();
    this.version = processDefinition.getVersion();
    this.deploymentId = processDefinition.getDeploymentId();
    this.tenantId = processDefinition.getTenantId();
    this.hasStartForm = processDefinition.hasStartFormKey();
}
 
Example 11
Source File: ProcessInstanceRepresentation.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void mapProcessDefinition(ProcessDefinition processDefinition) {
    if (processDefinition != null) {
        this.processDefinitionName = processDefinition.getName();
        this.processDefinitionDescription = processDefinition.getDescription();
        this.processDefinitionKey = processDefinition.getKey();
        this.processDefinitionCategory = processDefinition.getCategory();
        this.processDefinitionVersion = processDefinition.getVersion();
        this.processDefinitionDeploymentId = processDefinition.getDeploymentId();
    }
}
 
Example 12
Source File: GetDeploymentProcessModelCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public InputStream execute(CommandContext commandContext) {
  ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
  String deploymentId = processDefinition.getDeploymentId();
  String resourceName = processDefinition.getResourceName();
  InputStream processModelStream = new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);
  return processModelStream;
}
 
Example 13
Source File: GetDeploymentProcessDiagramCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public InputStream execute(CommandContext commandContext) {
  ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
  String deploymentId = processDefinition.getDeploymentId();
  String resourceName = processDefinition.getDiagramResourceName();
  if (resourceName == null) {
    log.info("Resource name is null! No process diagram stream exists.");
    return null;
  } else {
    InputStream processDiagramStream = new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);
    return processDiagramStream;
  }
}
 
Example 14
Source File: BusinessRuleTaskActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) {
  ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(execution.getProcessDefinitionId());
  String deploymentId = processDefinition.getDeploymentId();

  KnowledgeBase knowledgeBase = RulesHelper.findKnowledgeBaseByDeploymentId(deploymentId);
  StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();

  if (variablesInputExpressions != null) {
    Iterator<Expression> itVariable = variablesInputExpressions.iterator();
    while (itVariable.hasNext()) {
      Expression variable = itVariable.next();
      ksession.insert(variable.getValue(execution));
    }
  }

  if (!rulesExpressions.isEmpty()) {
    RulesAgendaFilter filter = new RulesAgendaFilter();
    Iterator<Expression> itRuleNames = rulesExpressions.iterator();
    while (itRuleNames.hasNext()) {
      Expression ruleName = itRuleNames.next();
      filter.addSuffic(ruleName.getValue(execution).toString());
    }
    filter.setAccept(!exclude);
    ksession.fireAllRules(filter);

  } else {
    ksession.fireAllRules();
  }

  Collection<Object> ruleOutputObjects = ksession.getObjects();
  if (ruleOutputObjects != null && !ruleOutputObjects.isEmpty()) {
    Collection<Object> outputVariables = new ArrayList<Object>();
    for (Object object : ruleOutputObjects) {
      outputVariables.add(object);
    }
    execution.setVariable(resultVariable, outputVariables);
  }
  ksession.dispose();
  leave(execution);
}
 
Example 15
Source File: ActivitiTaskFormService.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public FormDefinition getTaskForm(String taskId) {
  HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(SecurityUtils.getCurrentUserObject(), taskId);
  
  Map<String, Object> variables = new HashMap<String, Object>();
  if (task.getProcessInstanceId() != null) {
    List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
        .processInstanceId(task.getProcessInstanceId())
        .list();
    
    for (HistoricVariableInstance historicVariableInstance : variableInstances) {
      variables.put(historicVariableInstance.getVariableName(), historicVariableInstance.getValue());
    }
  }
  
  String parentDeploymentId = null;
  if (StringUtils.isNotEmpty(task.getProcessDefinitionId())) {
    try {
      ProcessDefinition processDefinition = repositoryService.getProcessDefinition(task.getProcessDefinitionId());
      parentDeploymentId = processDefinition.getDeploymentId();
      
    } catch (ActivitiException e) {
      logger.error("Error getting process definition " + task.getProcessDefinitionId(), e);
    }
  }
  
  FormDefinition formDefinition = null;
  if (task.getEndTime() != null) {
    formDefinition = formService.getCompletedTaskFormDefinitionByKeyAndParentDeploymentId(task.getFormKey(), parentDeploymentId, 
        taskId, task.getProcessInstanceId(), variables, task.getTenantId());
    
  } else {
    formDefinition = formService.getTaskFormDefinitionByKeyAndParentDeploymentId(task.getFormKey(), parentDeploymentId, 
        task.getProcessInstanceId(), variables, task.getTenantId());
  }

  // If form does not exists, we don't want to leak out this info to just anyone
  if (formDefinition == null) {
    throw new NotFoundException("Form definition for task " + task.getTaskDefinitionKey() + " cannot be found for form key " + task.getFormKey());
  }

  return formDefinition;
}