@Test public void testAddRuleWithPatterns() { final RuleImpl rule = new RuleImpl( "only patterns" ); final Pattern c1 = new Pattern( 0, new ClassObjectType( String.class ) ); final Pattern c2 = new Pattern( 1, new ClassObjectType( String.class ) ); final Pattern c3 = new Pattern( 2, new ClassObjectType( String.class ) ); final GroupElement lhsroot = GroupElementFactory.newAndInstance(); lhsroot.addChild( c1 ); lhsroot.addChild( c2 ); lhsroot.addChild( c3 ); rule.setLhs( lhsroot ); final Consequence consequence = new Consequence() { public void evaluate(KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory) throws Exception { System.out.println( "Consequence!" ); } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { } public void writeExternal(ObjectOutput out) throws IOException { } public String getName() { return "default"; } }; rule.setConsequence( consequence ); final List terminals = this.builder.addRule( rule, this.rulebase ); assertEquals( "Rule must have a single terminal node", 1, terminals.size() ); final RuleTerminalNode terminal = (RuleTerminalNode) terminals.get( 0 ); }
public List<TerminalNode> addRule( final RuleImpl rule, final InternalKnowledgeBase kBase ) throws InvalidPatternException { final List<TerminalNode> nodes = new ArrayList<TerminalNode>(); final GroupElement[] subrules = rule.getTransformedLhs( kBase.getConfiguration().getComponentFactory().getLogicTransformerFactory().getLogicTransformer(), kBase.getGlobals() ); for (int i = 0; i < subrules.length; i++) { final BuildContext context = new BuildContext( kBase ); context.setRule( rule ); if (EventProcessingOption.STREAM.equals( kBase.getConfiguration().getEventProcessingMode() )) { TemporalDependencyMatrix temporal = this.utils.calculateTemporalDistance( subrules[i] ); context.setTemporalDistance( temporal ); } if (kBase.getConfiguration().isSequential() ) { context.setTupleMemoryEnabled( false ); context.setObjectTypeNodeMemoryEnabled( false ); } else { context.setTupleMemoryEnabled( true ); context.setObjectTypeNodeMemoryEnabled( true ); } final TerminalNode node = this.addSubRule( context, subrules[i], i, rule ); nodes.add( node ); } return nodes; }
ReteooRuleBuilder implements RuleBuilder { public List<TerminalNode> addRule( final RuleImpl rule, final InternalKnowledgeBase kBase ) throws InvalidPatternException { final List<TerminalNode> nodes = new ArrayList<TerminalNode>(); final GroupElement[] subrules = rule.getTransformedLhs( kBase.getConfiguration().getComponentFactory().getLogicTransformerFactory().getLogicTransformer(), kBase.getGlobals() ); for (int i = 0; i < subrules.length; i++) { final BuildContext context = new BuildContext( kBase ); context.setRule( rule ); if (EventProcessingOption.STREAM.equals( kBase.getConfiguration().getEventProcessingMode() )) { TemporalDependencyMatrix temporal = this.utils.calculateTemporalDistance( subrules[i] ); context.setTemporalDistance( temporal ); } if (kBase.getConfiguration().isSequential() ) { context.setTupleMemoryEnabled( false ); context.setObjectTypeNodeMemoryEnabled( false ); } else { context.setTupleMemoryEnabled( true ); context.setObjectTypeNodeMemoryEnabled( true ); } final TerminalNode node = this.addSubRule( context, subrules[i], i, rule ); nodes.add( node ); } return nodes; } }
ReteooRuleBuilder implements RuleBuilder { public List<TerminalNode> addRule( final RuleImpl rule, final InternalKnowledgeBase kBase ) throws InvalidPatternException { final List<TerminalNode> nodes = new ArrayList<TerminalNode>(); final GroupElement[] subrules = rule.getTransformedLhs( kBase.getConfiguration().getComponentFactory().getLogicTransformerFactory().getLogicTransformer(), kBase.getGlobals() ); for (int i = 0; i < subrules.length; i++) { final BuildContext context = new BuildContext( kBase ); context.setRule( rule ); if (EventProcessingOption.STREAM.equals( kBase.getConfiguration().getEventProcessingMode() )) { TemporalDependencyMatrix temporal = this.utils.calculateTemporalDistance( subrules[i] ); context.setTemporalDistance( temporal ); } if (kBase.getConfiguration().isSequential() ) { context.setTupleMemoryEnabled( false ); context.setObjectTypeNodeMemoryEnabled( false ); } else { context.setTupleMemoryEnabled( true ); context.setObjectTypeNodeMemoryEnabled( true ); } final TerminalNode node = this.addSubRule( context, subrules[i], i, rule ); nodes.add( node ); } return nodes; } ReteooRuleBuilder(); }
ReteooRuleBuilder implements RuleBuilder { public List<TerminalNode> addRule( final RuleImpl rule, final InternalKnowledgeBase kBase ) throws InvalidPatternException { final List<TerminalNode> nodes = new ArrayList<TerminalNode>(); final GroupElement[] subrules = rule.getTransformedLhs( kBase.getConfiguration().getComponentFactory().getLogicTransformerFactory().getLogicTransformer(), kBase.getGlobals() ); for (int i = 0; i < subrules.length; i++) { final BuildContext context = new BuildContext( kBase ); context.setRule( rule ); if (EventProcessingOption.STREAM.equals( kBase.getConfiguration().getEventProcessingMode() )) { TemporalDependencyMatrix temporal = this.utils.calculateTemporalDistance( subrules[i] ); context.setTemporalDistance( temporal ); } if (kBase.getConfiguration().isSequential() ) { context.setTupleMemoryEnabled( false ); context.setObjectTypeNodeMemoryEnabled( false ); } else { context.setTupleMemoryEnabled( true ); context.setObjectTypeNodeMemoryEnabled( true ); } final TerminalNode node = this.addSubRule( context, subrules[i], i, rule ); nodes.add( node ); } return nodes; } ReteooRuleBuilder(); List<TerminalNode> addRule( final RuleImpl rule,
                                       final InternalKnowledgeBase kBase ); void addEntryPoint( final String id,
            final InternalKnowledgeBase kBase ); WindowNode addWindowNode( WindowDeclaration window,
                                     InternalKnowledgeBase kBase ); }
ReteooRuleBuilder implements RuleBuilder { public List<TerminalNode> addRule( final RuleImpl rule, final InternalKnowledgeBase kBase ) throws InvalidPatternException { final List<TerminalNode> nodes = new ArrayList<TerminalNode>(); final GroupElement[] subrules = rule.getTransformedLhs( kBase.getConfiguration().getComponentFactory().getLogicTransformerFactory().getLogicTransformer(), kBase.getGlobals() ); for (int i = 0; i < subrules.length; i++) { final BuildContext context = new BuildContext( kBase ); context.setRule( rule ); if (EventProcessingOption.STREAM.equals( kBase.getConfiguration().getEventProcessingMode() )) { TemporalDependencyMatrix temporal = this.utils.calculateTemporalDistance( subrules[i] ); context.setTemporalDistance( temporal ); } if (kBase.getConfiguration().isSequential() ) { context.setTupleMemoryEnabled( false ); context.setObjectTypeNodeMemoryEnabled( false ); } else { context.setTupleMemoryEnabled( true ); context.setObjectTypeNodeMemoryEnabled( true ); } final TerminalNode node = this.addSubRule( context, subrules[i], i, rule ); nodes.add( node ); } return nodes; } ReteooRuleBuilder(); List<TerminalNode> addRule( final RuleImpl rule,
                                       final InternalKnowledgeBase kBase ); void addEntryPoint( final String id,
            final InternalKnowledgeBase kBase ); WindowNode addWindowNode( WindowDeclaration window,
                                     InternalKnowledgeBase kBase );  }