org.kie.api.command.KieCommands Java Examples

The following examples show how to use org.kie.api.command.KieCommands. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BusinessRulesBean.java    From iot-ocp with Apache License 2.0 5 votes vote down vote up
public Measure processRules(@Body Measure measure) {
	
	KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(
			kieHost, kieUser,
			kiePassword);
	
	Set<Class<?>> jaxBClasses = new HashSet<Class<?>>();
	jaxBClasses.add(Measure.class);
	
	config.addJaxbClasses(jaxBClasses);
	config.setMarshallingFormat(MarshallingFormat.JAXB);
	RuleServicesClient client = KieServicesFactory.newKieServicesClient(config)
			.getServicesClient(RuleServicesClient.class);

       List<Command<?>> cmds = new ArrayList<Command<?>>();
	KieCommands commands = KieServices.Factory.get().getCommands();
	cmds.add(commands.newInsert(measure));
	
    GetObjectsCommand getObjectsCommand = new GetObjectsCommand();
    getObjectsCommand.setOutIdentifier("objects");

	
	cmds.add(commands.newFireAllRules());
	cmds.add(getObjectsCommand);
	BatchExecutionCommand myCommands = CommandFactory.newBatchExecution(cmds,
			"DecisionTableKS");
	ServiceResponse<ExecutionResults> response = client.executeCommandsWithResults("iot-ocp-businessrules-service", myCommands);
			
	List responseList = (List) response.getResult().getValue("objects");
	
	Measure responseMeasure = (Measure) responseList.get(0);
	
	return responseMeasure;

}
 
Example #2
Source File: KieServicesImpl.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public KieCommands getCommands() {
    // instantiating directly, but we might want to use the service registry instead
    return new CommandFactoryServiceImpl();
}
 
Example #3
Source File: DroolsStatelessSession.java    From Decision with Apache License 2.0 4 votes vote down vote up
public Results fireRules(List data) {
    Results res = new Results();

    KieCommands commands = kServices.getCommands();

    List<Command> cmds = new ArrayList<Command>();

    cmds.add(commands.newInsertElements(data));
    cmds.add(CommandFactory.newFireAllRules());
    cmds.add(CommandFactory.newQuery(QUERY_RESULT, QUERY_NAME));

    ExecutionResults er = session.execute(commands.newBatchExecution(cmds));

    this.addResults(res.getResults(), er, QUERY_RESULT);

    return res;
}
 
Example #4
Source File: KieServices.java    From kogito-runtimes with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the KieCommands, a factory for Commands
 * @return commands
 */
KieCommands getCommands();