本文整理汇总了Java中org.kie.internal.command.CommandFactory.newBatchExecution方法的典型用法代码示例。如果您正苦于以下问题:Java CommandFactory.newBatchExecution方法的具体用法?Java CommandFactory.newBatchExecution怎么用?Java CommandFactory.newBatchExecution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kie.internal.command.CommandFactory
的用法示例。
在下文中一共展示了CommandFactory.newBatchExecution方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRules
import org.kie.internal.command.CommandFactory; //导入方法依赖的package包/类
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;
}
示例2: insertAndFireAll
import org.kie.internal.command.CommandFactory; //导入方法依赖的package包/类
public void insertAndFireAll(Exchange exchange) {
final Message in = exchange.getIn();
final Object body = in.getBody();
final List<Command<?>> commands = new ArrayList<Command<?>>(2);
commands.add(CommandFactory.newInsert(body));
commands.add(CommandFactory.newFireAllRules());
Command<?> batch = CommandFactory.newBatchExecution(commands);
in.setBody(batch);
}
示例3: insertAndFireAll
import org.kie.internal.command.CommandFactory; //导入方法依赖的package包/类
/**
* Create commands for Drools engine.
*
* @param body {@link org.apache.camel.Exchange}
*/
public Command<ExecutionResults> insertAndFireAll(final Customer body) {
Command<?> insert = CommandFactory.newInsert(body, "customer");
@SuppressWarnings("unchecked")
Command<ExecutionResults> batch = CommandFactory
.newBatchExecution(Arrays.asList(insert));
return batch;
}
示例4: testSessionBatchExecutionCommand
import org.kie.internal.command.CommandFactory; //导入方法依赖的package包/类
@Test
public void testSessionBatchExecutionCommand() throws Exception {
Person john = new Person();
john.setName("John Smith");
List<Command> commands = new ArrayList<Command>();
commands.add(CommandFactory.newInsert(john, "john"));
BatchExecutionCommand batchExecutionCommand = CommandFactory.newBatchExecution(commands);
ExecutionResults response = (ExecutionResults)template.requestBody("direct:test-with-session", batchExecutionCommand);
assertTrue("Expected valid ExecutionResults object", response != null);
assertTrue("ExecutionResults missing expected fact", response.getFactHandle("john") != null);
assertTrue("ExecutionResults missing expected fact", response.getFactHandle("john") instanceof FactHandle);
}
示例5: testSessionBatchExecutionCommandWithHeader
import org.kie.internal.command.CommandFactory; //导入方法依赖的package包/类
@Test
public void testSessionBatchExecutionCommandWithHeader() throws Exception {
MockEndpoint mockResult = context.getEndpoint("mock:resultWithHeader", MockEndpoint.class);
String headerName = "testHeaderName";
String headerValue = "testHeaderValue";
Person john = new Person();
john.setName("John Smith");
List<Command> commands = new ArrayList<Command>();
commands.add(CommandFactory.newInsert(john, "john"));
BatchExecutionCommand batchExecutionCommand = CommandFactory.newBatchExecution(commands);
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(headerName, headerValue);
// set mock expectations
mockResult.expectedMessageCount(1);
mockResult.expectedHeaderReceived(headerName, headerValue);
// do test
template.requestBodyAndHeaders("direct:test-with-session-withHeader", batchExecutionCommand, headers);
ExecutionResults response = mockResult.getReceivedExchanges().get(0).getIn().getBody(ExecutionResults.class);
assertTrue("Expected valid ExecutionResults object", response != null);
assertTrue("ExecutionResults missing expected fact", response.getFactHandle("john") != null);
assertTrue("ExecutionResults missing expected fact", response.getFactHandle("john") instanceof FactHandle);
mockResult.assertIsSatisfied();
}
示例6: testInsert
import org.kie.internal.command.CommandFactory; //导入方法依赖的package包/类
/** bz771203
* creates batch-execution command with insert. Marshalls it to XML
* and send to drools */
@Test
public void testInsert() throws Exception {
Person p = new Person("Alice", "spicy meals", 30);
List<Command> commands = new ArrayList<Command>();
commands.add(CommandFactory.newInsert(p, "tempPerson"));
BatchExecutionCommand command = CommandFactory.newBatchExecution(commands);
String xmlCommand = template.requestBody("direct:marshall", command, String.class);
String xml = template.requestBody("direct:test-session", xmlCommand, String.class);
ExecutionResults res = (ExecutionResults)template.requestBody("direct:unmarshall", xml);
Object o = res.getFactHandle("tempPerson");
assertTrue("returned String instead of FactHandle instance", o instanceof FactHandle);
}