Search in sources :

Example 1 with MigrationPlan

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());
    }
}
Also used : RuntimeService(org.camunda.bpm.engine.RuntimeService) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) MigrationInstructionsBuilder(org.camunda.bpm.engine.migration.MigrationInstructionsBuilder) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 2 with MigrationPlan

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());
    }
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 3 with MigrationPlan

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());
    }
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with MigrationPlan

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);
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Example 5 with MigrationPlan

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);
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Aggregations

MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)485 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)474 Test (org.junit.Test)474 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)272 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)67 Job (org.camunda.bpm.engine.runtime.Job)48 Task (org.camunda.bpm.engine.task.Task)45 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)26 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)22 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)22 MigratingProcessInstanceValidationException (org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException)21 UserTask (org.camunda.bpm.model.bpmn.instance.UserTask)21 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)20 Incident (org.camunda.bpm.engine.runtime.Incident)14 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)14 MigratingBpmnEventTrigger (org.camunda.bpm.engine.test.api.runtime.migration.util.MigratingBpmnEventTrigger)14 Batch (org.camunda.bpm.engine.batch.Batch)13 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)13 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)13 Execution (org.camunda.bpm.engine.runtime.Execution)11