use of org.kie.server.client.RuleServicesClient in project rhpam-7-openshift-image by jboss-container-images.
the class HelloRulesClient method runRemote.
private void runRemote(HelloRulesCallback callback, KieServicesConfiguration config) {
MarshallingFormat marshallingFormat = getMarshallingFormat();
config.setMarshallingFormat(marshallingFormat);
if (MarshallingFormat.JAXB.equals(marshallingFormat)) {
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(Greeting.class);
classes.add(Person.class);
config.addExtraClasses(classes);
}
RuleServicesClient client = KieServicesFactory.newKieServicesClient(config).getServicesClient(RuleServicesClient.class);
BatchExecutionCommand batch = createBatch();
ServiceResponse<ExecutionResults> response = client.executeCommandsWithResults("rhpam-kieserver-decisions", batch);
ExecutionResults execResults = response.getResult();
handleResults(callback, execResults);
}
use of org.kie.server.client.RuleServicesClient in project rhpam-7-openshift-image by jboss-container-images.
the class LibraryClient method runRemote.
private void runRemote(PrintWriter out, KieServicesConfiguration kiecfg) throws Exception {
appcfg.setKieSession(null);
MarshallingFormat marshallingFormat = appcfg.getMarshallingFormat();
out.println(String.format("Using %s MarshallingFormat.%s", marshallingFormat.getType(), marshallingFormat.name()));
kiecfg.setMarshallingFormat(marshallingFormat);
if (MarshallingFormat.JAXB.equals(marshallingFormat)) {
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(Book.class);
classes.add(Loan.class);
classes.add(LoanRequest.class);
classes.add(LoanResponse.class);
classes.add(ReturnRequest.class);
classes.add(ReturnResponse.class);
classes.add(Suggestion.class);
classes.add(SuggestionRequest.class);
classes.add(SuggestionResponse.class);
kiecfg.addExtraClasses(classes);
}
KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(kiecfg);
RuleServicesClient ruleServicesClient = kieServicesClient.getServicesClient(RuleServicesClient.class);
ProcessServicesClient processServicesClient = kieServicesClient.getServicesClient(ProcessServicesClient.class);
appcfg.setRuleServicesClient(ruleServicesClient);
appcfg.setProcessServicesClient(processServicesClient);
runApp(out);
}
use of org.kie.server.client.RuleServicesClient in project kiegroup-examples by tkobayas.
the class StatelessTest method testRule.
@Test
public void testRule() {
KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(BASE_URL, USERNAME, PASSWORD);
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(Person.class);
config.addExtraClasses(classes);
config.setMarshallingFormat(MarshallingFormat.JSON);
KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
RuleServicesClient ruleClient = client.getServicesClient(RuleServicesClient.class);
List<Command<?>> commands = new ArrayList<Command<?>>();
KieCommands commandsFactory = KieServices.Factory.get().getCommands();
commands.add(commandsFactory.newInsert(Integer.valueOf(10), "fact-10"));
commands.add(commandsFactory.newFireAllRules("fire-result"));
BatchExecutionCommand batchExecution = commandsFactory.newBatchExecution(commands, KSESSION_NAME);
ServiceResponse<ExecutionResults> response = ruleClient.executeCommandsWithResults(CONTAINER_ID, batchExecution);
System.out.println("-----------------------------------");
System.out.println(response);
// No need to dispose stateless ksession
}
use of org.kie.server.client.RuleServicesClient in project kiegroup-examples by tkobayas.
the class StatelessTestInteger method testRule.
@Test
public void testRule() {
KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(BASE_URL, USERNAME, PASSWORD);
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(Person.class);
config.addExtraClasses(classes);
config.setMarshallingFormat(MarshallingFormat.JSON);
KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
RuleServicesClient ruleClient = client.getServicesClient(RuleServicesClient.class);
List<Command<?>> commands = new ArrayList<Command<?>>();
KieCommands commandsFactory = KieServices.Factory.get().getCommands();
commands.add(commandsFactory.newInsert(Integer.valueOf(10), "fact-10"));
commands.add(commandsFactory.newFireAllRules("fire-result"));
BatchExecutionCommand batchExecution = commandsFactory.newBatchExecution(commands, KSESSION_NAME);
ServiceResponse<ExecutionResults> response = ruleClient.executeCommandsWithResults(CONTAINER_ID, batchExecution);
System.out.println("-----------------------------------");
System.out.println(response);
// No need to dispose stateless ksession
}
use of org.kie.server.client.RuleServicesClient in project kiegroup-examples by tkobayas.
the class StatelessTestOrig method testRule.
@Test
public void testRule() {
KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(BASE_URL, USERNAME, PASSWORD);
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(Person.class);
config.addExtraClasses(classes);
KieServicesClient client = KieServicesFactory.newKieServicesClient(config);
RuleServicesClient ruleClient = client.getServicesClient(RuleServicesClient.class);
List<Command<?>> commands = new ArrayList<Command<?>>();
KieCommands commandsFactory = KieServices.Factory.get().getCommands();
Person person = new Person("John", 36);
commands.add(commandsFactory.newSetGlobal(GLOBAL_IDENTIFIER, new ArrayList<>()));
commands.add(commandsFactory.newInsert(person, "fact-" + person.getName()));
commands.add(commandsFactory.newFireAllRules("fire-result"));
commands.add(commandsFactory.newGetGlobal(GLOBAL_IDENTIFIER));
BatchExecutionCommand batchExecution = commandsFactory.newBatchExecution(commands, KSESSION_NAME);
ServiceResponse<ExecutionResults> response = ruleClient.executeCommandsWithResults(CONTAINER_ID, batchExecution);
System.out.println("-----------------------------------");
System.out.println(response);
List<Object> results = (List<Object>) response.getResult().getValue(GLOBAL_IDENTIFIER);
System.out.println("results = " + results);
// No need to dispose stateless ksession
}
Aggregations