use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class BaseKieServerClientKarafIntegrationTest method testCompleteInteractionWithKieServer.
protected void testCompleteInteractionWithKieServer(MarshallingFormat marshallingFormat) {
KieServicesConfiguration configuration = KieServicesFactory.newRestConfiguration(serverUrl, KieServerConstants.user, KieServerConstants.password);
configuration.setMarshallingFormat(marshallingFormat);
// configuration.addJaxbClasses(extraClasses);
// KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(configuration, kieContainer.getClassLoader());
KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(configuration, this.getClass().getClassLoader());
// query for all available process definitions
QueryServicesClient queryClient = kieServicesClient.getServicesClient(QueryServicesClient.class);
List<ProcessDefinition> processes = queryClient.findProcesses(0, 10);
System.out.println("\t######### Available processes" + processes);
ProcessServicesClient processClient = kieServicesClient.getServicesClient(ProcessServicesClient.class);
// get details of process definition
ProcessDefinition definition = processClient.getProcessDefinition(KieServerConstants.containerId, KieServerConstants.processId);
System.out.println("\t######### Definition details: " + definition);
// start process instance
Map<String, Object> params = new HashMap<String, Object>();
params.put("employee", KieServerConstants.user);
Long processInstanceId = processClient.startProcess(KieServerConstants.containerId, KieServerConstants.processId, params);
System.out.println("\t######### Process instance id: " + processInstanceId);
UserTaskServicesClient taskClient = kieServicesClient.getServicesClient(UserTaskServicesClient.class);
// find available tasks
List<TaskSummary> tasks = taskClient.findTasks(KieServerConstants.user, 0, 10);
System.out.println("\t######### Tasks: " + tasks);
// complete task
Long taskId = tasks.get(0).getId();
taskClient.startTask(KieServerConstants.containerId, taskId, KieServerConstants.user);
taskClient.completeTask(KieServerConstants.containerId, taskId, KieServerConstants.user, null);
// work with rules
List<ExecutableCommand<?>> commands = new ArrayList<ExecutableCommand<?>>();
BatchExecutionCommandImpl executionCommand = new BatchExecutionCommandImpl(commands);
executionCommand.setLookup("defaultKieSession");
InsertObjectCommand insertObjectCommand = new InsertObjectCommand();
insertObjectCommand.setOutIdentifier("person");
insertObjectCommand.setObject("john");
FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
commands.add(insertObjectCommand);
commands.add(fireAllRulesCommand);
RuleServicesClient ruleClient = kieServicesClient.getServicesClient(RuleServicesClient.class);
ruleClient.executeCommands(KieServerConstants.containerId, executionCommand);
System.out.println("\t######### Rules executed");
// at the end abort process instance
processClient.abortProcessInstance(KieServerConstants.containerId, processInstanceId);
ProcessInstance processInstance = queryClient.findProcessInstanceById(processInstanceId);
System.out.println("\t######### ProcessInstance: " + processInstance);
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getProcessesByDeploymentIdProcessId.
@ApiOperation(value = "Returns information about a specified process definition in a specified KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = ProcessDefinition.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_DEF_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_DEFINITIONS_BY_CONTAINER_ID_DEF_ID_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessesByDeploymentIdProcessId(@Context HttpHeaders headers, @ApiParam(value = "container id that process definition belongs to", required = true) @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "process id to load process definition", required = true) @PathParam(PROCESS_ID) String processId) {
Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
ProcessDefinition processDesc = null;
try {
processDesc = runtimeDataServiceBase.getProcessesByDeploymentIdProcessId(containerId, processId);
return createCorrectVariant(processDesc, headers, Response.Status.OK, conversationIdHeader);
} catch (IllegalArgumentException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, containerId), v, conversationIdHeader);
}
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class ProcessClientIntegrationTest method testGetProcessDefinition.
@Test
public void testGetProcessDefinition() {
final Map<String, Object> parameters = new HashMap<>();
parameters.put("containerId", CONTAINER_ID);
parameters.put("processId", PROCESS_ID);
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("process");
executionServerCommand.setOperation("getProcessDefinition");
executionServerCommand.setParameters(parameters);
final Object response = runOnExecutionServer(executionServerCommand);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response).isInstanceOf(ProcessDefinition.class);
final ProcessDefinition processDefinition = (ProcessDefinition) response;
Assertions.assertThat(processDefinition.getName()).isEqualTo(PROCESS_ID);
Assertions.assertThat(processDefinition.getVersion()).isEqualTo("1.0");
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class QueryClientIntegrationTest method testFindProcessesById.
@Test
public void testFindProcessesById() {
final Map<String, Object> parameters = new HashMap<>();
parameters.put("processId", PROCESS_ID);
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("query");
executionServerCommand.setOperation("findProcessesById");
executionServerCommand.setParameters(parameters);
final Object response = runOnExecutionServer(executionServerCommand);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response).isInstanceOf(List.class);
final List<ProcessDefinition> processDefinitions = (List<ProcessDefinition>) response;
Assertions.assertThat(processDefinitions).isNotEmpty();
final List<String> processIds = processDefinitions.stream().map(p -> p.getId()).collect(Collectors.toList());
Assertions.assertThat(processIds).contains(PROCESS_ID);
}
use of org.kie.server.api.model.definition.ProcessDefinition in project droolsjbpm-integration by kiegroup.
the class QueryClientIntegrationTest method testFindProcessByContainerIdProcessId.
@Test
public void testFindProcessByContainerIdProcessId() {
final Map<String, Object> parameters = new HashMap<>();
parameters.put("containerId", CONTAINER_ID);
parameters.put("processId", PROCESS_ID);
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("query");
executionServerCommand.setOperation("findProcessByContainerIdProcessId");
executionServerCommand.setParameters(parameters);
final Object response = runOnExecutionServer(executionServerCommand);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response).isInstanceOf(ProcessDefinition.class);
final ProcessDefinition processDefinition = (ProcessDefinition) response;
Assertions.assertThat(processDefinition.getContainerId()).isEqualTo(CONTAINER_ID);
Assertions.assertThat(processDefinition.getId()).isEqualTo(PROCESS_ID);
}
Aggregations