use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationRestServiceImpl method generateMigrationPlan.
public MigrationPlanDto generateMigrationPlan(MigrationPlanGenerationDto generationDto) {
RuntimeService runtimeService = processEngine.getRuntimeService();
String sourceProcessDefinitionId = generationDto.getSourceProcessDefinitionId();
String targetProcessDefinitionId = generationDto.getTargetProcessDefinitionId();
try {
MigrationInstructionsBuilder instructionsBuilder = runtimeService.createMigrationPlan(sourceProcessDefinitionId, targetProcessDefinitionId).mapEqualActivities();
if (generationDto.isUpdateEventTriggers()) {
instructionsBuilder = instructionsBuilder.updateEventTriggers();
}
MigrationPlan migrationPlan = instructionsBuilder.build();
return MigrationPlanDto.from(migrationPlan);
} catch (BadUserRequestException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e, e.getMessage());
}
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrateProcessInstanceAsyncTest method testMigrate.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/authorization/oneIncidentProcess.bpmn20.xml")
public void testMigrate() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
// when
authRule.init(scenario).withUser("userId").bindResource("sourceDefinitionKey", sourceDefinition.getKey()).bindResource("targetDefinitionKey", targetDefinition.getKey()).bindResource("processInstance", processInstance.getId()).start();
batch = engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).executeAsync();
// then
if (authRule.assertScenario(scenario)) {
Assert.assertEquals(1, engineRule.getManagementService().createBatchQuery().count());
}
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrateProcessInstanceAsyncTest method testMigrateWithQuery.
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/authorization/oneIncidentProcess.bpmn20.xml")
public void testMigrateWithQuery() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
ProcessInstanceQuery query = engineRule.getRuntimeService().createProcessInstanceQuery();
// when
authRule.init(scenario).withUser("userId").bindResource("sourceDefinitionKey", sourceDefinition.getKey()).bindResource("targetDefinitionKey", targetDefinition.getKey()).bindResource("processInstance", processInstance.getId()).start();
batch = engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceQuery(query).executeAsync();
// then
if (authRule.assertScenario(scenario)) {
Assert.assertEquals(1, engineRule.getManagementService().createBatchQuery().count());
}
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MultiTenancyMigrationTest method canMigrateInstanceWithTenantIdToDefinitionWithoutTenantId.
@Test
public void canMigrateInstanceWithTenantIdToDefinitionWithoutTenantId() {
// given
ProcessDefinition sourceDefinition = testHelper.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
// when
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then
assertMigratedTo(processInstance, targetDefinition);
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MultiTenancyMigrationTest method canCreateMigrationPlanFromTenantToNoTenant.
@Test
public void canCreateMigrationPlanFromTenantToNoTenant() {
// given
ProcessDefinition sharedDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition tenantDefinition = testHelper.deployForTenantAndGetDefinition(TENANT_ONE, ProcessModels.ONE_TASK_PROCESS);
// when
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(tenantDefinition.getId(), sharedDefinition.getId()).mapEqualActivities().build();
// then
Assert.assertNotNull(migrationPlan);
}
Aggregations