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


Java ExecutionResults类代码示例

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


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

示例1: processRules

import org.kie.api.runtime.ExecutionResults; //导入依赖的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: recommendMeal

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

示例3: executeCommands

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Test
public void executeCommands() {
	System.out.println("== Sending commands to the server ==");
	RuleServicesClient rulesClient = kieServicesClient
			.getServicesClient(RuleServicesClient.class);
	KieCommands commandsFactory = KieServices.Factory.get().getCommands();
	Command<?> insert = commandsFactory.newInsert("Some String OBJ");
	Command<?> fireAllRules = commandsFactory.newFireAllRules();
	Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays
			.asList(insert, fireAllRules));
	ServiceResponse<ExecutionResults> executeResponse = rulesClient
			.executeCommandsWithResults(RULES_CONTAINER, batchCommand);
	if (executeResponse.getType() == ResponseType.SUCCESS) {
		System.out.println("Commands executed with success! Response: ");
		System.out.println(executeResponse.getResult());
	} else {
		System.out.println("Error executing rules. Message: ");
		System.out.println(executeResponse.getMsg());
	}
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:21,代码来源:DecisionServerJMSTest.java

示例4: executeCommands

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Test
public void executeCommands() {
	System.out.println("== Sending commands to the server ==");
	RuleServicesClient rulesClient = kieServicesClient
			.getServicesClient(RuleServicesClient.class);
	KieCommands commandsFactory = KieServices.Factory.get().getCommands();
	Command<?> insert = commandsFactory.newInsert("Some String OBJ");
	Command<?> fireAllRules = commandsFactory.newFireAllRules();
	Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays
			.asList(insert, fireAllRules));
	ServiceResponse<ExecutionResults> executeResponse = rulesClient.executeCommandsWithResults(RULES_CONTAINER, batchCommand);
	if (executeResponse.getType() == ResponseType.SUCCESS) {
		System.out.println("Commands executed with success! Response: ");
		System.out.println(executeResponse.getResult());
	} else {
		System.out.println("Error executing rules. Message: ");
		System.out.println(executeResponse.getMsg());
	}
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:20,代码来源:DecisionServerTest.java

示例5: start

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
/**
 *
 */
public void start() throws Exception {

    for (int i = 0; i < 10; i++) {
        Customer customer = customer();
        logger.info("------------------- START ------------------\n"
                + " KieSession fireAllRules. {}", customer);

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

        commands.add(CommandFactory.newInsert(customer, "customer"));
        commands.add(CommandFactory.newFireAllRules("num-rules-fired"));

        ExecutionResults results = ksession.execute(CommandFactory
                .newBatchExecution(commands));

        int fired = Integer.parseInt(results.getValue("num-rules-fired")
                .toString());

        customer = (Customer)results.getValue("customer");

        logger.info("After rule rules-fired={} {} \n"
                        + "------------------- STOP ---------------------", fired,
                customer);
    }
}
 
开发者ID:apache,项目名称:servicemix,代码行数:29,代码来源:SimpleRuleBean.java

示例6: testJSonSessionInsert

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Test
public void testJSonSessionInsert() throws Exception {

    String inXml = "";
    inXml += "{\"batch-execution\":{\"commands\":[";
    inXml += "{\"insert\":{\"lookup\":\"ksession1\", ";
    inXml += "             \"object\":{\"org.kie.pipeline.camel.Person\":{\"name\":\"salaboy\"}}, \"out-identifier\":\"salaboy\" } }";
    inXml += ", {\"fire-all-rules\":\"\"}";
    inXml += "]}}";

    String outXml = new String((byte[])template.requestBody("direct:test-with-session-json", inXml));

    ExecutionResults result = (ExecutionResults)BatchExecutionHelper.newJSonMarshaller().fromXML(outXml);
    Person person = (Person)result.getValue("salaboy");
    assertEquals("salaboy", person.getName());
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:17,代码来源:CamelEndpointWithMarshallersTest.java

示例7: testSessionGetObject

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Test
public void testSessionGetObject() throws Exception {
    String cmd = "";
    cmd += "<batch-execution lookup=\"ksession1\">\n";
    cmd += "<get-object out-identifier=\"rider\" fact-handle=\"" + this.handle + "\"/>\n";
    cmd += "</batch-execution>\n";

    String outXml = new String((byte[])template.requestBody("direct:test-with-session", cmd));

    ExecutionResults result = (ExecutionResults)BatchExecutionHelper.newXStreamMarshaller().fromXML(outXml);
    Person person = (Person)result.getValue("rider");
    assertEquals("Hadrian", person.getName());

    String expectedXml = "";
    expectedXml += "<?xml version='1.0' encoding='UTF-8'?><execution-results>";
    expectedXml += "<result identifier=\"rider\">";
    expectedXml += "<org.kie.pipeline.camel.Person>";
    expectedXml += "<name>Hadrian</name>";
    expectedXml += "</org.kie.pipeline.camel.Person>";
    expectedXml += "</result>";
    expectedXml += "</execution-results>";

    assertXMLEqual(expectedXml, outXml);

}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:26,代码来源:CamelEndpointWithMarshallersTest.java

示例8: configureDroolsContext

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Override
protected void configureDroolsContext(javax.naming.Context jndiContext) {
    Person me = new Person();
    me.setName("Hadrian");

    KieSession ksession = registerKnowledgeRuntime("ksession1", null);
    InsertObjectCommand cmd = new InsertObjectCommand(me);
    cmd.setOutIdentifier("camel-rider");
    cmd.setReturnObject(false);

    BatchExecutionCommandImpl script = new BatchExecutionCommandImpl(Arrays.asList(new GenericCommand<?>[] {cmd}));

    ExecutionResults results = ksession.execute(script);
    handle = ((FactHandle)results.getFactHandle("camel-rider")).toExternalForm();

}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:17,代码来源:CamelEndpointWithMarshallersTest.java

示例9: testSessionGetObject

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Test
public void testSessionGetObject() throws Exception {

    BatchExecutionCommandImpl cmd = new BatchExecutionCommandImpl();
    cmd.setLookup("ksession1");
    cmd.getCommands().add(new GetObjectCommand(DefaultFactHandle.createFromExternalFormat(handle), "hadrian"));

    StringWriter xmlReq = new StringWriter();
    Marshaller marshaller = getJaxbContext().createMarshaller();
    marshaller.setProperty("jaxb.formatted.output", true);
    marshaller.marshal(cmd, xmlReq);

    logger.debug(xmlReq.toString());

    byte[] xmlResp = (byte[])template.requestBody("direct:test-with-session", xmlReq.toString());

    ExecutionResults resp = (ExecutionResults)getJaxbContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xmlResp));
    assertNotNull(resp);

    assertEquals(1, resp.getIdentifiers().size());

    assertNotNull(resp.getValue("hadrian"));
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:24,代码来源:CamelEndpointWithJaxbTest.java

示例10: testExecutionResults

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Test
public void testExecutionResults() throws JAXBException {
    JAXBContext jaxbContext = getJaxbContext();

    KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

    List<Command> commands = new ArrayList<Command>();
    commands.add(CommandFactory.newInsert(new Person("darth", 105), "p"));
    commands.add(CommandFactory.newFireAllRules());

    ExecutionResults res1 = ksession.execute(CommandFactory.newBatchExecution(commands));

    Marshaller marshaller = jaxbContext.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    marshaller.marshal(res1, baos);

    // note it's using xsi:type
    logger.debug(new String(baos.toByteArray()));

    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    ExecutionResults res2 = (ExecutionResults)unmarshaller.unmarshal(new StringReader(baos.toString()));
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:25,代码来源:JaxbTest.java

示例11: testWorkingSetGlobalTestSessionSetAndGetGlobal

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Test
public void testWorkingSetGlobalTestSessionSetAndGetGlobal() throws Exception {

    BatchExecutionCommandImpl cmd = new BatchExecutionCommandImpl();
    cmd.setLookup("ksession1");

    SetGlobalCommand setGlobal = new SetGlobalCommand("list", new WrappedList());
    setGlobal.setOutIdentifier("list");

    cmd.getCommands().add(setGlobal);
    cmd.getCommands().add(new InsertObjectCommand(new Person("baunax")));
    cmd.getCommands().add(new FireAllRulesCommand());
    cmd.getCommands().add(new GetGlobalCommand("list"));

    Marshaller marshaller = getJaxbContext().createMarshaller();
    marshaller.setProperty("jaxb.formatted.output", true);
    StringWriter xml = new StringWriter();
    marshaller.marshal(cmd, xml);

    logger.debug(xml.toString());

    byte[] response = (byte[])template.requestBody("direct:test-with-session", xml.toString());
    assertNotNull(response);
    logger.debug("response:\n" + new String(response));
    Unmarshaller unmarshaller = getJaxbContext().createUnmarshaller();
    ExecutionResults res = (ExecutionResults)unmarshaller.unmarshal(new ByteArrayInputStream(response));
    WrappedList resp = (WrappedList)res.getValue("list");
    assertNotNull(resp);

    assertEquals(resp.size(), 2);
    assertEquals("baunax", resp.get(0).getName());
    assertEquals("Hadrian", resp.get(1).getName());

}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:35,代码来源:CamelEndpointWithJaxWrapperCollectionTest.java

示例12: testInsertWithReturnObjectFalse

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Test
public void testInsertWithReturnObjectFalse() throws Exception {
    String str = "";
    str += "package org.kie \n";
    str += "import org.kie.camel.testdomain.Cheese \n";
    str += "rule rule1 \n";
    str += "  when \n";
    str += "    $c : Cheese() \n";
    str += " \n";
    str += "  then \n";
    str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
    str += "end\n";

    KieSession ksession = getKieSession(ResourceFactory.newByteArrayResource(str.getBytes()));
    setExec(ksession);

    String outXml = execContent("testInsertWithReturnObjectFalse.in.1");
    ExecutionResults result = unmarshalOutXml(outXml, ExecutionResults.class);

    String expectedXml = getContent("testInsertWithReturnObjectFalse.expected.1", ((FactHandle)result.getFactHandle("outStilton")).toExternalForm());

    assertXMLEqual(expectedXml, outXml);
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:24,代码来源:BatchTest.java

示例13: extractResult

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
public Greeting extractResult(ServiceResponse<ExecutionResults> response) {
    ExecutionResults res = response.getResult();
    Greeting greeting = null;
    if (res != null) {
        QueryResults queryResults = (QueryResults) res.getValue("greetings");
        for (QueryResultsRow queryResult : queryResults) {
            greeting = (Greeting) queryResult.get("greeting");
            break;
        }
    }

    return greeting;
}
 
开发者ID:fabric8-quickstarts,项目名称:spring-boot-camel-drools,代码行数:14,代码来源:DecisionServerHelper.java

示例14: determinePersonsAge

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
private static Person determinePersonsAge(Person person, String containerId) {
	//The container id is used to specify the KieBase to be used on the remote server
	RemoteCommandExecutor remoteCommandExecutor = new RemoteCommandExecutor();

       BatchExecutionCommandImpl batchExecutionCommand = new BatchExecutionCommandImpl();
       
       //Set the KieSession name
       batchExecutionCommand.setLookup("defaultKieSession");
       InsertObjectCommand insertObjectCommand = new InsertObjectCommand(person);
       
       //Ensure the person object is returned
       insertObjectCommand.setOutIdentifier("person");
       FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
       batchExecutionCommand.getCommands().add(insertObjectCommand);
       batchExecutionCommand.getCommands().add(fireAllRulesCommand);

       ExecutionResults executionResult = (ExecutionResults) remoteCommandExecutor.execute(batchExecutionCommand, containerId);
	
       //Get the person object back 
       Object result = executionResult.getValue("person");
	
	
	if (result instanceof Person) {
		return (Person)result;
	} else {
		System.err.println(result.toString());
		return null;
	}
}
 
开发者ID:anurag-saran,项目名称:drools-usage-patterns,代码行数:30,代码来源:Runner.java

示例15: fireAllRules

import org.kie.api.runtime.ExecutionResults; //导入依赖的package包/类
@Override
public void fireAllRules() {
    FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
    fireAllRulesCommand.setOutIdentifier(IDENTIFIER_NUMBER_OF_FIRED_RULES);
    commands.add(fireAllRulesCommand);
    ExecutionResults executionResults = kSession.execute(CommandFactory.newBatchExecution(commands));
    this.numberOfFiredRules = (Integer) executionResults.getValue(IDENTIFIER_NUMBER_OF_FIRED_RULES);
}
 
开发者ID:jeichler,项目名称:junit-drools,代码行数:9,代码来源:DroolsStatelessSession.java


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