cmds.add( new SetVariableCommand( "ROOT",
"kbuilder",
new NewKnowledgeBuilderCommand( null ) ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new KnowledgeBuilderAddCommand( ResourceFactory.newByteArrayResource( str.getBytes() ),
ResourceType.DRL,
null ),
"kbuilder",
null,
null, null ) );
cmds.add( new SetVariableCommand( "ROOT",
"kbase",
new NewKnowledgeBaseCommand( null ) ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new KnowledgeBaseAddKnowledgePackagesCommand(),
"kbuilder",
"kbase",
null, null ) );
KnowledgeSessionConfiguration ksessionConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
ksessionConf.setOption( ClockTypeOption.get( "pseudo" ) );
cmds.add( new SetVariableCommand( "ROOT",
"ksession",
new KnowledgeContextResolveFromContextCommand( new NewStatefulKnowledgeSessionCommand( ksessionConf ),
"kbuilder",
"kbase",
null, null ) ) );
List list = new ArrayList();
cmds.add( new KnowledgeContextResolveFromContextCommand( new SetGlobalCommand( "list",
list ),
"kbuilder",
"kbase",
"ksession", null ) );
steps.add( new StepImpl( path,
cmds,
0 ) );
cmds = new ArrayList<Command>();
cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "darth",
97 ) ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
"kbuilder",
"kbase",
"ksession", null ) );
steps.add( new StepImpl( path,
cmds,
2000 ) );
cmds = new ArrayList<Command>();
cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "yoda",
98 ) ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
"kbuilder",
"kbase",
"ksession", null ) );
steps.add( new StepImpl( path,
cmds,
4000 ) );
path.setSteps( steps );
simulation.getPaths().put( "path1",
path );
path = new PathImpl( simulation,
"path2" );
steps = new ArrayList<Step>();
cmds = new ArrayList<Command>();
cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "bobba",
77 ) ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
"kbuilder",
"kbase",
"ksession", null ) );
steps.add( new StepImpl( path,
cmds,
1500 ) );
cmds = new ArrayList<Command>();
cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "luke",
30 ) ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
"kbuilder",
"kbase",
"ksession", null ) );
steps.add( new StepImpl( path,
cmds,
2200 ) );
cmds = new ArrayList<Command>();
cmds.add( new KnowledgeContextResolveFromContextCommand( new InsertObjectCommand( new Person( "ben",
150 ) ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand(),
"kbuilder",
"kbase",
"ksession", null ) );
steps.add( new StepImpl( path,
cmds,
4500 ) );
cmds = new ArrayList<Command>();
cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check List size",
5,
new GetGlobalCommand( "list" ),
"size()" ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
new Person( "bobba",
77 ),
new GetGlobalCommand( "list" ),
"get( 0 )" ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
new Person( "darth",
97 ),
new GetGlobalCommand( "list" ),
"get( 1 )" ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
new Person( "luke",
30 ),
new GetGlobalCommand( "list" ),
"get( 2 )" ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
new Person( "yoda",
98 ),
new GetGlobalCommand( "list" ),
"get( 3 )" ),
"kbuilder",
"kbase",
"ksession", null ) );
cmds.add( new KnowledgeContextResolveFromContextCommand( new AssertEquals( "Check Person",
new Person( "ben",
150 ),
new GetGlobalCommand( "list" ),
"get( 4 )" ),
"kbuilder",