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


Java KieSession.getQueryResults方法代码示例

本文整理汇总了Java中org.kie.api.runtime.KieSession.getQueryResults方法的典型用法代码示例。如果您正苦于以下问题:Java KieSession.getQueryResults方法的具体用法?Java KieSession.getQueryResults怎么用?Java KieSession.getQueryResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kie.api.runtime.KieSession的用法示例。


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

示例1: execute

import org.kie.api.runtime.KieSession; //导入方法依赖的package包/类
@Override
public Room execute( Context ctx ) {
    KieSession session = ( KieSession ) ctx.getData().get( "session" );
    GameMessageService messageService = ( GameMessageService ) ctx.getData().get( "messageService" );

    QueryResults queryResults = session.getQueryResults( "WhereAmI", getPlayer().getName() );
    Iterator<QueryResultsRow> iterator = queryResults.iterator();
    Room room = null;
    while ( iterator.hasNext() ) {
        room = ( Room ) iterator.next().get( "$r" );
        break;
    }
    if ( room != null ) {
        session.insert( messageService.newGameMessage( getPlayer().getName(), "You are in " + room.getName() ) );
    }
    return room;
}
 
开发者ID:Salaboy,项目名称:drools-game-engine,代码行数:18,代码来源:WhereAmICommand.java

示例2: execute

import org.kie.api.runtime.KieSession; //导入方法依赖的package包/类
@Override
public Void execute( Context ctx ) {
    KieSession session = ( KieSession ) ctx.getData().get( "session" );
    GameMessageService messageService = ( GameMessageService ) ctx.getData().get( "messageService" );
    FactHandle roomInFH = session.getFactHandle( roomIn );
    roomIn.getPeopleInTheRoom().remove( getPlayer().getName() );
    session.update( roomInFH, roomIn );
    QueryResults queryResults = session.getQueryResults( "getRoomByName", door.getLeadsTo() );
    Iterator<QueryResultsRow> iterator = queryResults.iterator();
    Room roomTo = null;
    while ( iterator.hasNext() ) {
        roomTo = ( Room ) iterator.next().get( "$r" );
        break;
    }
    if ( roomTo != null ) {
        FactHandle roomToFH = session.getFactHandle( roomTo );
        roomTo.getPeopleInTheRoom().add( getPlayer().getName() );
        session.update( roomToFH, roomTo );
        session.insert( messageService.newGameMessage( getPlayer().getName(), "Player moved from  " + roomIn.getName() + " to " + roomTo.getName() ) );
    } else {
        session.insert( messageService.newGameMessage( getPlayer().getName(), "ERROR: Door cannot be used because the room:   " + door.getLeadsTo() + " was not found. " ) );
    }
    return null;
}
 
开发者ID:Salaboy,项目名称:drools-game-engine,代码行数:25,代码来源:UseDoorCommand.java

示例3: testPatientWithBloodPressureObservations

import org.kie.api.runtime.KieSession; //导入方法依赖的package包/类
@Test
public void testPatientWithBloodPressureObservations() {

    printGeneratedDRL( ClinicalRulesJUnitTest.class.getResourceAsStream( "/rules/clinical-decision-table.xls" ), System.out );

    Assert.assertNotNull( kBase );
    KieSession kSession = kBase.newKieSession();

    kSession.insert( generatePatients( 1 ).get( 0 ) );

    List<Observation> observations = generateObservations( "headache", 4 );
    for ( Observation observation : observations ) {
        kSession.insert( observation );
    }

    Assert.assertEquals( 2, kSession.fireAllRules() );

    QueryResults queryResults = kSession.getQueryResults( "getAllRecommendations", ( Object ) null );
    for ( QueryResultsRow row : queryResults ) {
        Recommendation r = ( Recommendation ) row.get( "$r" );
        System.out.println( " >>> Result : " + r );
    }

    kSession.dispose();
}
 
开发者ID:Salaboy,项目名称:drools-workshop,代码行数:26,代码来源:ClinicalRulesJUnitTest.java

示例4: testQuery

import org.kie.api.runtime.KieSession; //导入方法依赖的package包/类
@Test
public void testQuery() {
    Assert.assertNotNull(kBase);
    KieSession kSession = kBase.newKieSession();
    System.out.println(" ---- Starting testQuery() Test ---");

    List<Person> generatePersons = generatePersons(100);
    for (Person p : generatePersons) {
        kSession.insert(p);
    }
    kSession.fireAllRules();
    QueryResults queryResults = kSession.getQueryResults("all persons older than", 50);
    for (QueryResultsRow row : queryResults) {
            System.out.println(" >>> Result : " + row.get("$p"));
    }

    System.out.println(" ---- Finished testQuery() Test ---");
    kSession.dispose();
}
 
开发者ID:Salaboy,项目名称:drools-workshop,代码行数:20,代码来源:QueryRulesJUnitTest.java

示例5: execute

import org.kie.api.runtime.KieSession; //导入方法依赖的package包/类
@Override
public List<Door> execute( Context ctx ) {
    KieSession session = ( KieSession ) ctx.getData().get( "session" );
    GameMessageService messageService = ( GameMessageService ) ctx.getData().get( "messageService" );
    
    QueryResults queryResults = session.getQueryResults( "getDoors", room.getName() );
    Iterator<QueryResultsRow> iterator = queryResults.iterator();
    List<Door> doors = new ArrayList<Door>();
    while ( iterator.hasNext() ) {
        Door door = ( Door ) iterator.next().get( "$d" );
        doors.add( door );
    }
    session.insert( messageService.newGameMessage( getPlayer().getName(), doors.size() + " Door(s) unlocked and open" ) );
    return doors;
}
 
开发者ID:Salaboy,项目名称:drools-game-engine,代码行数:16,代码来源:ExploreDoorsCommand.java

示例6: execute

import org.kie.api.runtime.KieSession; //导入方法依赖的package包/类
@Override
public List<ItemContainer> execute( Context ctx ) {
    KieSession session = ( KieSession ) ctx.getData().get( "session" );
    GameMessageService messageService = ( GameMessageService ) ctx.getData().get( "messageService" );

    QueryResults queryResults = session.getQueryResults( "getAllContainers", ( Object ) null );
    Iterator<QueryResultsRow> iterator = queryResults.iterator();
    List<ItemContainer> itemContainers = new ArrayList<ItemContainer>();
    while ( iterator.hasNext() ) {
        ItemContainer itemContainer = ( ItemContainer ) iterator.next().get( "$ic" );
        itemContainers.add( itemContainer );
    }
    session.insert( messageService.newGameMessage( getPlayer().getName(), itemContainers.size() + " Item Containers available" ) );
    return itemContainers;
}
 
开发者ID:Salaboy,项目名称:drools-game-engine,代码行数:16,代码来源:ExploreContainersCommand.java

示例7: getDelivery

import org.kie.api.runtime.KieSession; //导入方法依赖的package包/类
@Override
public Delivery getDelivery(String deliveryId) throws BusinessException {
    KieSession kieSession = onGoingDeliveries.get(deliveryId);
    QueryResults queryResults = kieSession.getQueryResults("getDelivery", new Object[]{});
    for (QueryResultsRow qrr : queryResults) {
        return (Delivery) qrr.get("$d");
    }
    return null;
}
 
开发者ID:Salaboy,项目名称:drools-workshop,代码行数:10,代码来源:DeliveryServiceImpl.java


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