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 <archerovi@hotmail.com>
To: rules-users@lists.jboss.org
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