[rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Wolfgang Laun
wolfgang.laun at gmail.com
Thu Jan 20 09:41:21 EST 2011
I understand this so that there must be *exactly* 2 Option facts, and therefore:
$o1: Option (code == "P1")
$o2: Option (code == "P2")
not Option( this != $o1, this != $o2 )
On 20 January 2011 14:33, Bruno Freudensprung
<bruno.freudensprung at temis.com> wrote:
>
> Hello,
>
> Maybe could you try the following rule?
>
> rule "Matched Options"
> when
> $o : Option (code == "P1")
> Option (this != $o, code == "P2")
> then
> System.out.println ( "Priced using G/S ");
> end
>
> Best regards,
>
> Bruno.
>
>
>
>
> groovenarula a écrit :
>> Hello,
>>
>> I have a fact called 'Option' :
>>
>> public class Option {
>> private String code;
>>
>> private Item item;
>> public String getCode() {
>> return code;
>> }
>> public void setCode(String optionCode) {
>> this.code = optionCode;
>> }
>>
>> At any point in time, the working memory can have several Option instances
>> with different code values. My rules need to fire specifically when the
>> working memory contains a specific set of options. e.g. Rule 1 should fire
>> if and only if the working memory contains 2 option instances one with code
>> "P1" and the other with "P2" (order should not matter).
>>
>> I tried to use 'forall' as follows :
>>
>> rule "Matched Options"
>> when
>> forall (
>> Option ( code == "P1" || code == "P2" )
>> )
>> then
>> //insert( new IsPriced( i ) );
>> System.out.println ( "Priced using G/S ");
>> end
>>
>> However, the rule above never fires. Maybe I should be taking a different
>> approach. I'm still learning through how to create rules. So any
>> help/suggestions on how to tackle the above will be appreciated.
>>
>> Thanks
>> Gurvinder
>>
>>
>
> _______________________________________________
> 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