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;
}
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);
}
}
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));
}
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());
}
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;
}
Aggregations