use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessInstanceByCorrelationKey.
@Override
public ProcessInstance findProcessInstanceByCorrelationKey(CorrelationKey correlationKey) {
ProcessInstance result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CORRELATION_KEY, correlationKey.toExternalForm());
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCE_BY_CORRELATION_KEY_GET_URI, valuesMap), ProcessInstance.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstanceByCorrelationKey", new Object[] { correlationKey.toExternalForm() })));
ServiceResponse<ProcessInstance> response = (ServiceResponse<ProcessInstance>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
return response.getResult();
}
return result;
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class TaskAssigningIntegrationTest method task_assigning_with_skills.
@Test
public void task_assigning_with_skills() {
// Skip for MySQL and MariaDB until PLANNER-2079 is fixed
assumeFalse(TestConfig.isMySqlDataSource());
assumeFalse(TestConfig.isMariaDbDataSource());
Map<String, Object> parameters = new HashMap<>();
parameters.put("cardType", "VISA");
parameters.put("language", "ZH");
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID, parameters);
// maciek is in the CreditAnalyst group and has a VISA skill => should be assigned to the ResolveDispute task.
doNextTaskByUser("maciek");
// mary is in the ClientRelations group and has a ZH (Chinese) skill => should be assigned to the NotifyCustomer task.
doNextTaskByUser("mary");
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertThat(processInstance).isNotNull();
assertThat(processInstance.getState().intValue()).isEqualTo(org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED);
}
use of org.kie.server.api.model.instance.ProcessInstance 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.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class AbstractRemoteIntegrationTest method findActiveProcesses.
protected List<ProcessInstance> findActiveProcesses() {
final List<Integer> statuses = Arrays.asList(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE);
final Map<String, Object> parameters = new HashMap<>();
parameters.put("status", statuses);
parameters.put("page", "0");
parameters.put("pageSize", "100");
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("query");
executionServerCommand.setOperation("findProcessInstancesByStatus");
executionServerCommand.setParameters(parameters);
final Object response = runOnExecutionServer(executionServerCommand);
final List<ProcessInstance> processInstances = (List<ProcessInstance>) response;
return processInstances;
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class QueryClientIntegrationTest method testFindProcessInstancesByStatus.
@Test
public void testFindProcessInstancesByStatus() {
final Long processInstanceId = startProcess(CONTAINER_ID, PROCESS_WITH_SIGNAL_ID);
final List<Integer> statuses = Arrays.asList(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE);
final Map<String, Object> parameters = new HashMap<>();
parameters.put("status", statuses);
parameters.put("page", "0");
parameters.put("pageSize", "10");
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("query");
executionServerCommand.setOperation("findProcessInstancesByStatus");
executionServerCommand.setParameters(parameters);
final Object response = runOnExecutionServer(executionServerCommand);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response).isInstanceOf(List.class);
final List<ProcessInstance> processInstances = (List<ProcessInstance>) response;
Assertions.assertThat(processInstances).isNotEmpty();
final List<Long> processInstancesIds = processInstances.stream().map(p -> p.getId()).collect(Collectors.toList());
Assertions.assertThat(processInstancesIds).contains(processInstanceId);
sendSignalToProcessInstance(CONTAINER_ID, processInstanceId, SIGNAL_NAME);
}
Aggregations