use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class AbstractBpmnActivityBehavior method doLeave.
/**
* 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);
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class SignalEventReceivedCmd method startProcessInstances.
private void startProcessInstances(List<EventSubscriptionEntity> startSignalEventSubscriptions, Map<String, ProcessDefinitionEntity> processDefinitions) {
for (EventSubscriptionEntity signalStartEventSubscription : startSignalEventSubscriptions) {
ProcessDefinitionEntity processDefinition = processDefinitions.get(signalStartEventSubscription.getId());
if (processDefinition != null) {
ActivityImpl signalStartEvent = processDefinition.findActivity(signalStartEventSubscription.getActivityId());
PvmProcessInstance processInstance = processDefinition.createProcessInstanceForInitial(signalStartEvent);
processInstance.start(builder.getVariables());
}
}
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class StartProcessInstanceAtActivitiesCmd method determineFirstActivity.
/**
* get the activity that is started by the first instruction, if exists;
* return null if the first instruction is a start-transition instruction
*/
protected ActivityImpl determineFirstActivity(ProcessDefinitionImpl processDefinition, ProcessInstanceModificationBuilderImpl modificationBuilder) {
AbstractProcessInstanceModificationCommand firstInstruction = modificationBuilder.getModificationOperations().get(0);
if (firstInstruction instanceof AbstractInstantiationCmd) {
AbstractInstantiationCmd instantiationInstruction = (AbstractInstantiationCmd) firstInstruction;
CoreModelElement targetElement = instantiationInstruction.getTargetElement(processDefinition);
ensureNotNull(NotValidException.class, "Element '" + instantiationInstruction.getTargetElementId() + "' does not exist in process " + processDefinition.getId(), "targetElement", targetElement);
if (targetElement instanceof ActivityImpl) {
return (ActivityImpl) targetElement;
} else if (targetElement instanceof TransitionImpl) {
return (ActivityImpl) ((TransitionImpl) targetElement).getDestination();
}
}
return null;
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class ConditionalEventHandler method handleEvent.
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, String businessKey, CommandContext commandContext) {
VariableEvent variableEvent;
if (payload == null || payload instanceof VariableEvent) {
variableEvent = (VariableEvent) payload;
} else {
throw new ProcessEngineException("Payload have to be " + VariableEvent.class.getName() + ", to evaluate condition.");
}
ActivityImpl activity = eventSubscription.getActivity();
ActivityBehavior activityBehavior = activity.getActivityBehavior();
if (activityBehavior instanceof ConditionalEventBehavior) {
ConditionalEventBehavior conditionalBehavior = (ConditionalEventBehavior) activityBehavior;
conditionalBehavior.leaveOnSatisfiedCondition(eventSubscription, variableEvent);
} else {
throw new ProcessEngineException("Conditional Event has not correct behavior: " + activityBehavior);
}
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class CompensationEventHandler method handleEvent.
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, String businessKey, CommandContext commandContext) {
eventSubscription.delete();
String configuration = eventSubscription.getConfiguration();
ensureNotNull("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId(), "configuration", configuration);
ExecutionEntity compensatingExecution = commandContext.getExecutionManager().findExecutionById(configuration);
ActivityImpl compensationHandler = eventSubscription.getActivity();
// activate execution
compensatingExecution.setActive(true);
if (compensatingExecution.getActivity().getActivityBehavior() instanceof CompositeActivityBehavior) {
compensatingExecution.getParent().setActivityInstanceId(compensatingExecution.getActivityInstanceId());
}
if (compensationHandler.isScope() && !compensationHandler.isCompensationHandler()) {
// descend into scope:
List<EventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();
CompensationUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);
} else {
try {
if (compensationHandler.isSubProcessScope() && compensationHandler.isTriggeredByEvent()) {
compensatingExecution.executeActivity(compensationHandler);
} else {
// since we already have a scope execution, we don't need to create another one
// for a simple scoped compensation handler
compensatingExecution.setActivity(compensationHandler);
compensatingExecution.performOperation(PvmAtomicOperation.ACTIVITY_START);
}
} catch (Exception e) {
throw new ProcessEngineException("Error while handling compensation event " + eventSubscription, e);
}
}
}
Aggregations