Search in sources :

Example 11 with MigrationReportInstance

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

the class ProcessAdminResource method migrateProcessInstance.

@ApiOperation(value = "Migrates a specified process instance to a process definition in another KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process instance or Container Id not found"), @ApiResponse(code = 404, message = "Container Id not found"), @ApiResponse(code = 201, response = MigrationReportInstance.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_MIGRATION_REPORT_RESPONSE_JSON) })) })
@PUT
@Path(MIGRATE_PROCESS_INST_PUT_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response migrateProcessInstance(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of process instance to be migrated", required = true, example = "123") @PathParam(PROCESS_INST_ID) Long processInstanceId, @ApiParam(value = "container id that new process definition belongs to", required = true) @QueryParam("targetContainerId") String targetContainerId, @ApiParam(value = "process definition that process instance should be migrated to", required = true) @QueryParam("targetProcessId") String targetProcessId, @ApiParam(value = "node mapping - unique ids of old definition to new definition given as Map", required = false, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = SIMPLE_VAR_MAP_JSON), @ExampleProperty(mediaType = XML, value = SIMPLE_VAR_MAP_XML) })) String payload) {
    Variant v = getVariant(headers);
    String type = getContentType(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        MigrationReportInstance reportInstance = processAdminServiceBase.migrateProcessInstance(containerId, processInstanceId, targetContainerId, targetProcessId, payload, type);
        return createCorrectVariant(reportInstance, headers, Response.Status.CREATED, conversationIdHeader);
    } catch (ProcessInstanceNotFoundException e) {
        return notFound(MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId), v, conversationIdHeader);
    } catch (DeploymentNotFoundException e) {
        return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), v, conversationIdHeader);
    }
}
Also used : RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) Variant(javax.ws.rs.core.Variant) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) MigrationReportInstance(org.kie.server.api.model.admin.MigrationReportInstance) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) NodeInstanceNotFoundException(org.jbpm.services.api.NodeInstanceNotFoundException) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) ExecutionErrorNotFoundException(org.jbpm.services.api.admin.ExecutionErrorNotFoundException) NodeNotFoundException(org.jbpm.services.api.NodeNotFoundException) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) PUT(javax.ws.rs.PUT)

Example 12 with MigrationReportInstance

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

the class ConvertUtils method convertMigrationReports.

public static MigrationReportInstanceList convertMigrationReports(List<MigrationReport> reports) {
    if (reports == null) {
        return new MigrationReportInstanceList();
    }
    MigrationReportInstance[] reportInstances = new MigrationReportInstance[reports.size()];
    int index = 0;
    for (MigrationReport report : reports) {
        MigrationReportInstance instance = convertMigrationReport(report);
        reportInstances[index] = instance;
        index++;
    }
    return new MigrationReportInstanceList(reportInstances);
}
Also used : CaseMigrationReportInstance(org.kie.server.api.model.cases.CaseMigrationReportInstance) MigrationReportInstance(org.kie.server.api.model.admin.MigrationReportInstance) MigrationReportInstanceList(org.kie.server.api.model.admin.MigrationReportInstanceList) CaseMigrationReport(org.jbpm.casemgmt.api.admin.CaseMigrationReport) MigrationReport(org.jbpm.services.api.admin.MigrationReport)

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