Search in sources :

Example 51 with ActivityImpl

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);
        }
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)

Example 52 with ActivityImpl

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);
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)

Example 53 with ActivityImpl

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());
}
Also used : ExecutionVariableSnapshotObserver(org.camunda.bpm.engine.impl.persistence.entity.ExecutionVariableSnapshotObserver) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ProcessInstanceWithVariablesImpl(org.camunda.bpm.engine.impl.persistence.entity.ProcessInstanceWithVariablesImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) ProcessInstanceModificationBuilderImpl(org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 54 with ActivityImpl

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;
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigratingCompensationEventSubscriptionInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingCompensationEventSubscriptionInstance) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction)

Example 55 with ActivityImpl

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);
    }
}
Also used : MigratingEventSubscriptionInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingEventSubscriptionInstance) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) EventSubscriptionDeclaration(org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Aggregations

ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)94 Deployment (org.camunda.bpm.engine.test.Deployment)29 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)12 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)12 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)10 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)10 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)8 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)8 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)7 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)7 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)5 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)4 ArrayList (java.util.ArrayList)3 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)3 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)3 ConditionalEventBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior)2 MultiInstanceActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior)2 SequentialMultiInstanceActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.SequentialMultiInstanceActivityBehavior)2 CoreModelElement (org.camunda.bpm.engine.impl.core.model.CoreModelElement)2 AsyncContinuationConfiguration (org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)2