[rules-dev] Get node's rule

Waleed Zedan wzedan at gmail.com
Wed Nov 12 04:36:41 EST 2008


Hi,

I tried your guidelines, but I need to get the rule id (or object) and store
it in the ObjectTypeNode , the problem I don't know from where to get this
information as this is the stack trace till the ObjectTypeNode constructor.

ObjectTypeNode.<init>(int, ObjectType, BuildContext) line: 96
PatternBuilder.attachAlphaNodes(BuildContext, BuildUtils, Pattern, List)
line: 187
PatternBuilder.attachPattern(BuildContext, BuildUtils, Pattern) line: 88
PatternBuilder.build(BuildContext, BuildUtils, RuleConditionElement) line:
60
GroupElementBuilder$AndBuilder.build(BuildContext, BuildUtils,
RuleConditionElement) line: 111
GroupElementBuilder.build(BuildContext, BuildUtils, RuleConditionElement)
line: 69
ReteooRuleBuilder.addSubRule(BuildContext, GroupElement, Rule) line: 149
ReteooRuleBuilder.addRule(Rule, InternalRuleBase, ReteooBuilder$IdGenerator)
line: 122
ReteooBuilder.addRule(Rule) line: 119
ReteooRuleBase.addRule(Rule) line: 266

Can you give me guidelines on how to get the rule object or rule name in the
ObjectTypeNode constructor?

Thanks.

On Wed, Nov 12, 2008 at 7:56 AM, Waleed Zedan <wzedan at gmail.com> wrote:

> Thanks Mark And Edson for your guidlines.
>
> I need to gather statistics about how many rules have been fired, and also
> partial rule firing, for example if a rule 1 has 3 conditions, 1 of them is
> never fired, but the other conditions get fired, then we have to remove this
> condition. (the rule firing data will be persisted somewhere).
>
> Thanks.
>
>
>
> On Mon, Nov 10, 2008 at 10:45 PM, Edson Tirelli <tirelli at post.com> wrote:
>
>>
>>    I would follow a different path. During network building you have that
>> information. So, make the nodes reference their rules objects, or have a
>> String[] for the rule names at least.
>>    Some considerations:
>>
>> * A node may be shared among multiple rules, so you will need a list of
>> rule references for each node.
>>
>> * Be careful with memory consumption. Find a cheap way to store such
>> information.
>>
>> * Make sure your schema does not increase serialization cost too much.
>>
>>     At runtime, then you have the information ready to go in each node.
>>
>>     What are you working on? Would you be willing to contribute back to
>> the project?
>>
>>     []s
>>     Edson
>>
>> 2008/11/10 Mark Proctor <mproctor at codehaus.org>
>>
>>  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 listrules-dev at lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-dev
>>>
>>>
>>>
>>> _______________________________________________
>>> rules-dev mailing list
>>> rules-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>>
>>>
>>
>>
>> --
>>  Edson Tirelli
>>  JBoss Drools Core Development
>>  JBoss, a division of Red Hat @ www.jboss.com
>>
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>
>
> --
> Waleed Zedan
> SCJP 1.4 , CCNA
>



-- 
Waleed Zedan
SCJP 1.4 , CCNA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20081112/3d9d31f7/attachment.html 


More information about the rules-dev mailing list