Java Code Examples for org.activiti.engine.impl.persistence.entity.ExecutionEntity#getActivityId()

The following examples show how to use org.activiti.engine.impl.persistence.entity.ExecutionEntity#getActivityId() . 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: SetProcessDefinitionVersionCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinition newProcessDefinition) {
  // check that the new process definition version contains the current activity
  org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(newProcessDefinition.getId());
  if (execution.getActivityId() != null && process.getFlowElement(execution.getActivityId(), true) == null) { 
    throw new ActivitiException("The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '"
        + execution.getActivityId() + "') " + "of the process instance " + "(id = '" + processInstanceId + "').");
  }

  // switch the process instance to the new process definition version
  execution.setProcessDefinitionId(newProcessDefinition.getId());
  execution.setProcessDefinitionName(newProcessDefinition.getName());
  execution.setProcessDefinitionKey(newProcessDefinition.getKey());

  // and change possible existing tasks (as the process definition id is stored there too)
  List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByExecutionId(execution.getId());
  for (TaskEntity taskEntity : tasks) {
    taskEntity.setProcessDefinitionId(newProcessDefinition.getId());
    commandContext.getHistoryManager().recordTaskProcessDefinitionChange(taskEntity.getId(), newProcessDefinition.getId());
  }
}
 
Example 2
Source File: InactiveExecutionsInActivityAndProcInstMatcher.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRetained(ExecutionEntity executionEntity, Object parameter) {
  Map<String, Object> paramMap = (Map<String, Object>) parameter;
  String activityId = (String) paramMap.get("activityId");
  String processInstanceId = (String) paramMap.get("processInstanceId");
  
  return executionEntity.getProcessInstanceId() != null 
      && executionEntity.getProcessInstanceId().equals(processInstanceId) 
      && !executionEntity.isActive() 
      && executionEntity.getActivityId() != null 
      && executionEntity.getActivityId().equals(activityId);
}
 
Example 3
Source File: ExecutionsByParentExecutionIdAndActivityIdEntityMatcher.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRetained(ExecutionEntity executionEntity, Object parameter) {
  Map<String, Object> paramMap = (Map<String, Object>) parameter;
  String parentExecutionId = (String) paramMap.get("parentExecutionId");
  Collection<String> activityIds = (Collection<String>) paramMap.get("activityIds");
  
  return executionEntity.getParentId() != null && executionEntity.getParentId().equals(parentExecutionId)
      && executionEntity.getActivityId() != null && activityIds.contains(executionEntity.getActivityId());
}
 
Example 4
Source File: FindActiveActivityIdsCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void collectActiveActivityIds(ExecutionEntity executionEntity, List<String> activeActivityIds) {
  if (executionEntity.isActive() && executionEntity.getActivityId() != null) {
    activeActivityIds.add(executionEntity.getActivityId());
  }
  
  for (ExecutionEntity childExecution : executionEntity.getExecutions()) {
    collectActiveActivityIds(childExecution, activeActivityIds);
  }
}
 
Example 5
Source File: ExecutionQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked" })
public List<Execution> executeList(CommandContext commandContext, Page page) {
  checkQueryOk();
  ensureVariablesInitialized();
  List<?> executions = commandContext.getExecutionEntityManager().findExecutionsByQueryCriteria(this, page);
  
  if (Context.getProcessEngineConfiguration().getPerformanceSettings().isEnableLocalization()) {
    for (ExecutionEntity execution : (List<ExecutionEntity>) executions) {
      String activityId = null;
      if (execution.getId().equals(execution.getProcessInstanceId())) {
        if (execution.getProcessDefinitionId() != null) {
          ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration()
              .getDeploymentManager()
              .findDeployedProcessDefinitionById(execution.getProcessDefinitionId());
          activityId = processDefinition.getKey();
        }
        
      } else {
        activityId = execution.getActivityId();
      }

      if (activityId != null) {
        localize(execution, activityId);
      }
    }
  }

  return (List<Execution>) executions;
}
 
Example 6
Source File: DefaultHistoryManager.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void recordActivityStart(ExecutionEntity executionEntity) {
  if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
    if (executionEntity.getActivityId() != null && executionEntity.getCurrentFlowElement() != null) {
      
      HistoricActivityInstanceEntity historicActivityInstanceEntity = null;
      
      // Historic activity instance could have been created (but only in cache, never persisted)
      // for example when submitting form properties
      HistoricActivityInstanceEntity historicActivityInstanceEntityFromCache = 
          getHistoricActivityInstanceFromCache(executionEntity.getId(), executionEntity.getActivityId(), true);
      if (historicActivityInstanceEntityFromCache != null) {
        historicActivityInstanceEntity = historicActivityInstanceEntityFromCache;
      } else {
        historicActivityInstanceEntity = createHistoricActivityInstanceEntity(executionEntity);
      }
      
      // Fire event
      ActivitiEventDispatcher activitiEventDispatcher = getEventDispatcher();
      if (activitiEventDispatcher != null && activitiEventDispatcher.isEnabled()) {
        activitiEventDispatcher.dispatchEvent(
            ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstanceEntity));
      }
      
    }
  }
}
 
Example 7
Source File: ExecutionQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked"})
public List<Execution> executeList(CommandContext commandContext, Page page) {
    checkQueryOk();
    ensureVariablesInitialized();
    List<?> executions = commandContext.getExecutionEntityManager().findExecutionsByQueryCriteria(this, page);

    for (ExecutionEntity execution : (List<ExecutionEntity>) executions) {
        String activityId = null;
        if (execution.getId().equals(execution.getProcessInstanceId())) {
            if (execution.getProcessDefinitionId() != null) {
                ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration()
                        .getDeploymentManager()
                        .findDeployedProcessDefinitionById(execution.getProcessDefinitionId());
                activityId = processDefinition.getKey();
            }

        } else {
            activityId = execution.getActivityId();
        }

        if (activityId != null) {
            localize(execution, activityId);
        }
    }

    return (List<Execution>) executions;
}
 
Example 8
Source File: WorkFlowController.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * 输出跟踪流程信息
 * @param processInstanceId
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/process/{executionId}/trace/{processInstanceId}",produces={MediaType.APPLICATION_JSON_VALUE})
public @ResponseBody Map<String,Object> traceProcess(@PathVariable("executionId") String executionId,@PathVariable("processInstanceId") String processInstanceId) throws Exception {
	
	//根据executionId查询当前执行的节点
	ExecutionEntity execution=(ExecutionEntity) runtimeService.createExecutionQuery().processInstanceId(processInstanceId).executionId(executionId).singleResult();
	
	//获取当前节点的activityId
	String activityId=execution.getActivityId();
	
	ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
	
	ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
	
	List<ActivityImpl> activities = processDefinitionEntity.getActivities();
	
	Map<String,Object> activityImageInfo=new HashMap<String,Object>();
	
	for (ActivityImpl activityImpl : activities) {
		String id=activityImpl.getId();
		//判断是否是当前节点
		if(id.equals(activityId)){
			activityImageInfo.put("x", activityImpl.getX());
			activityImageInfo.put("y", activityImpl.getY());
			activityImageInfo.put("width", activityImpl.getWidth());
			activityImageInfo.put("height", activityImpl.getHeight());
			break;//跳出循环
		}
	}
	return activityImageInfo;
}
 
Example 9
Source File: InactiveExecutionsInActivityMatcher.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRetained(ExecutionEntity entity, Object parameter) {
  Map<String, Object> paramMap = (Map<String, Object>) parameter;
  String activityId = (String) paramMap.get("activityId");
  return !entity.isActive() && entity.getActivityId() != null && entity.getActivityId().equals(activityId);
}