Search in sources :

Example 56 with ActivityImpl

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

the class AsyncAfterMigrationValidator method validate.

@Override
public void validate(MigratingTransitionInstance migratingInstance, MigratingProcessInstance migratingProcessInstance, MigratingTransitionInstanceValidationReportImpl instanceReport) {
    ActivityImpl targetActivity = (ActivityImpl) migratingInstance.getTargetScope();
    if (targetActivity != null && migratingInstance.isAsyncAfter()) {
        MigratingJobInstance jobInstance = migratingInstance.getJobInstance();
        AsyncContinuationConfiguration config = (AsyncContinuationConfiguration) jobInstance.getJobEntity().getJobHandlerConfiguration();
        String sourceTransitionId = config.getTransitionId();
        if (targetActivity.getOutgoingTransitions().size() > 1) {
            if (sourceTransitionId == null) {
                instanceReport.addFailure("Transition instance is assigned to no sequence flow" + " and target activity has more than one outgoing sequence flow");
            } else {
                TransitionImpl matchingOutgoingTransition = targetActivity.findOutgoingTransition(sourceTransitionId);
                if (matchingOutgoingTransition == null) {
                    instanceReport.addFailure("Transition instance is assigned to a sequence flow" + " that cannot be matched in the target activity");
                }
            }
        }
    }
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigratingJobInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance) AsyncContinuationConfiguration(org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)

Example 57 with ActivityImpl

use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl 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 58 with ActivityImpl

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

the class GatewayMappingValidator method validateIncomingSequenceFlows.

protected void validateIncomingSequenceFlows(ValidatingMigrationInstruction instruction, ValidatingMigrationInstructions instructions, MigrationInstructionValidationReportImpl report) {
    ActivityImpl sourceActivity = instruction.getSourceActivity();
    ActivityImpl targetActivity = instruction.getTargetActivity();
    int numSourceIncomingFlows = sourceActivity.getIncomingTransitions().size();
    int numTargetIncomingFlows = targetActivity.getIncomingTransitions().size();
    if (numSourceIncomingFlows > numTargetIncomingFlows) {
        report.addFailure("The target gateway must have at least the same number " + "of incoming sequence flows that the source gateway has");
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)

Example 59 with ActivityImpl

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

the class GatewayMappingValidator method validateSingleInstruction.

protected void validateSingleInstruction(ValidatingMigrationInstruction instruction, ValidatingMigrationInstructions instructions, MigrationInstructionValidationReportImpl report) {
    ActivityImpl targetActivity = instruction.getTargetActivity();
    List<ValidatingMigrationInstruction> instructionsToTargetGateway = instructions.getInstructionsByTargetScope(targetActivity);
    if (instructionsToTargetGateway.size() > 1) {
        report.addFailure("Only one gateway can be mapped to gateway '" + targetActivity.getId() + "'");
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)

Example 60 with ActivityImpl

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

the class MigratingAsyncJobInstance method updateAsyncAfterTargetConfiguration.

protected void updateAsyncAfterTargetConfiguration(AsyncContinuationConfiguration currentConfiguration) {
    ActivityImpl targetActivity = (ActivityImpl) targetScope;
    List<PvmTransition> outgoingTransitions = targetActivity.getOutgoingTransitions();
    AsyncContinuationConfiguration targetConfiguration = new AsyncContinuationConfiguration();
    if (outgoingTransitions.isEmpty()) {
        targetConfiguration.setAtomicOperation(PvmAtomicOperation.ACTIVITY_END.getCanonicalName());
    } else {
        targetConfiguration.setAtomicOperation(PvmAtomicOperation.TRANSITION_NOTIFY_LISTENER_TAKE.getCanonicalName());
        if (outgoingTransitions.size() == 1) {
            targetConfiguration.setTransitionId(outgoingTransitions.get(0).getId());
        } else {
            TransitionImpl matchingTargetTransition = null;
            String currentTransitionId = currentConfiguration.getTransitionId();
            if (currentTransitionId != null) {
                matchingTargetTransition = targetActivity.findOutgoingTransition(currentTransitionId);
            }
            if (matchingTargetTransition != null) {
                targetConfiguration.setTransitionId(matchingTargetTransition.getId());
            } else {
                // should not happen since it is avoided by validation
                throw new ProcessEngineException("Cannot determine matching outgoing sequence flow");
            }
        }
    }
    jobEntity.setJobHandlerConfiguration(targetConfiguration);
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) AsyncContinuationConfiguration(org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)

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