當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。