org.activiti.engine.impl.pvm.delegate.ActivityExecution Java Examples

The following examples show how to use org.activiti.engine.impl.pvm.delegate.ActivityExecution. 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: EventSubProcessStartEventActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    InterpretableExecution interpretableExecution = (InterpretableExecution) execution;
    ActivityImpl activity = interpretableExecution.getProcessDefinition().findActivity(activityId);

    ActivityExecution outgoingExecution = activityExecution;

    if (isInterrupting) {
        activityExecution.destroyScope("Event subprocess triggered using activity " + activityId);
    } else {
        outgoingExecution = activityExecution.createExecution();
        outgoingExecution.setActive(true);
        outgoingExecution.setScope(false);
        outgoingExecution.setConcurrent(true);
    }

    // set the outgoing execution to this activity
    ((InterpretableExecution) outgoingExecution).setActivity(activity);

    // continue execution
    outgoingExecution.takeAll(activity.getOutgoingTransitions(), Collections.EMPTY_LIST);
}
 
Example #2
Source File: TerminateEndEventActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private void dispatchExecutionCancelled(ActivityExecution execution, ActivityImpl causeActivity) {
    // subprocesses
    for (ActivityExecution subExecution : execution.getExecutions()) {
        dispatchExecutionCancelled(subExecution, causeActivity);
    }

    // call activities
    ExecutionEntity subProcessInstance = Context.getCommandContext().getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId());
    if (subProcessInstance != null) {
        dispatchExecutionCancelled(subProcessInstance, causeActivity);
    }

    // activity with message/signal boundary events
    ActivityImpl activity = (ActivityImpl) execution.getActivity();
    if (activity != null && activity.getActivityBehavior() != null && activity != causeActivity) {
        dispatchActivityCancelled(execution, activity, causeActivity);
    }
}
 
Example #3
Source File: ParallelGatewayActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    // Join
    PvmActivity activity = activityExecution.getActivity();
    List<PvmTransition> outgoingTransitions = activityExecution.getActivity().getOutgoingTransitions();
    execution.inactivate();
    lockConcurrentRoot(activityExecution);

    List<ActivityExecution> joinedExecutions = activityExecution.findInactiveConcurrentExecutions(activity);
    int nbrOfExecutionsToJoin = activityExecution.getActivity().getIncomingTransitions().size();
    int nbrOfExecutionsJoined = joinedExecutions.size();
    Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) execution);
    if (nbrOfExecutionsJoined == nbrOfExecutionsToJoin) {

        // Fork
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("parallel gateway '{}' activates: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
        }
        activityExecution.takeAll(outgoingTransitions, joinedExecutions);

    } else if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("parallel gateway '{}' does not activate: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
    }
}
 
Example #4
Source File: MultiInstanceActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Since the first loop of the multi instance is not executed as a regular activity, it is needed to call the start listeners yourself.
 */
protected void callCustomActivityStartListeners(ActivityExecution execution) {
    List<ExecutionListener> listeners = activity.getExecutionListeners(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START);

    if (listeners != null) {
        List<ExecutionListener> filteredExecutionListeners = new ArrayList<>(listeners.size());
        // Sad that we have to do this, but it's the only way I could find (which is also safe for backwards compatibility)

        for (ExecutionListener executionListener : listeners) {
            if (!(executionListener instanceof ActivityInstanceStartHandler)) {
                filteredExecutionListeners.add(executionListener);
            }
        }

        CallActivityListenersOperation atomicOperation = new CallActivityListenersOperation(filteredExecutionListeners);
        Context.getCommandContext().performOperation(atomicOperation, (InterpretableExecution) execution);
    }

}
 
Example #5
Source File: SequentialMultiInstanceBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Handles the sequential case of spawning the instances. Will only create one instance, since at most one instance can be active.
 */
@Override
protected void createInstances(ActivityExecution execution) {
    int nrOfInstances = resolveNrOfInstances(execution);
    if (nrOfInstances < 0) {
        throw new ActivitiIllegalArgumentException("Invalid number of instances: must be a non-negative integer value"
                + ", but was " + nrOfInstances);
    }

    setLoopVariable(execution, NUMBER_OF_INSTANCES, nrOfInstances);
    setLoopVariable(execution, NUMBER_OF_COMPLETED_INSTANCES, 0);
    setLoopVariable(execution, getCollectionElementIndexVariable(), 0);
    setLoopVariable(execution, NUMBER_OF_ACTIVE_INSTANCES, 1);
    logLoopDetails(execution, "initialized", 0, 0, 1, nrOfInstances);

    if (nrOfInstances > 0) {
        executeOriginalBehavior(execution, 0);
    }
}
 
Example #6
Source File: MultiInstanceActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected boolean completionConditionSatisfied(ActivityExecution execution) {
    if (completionConditionExpression != null) {
        Object value = completionConditionExpression.getValue(execution);
        if (!(value instanceof Boolean)) {
            throw new ActivitiIllegalArgumentException("completionCondition '"
                    + completionConditionExpression.getExpressionText()
                    + "' does not evaluate to a boolean value");
        }
        Boolean booleanValue = (Boolean) value;
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Completion condition of multi-instance satisfied: {}", booleanValue);
        }
        return booleanValue;
    }
    return false;
}
 
Example #7
Source File: MyUserTaskActivityBehavior.java    From openwebflow with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected TaskAssignmentHandlerChainImpl createHandlerChain()
{
	TaskAssignmentHandlerChainImpl handlerChain = new TaskAssignmentHandlerChainImpl();
	final MyUserTaskActivityBehavior myUserTaskActivityBehavior = this;
	handlerChain.addHandler(new TaskAssignmentHandler()
	{
		@Override
		public void handleAssignment(TaskAssignmentHandlerChain chain, Expression assigneeExpression, Expression ownerExpression, Set<Expression> candidateUserExpressions,
			      Set<Expression> candidateGroupExpressions, TaskEntity task, ActivityExecution execution)
		{
			myUserTaskActivityBehavior.superHandleAssignments(assigneeExpression, ownerExpression, candidateUserExpressions, 
			        candidateGroupExpressions, task, execution);
		}
	});

	handlerChain.addHandlers(_handlers);
	return handlerChain;
}
 
Example #8
Source File: AbstractBpmnActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void signalCompensationDone(ActivityExecution execution, Object signalData) {
    // default behavior is to join compensating executions and propagate the signal if all executions
    // have compensated

    // join compensating executions
    if (execution.getExecutions().isEmpty()) {
        if (execution.getParent() != null) {
            ActivityExecution parent = execution.getParent();
            ((InterpretableExecution) execution).remove();
            ((InterpretableExecution) parent).signal("compensationDone", signalData);
        }
    } else {
        ((ExecutionEntity) execution).forceUpdate();
    }

}
 
Example #9
Source File: EventScopeCreatingSubprocess.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void lastExecutionEnded(ActivityExecution execution) {

    ActivityExecution outgoingExecution = execution.getParent().createExecution();
    outgoingExecution.setConcurrent(false);
    ((InterpretableExecution) outgoingExecution).setActivity((ActivityImpl) execution.getActivity());

    // eventscope execution
    execution.setConcurrent(false);
    execution.setActive(false);
    ((InterpretableExecution) execution).setEventScope(true);

    List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
    if (outgoingTransitions.isEmpty()) {
        outgoingExecution.end();
    } else {
        outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
    }
}
 
Example #10
Source File: TaskDelagationAssignmentHandler.java    From openwebflow with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void handleAssignment(TaskAssignmentHandlerChain chain, Expression assigneeExpression,
		Expression ownerExpression, Set<Expression> candidateUserExpressions,
		Set<Expression> candidateGroupExpressions, TaskEntity task, ActivityExecution execution)
{
	//先执行其它规则
	chain.resume(assigneeExpression, ownerExpression, candidateUserExpressions,
		      candidateGroupExpressions, task, execution);

	overwriteAssignee(task);

	Map<String, Object> userIdMap = new HashMap<String, Object>();
	Map<String, Object> groupIdMap = new HashMap<String, Object>();
	retrieveCandidateUserIdsAndGroupIds(task, userIdMap, groupIdMap);
	Map<String, Object> newUserIdMap = new HashMap<String, Object>();
	Map<String, Object> removeUserIdMap = new HashMap<String, Object>();

	//遍历所有的被代理人
	List<DelegationEntity> entries = _delegationManager.listDelegationEntities();
	overwriteCandicateUserIds(userIdMap, newUserIdMap, removeUserIdMap, entries);
	overwriteCandicateGroupIds(groupIdMap, newUserIdMap, entries);

	addCandidateUsers(task, newUserIdMap.keySet());
	removeCandidateUsers(task, removeUserIdMap.keySet());
}
 
Example #11
Source File: While.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    PvmTransition more = activityExecution.getActivity().findOutgoingTransition("more");
    PvmTransition done = activityExecution.getActivity().findOutgoingTransition("done");

    Integer value = (Integer) execution.getVariable(variableName);

    if (value == null) {
        execution.setVariable(variableName, from);
        activityExecution.take(more);

    } else {
        value = value + 1;

        if (value < to) {
            execution.setVariable(variableName, value);
            activityExecution.take(more);

        } else {
            activityExecution.take(done);
        }
    }
}
 
Example #12
Source File: TerminateEndEventActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void terminateExecution(ActivityExecution execution, ActivityImpl terminateEndEventActivity, ActivityExecution scopeExecution) {
    // send cancelled event
    sendCancelledEvent(execution, terminateEndEventActivity, scopeExecution);

    // destroy the scope
    scopeExecution.destroyScope("terminate end event fired");

    // set the scope execution to the terminate end event and make it end here.
    // (the history should reflect that the execution ended here and we want an 'end time' for the
    // historic activity instance.)
    ((InterpretableExecution) scopeExecution).setActivity(terminateEndEventActivity);
    // end the scope execution
    scopeExecution.end();

    // Scope execution can already have been ended (for example when multiple seq flow arrive in the same terminate end event)
    // in that case, we need to make sure the activity instance is ended
    if (scopeExecution.isEnded()) {
        Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) execution);
    }

}
 
Example #13
Source File: SubProcessActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    PvmActivity activity = activityExecution.getActivity();
    ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);

    if (initialActivity == null) {
        throw new ActivitiException("No initial activity found for subprocess "
                + activityExecution.getActivity().getId());
    }

    // initialize the template-defined data objects as variables
    initializeDataObjects(activityExecution, activity);

    if (initialActivity.getActivityBehavior() != null
            && initialActivity.getActivityBehavior() instanceof NoneStartEventActivityBehavior) { // embedded subprocess: only none start allowed
        ((ExecutionEntity) execution).setActivity(initialActivity);
        Context.getCommandContext().getHistoryManager().recordActivityStart((ExecutionEntity) execution);
    }

    activityExecution.executeActivity(initialActivity);
}
 
Example #14
Source File: ErrorPropagation.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private static String findLocalErrorEventHandler(ActivityExecution execution, String errorCode) {
    PvmScope scope = execution.getActivity();
    while (scope != null) {

        @SuppressWarnings("unchecked")
        List<ErrorEventDefinition> definitions = (List<ErrorEventDefinition>) scope.getProperty(BpmnParse.PROPERTYNAME_ERROR_EVENT_DEFINITIONS);
        if (definitions != null) {
            // definitions are sorted by precedence, ie. event subprocesses first.
            for (ErrorEventDefinition errorEventDefinition : definitions) {
                if (errorEventDefinition.catches(errorCode)) {
                    return scope.findActivity(errorEventDefinition.getHandlerActivityId()).getId();
                }
            }
        }

        // search for error handlers in parent scopes
        if (scope instanceof PvmActivity) {
            scope = ((PvmActivity) scope).getParent();
        } else {
            scope = null;
        }
    }
    return null;
}
 
Example #15
Source File: ErrorPropagation.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public static void propagateError(String errorCode, ActivityExecution execution) {

        while (execution != null) {
            String eventHandlerId = findLocalErrorEventHandler(execution, errorCode);
            if (eventHandlerId != null) {
                executeCatch(eventHandlerId, execution, errorCode);
                break;
            }

            if (execution.isProcessInstanceType()) {
                // dispatch process completed event
                if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
                    Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                            ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.PROCESS_COMPLETED_WITH_ERROR_END_EVENT, execution));
                }
            }
            execution = getSuperExecution(execution);
        }
        if (execution == null) {
            throw new BpmnError(errorCode, "No catching boundary event found for error with errorCode '"
                    + errorCode + "', neither in same process nor in parent process");
        }
    }
 
Example #16
Source File: ClassDelegate.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution execution) {
    Object delegateInstance = instantiateDelegate(className, fieldDeclarations);

    if (delegateInstance instanceof ActivityBehavior) {
        return determineBehaviour((ActivityBehavior) delegateInstance, execution);
    } else if (delegateInstance instanceof JavaDelegate) {
        return determineBehaviour(new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance, skipExpression), execution);
    } else {
        throw new ActivitiIllegalArgumentException(delegateInstance.getClass().getName() + " doesn't implement " + JavaDelegate.class.getName() + " nor " + ActivityBehavior.class.getName());
    }
}
 
Example #17
Source File: ClassDelegate.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected ActivityBehavior determineBehaviour(ActivityBehavior delegateInstance, ActivityExecution execution) {
    if (hasMultiInstanceCharacteristics()) {
        multiInstanceActivityBehavior.setInnerActivityBehavior((AbstractBpmnActivityBehavior) delegateInstance);
        return multiInstanceActivityBehavior;
    }
    return delegateInstance;
}
 
Example #18
Source File: IntermediateThrowCompensationEventActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {

    // join compensating executions
    if (execution.getExecutions().isEmpty()) {
        leave(execution);
    } else {
        ((ExecutionEntity) execution).forceUpdate();
    }

}
 
Example #19
Source File: TerminateEndEventActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void dispatchActivityCancelled(ActivityExecution execution, ActivityImpl activity, ActivityImpl causeActivity) {
    Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
            ActivitiEventBuilder.createActivityCancelledEvent(activity.getId(),
                    (String) activity.getProperties().get("name"),
                    execution.getId(),
                    execution.getProcessInstanceId(), execution.getProcessDefinitionId(),
                    (String) activity.getProperties().get("type"),
                    activity.getActivityBehavior().getClass().getCanonicalName(),
                    causeActivity));
}
 
Example #20
Source File: Automatic.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
public void execute(ActivityExecution execution) throws Exception {
    List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
    if (outgoingTransitions.isEmpty()) {
        execution.end();
        System.out.println("流程已结束,结束节点:" + execution.getActivity().getId());
    } else {
        System.out.println("自动节点:" + execution.getActivity().getId());
        execution.take(outgoingTransitions.get(0));
    }
}
 
Example #21
Source File: ExecutionEntity.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public List<ActivityExecution> findInactiveConcurrentExecutions(PvmActivity activity) {
    List<ActivityExecution> inactiveConcurrentExecutionsInActivity = new ArrayList<>();
    List<ActivityExecution> otherConcurrentExecutions = new ArrayList<>();
    if (isConcurrent()) {
        List<? extends ActivityExecution> concurrentExecutions = getParent().getAllChildExecutions();
        for (ActivityExecution concurrentExecution : concurrentExecutions) {
            if (concurrentExecution.getActivity() != null && concurrentExecution.getActivity().getId().equals(activity.getId())) {
                if (!concurrentExecution.isActive()) {
                    inactiveConcurrentExecutionsInActivity.add(concurrentExecution);
                }
            } else {
                otherConcurrentExecutions.add(concurrentExecution);
            }
        }
    } else {
        if (!isActive()) {
            inactiveConcurrentExecutionsInActivity.add(this);
        } else {
            otherConcurrentExecutions.add(this);
        }
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("inactive concurrent executions in '{}': {}", activity, inactiveConcurrentExecutionsInActivity);
        LOGGER.debug("other concurrent executions: {}", otherConcurrentExecutions);
    }
    return inactiveConcurrentExecutionsInActivity;
}
 
Example #22
Source File: ClassDelegate.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void completing(DelegateExecution execution, DelegateExecution subProcessInstance) throws Exception {
    if (activityBehaviorInstance == null) {
        activityBehaviorInstance = getActivityBehaviorInstance((ActivityExecution) execution);
    }

    if (activityBehaviorInstance instanceof SubProcessActivityBehavior) {
        ((SubProcessActivityBehavior) activityBehaviorInstance).completing(execution, subProcessInstance);
    } else {
        throw new ActivitiException("completing() can only be called on a " + SubProcessActivityBehavior.class.getName() + " instance");
    }
}
 
Example #23
Source File: ClassDelegate.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {
    if (activityBehaviorInstance == null) {
        activityBehaviorInstance = getActivityBehaviorInstance(execution);
    }

    if (activityBehaviorInstance instanceof SignallableActivityBehavior) {
        ((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData);
    } else {
        throw new ActivitiException("signal() can only be called on a " + SignallableActivityBehavior.class.getName() + " instance");
    }
}
 
Example #24
Source File: MultiInstanceActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected int resolveLoopCardinality(ActivityExecution execution) {
    // Using Number since expr can evaluate to eg. Long (which is also the default for Juel)
    Object value = loopCardinalityExpression.getValue(execution);
    if (value instanceof Number) {
        return ((Number) value).intValue();
    } else if (value instanceof String) {
        return Integer.valueOf((String) value);
    } else {
        throw new ActivitiIllegalArgumentException("Could not resolve loopCardinality expression '"
                + loopCardinalityExpression.getExpressionText() + "': not a number nor number String");
    }
}
 
Example #25
Source File: IntermediateThrowSignalEventActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {

    CommandContext commandContext = Context.getCommandContext();

    List<SignalEventSubscriptionEntity> subscriptionEntities = null;
    if (processInstanceScope) {
        subscriptionEntities = commandContext
                .getEventSubscriptionEntityManager()
                .findSignalEventSubscriptionsByProcessInstanceAndEventName(execution.getProcessInstanceId(), signalDefinition.getEventName());
    } else {
        subscriptionEntities = commandContext
                .getEventSubscriptionEntityManager()
                .findSignalEventSubscriptionsByEventName(signalDefinition.getEventName(), execution.getTenantId());
    }

    for (SignalEventSubscriptionEntity signalEventSubscriptionEntity : subscriptionEntities) {
        ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(signalEventSubscriptionEntity.getProcessDefinitionId());
        if (Flowable5Util.isVersion5Tag(processDefinition.getEngineVersion())) {
            signalEventSubscriptionEntity.eventReceived(null, signalDefinition.isAsync());
            
        } else {
            EventSubscriptionService eventSubscriptionService = CommandContextUtil.getEventSubscriptionService();
            EventSubscriptionEntity flowable6EventSubscription = eventSubscriptionService.findById(signalEventSubscriptionEntity.getId());
            EventSubscriptionUtil.eventReceived(flowable6EventSubscription, null, signalDefinition.isAsync());
        }
    }

    ActivityExecution activityExecution = (ActivityExecution) execution;
    if (activityExecution.getActivity() != null) { // don't continue if process has already finished
        leave(activityExecution);
    }
}
 
Example #26
Source File: MyUserTaskActivityBehavior.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void handleAssignments(Expression assigneeExpression, Expression ownerExpression, Set<Expression> candidateUserExpressions,
	      Set<Expression> candidateGroupExpressions, TaskEntity task, ActivityExecution execution)
{
	createHandlerChain().resume(assigneeExpression, ownerExpression, candidateUserExpressions, 
	        candidateGroupExpressions, task, execution);
}
 
Example #27
Source File: ErrorPropagation.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
private static ActivityExecution getSuperExecution(ActivityExecution execution) {
    ExecutionEntity executionEntity = (ExecutionEntity) execution;
    ExecutionEntity superExecution = executionEntity.getProcessInstance().getSuperExecution();
    if (superExecution != null && !superExecution.isScope()) {
        return superExecution.getParent();
    }
    return superExecution;
}
 
Example #28
Source File: GatewayActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void lockConcurrentRoot(ActivityExecution execution) {
    ActivityExecution concurrentRoot = null;
    if (execution.isConcurrent()) {
        concurrentRoot = execution.getParent();
    } else {
        concurrentRoot = execution;
    }
    ((ExecutionEntity) concurrentRoot).forceUpdate();
}
 
Example #29
Source File: MultiInstanceActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected Integer getLoopVariable(ActivityExecution execution, String variableName) {
    Object value = execution.getVariableLocal(variableName);
    ActivityExecution parent = execution.getParent();
    while (value == null && parent != null) {
        value = parent.getVariableLocal(variableName);
        parent = parent.getParent();
    }
    return (Integer) (value != null ? value : 0);
}
 
Example #30
Source File: ActivityPermissionAssignmentHandler.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void handleAssignment(TaskAssignmentHandlerChain chain, Expression assigneeExpression,
		Expression ownerExpression, Set<Expression> candidateUserExpressions,
		Set<Expression> candidateGroupExpressions, TaskEntity task, ActivityExecution execution)
{
	//设置assignment信息
	String processDefinitionId = task.getProcessDefinitionId();
	String taskDefinitionKey = task.getTaskDefinitionKey();

	ActivityPermissionEntity entity;
	try
	{
		entity = _activityPermissionManager.load(processDefinitionId, taskDefinitionKey, true);
	}
	catch (Exception e)
	{
		throw new OwfException(e);
	}

	//没有自定义授权规则
	if (entity == null)
	{
		chain.resume(assigneeExpression, ownerExpression, candidateUserExpressions,
			      candidateGroupExpressions, task, execution);
		return;
	}

	//彻底忽略原有规则
	task.setAssignee(entity.getAssignee());
	task.addCandidateGroups(asList(entity.getGrantedGroupIds()));
	task.addCandidateUsers(asList(entity.getGrantedUserIds()));
}