use of org.kie.server.api.model.cases.CaseMigrationReportInstance in project droolsjbpm-integration by kiegroup.
the class CaseInstanceMigrationIntegrationTest method testCarInsuranceClaimCaseMigrationWithSubprocess.
@Test
public void testCarInsuranceClaimCaseMigrationWithSubprocess() throws Exception {
// start case with users assigned to roles
String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN);
// let's verify case is created
assertCaseInstance(caseId);
caseClient.addDynamicSubProcess(CONTAINER_ID, caseId, PROCESS_DEF_ID, null);
List<ProcessInstance> processInstances = caseClient.getProcessInstances(CONTAINER_ID, caseId, Arrays.asList(1), 0, 10);
assertThat(processInstances).isNotNull();
assertThat(processInstances).hasSize(2);
for (ProcessInstance pi : processInstances) {
assertThat(pi.getContainerId()).isEqualTo(CONTAINER_ID);
}
Map<String, String> processMapping = new HashMap<>();
processMapping.put(CLAIM_CASE_DEF_ID, CLAIM_CASE_DEF_ID_2);
processMapping.put(PROCESS_DEF_ID, PROCESS_DEF_ID_2);
CaseMigrationReportInstance report = caseAdminClient.migrateCaseInstance(CONTAINER_ID, caseId, CONTAINER_ID_2, processMapping);
assertThat(report).isNotNull();
assertThat(report.isSuccessful()).isTrue();
assertMigratedCaseInstance(caseId);
processInstances = caseClient.getProcessInstances(CONTAINER_ID_2, caseId, Arrays.asList(1), 0, 10);
assertThat(processInstances).isNotNull();
assertThat(processInstances).hasSize(2);
for (ProcessInstance pi : processInstances) {
assertThat(pi.getContainerId()).isEqualTo(CONTAINER_ID_2);
}
}
use of org.kie.server.api.model.cases.CaseMigrationReportInstance in project droolsjbpm-integration by kiegroup.
the class CaseAdminResource method migrateCaseInstance.
@ApiOperation(value = "Migrates a specified case instance to another KIE container and case definition.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Case instance or Container Id not found"), @ApiResponse(code = 201, response = CaseMigrationReportInstance.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_MIGRATION_REPORT_JSON) })) })
@PUT
@Path(MIGRATE_CASE_INST_PUT_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response migrateCaseInstance(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that case instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of case instance to be migrated", required = true, example = "CASE-000000001") @PathParam("caseId") String caseId, @ApiParam(value = "container id that new case definition should be migrated to to", required = true) @QueryParam("targetContainerId") String targetContainerId, @ApiParam(value = "process and node mapping - unique ids of old definition to new definition given as Map of Maps - ProcessMapping should provide map of process definitions (mandatory), NodeMapping should provide map of node mappings (optional)", required = false, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_MIGRATION_MAP_JSON), @ExampleProperty(mediaType = XML, value = CASE_MIGRATION_MAP_XML) })) String payload) {
return invokeCaseOperation(headers, "", null, (Variant v, String type, Header... customHeaders) -> {
CaseMigrationReportInstance responseObject = caseAdminServiceBase.migrateCaseInstance(containerId, caseId, targetContainerId, payload, type);
logger.debug("Returning CREATED response with content '{}'", responseObject);
return createCorrectVariant(responseObject, headers, Response.Status.CREATED, customHeaders);
});
}
use of org.kie.server.api.model.cases.CaseMigrationReportInstance in project droolsjbpm-integration by kiegroup.
the class CaseAdminServicesClientImpl method migrateCaseInstance.
@Override
public CaseMigrationReportInstance migrateCaseInstance(String containerId, String caseId, String targetContainerId, Map<String, String> processMapping, Map<String, String> nodeMapping) {
CaseMigrationReportInstance report = null;
Map<String, Object> mappings = new HashMap<>();
mappings.put("ProcessMapping", processMapping);
mappings.put("NodeMapping", nodeMapping);
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(CASE_ID, caseId);
String queryString = "?targetContainerId=" + targetContainerId;
report = makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_CASE_URI + "/" + MIGRATE_CASE_INST_PUT_URI, valuesMap) + queryString, serialize(mappings), CaseMigrationReportInstance.class, new HashMap<>());
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseAdminService", "migrateCaseInstance", serialize(safeMap(mappings)), marshaller.getFormat().getType(), new Object[] { containerId, caseId, targetContainerId })));
ServiceResponse<CaseMigrationReportInstance> response = (ServiceResponse<CaseMigrationReportInstance>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
report = response.getResult();
}
return report;
}
use of org.kie.server.api.model.cases.CaseMigrationReportInstance in project droolsjbpm-integration by kiegroup.
the class CaseInstanceMigrationIntegrationTest method testCarInsuranceClaimCaseMigration.
@Test
public void testCarInsuranceClaimCaseMigration() throws Exception {
// start case with users assigned to roles
String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN);
// let's verify case is created
assertCaseInstance(caseId);
Map<String, String> processMapping = new HashMap<>();
processMapping.put(CLAIM_CASE_DEF_ID, CLAIM_CASE_DEF_ID_2);
CaseMigrationReportInstance report = caseAdminClient.migrateCaseInstance(CONTAINER_ID, caseId, CONTAINER_ID_2, processMapping);
assertThat(report).isNotNull();
assertThat(report.isSuccessful()).isTrue();
assertMigratedCaseInstance(caseId);
}
Aggregations