Earnie,

Thanks for this.  Do your two solutions to fact enrichment presume use of the 
Hibernate framework to interact with a database in the rules? Would an example 
of your first solution be the following?

when
    $w : WMFact($key : id)
    $d : DatabaseFact(parentKey == $key)
then
    $w.Field1=$d.Field1 AND $w.Field2=$d.Field2 AND $w.Field3=$d.Field3

Ken 

Date: Tue, 28 Jul 2009 09:35:47 -0700
From: [email protected]
To: [email protected]
Subject: Re: [rules-users] How to Enrich Facts with Data from a Database



One way is to extend the original classes and add the desired attributes, then 
insert the extended class into WorkingMemory. You could then use RHS to modify 
matched facts. Another way is to inject "related" facts. So your LHS matches a 
fact and you insert a new "related" fact in the RHS. Rules that must evaluate 
data from both facts can the do something like this:

when
    $b : BaseFact($key : id)
    $r : RelatedFact(parentKey == $key)
then
    ...

I have used both albeit on small sets of facts and both worked fine.

Earnie!

From: Ken Archer <[email protected]>
To: [email protected]
Sent: Tuesday, July 28, 2009 12:22:37 PM
Subject: [rules-users] How to Enrich Facts with Data from a Database






I would like to append values to facts in working memory with
values from a database before rules processing.  The Fusion documentation
says, “one of the most common use cases for rules is event data enrichment”,
but no documentation seems to explain how this is done whether we’re talking
about events or just plain old facts.  And the RHS syntax seems to be
limited to working with data already in working memory.  How can I enrich
facts with data from another system?  Thanks in advance.

 

Ken Archer

Telogical Systems



_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to