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

The following examples show how to use org.activiti.engine.impl.persistence.entity.ExecutionEntity#setConcurrent() . 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: ScopeUtil.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * creates an event scope for the given execution:
 * 
 * create a new event scope execution under the parent of the given execution and move all event subscriptions to that execution.
 * 
 * this allows us to "remember" the event subscriptions after finishing a scope
 */
public static void createEventScopeExecution(ExecutionEntity execution) {

    ExecutionEntity eventScope = ScopeUtil.findScopeExecutionForScope(execution, execution.getActivity().getParent());

    List<CompensateEventSubscriptionEntity> eventSubscriptions = execution.getCompensateEventSubscriptions();

    if (!eventSubscriptions.isEmpty()) {

        ExecutionEntity eventScopeExecution = eventScope.createExecution();
        eventScopeExecution.setActive(false);
        eventScopeExecution.setConcurrent(false);
        eventScopeExecution.setEventScope(true);
        eventScopeExecution.setActivity(execution.getActivity());

        execution.setConcurrent(false);

        // copy local variables to eventScopeExecution by value. This way,
        // the eventScopeExecution references a 'snapshot' of the local variables
        Map<String, Object> variables = execution.getVariablesLocal();
        for (Entry<String, Object> variable : variables.entrySet()) {
            eventScopeExecution.setVariableLocal(variable.getKey(), variable.getValue());
        }

        // set event subscriptions to the event scope execution:
        for (CompensateEventSubscriptionEntity eventSubscriptionEntity : eventSubscriptions) {
            eventSubscriptionEntity = eventSubscriptionEntity.moveUnder(eventScopeExecution);
        }

        CompensateEventSubscriptionEntity eventSubscription = CompensateEventSubscriptionEntity.createAndInsert(eventScope);
        eventSubscription.setActivity(execution.getActivity());
        eventSubscription.setConfiguration(eventScopeExecution.getId());

    }
}
 
Example 2
Source File: CounterSignCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * <li>添加一条并行实例
 */
private void addParallelInstance() {
    ExecutionEntity parentExecutionEntity = commandContext
            .getExecutionEntityManager()
            .findExecutionById(processInstanceId).findExecution(activityId);
    ActivityImpl activity = getActivity();
    ExecutionEntity execution = parentExecutionEntity.createExecution();
    execution.setActive(true);
    execution.setConcurrent(true);
    execution.setScope(false);

    if (getActivity().getProperty("type").equals("subProcess")) {
        ExecutionEntity extraScopedExecution = execution.createExecution();
        extraScopedExecution.setActive(true);
        extraScopedExecution.setConcurrent(false);
        extraScopedExecution.setScope(true);
        execution = extraScopedExecution;
    }

    setLoopVariable(parentExecutionEntity, "nrOfInstances",
            (Integer) parentExecutionEntity
                    .getVariableLocal("nrOfInstances") + 1);
    setLoopVariable(parentExecutionEntity, "nrOfActiveInstances",
            (Integer) parentExecutionEntity
                    .getVariableLocal("nrOfActiveInstances") + 1);
    setLoopVariable(execution, "loopCounter", parentExecutionEntity
            .getExecutions().size() + 1);
    setLoopVariable(execution, collectionElementVariableName, assignee);
    execution.executeActivity(activity);
}
 
Example 3
Source File: BoundaryEventActivityBehavior.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void execute(DelegateExecution execution) {
    ExecutionEntity executionEntity = (ExecutionEntity) execution;
    ActivityImpl boundaryActivity = executionEntity.getProcessDefinition().findActivity(activityId);
    ActivityImpl interruptedActivity = executionEntity.getActivity();

    List<PvmTransition> outgoingTransitions = boundaryActivity.getOutgoingTransitions();
    List<ExecutionEntity> interruptedExecutions = null;

    if (interrupting) {

        // Call activity
        if (executionEntity.getSubProcessInstance() != null) {
            executionEntity.getSubProcessInstance().deleteCascade(executionEntity.getDeleteReason());
        } else {
            Context.getCommandContext().getHistoryManager().recordActivityEnd(executionEntity);
        }

        executionEntity.setActivity(boundaryActivity);

        interruptedExecutions = new ArrayList<>(executionEntity.getExecutions());
        for (ExecutionEntity interruptedExecution : interruptedExecutions) {
            interruptedExecution.deleteCascade("interrupting boundary event '" + executionEntity.getActivity().getId() + "' fired");
        }

        executionEntity.takeAll(outgoingTransitions, (List) interruptedExecutions);
    } else {
        // non interrupting event, introduced with BPMN 2.0, we need to create a new execution in this case

        // create a new execution and move it out from the timer activity
        ExecutionEntity concurrentRoot = executionEntity.getParent().isConcurrent() ? executionEntity.getParent() : executionEntity;
        ExecutionEntity outgoingExecution = concurrentRoot.createExecution();

        outgoingExecution.setActive(true);
        outgoingExecution.setScope(false);
        outgoingExecution.setConcurrent(true);

        outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
        outgoingExecution.remove();
        // now we have to move the execution back to the real activity
        // since the execution stays there (non interrupting) and it was
        // set to the boundary event before
        executionEntity.setActivity(interruptedActivity);
    }
}