Java Code Examples for org.flowable.engine.impl.persistence.entity.ExecutionEntity#getId()

The following examples show how to use org.flowable.engine.impl.persistence.entity.ExecutionEntity#getId() . 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: EndExecutionOperation.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void scheduleAsyncCompleteCallActivity(ExecutionEntity superExecutionEntity, ExecutionEntity childProcessInstanceExecutionEntity) {
    JobService jobService = CommandContextUtil.getJobService(commandContext);
    
    JobEntity job = jobService.createJob();
    
    // Needs to be the parent process instance, as the parent needs to be locked to avoid concurrency when multiple call activities are ended
    job.setExecutionId(superExecutionEntity.getId()); 
    
    // Child execution of subprocess is passed as configuration
    job.setJobHandlerConfiguration(childProcessInstanceExecutionEntity.getId());
    
    String processInstanceId = superExecutionEntity.getProcessInstanceId() != null ? superExecutionEntity.getProcessInstanceId() : superExecutionEntity.getId();
    job.setProcessInstanceId(processInstanceId);
    job.setProcessDefinitionId(childProcessInstanceExecutionEntity.getProcessDefinitionId());
    job.setElementId(superExecutionEntity.getCurrentFlowElement().getId());
    job.setElementName(superExecutionEntity.getCurrentFlowElement().getName());
    job.setTenantId(childProcessInstanceExecutionEntity.getTenantId());
    job.setJobHandlerType(AsyncCompleteCallActivityJobHandler.TYPE);
    
    superExecutionEntity.getJobs().add(job);
    
    jobService.createAsyncJob(job, true); // Always exclusive to avoid concurrency problems
    jobService.scheduleAsyncJob(job);
}
 
Example 2
Source File: LogMDC.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public static void putMDCExecution(ExecutionEntity e) {
    if (e.getId() != null)
        MDC.put(LOG_MDC_EXECUTION_ID, e.getId());
    if (e.getProcessDefinitionId() != null)
        MDC.put(LOG_MDC_PROCESSDEFINITION_ID, e.getProcessDefinitionId());
    if (e.getProcessInstanceId() != null)
        MDC.put(LOG_MDC_PROCESSINSTANCE_ID, e.getProcessInstanceId());
    if (e.getProcessInstanceBusinessKey() != null)
        MDC.put(LOG_MDC_BUSINESS_KEY, e.getProcessInstanceBusinessKey());

}
 
Example 3
Source File: FlowableProcessTerminatedEventImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public FlowableProcessTerminatedEventImpl(ExecutionEntity execution, Object cause) {
    super(execution, FlowableEngineEventType.PROCESS_COMPLETED_WITH_TERMINATE_END_EVENT);
    if (!execution.isProcessInstanceType()) {
        throw new FlowableException("Execution '"+ execution +"' is not a processInstance");
    }
    
    this.subScopeId = execution.getId();
    this.scopeId = execution.getProcessInstanceId();
    this.scopeDefinitionId = execution.getProcessDefinitionId();
    this.scopeType = ScopeTypes.BPMN;
    this.cause = cause;
}
 
Example 4
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static void addInvolvedExecution(CommandContext commandContext, ExecutionEntity executionEntity) {
    if (executionEntity.getId() != null) {
        Map<String, ExecutionEntity> involvedExecutions = null;
        Object obj = commandContext.getAttribute(ATTRIBUTE_INVOLVED_EXECUTIONS);
        if (obj != null) {
            involvedExecutions = (Map<String, ExecutionEntity>) obj;
        } else {
            involvedExecutions = new HashMap<>();
            commandContext.addAttribute(ATTRIBUTE_INVOLVED_EXECUTIONS, involvedExecutions);
        }
        involvedExecutions.put(executionEntity.getId(), executionEntity);
    }
}
 
Example 5
Source File: AbstractHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected HistoricActivityInstanceEntity findHistoricActivityInstance(ExecutionEntity execution, String activityId, boolean endTimeMustBeNull) {

        // No use looking for the HistoricActivityInstance when no activityId is provided.
        if (activityId == null) {
            return null;
        }

        String executionId = execution.getId();

        // Check the cache
        HistoricActivityInstanceEntity historicActivityInstanceEntityFromCache = getHistoricActivityInstanceFromCache(executionId, activityId, endTimeMustBeNull);
        if (historicActivityInstanceEntityFromCache != null) {
            return historicActivityInstanceEntityFromCache;
        }

        // If the execution was freshly created, there is no need to check the database,
        // there can never be an entry for a historic activity instance with this execution id.
        if (!execution.isInserted() && !execution.isProcessInstanceType()) {

            // Check the database
            List<HistoricActivityInstanceEntity> historicActivityInstances = getHistoricActivityInstanceEntityManager()
                            .findUnfinishedHistoricActivityInstancesByExecutionAndActivityId(executionId, activityId);

            if (historicActivityInstances.size() > 0 && (!endTimeMustBeNull || historicActivityInstances.get(0).getEndTime() == null)) {
                return historicActivityInstances.get(0);
            }

        }

        return null;
    }