use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class IntermediateConditionalEventBehavior method leaveOnSatisfiedCondition.
@Override
public void leaveOnSatisfiedCondition(final EventSubscriptionEntity eventSubscription, final VariableEvent variableEvent) {
PvmExecutionImpl execution = eventSubscription.getExecution();
if (execution != null && !execution.isEnded() && variableEvent != null && conditionalEvent.tryEvaluate(variableEvent, execution) && execution.isActive() && execution.isScope()) {
if (isAfterEventBasedGateway) {
final ActivityImpl activity = eventSubscription.getActivity();
execution.executeEventHandlerActivity(activity);
} else {
leave(execution);
}
}
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class SequentialMultiInstanceActivityBehavior method createInstances.
@Override
protected void createInstances(ActivityExecution execution, int nrOfInstances) throws Exception {
prepareScope(execution, nrOfInstances);
setLoopVariable(execution, NUMBER_OF_ACTIVE_INSTANCES, 1);
ActivityImpl innerActivity = getInnerActivity(execution.getActivity());
performInstance(execution, innerActivity, 0);
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class StartProcessInstanceAtActivitiesCmd method execute.
public ProcessInstanceWithVariables execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = new GetDeployedProcessDefinitionCmd(instantiationBuilder, false).execute(commandContext);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkCreateProcessInstance(processDefinition);
}
ProcessInstanceModificationBuilderImpl modificationBuilder = instantiationBuilder.getModificationBuilder();
ensureNotEmpty("At least one instantiation instruction required (e.g. by invoking startBefore(..), startAfter(..) or startTransition(..))", "instructions", modificationBuilder.getModificationOperations());
// instantiate the process
ActivityImpl initialActivity = determineFirstActivity(processDefinition, modificationBuilder);
ExecutionEntity processInstance = processDefinition.createProcessInstance(instantiationBuilder.getBusinessKey(), instantiationBuilder.getCaseInstanceId(), initialActivity);
if (instantiationBuilder.getTenantId() != null) {
processInstance.setTenantId(instantiationBuilder.getTenantId());
}
processInstance.setSkipCustomListeners(modificationBuilder.isSkipCustomListeners());
VariableMap variables = modificationBuilder.getProcessVariables();
final ExecutionVariableSnapshotObserver variablesListener = new ExecutionVariableSnapshotObserver(processInstance);
processInstance.startWithoutExecuting(variables);
// prevent ending of the process instance between instructions
processInstance.setPreserveScope(true);
// apply modifications
List<AbstractProcessInstanceModificationCommand> instructions = modificationBuilder.getModificationOperations();
for (int i = 0; i < instructions.size(); i++) {
AbstractProcessInstanceModificationCommand instruction = instructions.get(i);
LOG.debugStartingInstruction(processInstance.getId(), i, instruction.describe());
instruction.setProcessInstanceId(processInstance.getId());
instruction.setSkipCustomListeners(modificationBuilder.isSkipCustomListeners());
instruction.setSkipIoMappings(modificationBuilder.isSkipIoMappings());
instruction.execute(commandContext);
}
if (!processInstance.hasChildren() && processInstance.isEnded()) {
// process instance has ended regularly but this has not been propagated yet
// due to preserveScope setting
processInstance.propagateEnd();
}
return new ProcessInstanceWithVariablesImpl(processInstance, variablesListener.getVariables());
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class CompensationInstanceHandler method createMigratingEventSubscriptionInstance.
protected MigratingProcessElementInstance createMigratingEventSubscriptionInstance(MigratingInstanceParseContext parseContext, EventSubscriptionEntity element) {
ActivityImpl compensationHandler = parseContext.getSourceProcessDefinition().findActivity(element.getActivityId());
MigrationInstruction migrationInstruction = getMigrationInstruction(parseContext, compensationHandler);
ActivityImpl targetScope = null;
if (migrationInstruction != null) {
ActivityImpl targetEventScope = (ActivityImpl) parseContext.getTargetActivity(migrationInstruction).getEventScope();
targetScope = targetEventScope.findCompensationHandler();
}
MigratingCompensationEventSubscriptionInstance migratingCompensationInstance = parseContext.getMigratingProcessInstance().addCompensationSubscriptionInstance(migrationInstruction, element, compensationHandler, targetScope);
parseContext.consume(element);
return migratingCompensationInstance;
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class EventSubscriptionInstanceHandler method handle.
@Override
public void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance owningInstance, List<EventSubscriptionEntity> elements) {
Map<String, EventSubscriptionDeclaration> targetDeclarations = getDeclarationsByTriggeringActivity(owningInstance.getTargetScope());
for (EventSubscriptionEntity eventSubscription : elements) {
if (!getSupportedEventTypes().contains(eventSubscription.getEventType())) {
// ignore unsupported event subscriptions
continue;
}
MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(eventSubscription.getActivityId());
ActivityImpl targetActivity = parseContext.getTargetActivity(migrationInstruction);
if (targetActivity != null && owningInstance.migratesTo(targetActivity.getEventScope())) {
// the event subscription is migrated
EventSubscriptionDeclaration targetDeclaration = targetDeclarations.remove(targetActivity.getId());
owningInstance.addMigratingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription, targetActivity, migrationInstruction.isUpdateEventTrigger(), targetDeclaration));
} else {
// the event subscription will be removed
owningInstance.addRemovingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription));
}
parseContext.consume(eventSubscription);
}
if (owningInstance.migrates()) {
addEmergingEventSubscriptions(owningInstance, targetDeclarations);
}
}
Aggregations