Java Code Examples for org.activiti.engine.runtime.Execution#getProcessInstanceId()

The following examples show how to use org.activiti.engine.runtime.Execution#getProcessInstanceId() . 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: RestResponseFactory.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public ExecutionResponse createExecutionResponse(Execution execution, RestUrlBuilder urlBuilder) {
  ExecutionResponse result = new ExecutionResponse();
  result.setActivityId(execution.getActivityId());
  result.setId(execution.getId());
  result.setUrl(urlBuilder.buildUrl(RestUrls.URL_EXECUTION, execution.getId()));
  result.setSuspended(execution.isSuspended());
  result.setTenantId(execution.getTenantId());

  result.setParentId(execution.getParentId());
  if (execution.getParentId() != null) {
    result.setParentUrl(urlBuilder.buildUrl(RestUrls.URL_EXECUTION, execution.getParentId()));
  }
  
  result.setSuperExecutionId(execution.getSuperExecutionId());
  if (execution.getSuperExecutionId() != null) {
    result.setSuperExecutionUrl(urlBuilder.buildUrl(RestUrls.URL_EXECUTION, execution.getSuperExecutionId()));
  }

  result.setProcessInstanceId(execution.getProcessInstanceId());
  if (execution.getProcessInstanceId() != null) {
    result.setProcessInstanceUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE, execution.getProcessInstanceId()));
  }
  return result;
}
 
Example 2
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 读取历史数据
 *
 * @return
 */
@RequestMapping(value = "trace/view/{executionId}")
public ModelAndView historyDatas(@PathVariable("executionId") String executionId) {
    ModelAndView mav = new ModelAndView("chapter13/trace-process");

    // 查询Execution对象
    Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();

    // 查询所有的历史活动记录
    String processInstanceId = execution.getProcessInstanceId();
    List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();

    // 查询历史流程实例
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

    // 查询流程有关的变量
    List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
            .processInstanceId(processInstanceId).list();

    List<HistoricDetail> formProperties = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).formProperties().list();

    // 查询流程定义对象
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult();

    // 查询运行时流程实例
    ProcessInstance parentProcessInstance = runtimeService.createProcessInstanceQuery()
            .subProcessInstanceId(execution.getProcessInstanceId()).singleResult();

    mav.addObject("parentProcessInstance", parentProcessInstance);
    mav.addObject("historicProcessInstance", historicProcessInstance);
    mav.addObject("variableInstances", variableInstances);
    mav.addObject("activities", activityInstances);
    mav.addObject("formProperties", formProperties);
    mav.addObject("processDefinition", processDefinition);
    mav.addObject("executionId", executionId);

    return mav;
}
 
Example 3
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 读取历史数据
 *
 * @return
 */
@RequestMapping(value = "trace/view/{executionId}")
public ModelAndView historyDatas(@PathVariable("executionId") String executionId) {
    ModelAndView mav = new ModelAndView("chapter13/trace-process");

    // 查询Execution对象
    Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();

    // 查询所有的历史活动记录
    String processInstanceId = execution.getProcessInstanceId();
    List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();

    // 查询历史流程实例
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

    // 查询流程有关的变量
    List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
            .processInstanceId(processInstanceId).list();

    List<HistoricDetail> formProperties = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).formProperties().list();

    // 查询流程定义对象
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult();

    // 查询运行时流程实例
    ProcessInstance parentProcessInstance = runtimeService.createProcessInstanceQuery()
            .subProcessInstanceId(execution.getProcessInstanceId()).singleResult();

    mav.addObject("parentProcessInstance", parentProcessInstance);
    mav.addObject("historicProcessInstance", historicProcessInstance);
    mav.addObject("variableInstances", variableInstances);
    mav.addObject("activities", activityInstances);
    mav.addObject("formProperties", formProperties);
    mav.addObject("processDefinition", processDefinition);
    mav.addObject("executionId", executionId);

    return mav;
}
 
Example 4
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 读取历史数据
 *
 * @return
 */
@RequestMapping(value = "trace/view/{executionId}")
public ModelAndView historyDatas(@PathVariable("executionId") String executionId) {
    ModelAndView mav = new ModelAndView("chapter13/trace-process");

    // 查询Execution对象
    Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();

    // 查询所有的历史活动记录
    String processInstanceId = execution.getProcessInstanceId();
    List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();

    // 查询历史流程实例
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

    // 查询流程有关的变量
    List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
            .processInstanceId(processInstanceId).list();

    List<HistoricDetail> formProperties = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).formProperties().list();

    // 查询流程定义对象
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult();

    // 查询运行时流程实例
    ProcessInstance parentProcessInstance = runtimeService.createProcessInstanceQuery()
            .subProcessInstanceId(execution.getProcessInstanceId()).singleResult();

    mav.addObject("parentProcessInstance", parentProcessInstance);
    mav.addObject("historicProcessInstance", historicProcessInstance);
    mav.addObject("variableInstances", variableInstances);
    mav.addObject("activities", activityInstances);
    mav.addObject("formProperties", formProperties);
    mav.addObject("processDefinition", processDefinition);
    mav.addObject("executionId", executionId);

    return mav;
}
 
Example 5
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 读取历史数据
 *
 * @return
 */
@RequestMapping(value = "trace/view/{executionId}")
public ModelAndView historyDatas(@PathVariable("executionId") String executionId) {
    ModelAndView mav = new ModelAndView("chapter13/trace-process");

    // 查询Execution对象
    Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();

    // 查询所有的历史活动记录
    String processInstanceId = execution.getProcessInstanceId();
    List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();

    // 查询历史流程实例
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

    // 查询流程有关的变量
    List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
            .processInstanceId(processInstanceId).list();

    List<HistoricDetail> formProperties = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).formProperties().list();

    // 查询流程定义对象
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult();

    // 查询运行时流程实例
    ProcessInstance parentProcessInstance = runtimeService.createProcessInstanceQuery()
            .subProcessInstanceId(execution.getProcessInstanceId()).singleResult();

    mav.addObject("parentProcessInstance", parentProcessInstance);
    mav.addObject("historicProcessInstance", historicProcessInstance);
    mav.addObject("variableInstances", variableInstances);
    mav.addObject("activities", activityInstances);
    mav.addObject("formProperties", formProperties);
    mav.addObject("processDefinition", processDefinition);
    mav.addObject("executionId", executionId);

    return mav;
}
 
Example 6
Source File: TraceProcessController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 读取历史数据
 *
 * @return
 */
@RequestMapping(value = "trace/view/{executionId}")
public ModelAndView historyDatas(@PathVariable("executionId") String executionId) {
    ModelAndView mav = new ModelAndView("chapter13/trace-process");

    // 查询Execution对象
    Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();

    // 查询所有的历史活动记录
    String processInstanceId = execution.getProcessInstanceId();
    List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();

    // 查询历史流程实例
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();

    // 查询流程有关的变量
    List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
            .processInstanceId(processInstanceId).list();

    List<HistoricDetail> formProperties = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).formProperties().list();

    // 查询流程定义对象
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult();

    // 查询运行时流程实例
    ProcessInstance parentProcessInstance = runtimeService.createProcessInstanceQuery()
            .subProcessInstanceId(execution.getProcessInstanceId()).singleResult();

    mav.addObject("parentProcessInstance", parentProcessInstance);
    mav.addObject("historicProcessInstance", historicProcessInstance);
    mav.addObject("variableInstances", variableInstances);
    mav.addObject("activities", activityInstances);
    mav.addObject("formProperties", formProperties);
    mav.addObject("processDefinition", processDefinition);
    mav.addObject("executionId", executionId);

    return mav;
}
 
Example 7
Source File: DocumentWorkflow.java    From maven-framework-project with MIT License 5 votes vote down vote up
public void publish(Execution execution) {
    String pId = execution.getProcessInstanceId();
    log.debug("doc being published - procId={}", pId);
    ProcessInstance pi = runtimeService.createProcessInstanceQuery().
            processInstanceId(execution.getProcessInstanceId()).singleResult();
    String docId = pi.getBusinessKey();
    Document doc = this.docSrvc.getDocument(docId);
    doc.setState(Document.STATE_PUBLISHED);
    String message = String.format("Document entitled '%s' has been successfully published ", doc.getTitle());
    this.alertService.sendAlert(doc.getAuthor(), Alert.SUCCESS, message);
    this.docSrvc.updateDocument(doc);
}
 
Example 8
Source File: DocumentWorkflow.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * Task listener that runs when an approveDoc task is created. Sets the candidate group to the document's group.
 *
 * @param execution
 * @param task
 */
public void setAssignee(Execution execution, DelegateTask task) {
    String pId = execution.getProcessInstanceId();
    log.debug("doc being published - procId={}", pId);
    ProcessInstance pi = runtimeService.createProcessInstanceQuery().
            processInstanceId(execution.getProcessInstanceId()).singleResult();
    String docId = pi.getBusinessKey();
    Document doc = this.docSrvc.getDocument(docId);
    taskService.addCandidateGroup(task.getId(), doc.getGroupId());
}
 
Example 9
Source File: BusinessProcess.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the id of the currently associated process instance or 'null'
 */
public String getProcessInstanceId() {
  Execution execution = associationManager.getExecution();
  return execution != null ? execution.getProcessInstanceId() : null;
}
 
Example 10
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
* {@inheritDoc}
*/
public List<WorkflowTask> getTasksForWorkflowPath(String pathId)
{
    try
    {
        // Extract the Activiti ID from the path
        String executionId = createLocalId(pathId);
        if (executionId == null)
        {
            throw new WorkflowException(messageService.getMessage(ERR_GET_WORKFLOW_TOKEN_INVALID, pathId));
        }

        // Check if the execution exists
        Execution execution = runtimeService.createExecutionQuery().executionId(executionId).singleResult();
        if (execution == null)
        {
            throw new WorkflowException(messageService.getMessage(ERR_GET_WORKFLOW_TOKEN_NULL, pathId));
        }

        String processInstanceId = execution.getProcessInstanceId();
        ArrayList<WorkflowTask> resultList = new ArrayList<WorkflowTask>();
        if(!activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && false == typeConverter.isCorrectTenantRuntime(processInstanceId))
        {
            return resultList; //Wrong tenant
        }
        // Check if workflow's start task has been completed. If not, return
        // the virtual task
        // Otherwise, just return the runtime Activiti tasks
        if (typeConverter.isStartTaskActive(processInstanceId))
        {
            resultList.add(typeConverter.getVirtualStartTask(processInstanceId, true));
        }
        else
        {
            List<Task> tasks = taskService.createTaskQuery().executionId(executionId).list();
            for (Task task : tasks)
            {
                resultList.add(typeConverter.convert(task));
            }
        }
        return resultList;
    }
    catch (ActivitiException ae)
    {
    	
        String msg = messageService.getMessage(ERR_GET_TASKS_FOR_PATH, pathId);
        if(logger.isDebugEnabled())
        {
        	logger.debug(msg, ae);
        }
        throw new WorkflowException(msg, ae);
    }
}
 
Example 11
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public WorkflowPath convert(Execution execution)
{
    String instanceId = execution.getProcessInstanceId();
    ProcessInstance instance = activitiUtil.getProcessInstance(instanceId);
    return convert(execution, instance);
}