Search in sources :

Example 16 with ScopeImpl

use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.

the class CompensationUtil method collectCompensateEventSubscriptionsForScope.

/**
 * Collect all compensate event subscriptions for scope of given execution.
 */
public static List<EventSubscriptionEntity> collectCompensateEventSubscriptionsForScope(ActivityExecution execution) {
    final Map<ScopeImpl, PvmExecutionImpl> scopeExecutionMapping = execution.createActivityExecutionMapping();
    ScopeImpl activity = (ScopeImpl) execution.getActivity();
    // <LEGACY>: different flow scopes may have the same scope execution =>
    // collect subscriptions in a set
    final Set<EventSubscriptionEntity> subscriptions = new HashSet<EventSubscriptionEntity>();
    TreeVisitor<ScopeImpl> eventSubscriptionCollector = new TreeVisitor<ScopeImpl>() {

        @Override
        public void visit(ScopeImpl obj) {
            PvmExecutionImpl execution = scopeExecutionMapping.get(obj);
            subscriptions.addAll(((ExecutionEntity) execution).getCompensateEventSubscriptions());
        }
    };
    new FlowScopeWalker(activity).addPostVisitor(eventSubscriptionCollector).walkUntil(new ReferenceWalker.WalkCondition<ScopeImpl>() {

        @Override
        public boolean isFulfilled(ScopeImpl element) {
            Boolean consumesCompensationProperty = (Boolean) element.getProperty(BpmnParse.PROPERTYNAME_CONSUMES_COMPENSATION);
            return consumesCompensationProperty == null || consumesCompensationProperty == Boolean.TRUE;
        }
    });
    return new ArrayList<EventSubscriptionEntity>(subscriptions);
}
Also used : PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ArrayList(java.util.ArrayList) TreeVisitor(org.camunda.bpm.engine.impl.tree.TreeVisitor) ReferenceWalker(org.camunda.bpm.engine.impl.tree.ReferenceWalker) FlowScopeWalker(org.camunda.bpm.engine.impl.tree.FlowScopeWalker) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity) HashSet(java.util.HashSet)

Example 17 with ScopeImpl

use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.

the class MigratingVariableInstance method attachState.

@Override
public void attachState(MigratingScopeInstance owningActivityInstance) {
    ExecutionEntity representativeExecution = owningActivityInstance.resolveRepresentativeExecution();
    ScopeImpl currentScope = owningActivityInstance.getCurrentScope();
    ExecutionEntity newOwningExecution = representativeExecution;
    if (currentScope.isScope() && isConcurrentLocalInParentScope) {
        newOwningExecution = representativeExecution.getParent();
    }
    newOwningExecution.addVariableInternal(variable);
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Example 18 with ScopeImpl

use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.

the class TransitionInstanceJobHandler method handle.

@Override
public void handle(MigratingInstanceParseContext parseContext, MigratingTransitionInstance transitionInstance, List<JobEntity> elements) {
    for (JobEntity job : elements) {
        if (!isAsyncContinuation(job)) {
            continue;
        }
        ScopeImpl targetScope = transitionInstance.getTargetScope();
        if (targetScope != null) {
            JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(transitionInstance.getTargetScope().getId(), job.getJobHandlerType());
            MigratingAsyncJobInstance migratingJobInstance = new MigratingAsyncJobInstance(job, targetJobDefinitionEntity, transitionInstance.getTargetScope());
            transitionInstance.setDependentJobInstance(migratingJobInstance);
            parseContext.submit(migratingJobInstance);
        }
        parseContext.consume(job);
    }
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) MigratingAsyncJobInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingAsyncJobInstance) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Example 19 with ScopeImpl

use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.

the class TransitionInstanceHandler method handle.

@Override
public void handle(MigratingInstanceParseContext parseContext, TransitionInstance transitionInstance) {
    if (!isAsyncTransitionInstance(transitionInstance)) {
        return;
    }
    MigrationInstruction applyingInstruction = parseContext.getInstructionFor(transitionInstance.getActivityId());
    ScopeImpl sourceScope = parseContext.getSourceProcessDefinition().findActivity(transitionInstance.getActivityId());
    ScopeImpl targetScope = null;
    if (applyingInstruction != null) {
        String activityId = applyingInstruction.getTargetActivityId();
        targetScope = parseContext.getTargetProcessDefinition().findActivity(activityId);
    }
    ExecutionEntity asyncExecution = Context.getCommandContext().getExecutionManager().findExecutionById(transitionInstance.getExecutionId());
    MigratingTransitionInstance migratingTransitionInstance = parseContext.getMigratingProcessInstance().addTransitionInstance(applyingInstruction, transitionInstance, sourceScope, targetScope, asyncExecution);
    MigratingActivityInstance parentInstance = parseContext.getMigratingActivityInstanceById(transitionInstance.getParentActivityInstanceId());
    migratingTransitionInstance.setParent(parentInstance);
    List<JobEntity> jobs = asyncExecution.getJobs();
    parseContext.handleDependentTransitionInstanceJobs(migratingTransitionInstance, jobs);
    parseContext.handleDependentVariables(migratingTransitionInstance, collectTransitionInstanceVariables(migratingTransitionInstance));
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigratingTransitionInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingTransitionInstance) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) MigratingActivityInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)

Example 20 with ScopeImpl

use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.

the class VariableConflictActivityInstanceValidator method validate.

@Override
public void validate(MigratingActivityInstance migratingInstance, MigratingProcessInstance migratingProcessInstance, MigratingActivityInstanceValidationReportImpl instanceReport) {
    ScopeImpl sourceScope = migratingInstance.getSourceScope();
    ScopeImpl targetScope = migratingInstance.getTargetScope();
    if (migratingInstance.migrates()) {
        boolean becomesNonScope = sourceScope.isScope() && !targetScope.isScope();
        if (becomesNonScope) {
            Map<String, List<MigratingVariableInstance>> dependentVariablesByName = getMigratingVariableInstancesByName(migratingInstance);
            for (String variableName : dependentVariablesByName.keySet()) {
                if (dependentVariablesByName.get(variableName).size() > 1) {
                    instanceReport.addFailure("The variable '" + variableName + "' exists in both, this scope and " + "concurrent local in the parent scope. " + "Migrating to a non-scope activity would overwrite one of them.");
                }
            }
        }
    }
}
Also used : List(java.util.List) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Aggregations

ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)37 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)10 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)10 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)6 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)6 FlowScopeWalker (org.camunda.bpm.engine.impl.tree.FlowScopeWalker)5 HashMap (java.util.HashMap)4 List (java.util.List)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 ReferenceWalker (org.camunda.bpm.engine.impl.tree.ReferenceWalker)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 PvmScope (org.camunda.bpm.engine.impl.pvm.PvmScope)3 Deployment (org.camunda.bpm.engine.test.Deployment)3 MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)2 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)2 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)2 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)2 CompositeActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior)2