当前位置: 首页>>代码示例>>Java>>正文


Java BatchExecutionCommand类代码示例

本文整理汇总了Java中org.kie.api.command.BatchExecutionCommand的典型用法代码示例。如果您正苦于以下问题:Java BatchExecutionCommand类的具体用法?Java BatchExecutionCommand怎么用?Java BatchExecutionCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BatchExecutionCommand类属于org.kie.api.command包,在下文中一共展示了BatchExecutionCommand类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processRules

import org.kie.api.command.BatchExecutionCommand; //导入依赖的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;

}
 
开发者ID:sabre1041,项目名称:iot-ocp,代码行数:36,代码来源:BusinessRulesBean.java

示例2: main

import org.kie.api.command.BatchExecutionCommand; //导入依赖的package包/类
public static void main(String[] args) {

    Drug seldane = new Drug();
    seldane.setDrugName("Seldane");
    Drug biaxin = new Drug();
    biaxin.setDrugName("Biaxin");

    Patient patient = new Patient();

    patient.setfName("Goku");
    patient.setPerscription(seldane);
    patient.getDrugList().add(biaxin);

    List<GenericCommand<?>> commands = new ArrayList<>();

    commands.add(new InsertObjectCommand(patient));
    commands.add(new FireAllRulesCommand());

    BatchExecutionCommand command = (BatchExecutionCommand) new BatchExecutionCommandImpl(commands);
    String json = BatchExecutionHelper.newJSonMarshaller().toXML(command);

    System.out.println(json);
  }
 
开发者ID:diabolicallabs,项目名称:vertx-process-manager,代码行数:24,代码来源:ComplexTest.java

示例3: recommendMeal

import org.kie.api.command.BatchExecutionCommand; //导入依赖的package包/类
@Override
public Meal recommendMeal(Person person) throws BusinessException {
    StatelessKieSession kieSession = kContainer.newStatelessKieSession();

    InsertObjectCommand insertObjectCommand = new InsertObjectCommand(person);
    FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
    QueryCommand queryCommand = new QueryCommand("results", "getMeal", (Object[]) null);
    List<GenericCommand<?>> commands = new ArrayList<GenericCommand<?>>();
    commands.add(insertObjectCommand);
    commands.add(fireAllRulesCommand);
    commands.add(queryCommand);
    BatchExecutionCommand batch = new BatchExecutionCommandImpl(commands);

    ExecutionResults results = kieSession.execute(batch);
    QueryResults queryResults = (QueryResults) results.getValue("results");
    Iterator<QueryResultsRow> iterator = queryResults.iterator();
    while (iterator.hasNext()) {
        Meal meal = (Meal) iterator.next().get("$m");
        if (meal != null) {
            System.out.println("Meal : " + meal);
            return meal;
        }
    }

    return null;
}
 
开发者ID:Salaboy,项目名称:drools-workshop,代码行数:27,代码来源:FoodRecommendationServiceImpl.java

示例4: createRandomCommand

import org.kie.api.command.BatchExecutionCommand; //导入依赖的package包/类
public BatchExecutionCommand createRandomCommand() {
    Person person = new Person();
    String name = NAMES[random.nextInt(NAMES.length)];
    person.setName(name);

    List<Command<?>> cmds = new ArrayList<Command<?>>();
    KieCommands commands = KieServices.Factory.get().getCommands();
    cmds.add(commands.newInsert(person));
    cmds.add(commands.newFireAllRules());
    cmds.add(commands.newQuery("greetings", "get greeting"));
    BatchExecutionCommand command = commands.newBatchExecution(cmds, "HelloRulesSession");
    return command;
}
 
开发者ID:fabric8-quickstarts,项目名称:spring-boot-camel-drools,代码行数:14,代码来源:DecisionServerHelper.java

示例5: testModifyFact

import org.kie.api.command.BatchExecutionCommand; //导入依赖的package包/类
@Test
public void testModifyFact() {
	GetObjectsCommand getObjectCommand = new GetObjectsCommand(new ClassObjectFilter(this.getClass()));
	getObjectCommand.setOutIdentifier("test");
	List<GenericCommand<?>> commands = new ArrayList<GenericCommand<?>>();
       commands.add(getObjectCommand);
       BatchExecutionCommand command = new BatchExecutionCommandImpl(commands);
       System.out.println(BatchExecutionHelper.newXStreamMarshaller().toXML(command));		
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:10,代码来源:DecisionServerTest.java

示例6: insertAndFireAll

import org.kie.api.command.BatchExecutionCommand; //导入依赖的package包/类
public void insertAndFireAll(Exchange exchange) {
    final Message in = exchange.getIn();
    final Object body = in.getBody();

    final KieCommands kieCommands = KieServices.Factory.get().getCommands();

    final List<Command> commands = new ArrayList<Command>();
    // since KIE commands are JAXB-annotated, the body has to be JAXB annotated class as well
    commands.add(kieCommands.newInsert(body, "person"));
    commands.add(kieCommands.newFireAllRules());

    BatchExecutionCommand command = kieCommands.newBatchExecution(commands);
    in.setBody(command);
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:15,代码来源:DroolsCommandHelper.java

示例7: testSessionBatchExecutionCommand

import org.kie.api.command.BatchExecutionCommand; //导入依赖的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);
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:15,代码来源:CamelEndpointTest.java

示例8: testSessionBatchExecutionCommandWithHeader

import org.kie.api.command.BatchExecutionCommand; //导入依赖的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();
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:34,代码来源:CamelEndpointTest.java

示例9: testInsert

import org.kie.api.command.BatchExecutionCommand; //导入依赖的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);
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:18,代码来源:JaxbInsertTest.java


注:本文中的org.kie.api.command.BatchExecutionCommand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。