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

The following examples show how to use org.flowable.engine.impl.persistence.entity.ExecutionEntity#isActive() . 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: DestroyScopeOperation.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {

    // Find the actual scope that needs to be destroyed.
    // This could be the incoming execution, or the first parent execution where isScope = true

    // Find parent scope execution
    ExecutionEntity scopeExecution = execution.isScope() ? execution : findFirstParentScopeExecution(execution);

    if (scopeExecution == null) {
        throw new FlowableException("Programmatic error: no parent scope execution found for boundary event");
    }

    ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);

    // Delete all child executions
    executionEntityManager.deleteChildExecutions(scopeExecution, execution.getDeleteReason(), true);
    executionEntityManager.deleteExecutionAndRelatedData(scopeExecution, execution.getDeleteReason(), false, true, null);

    if (scopeExecution.isActive()) {
        CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityEnd(scopeExecution, scopeExecution.getDeleteReason());
    }
    executionEntityManager.delete(scopeExecution);
}
 
Example 2
Source File: EndExecutionOperation.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected int getNumberOfActiveChildExecutionsForProcessInstance(ExecutionEntityManager executionEntityManager, String processInstanceId) {
    Collection<ExecutionEntity> executions = executionEntityManager.findChildExecutionsByProcessInstanceId(processInstanceId);
    int activeExecutions = 0;
    for (ExecutionEntity execution : executions) {
        if (execution.isActive() && !processInstanceId.equals(execution.getId())) {
            activeExecutions++;
        }
    }
    return activeExecutions;
}
 
Example 3
Source File: InactiveExecutionsInActivityAndProcInstMatcher.java    From flowable-engine 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 4
Source File: InactiveExecutionsByProcInstMatcher.java    From flowable-engine 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 processInstanceId = (String) paramMap.get("processInstanceId");

    return executionEntity.getProcessInstanceId() != null
            && executionEntity.getProcessInstanceId().equals(processInstanceId)
            && !executionEntity.isActive();
}
 
Example 5
Source File: FindActiveActivityIdsCmd.java    From flowable-engine 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 6
Source File: InactiveExecutionsInActivityMatcher.java    From flowable-engine 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);
}
 
Example 7
Source File: InclusiveGatewayActivityBehavior.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected void executeInclusiveGatewayLogic(ExecutionEntity execution, boolean inactiveCheck) {
    CommandContext commandContext = Context.getCommandContext();
    ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);

    lockFirstParentScope(execution);

    Collection<ExecutionEntity> allExecutions = executionEntityManager.findChildExecutionsByProcessInstanceId(execution.getProcessInstanceId());
    Iterator<ExecutionEntity> executionIterator = allExecutions.iterator();
    boolean oneExecutionCanReachGatewayInstance = false;
    while (!oneExecutionCanReachGatewayInstance && executionIterator.hasNext()) {
        ExecutionEntity executionEntity = executionIterator.next();
        if (!executionEntity.getActivityId().equals(execution.getCurrentActivityId())) {
            if (ExecutionGraphUtil.isReachable(execution.getProcessDefinitionId(), executionEntity.getActivityId(), execution.getCurrentActivityId())) {
                //Now check if they are in the same "execution path"
                if (executionEntity.getParentId().equals(execution.getParentId())) {
                    oneExecutionCanReachGatewayInstance = true;
                    break;
                }
            }
        } else if (executionEntity.getId().equals(execution.getId()) && executionEntity.isActive()) {
            // Special case: the execution has reached the inc gw, but the operation hasn't been executed yet for that execution
            oneExecutionCanReachGatewayInstance = true;
            break;
        }
    }

    // Is needed to set the endTime for all historic activity joins
    if (!inactiveCheck || !oneExecutionCanReachGatewayInstance) {
        CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityEnd(execution, null);
    }

    // If no execution can reach the gateway, the gateway activates and executes fork behavior
    if (!oneExecutionCanReachGatewayInstance) {

        LOGGER.debug("Inclusive gateway cannot be reached by any execution and is activated");

        // Kill all executions here (except the incoming)
        Collection<ExecutionEntity> executionsInGateway = executionEntityManager
            .findInactiveExecutionsByActivityIdAndProcessInstanceId(execution.getCurrentActivityId(), execution.getProcessInstanceId());
        for (ExecutionEntity executionEntityInGateway : executionsInGateway) {
            if (!executionEntityInGateway.getId().equals(execution.getId()) && executionEntityInGateway.getParentId().equals(execution.getParentId())) {

                if (!Objects.equals(executionEntityInGateway.getActivityId(), execution.getActivityId())) {
                    CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityEnd(executionEntityInGateway, null);
                }

                executionEntityManager.deleteExecutionAndRelatedData(executionEntityInGateway, null, false);
            }
        }

        // Leave
        CommandContextUtil.getAgenda(commandContext).planTakeOutgoingSequenceFlowsOperation(execution, true);
    }
}