[rules-users] can't refer to the bound column fields from the LHS?..
Edson Tirelli
tirelli at post.com
Tue Mar 13 19:00:08 EDT 2007
Vlad,
Not yet. We may eventually support that in the future through MVEL
integration, but right now you can't do it. You can though use a return
value predicate for that though:
Rule xxx
When
$r1: MyRecord (field1 == “xxx”)
$r2: MyRecord2 (field1 == ( $r1.getField1() ))
Then
System.out.println(“found match: “+$r2+”, “+$r1);
End
I know it was just an illustration example, but always good to
reinforce: for the above case, the best would be to bind the attribute
itself, not the fact:
Rule xxx
When
$r1: MyRecord ( $f1 : field1 == “xxx”)
$r2: MyRecord2 ( field1 == $f1 )
Then
System.out.println(“found match: “+$r2+”, “+$r1);
End
[]s
Edson
Olenin, Vladimir (MOH) wrote:
> Hi,
>
> I always assumed that one can refer to the properties of the bound
> column in the LHS like this:
>
> MyRecord {
>
> String field1, field2;
>
> }
>
> MyRecord2 {
>
> String field1, field3;
>
> }
>
> Rule xxx
>
> When
>
> $r1: MyRecord (field1 == “xxx”)
>
> $r2: MyRecord2 (field1 == $r1.field1)
>
> Then
>
> System.out.println(“found match: “+$r2+”, “+$r1);
>
> End
>
> Compiler does complain on ‘$r1’ usage in the LHS (as part of
> constraint for MyRecord2 fact), but works OK if used only in RHS. The
> error I’m getting is: “Unable to find class $r1”. “$r1.getField1()”
> doesn’t work either (getting “mismatched token, expecting ‘)’ “ error).
>
> Thanks,
>
> Vlad
>
>------------------------------------------------------------------------
>
>_______________________________________________
>rules-users mailing list
>rules-users at lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @ www.jboss.com
More information about the rules-users
mailing list