Search in sources :

Example 11 with MigrationInstruction

use of org.camunda.bpm.engine.migration.MigrationInstruction in project camunda-bpm-platform by camunda.

the class CompensationInstanceHandler method createMigratingEventSubscriptionInstance.

protected MigratingProcessElementInstance createMigratingEventSubscriptionInstance(MigratingInstanceParseContext parseContext, EventSubscriptionEntity element) {
    ActivityImpl compensationHandler = parseContext.getSourceProcessDefinition().findActivity(element.getActivityId());
    MigrationInstruction migrationInstruction = getMigrationInstruction(parseContext, compensationHandler);
    ActivityImpl targetScope = null;
    if (migrationInstruction != null) {
        ActivityImpl targetEventScope = (ActivityImpl) parseContext.getTargetActivity(migrationInstruction).getEventScope();
        targetScope = targetEventScope.findCompensationHandler();
    }
    MigratingCompensationEventSubscriptionInstance migratingCompensationInstance = parseContext.getMigratingProcessInstance().addCompensationSubscriptionInstance(migrationInstruction, element, compensationHandler, targetScope);
    parseContext.consume(element);
    return migratingCompensationInstance;
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigratingCompensationEventSubscriptionInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingCompensationEventSubscriptionInstance) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction)

Example 12 with MigrationInstruction

use of org.camunda.bpm.engine.migration.MigrationInstruction in project camunda-bpm-platform by camunda.

the class EventSubscriptionInstanceHandler method handle.

@Override
public void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance owningInstance, List<EventSubscriptionEntity> elements) {
    Map<String, EventSubscriptionDeclaration> targetDeclarations = getDeclarationsByTriggeringActivity(owningInstance.getTargetScope());
    for (EventSubscriptionEntity eventSubscription : elements) {
        if (!getSupportedEventTypes().contains(eventSubscription.getEventType())) {
            // ignore unsupported event subscriptions
            continue;
        }
        MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(eventSubscription.getActivityId());
        ActivityImpl targetActivity = parseContext.getTargetActivity(migrationInstruction);
        if (targetActivity != null && owningInstance.migratesTo(targetActivity.getEventScope())) {
            // the event subscription is migrated
            EventSubscriptionDeclaration targetDeclaration = targetDeclarations.remove(targetActivity.getId());
            owningInstance.addMigratingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription, targetActivity, migrationInstruction.isUpdateEventTrigger(), targetDeclaration));
        } else {
            // the event subscription will be removed
            owningInstance.addRemovingDependentInstance(new MigratingEventSubscriptionInstance(eventSubscription));
        }
        parseContext.consume(eventSubscription);
    }
    if (owningInstance.migrates()) {
        addEmergingEventSubscriptions(owningInstance, targetDeclarations);
    }
}
Also used : MigratingEventSubscriptionInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingEventSubscriptionInstance) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) EventSubscriptionDeclaration(org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 13 with MigrationInstruction

use of org.camunda.bpm.engine.migration.MigrationInstruction 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 14 with MigrationInstruction

use of org.camunda.bpm.engine.migration.MigrationInstruction in project camunda-bpm-platform by camunda.

the class MigrationExternalTaskTest method testProcessDefinitionWithoutIdField.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/externaltask/ExternalTaskWithoutIdTest.bpmn" })
public void testProcessDefinitionWithoutIdField() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deploy("org/camunda/bpm/engine/test/api/externaltask/ExternalTaskWithoutIdTest.bpmn").getDeployedProcessDefinitions().get(0);
    ProcessDefinition targetProcessDefinition = testHelper.deploy("org/camunda/bpm/engine/test/api/externaltask/ExternalTaskWithoutIdTest.bpmn").getDeployedProcessDefinitions().get(0);
    // external task is not mapped to new external task
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
    List<MigrationInstruction> instructions = migrationPlan.getInstructions();
    // test that the messageEventDefinition without an id isn't included
    assertEquals(2, instructions.size());
}
Also used : MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with MigrationInstruction

use of org.camunda.bpm.engine.migration.MigrationInstruction in project camunda-bpm-platform by camunda.

the class MigrationPlanAssert method hasInstructions.

public MigrationPlanAssert hasInstructions(MigrationInstructionAssert... instructionAsserts) {
    isNotNull();
    List<MigrationInstruction> notExpected = new ArrayList<MigrationInstruction>(actual.getInstructions());
    List<MigrationInstructionAssert> notFound = new ArrayList<MigrationInstructionAssert>();
    Collections.addAll(notFound, instructionAsserts);
    for (MigrationInstructionAssert instructionAssert : instructionAsserts) {
        for (MigrationInstruction instruction : actual.getInstructions()) {
            if (instructionAssert.sourceActivityId.equals(instruction.getSourceActivityId())) {
                notFound.remove(instructionAssert);
                notExpected.remove(instruction);
                assertEquals("Target activity ids do not match for instruction " + instruction, instructionAssert.targetActivityId, instruction.getTargetActivityId());
                if (instructionAssert.updateEventTrigger != null) {
                    assertEquals("Expected instruction to update event trigger: " + instructionAssert.updateEventTrigger + " but is: " + instruction.isUpdateEventTrigger(), instructionAssert.updateEventTrigger, instruction.isUpdateEventTrigger());
                }
            }
        }
    }
    if (!notExpected.isEmpty() || !notFound.isEmpty()) {
        StringBuilder builder = new StringBuilder();
        builder.append("\nActual migration instructions:\n\t").append(actual.getInstructions()).append("\n");
        if (!notExpected.isEmpty()) {
            builder.append("Unexpected migration instructions:\n\t").append(notExpected).append("\n");
        }
        if (!notFound.isEmpty()) {
            builder.append("Migration instructions missing:\n\t").append(notFound);
        }
        fail(builder.toString());
    }
    return this;
}
Also used : MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) ArrayList(java.util.ArrayList)

Aggregations

MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)18 Test (org.junit.Test)6 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)5 Matchers.anyString (org.mockito.Matchers.anyString)4 ArrayList (java.util.ArrayList)3 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)3 MigrationInstructionValidationReport (org.camunda.bpm.engine.migration.MigrationInstructionValidationReport)3 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)3 MigrationPlanValidationReport (org.camunda.bpm.engine.migration.MigrationPlanValidationReport)3 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)3 MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)2 ValidatingMigrationInstruction (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction)2 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)2 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)2 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)2 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 EventSubscriptionDeclaration (org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration)1 TimerDeclarationImpl (org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl)1 MigrationPlanImpl (org.camunda.bpm.engine.impl.migration.MigrationPlanImpl)1