本文整理匯總了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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}