Java Code Examples for org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution#getActivity()
The following examples show how to use
org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution#getActivity() .
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: LegacyBehavior.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
/** * This method * @param scopeExecution * @return */ protected static boolean isLegacyBehaviorRequired(ActivityExecution scopeExecution) { // legacy behavior is turned off: the current activity was parsed as scope. // now we need to check whether a scope execution was correctly created for the // event subprocess. // first create the mapping: Map<ScopeImpl, PvmExecutionImpl> activityExecutionMapping = scopeExecution.createActivityExecutionMapping(); // if the scope execution for the current activity is the same as for the parent scope // -> we need to perform legacy behavior PvmScope activity = scopeExecution.getActivity(); if (!activity.isScope()) { activity = activity.getFlowScope(); } return activityExecutionMapping.get(activity) == activityExecutionMapping.get(activity.getFlowScope()); }
Example 2
Source File: EventBasedGatewayActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public void execute(ActivityExecution execution) throws Exception { // If conditional events exist after the event based gateway they should be evaluated. // If a condition is satisfied the event based gateway should be left, // otherwise the event based gateway is a wait state ActivityImpl eventBasedGateway = (ActivityImpl) execution.getActivity(); for (ActivityImpl act : eventBasedGateway.getEventActivities()) { ActivityBehavior activityBehavior = act.getActivityBehavior(); if (activityBehavior instanceof ConditionalEventBehavior) { ConditionalEventBehavior conditionalEventBehavior = (ConditionalEventBehavior) activityBehavior; ConditionalEventDefinition conditionalEventDefinition = conditionalEventBehavior.getConditionalEventDefinition(); if (conditionalEventDefinition.tryEvaluate(execution)) { ((ExecutionEntity) execution).executeEventHandlerActivity(conditionalEventDefinition.getConditionalActivity()); return; } } } }
Example 3
Source File: ParallelGatewayActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void execute(ActivityExecution execution) throws Exception { // Join PvmActivity activity = execution.getActivity(); List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions(); execution.inactivate(); lockConcurrentRoot(execution); List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity); int nbrOfExecutionsToJoin = execution.getActivity().getIncomingTransitions().size(); int nbrOfExecutionsJoined = joinedExecutions.size(); if (nbrOfExecutionsJoined==nbrOfExecutionsToJoin) { // Fork LOG.activityActivation(activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin); execution.leaveActivityViaTransitions(outgoingTransitions, joinedExecutions); } else { LOG.noActivityActivation(activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin); } }
Example 4
Source File: ParallelGateway.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void execute(ActivityExecution execution) { PvmActivity activity = execution.getActivity(); List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions(); execution.inactivate(); List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity); int nbrOfExecutionsToJoin = execution.getActivity().getIncomingTransitions().size(); int nbrOfExecutionsJoined = joinedExecutions.size(); if (nbrOfExecutionsJoined==nbrOfExecutionsToJoin) { LOG.debug("parallel gateway '"+activity.getId()+"' activates: "+nbrOfExecutionsJoined+" of "+nbrOfExecutionsToJoin+" joined"); execution.leaveActivityViaTransitions(outgoingTransitions, joinedExecutions); } else { LOG.debug("parallel gateway '"+activity.getId()+"' does not activate: "+nbrOfExecutionsJoined+" of "+nbrOfExecutionsToJoin+" joined"); } }
Example 5
Source File: EscalationHandler.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * Walks through the activity execution hierarchy, fetches and executes matching escalation catch event * @return the escalation event definition if found matching escalation catch event */ public static EscalationEventDefinition executeEscalation(ActivityExecution execution, String escalationCode) { final PvmActivity currentActivity = execution.getActivity(); final EscalationEventDefinitionFinder escalationEventDefinitionFinder = new EscalationEventDefinitionFinder(escalationCode, currentActivity); ActivityExecutionMappingCollector activityExecutionMappingCollector = new ActivityExecutionMappingCollector(execution); ActivityExecutionHierarchyWalker walker = new ActivityExecutionHierarchyWalker(execution); walker.addScopePreVisitor(escalationEventDefinitionFinder); walker.addExecutionPreVisitor(activityExecutionMappingCollector); walker.addExecutionPreVisitor(new OutputVariablesPropagator()); walker.walkUntil(new ReferenceWalker.WalkCondition<ActivityExecutionTuple>() { @Override public boolean isFulfilled(ActivityExecutionTuple element) { return escalationEventDefinitionFinder.getEscalationEventDefinition() != null || element == null; } }); EscalationEventDefinition escalationEventDefinition = escalationEventDefinitionFinder.getEscalationEventDefinition(); if (escalationEventDefinition != null) { executeEscalationHandler(escalationEventDefinition, activityExecutionMappingCollector, escalationCode); } return escalationEventDefinition; }
Example 6
Source File: ThrowEscalationEventActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void execute(ActivityExecution execution) throws Exception { final PvmActivity currentActivity = execution.getActivity(); EscalationEventDefinition escalationEventDefinition = EscalationHandler.executeEscalation(execution, escalation.getEscalationCode()); if (escalationEventDefinition == null || !escalationEventDefinition.isCancelActivity()) { leaveExecution(execution, currentActivity, escalationEventDefinition); } }
Example 7
Source File: SubProcessActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void execute(ActivityExecution execution) throws Exception { PvmActivity activity = execution.getActivity(); PvmActivity initialActivity = activity.getProperties().get(BpmnProperties.INITIAL_ACTIVITY); ensureNotNull("No initial activity found for subprocess " + execution.getActivity().getId(), "initialActivity", initialActivity); execution.executeActivity(initialActivity); }
Example 8
Source File: ParallelMultiInstanceActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void concurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) { int nrOfCompletedInstances = getLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES) + 1; setLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES, nrOfCompletedInstances); int nrOfActiveInstances = getLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES) - 1; setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfActiveInstances); // inactivate the concurrent execution endedExecution.inactivate(); endedExecution.setActivityInstanceId(null); // join scopeExecution.forceUpdate(); // TODO: should the completion condition be evaluated on the scopeExecution or on the endedExecution? if(completionConditionSatisfied(endedExecution) || allExecutionsEnded(scopeExecution, endedExecution)) { ArrayList<ActivityExecution> childExecutions = new ArrayList<ActivityExecution>(((PvmExecutionImpl) scopeExecution).getNonEventScopeExecutions()); for (ActivityExecution childExecution : childExecutions) { // delete all not-ended instances; these are either active (for non-scope tasks) or inactive but have no activity id (for subprocesses, etc.) if (childExecution.isActive() || childExecution.getActivity() == null) { ((PvmExecutionImpl)childExecution).deleteCascade("Multi instance completion condition satisfied."); } else { childExecution.remove(); } } scopeExecution.setActivity((PvmActivity) endedExecution.getActivity().getFlowScope()); scopeExecution.setActive(true); leave(scopeExecution); } else { ((ExecutionEntity) scopeExecution).dispatchDelayedEventsAndPerformOperation((Callback<PvmExecutionImpl, Void>) null); } }
Example 9
Source File: AbstractBpmnActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * Subclasses that call leave() will first pass through this method, before * the regular {@link FlowNodeActivityBehavior#leave(ActivityExecution)} is * called. */ @Override public void doLeave(ActivityExecution execution) { PvmActivity currentActivity = execution.getActivity(); ActivityImpl compensationHandler = ((ActivityImpl) currentActivity).findCompensationHandler(); // subscription for compensation event subprocess is already created if(compensationHandler != null && !isCompensationEventSubprocess(compensationHandler)) { createCompensateEventSubscription(execution, compensationHandler); } super.doLeave(execution); }
Example 10
Source File: AbstractBpmnActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected void createCompensateEventSubscription(ActivityExecution execution, ActivityImpl compensationHandler) { // the compensate event subscription is created at subprocess or miBody of the the current activity PvmActivity currentActivity = execution.getActivity(); ActivityExecution scopeExecution = execution.findExecutionForFlowScope(currentActivity.getFlowScope()); EventSubscriptionEntity.createAndInsert((ExecutionEntity) scopeExecution, EventType.COMPENSATE, compensationHandler); }
Example 11
Source File: ActivityExecutionMappingCollector.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
private void appendActivityExecutionMapping(ActivityExecution execution) { if (execution.getActivity() != null && !LegacyBehavior.hasInvalidIntermediaryActivityId((PvmExecutionImpl) execution)) { activityExecutionMapping.putAll(execution.createActivityExecutionMapping()); } }
Example 12
Source File: BpmnExceptionHandler.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public static void propagateError(String errorCode, String errorMessage, Exception origException, ActivityExecution execution) throws Exception { ActivityExecutionHierarchyWalker walker = new ActivityExecutionHierarchyWalker(execution); final ErrorDeclarationForProcessInstanceFinder errorDeclarationFinder = new ErrorDeclarationForProcessInstanceFinder(origException, errorCode, execution.getActivity()); ActivityExecutionMappingCollector activityExecutionMappingCollector = new ActivityExecutionMappingCollector(execution); walker.addScopePreVisitor(errorDeclarationFinder); walker.addExecutionPreVisitor(activityExecutionMappingCollector); // map variables to super executions in the hierarchy of called process instances walker.addExecutionPreVisitor(new OutputVariablesPropagator()); try { walker.walkUntil(new ReferenceWalker.WalkCondition<ActivityExecutionTuple>() { @Override public boolean isFulfilled(ActivityExecutionTuple element) { return errorDeclarationFinder.getErrorEventDefinition() != null || element == null; } }); } catch(Exception e) { LOG.errorPropagationException(execution.getActivityInstanceId(), e); // separate the exception handling to support a fail-safe error propagation throw new ErrorPropagationException(e.getCause()); } PvmActivity errorHandlingActivity = errorDeclarationFinder.getErrorHandlerActivity(); // process the error if (errorHandlingActivity == null) { if (origException == null) { if (Context.getCommandContext().getProcessEngineConfiguration().isEnableExceptionsAfterUnhandledBpmnError()) { throw LOG.missingBoundaryCatchEventError(execution.getActivity().getId(), errorCode); } else { LOG.missingBoundaryCatchEvent(execution.getActivity().getId(), errorCode); execution.end(true); } } else { // throw original exception throw origException; } } else { ErrorEventDefinition errorDefinition = errorDeclarationFinder.getErrorEventDefinition(); PvmExecutionImpl errorHandlingExecution = activityExecutionMappingCollector.getExecutionForScope(errorHandlingActivity.getEventScope()); if(errorDefinition.getErrorCodeVariable() != null) { errorHandlingExecution.setVariable(errorDefinition.getErrorCodeVariable(), errorCode); } if(errorDefinition.getErrorMessageVariable() != null) { errorHandlingExecution.setVariable(errorDefinition.getErrorMessageVariable(), errorMessage); } errorHandlingExecution.executeActivity(errorHandlingActivity); } }
Example 13
Source File: InclusiveGatewayActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void execute(ActivityExecution execution) throws Exception { execution.inactivate(); lockConcurrentRoot(execution); PvmActivity activity = execution.getActivity(); if (activatesGateway(execution, activity)) { LOG.activityActivation(activity.getId()); List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity); String defaultSequenceFlow = (String) execution.getActivity().getProperty("default"); List<PvmTransition> transitionsToTake = new ArrayList<PvmTransition>(); // find matching non-default sequence flows for (PvmTransition outgoingTransition : execution.getActivity().getOutgoingTransitions()) { if (defaultSequenceFlow == null || !outgoingTransition.getId().equals(defaultSequenceFlow)) { Condition condition = (Condition) outgoingTransition.getProperty(BpmnParse.PROPERTYNAME_CONDITION); if (condition == null || condition.evaluate(execution)) { transitionsToTake.add(outgoingTransition); } } } // if none found, add default flow if (transitionsToTake.isEmpty()) { if (defaultSequenceFlow != null) { PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow); if (defaultTransition == null) { throw LOG.missingDefaultFlowException(execution.getActivity().getId(), defaultSequenceFlow); } transitionsToTake.add(defaultTransition); } else { // No sequence flow could be found, not even a default one throw LOG.stuckExecutionException(execution.getActivity().getId()); } } // take the flows found execution.leaveActivityViaTransitions(transitionsToTake, joinedExecutions); } else { LOG.noActivityActivation(activity.getId()); } }