Search in sources :

Example 1 with MigrationReportInstance

use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.

the class ConvertUtils method convertReports.

public static MigrationReportInstance[] convertReports(List<MigrationReport> entries) {
    MigrationReportInstance[] reports = new MigrationReportInstance[entries.size()];
    int counter = 0;
    if (entries != null) {
        for (MigrationReport entry : entries) {
            reports[counter++] = convertMigrationReport(entry);
        }
    }
    return reports;
}
Also used : CaseMigrationReportInstance(org.kie.server.api.model.cases.CaseMigrationReportInstance) MigrationReportInstance(org.kie.server.api.model.admin.MigrationReportInstance) CaseMigrationReport(org.jbpm.casemgmt.api.admin.CaseMigrationReport) MigrationReport(org.jbpm.services.api.admin.MigrationReport)

Example 2 with MigrationReportInstance

use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.

the class ProcessInstanceMigrationIntegrationTest method testUpgradeProcessInstanceWithNodeMapping.

@Test
public void testUpgradeProcessInstanceWithNodeMapping() {
    Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION);
    try {
        List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(1, tasks.size());
        TaskSummary task = tasks.get(0);
        assertEquals("Evaluate items?", tasks.get(0).getName());
        assertEquals(CONTAINER_ID, task.getContainerId());
        assertEquals(PROCESS_ID_EVALUATION, task.getProcessId());
        assertEquals(processInstanceId, task.getProcessInstanceId());
        Map<String, String> nodeMapping = new HashMap<String, String>();
        nodeMapping.put("_4E8E7545-FB70-494E-9136-2B9ABE655889", "_56FB3E50-DEDD-415B-94DD-0357C91836B9");
        // migrate process instance to evaluation 2 in container 2
        MigrationReportInstance report = processAdminClient.migrateProcessInstance(CONTAINER_ID, processInstanceId, CONTAINER_ID_2, PROCESS_ID_EVALUATION_2, nodeMapping);
        assertNotNull(report);
        assertTrue(report.isSuccessful());
        // migrated to Approve user task
        tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(1, tasks.size());
        task = tasks.get(0);
        assertEquals("Approve", task.getName());
        assertEquals(CONTAINER_ID_2, task.getContainerId());
        assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
        assertEquals(processInstanceId, task.getProcessInstanceId());
    } finally {
        try {
            processClient.getProcessInstance(CONTAINER_ID_2, processInstanceId);
            processClient.abortProcessInstance(CONTAINER_ID_2, processInstanceId);
        } catch (KieServicesException e) {
            processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
        }
    }
}
Also used : HashMap(java.util.HashMap) MigrationReportInstance(org.kie.server.api.model.admin.MigrationReportInstance) TaskSummary(org.kie.server.api.model.instance.TaskSummary) KieServicesException(org.kie.server.api.exception.KieServicesException) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 3 with MigrationReportInstance

use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.

the class ProcessInstanceMigrationIntegrationTest method testUpgradeProcessInstance.

@Test
public void testUpgradeProcessInstance() {
    Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION);
    try {
        List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(1, tasks.size());
        TaskSummary task = tasks.get(0);
        assertEquals("Evaluate items?", tasks.get(0).getName());
        assertEquals(CONTAINER_ID, task.getContainerId());
        assertEquals(PROCESS_ID_EVALUATION, task.getProcessId());
        assertEquals(processInstanceId, task.getProcessInstanceId());
        // migrate process instance to evaluation 2 in container 2
        MigrationReportInstance report = processAdminClient.migrateProcessInstance(CONTAINER_ID, processInstanceId, CONTAINER_ID_2, PROCESS_ID_EVALUATION_2);
        assertNotNull(report);
        assertTrue(report.isSuccessful());
        // it stays in the same task
        tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(1, tasks.size());
        task = tasks.get(0);
        assertEquals("Evaluate items?", task.getName());
        assertEquals(CONTAINER_ID_2, task.getContainerId());
        assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
        assertEquals(processInstanceId, task.getProcessInstanceId());
        taskClient.completeAutoProgress(CONTAINER_ID_2, task.getId(), USER_YODA, null);
        // but next task should be Approve user task
        tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(1, tasks.size());
        task = tasks.get(0);
        assertEquals("Approve", task.getName());
        assertEquals(CONTAINER_ID_2, task.getContainerId());
        assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
        assertEquals(processInstanceId, task.getProcessInstanceId());
    } finally {
        try {
            processClient.getProcessInstance(CONTAINER_ID_2, processInstanceId);
            processClient.abortProcessInstance(CONTAINER_ID_2, processInstanceId);
        } catch (KieServicesException e) {
            processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
        }
    }
}
Also used : MigrationReportInstance(org.kie.server.api.model.admin.MigrationReportInstance) TaskSummary(org.kie.server.api.model.instance.TaskSummary) KieServicesException(org.kie.server.api.exception.KieServicesException) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 4 with MigrationReportInstance

use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.

the class ProcessInstanceMigrationIntegrationTest method testUpgradeProcessInstances.

@Test
public void testUpgradeProcessInstances() {
    List<Long> ids = new ArrayList<Long>();
    for (int i = 0; i < 5; i++) {
        Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION);
        ids.add(processInstanceId);
    }
    try {
        List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(5, tasks.size());
        for (TaskSummary task : tasks) {
            assertEquals("Evaluate items?", tasks.get(0).getName());
            assertEquals(CONTAINER_ID, task.getContainerId());
            assertEquals(PROCESS_ID_EVALUATION, task.getProcessId());
        }
        // migrate process instance to evaluation 2 in container 2
        List<MigrationReportInstance> reports = processAdminClient.migrateProcessInstances(CONTAINER_ID, ids, CONTAINER_ID_2, PROCESS_ID_EVALUATION_2);
        assertNotNull(reports);
        assertEquals(5, reports.size());
        for (MigrationReportInstance report : reports) {
            assertTrue(report.isSuccessful());
        }
        // it stays in the same task
        tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(5, tasks.size());
        for (TaskSummary task : tasks) {
            assertEquals("Evaluate items?", tasks.get(0).getName());
            assertEquals(CONTAINER_ID_2, task.getContainerId());
            assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
            taskClient.completeAutoProgress(CONTAINER_ID_2, task.getId(), USER_YODA, null);
        }
        // but next task should be Approve user task
        tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
        assertEquals(5, tasks.size());
        for (TaskSummary task : tasks) {
            assertEquals("Approve", task.getName());
            assertEquals(CONTAINER_ID_2, task.getContainerId());
            assertEquals(PROCESS_ID_EVALUATION_2, task.getProcessId());
        }
    } finally {
        for (Long processInstanceId : ids) {
            try {
                processClient.getProcessInstance(CONTAINER_ID_2, processInstanceId);
                processClient.abortProcessInstance(CONTAINER_ID_2, processInstanceId);
            } catch (KieServicesException e) {
                processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
            }
        }
    }
}
Also used : MigrationReportInstance(org.kie.server.api.model.admin.MigrationReportInstance) ArrayList(java.util.ArrayList) TaskSummary(org.kie.server.api.model.instance.TaskSummary) KieServicesException(org.kie.server.api.exception.KieServicesException) Test(org.junit.Test) JbpmKieServerBaseIntegrationTest(org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)

Example 5 with MigrationReportInstance

use of org.kie.server.api.model.admin.MigrationReportInstance in project droolsjbpm-integration by kiegroup.

the class ProcessInstanceMigrationIntegrationTest method assertMigrateProcessInstanceWithSubprocess.

private void assertMigrateProcessInstanceWithSubprocess(Long processParentInstanceId, String sourceContainerId, String targetContainerId, MigrationSpecification spec, int totalMigratedInstances) {
    List<MigrationReportInstance> reports = processAdminClient.migrateProcessInstanceWithSubprocess(sourceContainerId, processParentInstanceId, targetContainerId, spec);
    assertNotNull(reports);
    for (MigrationReportInstance report : reports) {
        assertTrue(report.isSuccessful());
    }
    logger.info("process migration complete in container {} with id parent {}", targetContainerId, processParentInstanceId);
    assertEquals(totalMigratedInstances, reports.size());
}
Also used : MigrationReportInstance(org.kie.server.api.model.admin.MigrationReportInstance)

Aggregations

MigrationReportInstance (org.kie.server.api.model.admin.MigrationReportInstance)12 Test (org.junit.Test)6 HashMap (java.util.HashMap)4 KieServicesException (org.kie.server.api.exception.KieServicesException)4 TaskSummary (org.kie.server.api.model.instance.TaskSummary)4 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)4 MigrationReport (org.jbpm.services.api.admin.MigrationReport)3 ArrayList (java.util.ArrayList)2 CaseMigrationReport (org.jbpm.casemgmt.api.admin.CaseMigrationReport)2 MigrationReportInstanceList (org.kie.server.api.model.admin.MigrationReportInstanceList)2 CaseMigrationReportInstance (org.kie.server.api.model.cases.CaseMigrationReportInstance)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Variant (javax.ws.rs.core.Variant)1 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)1 NodeInstanceNotFoundException (org.jbpm.services.api.NodeInstanceNotFoundException)1