[rules-dev] Get node's rule

Mark Proctor mproctor at codehaus.org
Mon Nov 10 13:05:08 EST 2008


Waleed Zedan wrote:
> Hi,
>
> in AlphaNode.java (similarly beta nodes descendants)
> public void assertObject(final InternalFactHandle handle,
>                              final PropagationContext context,
>                              final InternalWorkingMemory 
> workingMemory) throws FactException {
> if ( this.constraint.isAllowed( handle.getObject(),
>                                         workingMemory,
>    ...        
> }
>  // I need to put code here to get the rule and previous statisfied 
> conditions
> }
>
> I need to get rule that owns the alpha or beta node as well as all the 
> previous conditions that have been satisfied.
>
> For example:
> Rule 1 :
>         Condition1 -> Node1
>         Condition2 -> Node2
>         Condition3 -> Node3
>
> so if fact1 satisfies condition 1 & 2 only, but condition 3 doesn't 
> satisfy it, I need to store the information that rule 1 with condition 
> 1 & condition 2 have been satisfied.
>        
> So , how can I get the rule that owns the condition?
> Can I get this information from 
> workingMemoryEventSupport.fireObjectInserted event?
The rete network information is not exposed publicly. Do you know how to 
get access to the nodes themselves already? Via the Rete object on the 
RuleBase, you'll need to cast the workingmemory and rulebase to 
implementations to do this. From there do you know how traverse the 
network, and from there now to lookup the node memories? The node 
memories are in the workingmemory, you can see the method in each node 
how it retrieves that memory.

Mark
>
> Thanks,
> -- 
> Waleed Zedan
> SCJP 1.4 , CCNA
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20081110/949c6809/attachment.html 


More information about the rules-dev mailing list