Search in sources :

Example 1 with MigrationObserverBehavior

use of org.camunda.bpm.engine.impl.pvm.delegate.MigrationObserverBehavior in project camunda-bpm-platform by camunda.

the class ActivityInstanceHandler method handle.

@Override
public void handle(MigratingInstanceParseContext parseContext, ActivityInstance element) {
    MigratingActivityInstance migratingInstance = null;
    MigrationInstruction applyingInstruction = parseContext.getInstructionFor(element.getActivityId());
    ScopeImpl sourceScope = null;
    ScopeImpl targetScope = null;
    ExecutionEntity representativeExecution = parseContext.getMapping().getExecution(element);
    if (element.getId().equals(element.getProcessInstanceId())) {
        sourceScope = parseContext.getSourceProcessDefinition();
        targetScope = parseContext.getTargetProcessDefinition();
    } else {
        sourceScope = parseContext.getSourceProcessDefinition().findActivity(element.getActivityId());
        if (applyingInstruction != null) {
            String activityId = applyingInstruction.getTargetActivityId();
            targetScope = parseContext.getTargetProcessDefinition().findActivity(activityId);
        }
    }
    migratingInstance = parseContext.getMigratingProcessInstance().addActivityInstance(applyingInstruction, element, sourceScope, targetScope, representativeExecution);
    MigratingActivityInstance parentInstance = parseContext.getMigratingActivityInstanceById(element.getParentActivityInstanceId());
    if (parentInstance != null) {
        migratingInstance.setParent(parentInstance);
    }
    CoreActivityBehavior<?> sourceActivityBehavior = sourceScope.getActivityBehavior();
    if (sourceActivityBehavior instanceof MigrationObserverBehavior) {
        ((MigrationObserverBehavior) sourceActivityBehavior).onParseMigratingInstance(parseContext, migratingInstance);
    }
    parseContext.submit(migratingInstance);
    parseTransitionInstances(parseContext, migratingInstance);
    parseDependentInstances(parseContext, migratingInstance);
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigrationObserverBehavior(org.camunda.bpm.engine.impl.pvm.delegate.MigrationObserverBehavior) MigratingActivityInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Aggregations

MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)1 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)1 MigrationObserverBehavior (org.camunda.bpm.engine.impl.pvm.delegate.MigrationObserverBehavior)1 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)1 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)1