Search in sources :

Example 21 with ScopeImpl

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

the class AdditionalFlowScopeInstructionValidator method validate.

public void validate(ValidatingMigrationInstruction instruction, ValidatingMigrationInstructions instructions, MigrationInstructionValidationReportImpl report) {
    ValidatingMigrationInstruction ancestorScopeInstruction = getClosestPreservedAncestorScopeMigrationInstruction(instruction, instructions);
    ScopeImpl targetScope = instruction.getTargetActivity();
    if (ancestorScopeInstruction != null && targetScope != null && targetScope != targetScope.getProcessDefinition()) {
        ScopeImpl parentInstanceTargetScope = ancestorScopeInstruction.getTargetActivity();
        if (parentInstanceTargetScope != null && !parentInstanceTargetScope.isAncestorFlowScopeOf(targetScope)) {
            report.addFailure("The closest mapped ancestor '" + ancestorScopeInstruction.getSourceActivity().getId() + "' is mapped to scope '" + parentInstanceTargetScope.getId() + "' which is not an ancestor of target scope '" + targetScope.getId() + "'");
        }
    }
}
Also used : ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Example 22 with ScopeImpl

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

the class CannotAddMultiInstanceBodyValidator method validate.

@Override
public void validate(ValidatingMigrationInstruction instruction, final ValidatingMigrationInstructions instructions, MigrationInstructionValidationReportImpl report) {
    ActivityImpl targetActivity = instruction.getTargetActivity();
    FlowScopeWalker flowScopeWalker = new FlowScopeWalker(targetActivity.getFlowScope());
    MiBodyCollector miBodyCollector = new MiBodyCollector();
    flowScopeWalker.addPreVisitor(miBodyCollector);
    // walk until a target scope is found that is mapped
    flowScopeWalker.walkWhile(new WalkCondition<ScopeImpl>() {

        @Override
        public boolean isFulfilled(ScopeImpl element) {
            return element == null || !instructions.getInstructionsByTargetScope(element).isEmpty();
        }
    });
    if (miBodyCollector.firstMiBody != null) {
        report.addFailure("Target activity '" + targetActivity.getId() + "' is a descendant of multi-instance body '" + miBodyCollector.firstMiBody.getId() + "' that is not mapped from the source process definition.");
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) FlowScopeWalker(org.camunda.bpm.engine.impl.tree.FlowScopeWalker) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Example 23 with ScopeImpl

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

the class MigratingProcessElementInstanceVisitor method collectNonExistingFlowScopes.

/**
 * Returns a list of flow scopes from the given scope until a scope is reached that is already present in the given
 * {@link MigratingScopeInstanceBranch} (exclusive). The order of the returned list is top-down, i.e. the highest scope
 * is the first element of the list.
 */
protected List<ScopeImpl> collectNonExistingFlowScopes(ScopeImpl scope, final MigratingScopeInstanceBranch migratingExecutionBranch) {
    FlowScopeWalker walker = new FlowScopeWalker(scope);
    final List<ScopeImpl> result = new LinkedList<ScopeImpl>();
    walker.addPreVisitor(new TreeVisitor<ScopeImpl>() {

        @Override
        public void visit(ScopeImpl obj) {
            result.add(0, obj);
        }
    });
    walker.walkWhile(new ReferenceWalker.WalkCondition<ScopeImpl>() {

        @Override
        public boolean isFulfilled(ScopeImpl element) {
            return migratingExecutionBranch.hasInstance(element);
        }
    });
    return result;
}
Also used : 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) LinkedList(java.util.LinkedList)

Example 24 with ScopeImpl

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

the class MigratingExternalTaskInstance method migrateState.

@Override
public void migrateState() {
    ScopeImpl targetActivity = migratingActivityInstance.getTargetScope();
    ProcessDefinition targetProcessDefinition = (ProcessDefinition) targetActivity.getProcessDefinition();
    externalTask.setActivityId(targetActivity.getId());
    externalTask.setProcessDefinitionId(targetProcessDefinition.getId());
    externalTask.setProcessDefinitionKey(targetProcessDefinition.getKey());
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Example 25 with ScopeImpl

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

the class SameEventScopeInstructionValidator method validate.

public void validate(ValidatingMigrationInstruction instruction, ValidatingMigrationInstructions instructions, MigrationInstructionValidationReportImpl report) {
    ActivityImpl sourceActivity = instruction.getSourceActivity();
    if (isCompensationBoundaryEvent(sourceActivity)) {
        // event scopes need not be active at runtime
        return;
    }
    ScopeImpl sourceEventScope = instruction.getSourceActivity().getEventScope();
    ScopeImpl targetEventScope = instruction.getTargetActivity().getEventScope();
    if (sourceEventScope == null || sourceEventScope == sourceActivity.getFlowScope()) {
        // => validation not necessary for event subprocesses
        return;
    }
    if (targetEventScope == null) {
        report.addFailure("The source activity's event scope (" + sourceEventScope.getId() + ") must be mapped but the " + "target activity has no event scope");
    } else {
        ScopeImpl mappedSourceEventScope = findMappedEventScope(sourceEventScope, instruction, instructions);
        if (mappedSourceEventScope == null || !mappedSourceEventScope.getId().equals(targetEventScope.getId())) {
            report.addFailure("The source activity's event scope (" + sourceEventScope.getId() + ") " + "must be mapped to the target activity's event scope (" + targetEventScope.getId() + ")");
        }
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) 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