Search in sources :

Example 1 with MigratingActivityInstance

use of org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance 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)

Example 2 with MigratingActivityInstance

use of org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance in project camunda-bpm-platform by camunda.

the class IncidentInstanceHandler method handleIncident.

protected void handleIncident(MigratingInstanceParseContext parseContext, IncidentEntity incident) {
    MigratingActivityInstance owningInstance = parseContext.getMigratingActivityInstanceById(incident.getExecution().getActivityInstanceId());
    if (owningInstance != null) {
        parseContext.consume(incident);
        MigratingIncident migratingIncident = new MigratingIncident(incident, owningInstance.getTargetScope());
        owningInstance.addMigratingDependentInstance(migratingIncident);
    }
}
Also used : MigratingIncident(org.camunda.bpm.engine.impl.migration.instance.MigratingIncident) MigratingActivityInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)

Example 3 with MigratingActivityInstance

use of org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance in project camunda-bpm-platform by camunda.

the class DefaultHistoryEventProducer method initActivityInstanceEvent.

protected void initActivityInstanceEvent(HistoricActivityInstanceEventEntity evt, MigratingActivityInstance migratingActivityInstance, HistoryEventType eventType) {
    PvmScope eventSource = migratingActivityInstance.getTargetScope();
    String activityInstanceId = migratingActivityInstance.getActivityInstanceId();
    MigratingActivityInstance parentInstance = migratingActivityInstance.getParent();
    String parentActivityInstanceId = null;
    if (parentInstance != null) {
        parentActivityInstanceId = parentInstance.getActivityInstanceId();
    }
    ExecutionEntity execution = migratingActivityInstance.resolveRepresentativeExecution();
    initActivityInstanceEvent(evt, execution, eventSource, activityInstanceId, parentActivityInstanceId, eventType);
}
Also used : PvmScope(org.camunda.bpm.engine.impl.pvm.PvmScope) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) MigratingActivityInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)

Example 4 with MigratingActivityInstance

use of org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance in project camunda-bpm-platform by camunda.

the class CompensationEventSubscriptionWalker method collectCompensationEventSubscriptions.

protected static List<EventSubscriptionEntity> collectCompensationEventSubscriptions(Collection<MigratingActivityInstance> activityInstances) {
    List<EventSubscriptionEntity> eventSubscriptions = new ArrayList<EventSubscriptionEntity>();
    for (MigratingActivityInstance activityInstance : activityInstances) {
        if (activityInstance.getSourceScope().isScope()) {
            ExecutionEntity scopeExecution = activityInstance.resolveRepresentativeExecution();
            eventSubscriptions.addAll(scopeExecution.getCompensateEventSubscriptions());
        }
    }
    return eventSubscriptions;
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ArrayList(java.util.ArrayList) MigratingActivityInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 5 with MigratingActivityInstance

use of org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance 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)

Aggregations

MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)7 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)4 MigratingTransitionInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingTransitionInstance)2 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)2 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)1 MigratingActivityInstanceVisitor (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstanceVisitor)1 MigratingCompensationEventSubscriptionInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingCompensationEventSubscriptionInstance)1 MigratingEventScopeInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingEventScopeInstance)1 MigratingIncident (org.camunda.bpm.engine.impl.migration.instance.MigratingIncident)1 MigratingProcessElementInstanceTopDownWalker (org.camunda.bpm.engine.impl.migration.instance.MigratingProcessElementInstanceTopDownWalker)1 MigrationCompensationInstanceVisitor (org.camunda.bpm.engine.impl.migration.instance.MigrationCompensationInstanceVisitor)1 MigratingActivityInstanceValidationReportImpl (org.camunda.bpm.engine.impl.migration.validation.instance.MigratingActivityInstanceValidationReportImpl)1 MigratingActivityInstanceValidator (org.camunda.bpm.engine.impl.migration.validation.instance.MigratingActivityInstanceValidator)1 MigratingCompensationInstanceValidator (org.camunda.bpm.engine.impl.migration.validation.instance.MigratingCompensationInstanceValidator)1 MigratingTransitionInstanceValidationReportImpl (org.camunda.bpm.engine.impl.migration.validation.instance.MigratingTransitionInstanceValidationReportImpl)1 MigratingTransitionInstanceValidator (org.camunda.bpm.engine.impl.migration.validation.instance.MigratingTransitionInstanceValidator)1 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)1