本文整理匯總了Java中org.kie.api.runtime.KieSession.update方法的典型用法代碼示例。如果您正苦於以下問題:Java KieSession.update方法的具體用法?Java KieSession.update怎麽用?Java KieSession.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.kie.api.runtime.KieSession
的用法示例。
在下文中一共展示了KieSession.update方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: testServiceCallInRHS
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void testServiceCallInRHS() {
Assert.assertNotNull(kBase);
KieSession kSession = kBase.newKieSession();
kSession.setGlobal("myDataProviderService", new MyDataProviderServiceImpl());
System.out.println(" ---- Starting testServiceCallInRHS() Test ---");
University university = new University("My Uni");
FactHandle univFactHandle = kSession.insert(university);
Assert.assertEquals(50, kSession.fireAllRules());
university.setName("My Uni (updated)");
kSession.update(univFactHandle, university);
Assert.assertEquals(50, kSession.fireAllRules());
System.out.println(" ---- Finished testServiceCallInRHS() Test ---");
kSession.dispose();
}
示例3: testServiceCallInRHS
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void testServiceCallInRHS() {
Assert.assertNotNull(kBase);
KieSession kSession = kBase.newKieSession();
kSession.setGlobal("myConditionsProviderService", new MyConditionsProviderServiceImpl());
System.out.println(" ---- Starting testServiceCallInRHS() Test ---");
Patient patient = (Patient) new Patient().setId("Patient/1");
FactHandle patientHandle = kSession.insert(patient);
Assert.assertEquals(50, kSession.fireAllRules());
//A modification of the patient will execute the service
patient.addName(new HumanNameDt().addFamily("Richards"));
kSession.update(patientHandle, patient);
Assert.assertEquals(50, kSession.fireAllRules());
System.out.println(" ---- Finished testServiceCallInRHS() Test ---");
kSession.dispose();
}
示例4: 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 playerFH = session.getFactHandle( getPlayer());
getPlayer().getInventory().getItems().add( flag );
session.update( playerFH, getPlayer() );
session.insert( messageService.newGameMessage( getPlayer().getName(), "Picked the Flag" ) );
return null;
}
示例5: 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 zoneFH = session.getFactHandle( zone );
zone.addPlayer( getPlayer().getName() );
session.update( zoneFH, zone );
session.insert( messageService.newGameMessage( getPlayer().getName(), "You entered the Zone: " + zone.getName() ) );
return null;
}
示例6: 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 zoneFH = session.getFactHandle( zone );
zone.removePlayer( getPlayer().getName() );
session.update( zoneFH, zone );
session.insert( messageService.newGameMessage( getPlayer().getName(), "You Exited the Zone: " + zone.getName() ) );
return null;
}
示例7: 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 containerFH = session.getFactHandle( container );
container.setOpen( true );
session.update( containerFH, container );
session.insert( messageService.newGameMessage( getPlayer().getName(), "Container Opened: " + container.getName() ) );
return null;
}
示例8: 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 lightSwitchFH = session.getFactHandle( lightSwitch );
lightSwitch.setOn( false );
session.update( lightSwitchFH, lightSwitch );
session.insert( messageService.newGameMessage( getPlayer().getName(), "Lights Turned Off" ) );
return null;
}
示例9: 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 lightSwitchFH = session.getFactHandle( lightSwitch );
lightSwitch.setOn( true );
session.update( lightSwitchFH, lightSwitch );
session.insert( messageService.newGameMessage( getPlayer().getName(), "Lights Turned On" ) );
return null;
}
示例10: 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 playerFH = session.getFactHandle( getPlayer() );
getPlayer().getInventory().getItems().add( pickableItem.getPickable() );
FactHandle containerFH = session.getFactHandle( container );
container.getItems().remove( pickableItem.getPickable() );
session.update( playerFH, getPlayer() );
session.update( containerFH, container );
session.insert( messageService.newGameMessage( getPlayer().getName(), "Item Picked! " + pickableItem ) );
return null;
}
示例11: 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 checkpointFH = session.getFactHandle(checkpoint );
checkpoint.addPlayer( getPlayer().getName() );
session.update(checkpointFH, checkpoint );
session.insert(messageService.newGameMessage(getPlayer().getName(), "You entered the checkpoint: " + checkpoint.getId() ) );
return null;
}
示例12: 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 scoreZoneFH = session.getFactHandle(checkpoint );
checkpoint.removePlayer( getPlayer().getName() );
session.update(scoreZoneFH, checkpoint );
session.insert(messageService.newGameMessage(getPlayer().getName(), "You left the checkpoint: " + checkpoint.getId() ) );
return null;
}
示例13: playerHitTheChasmTest
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void playerHitTheChasmTest() {
KieSession kSession = kBase.newKieSession();
assertNotNull( kSession );
kSession.setGlobal( "messageService", new GameMessageServiceImpl() );
kSession.setGlobal( "callback", new GameCallbackServiceImpl() );
// Init Player
Player salaboy = new BasePlayerImpl( "salaboy" );
FactHandle playerFH = kSession.insert( salaboy );
Chest chest = new Chest( "Flag Chest", new Location( 0, 0, 0 ) );
kSession.insert( chest );
// Red team
Team redTeam = new Team( "red" );
kSession.insert( redTeam );
Zone scoreZoneRed = new Zone( "red" );
kSession.insert( scoreZoneRed );
NamedLocation redSpawn = new NamedLocation( "red" );
kSession.insert( redSpawn );
// Blue team
Team blueTeam = new Team( "blue" );
kSession.insert( blueTeam );
Zone scoreZoneBlue = new Zone( "blue" );
kSession.insert( scoreZoneBlue );
NamedLocation blueSpawn = new NamedLocation( "blue" );
kSession.insert( blueSpawn );
int fired = kSession.fireAllRules();
assertEquals( 4, fired );
// Make the flag appear in the world
Flag flag = new Flag( "Flag", "banner" );
kSession.insert( flag );
Zone chasm = new Zone( "Chasm" );
FactHandle chasmFH = kSession.insert( chasm );
fired = kSession.fireAllRules();
assertEquals( 0, fired );
// Player picks the flag
salaboy.getInventory().getItems().add( flag );
kSession.update( playerFH, salaboy );
fired = kSession.fireAllRules();
assertEquals( 0, fired );
// Player moves to the Chasm/. and needs to be teleported back
chasm.addPlayer( salaboy.getName() );
kSession.update( chasmFH, chasm );
fired = kSession.fireAllRules();
assertEquals( 1, fired );
assertEquals( 0, salaboy.getInventory().getItems().size() );
assertTrue( chasm.getPlayersInZone().isEmpty() );
kSession.dispose();
}
示例14: mytest
import org.kie.api.runtime.KieSession; //導入方法依賴的package包/類
@Test
public void mytest() {
KieSession kSession = kBase.newKieSession();
assertNotNull( kSession );
kSession.setGlobal( "messageService", new GameMessageServiceImpl() );
kSession.setGlobal( "callback", new GameCallbackServiceImpl() );
Player player = new BasePlayerImpl( "Morton Abenthy Halputz" );
FactHandle playerFH = kSession.insert( player );
Checkpoint startfinish = new Checkpoint( "StartFinish", 0, true );
FactHandle startfinishFH = kSession.insert( startfinish );
Checkpoint checkpointone = new Checkpoint( "CheckPointOne", 1 );
FactHandle checkpointoneFH = kSession.insert( checkpointone );
Checkpoint checkpointtwo = new Checkpoint( "CheckPointTwo", 2 );
FactHandle checkpointtwoFH = kSession.insert( checkpointtwo );
Checkpoint checkpointthree = new Checkpoint( "CheckPointThree", 3 );
FactHandle checkpointthreeFH = kSession.insert( checkpointthree );
Checkpoint checkpointfour = new Checkpoint( "CheckPointFour", 4 );
FactHandle checkpointfourFH = kSession.insert( checkpointfour );
int fired = kSession.fireAllRules();
assertEquals( 1, fired );
startfinish.addPlayer( player.getName() );
kSession.update( startfinishFH, startfinish );
fired = kSession.fireAllRules();
assertEquals( 1, fired );
startfinish.removePlayer( player.getName() );
kSession.update( startfinishFH, startfinish );
checkpointone.addPlayer( player.getName() );
kSession.update( checkpointoneFH, checkpointone );
fired = kSession.fireAllRules();
assertEquals( 1, fired );
checkpointone.removePlayer( player.getName() );
kSession.update( checkpointoneFH, checkpointone );
checkpointtwo.addPlayer( player.getName() );
kSession.update( checkpointtwoFH, checkpointtwo );
fired = kSession.fireAllRules();
assertEquals( 2, fired );
checkpointtwo.removePlayer( player.getName() );
kSession.update( checkpointtwoFH, checkpointtwo );
checkpointthree.addPlayer( player.getName() );
kSession.update( checkpointthreeFH, checkpointthree );
fired = kSession.fireAllRules();
assertEquals( 2, fired );
checkpointthree.removePlayer( player.getName() );
kSession.update( checkpointthreeFH, checkpointthree );
checkpointfour.addPlayer( player.getName() );
kSession.update( checkpointfourFH, checkpointfour );
fired = kSession.fireAllRules();
assertEquals( 2, fired );
checkpointfour.removePlayer( player.getName() );
kSession.update( checkpointfourFH, checkpointfour );
startfinish.addPlayer( player.getName() );
kSession.update( startfinishFH, startfinish );
fired = kSession.fireAllRules();
assertEquals( 2, fired );
kSession.dispose();
}