[rules-users] How do I reference newly asserted facts?

kissro at lidp.com kissro at lidp.com
Mon Dec 10 16:10:06 EST 2007


I understand that part but FNCM_COMMENT is a separate object/fact.
Here's what I'm trying to do:

I have two objects(facts)
  FNAC_CLIENT_CONTROL
  FNCM_COMMENT

I insert(FNAC_CLIENT_CONTROL)
  fireAllRules()

My rule says when FNAC_CLIENT_CONTROL.FNAC_BIRTH_PLACE == "IL"
then insert a new fact that was not previously inserted - FNCM_COMMENT.
I now have 2 facts in WorkingMemory if I understand everything correctly.

When I return to my java program, after the fireAllRules() statement,
I'm hoping to have available to me both the FNAC_CLIENT_CONTROL fact and
the FNCM_COMMENT fact.  Is that true?  Will I have both available?
If so, how do I access the FNCM_COMMENT fact if it's not in the LHS and
I don't have a variable assigned to it?


> On Mon, Dec 10, 2007 at 11:01:41PM +0530, Darko IVANCAN wrote:
>   
>> Hi,
>>
>> In the BRMS you can assign a variable to your fact in the LHS.
>> This would then result in:
>> when
>>     a : FNAC_CLIENT_CONTROL( FNAC_BIRTH_PLACE == "IL" )
>> then
>>    a.set....
>>
>> good luck,
>> Darko Ivancan
>>
>> On 10/12/2007 20:38, kissro at lidp.com wrote:
>>     
>>> Hello,
>>>
>>> I am creating all my rules using the BRMS guided rule editor gui.
>>> In the rule editor, I have a rule that looks like this:
>>>
>>> WHEN
>>>       FNAC_CLIENT_CONTROL
>>>   FNAC_BIRTH_PLACE is equal to "IL"
>>>
>>> THEN
>>>   Assert FNCM_COMMENT FNCM_VARIABLE_DATA "This client lives in Illinois"
>>>
>>> When I click the 'View Source' button I see this:
>>>
>>> rule "Rule500"
>>>    dialect "mvel"
>>>    when
>>>          FNAC_CLIENT_CONTROL( FNAC_BIRTH_PLACE == "IL" )
>>>    then
>>>          FNCM_COMMENT fact0 = new FNCM_COMMENT();
>>>          fact0.setFNCM_VARIABLE_DATA( "This client lives in Illinois");
>>>          insert( fact0 );
>>> end
>>>
>>> After I return from "fireAllRules", how do I reference the newly
>>> asserted fact in my Java code?  Do I reference "fact0" or can I use the
>>> object's "real" name - FNCM_COMMENT.FNCM_VARIABLE_DATA?
>>>
>>> "fact0" is just a generated name created by BRMS when it generates the
>>> rule based on what I type in the gui, right?  I'm assuming if I insert
>>> more facts, they would be called fact1, fact2, etc.  If I want to
>>> reference these facts, do I have to keep track of how many I've inserted
>>> then reference the appropriate fact number?  I'm not sure how to
>>> reference these generated fact names after returning from the rule
>>> engine.  Could someone help me?
>>>
>>> Thanks,
>>> Rod  
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>>   
>>>       
>
>
>   
> 



More information about the rules-users mailing list