[rules-users] Trouble using || operator and after evaluator in constraints in 5.4.0.Final
Wolfgang Laun
wolfgang.laun at gmail.com
Thu Aug 16 08:23:59 EDT 2012
For the operations "a contains b" and "b memberOf a", operand a must
be a Collection or array; your MyObjectList is neither.
5.3.0 had less strict compile time checks; 5.4.0 fixed this.
I am surprised that this ever executed correctly. Did it really, with
the rule and classes exactly as shown?
-W
On 16/08/2012, abr <alexis.brouard at haulogy.net> wrote:
> Hi everyone,
>
> I've tried to go from Drools 5.3.0.Final to 5.4.0.Final and some strange
> errors appeared on constraints using the after evaluator and the ||
> operator.
>
> For instance, considering these 2 objects :
>
> public class MyObject {
>
> private Date myDate;
>
> public MyObject(Date myDate) {
> super();
> this.myDate = myDate;
> }
>
> public Date getMyDate() {
> return myDate;
> }
>
> public void setMyDate(Date myDate) {
> this.myDate = myDate;
> }
>
> }
>
> public class MyObjectList {
>
> private List<MyObject> myObjectList;
>
> public MyObjectList() {
> super();
> this.myObjectList = new ArrayList<MyObject>();
> }
>
> public List<MyObject> getMyObjectList() {
> return myObjectList;
> }
>
> public void setMyObjectList(List<MyObject> myObjectList) {
> this.myObjectList = myObjectList;
> }
>
> public void addObject(MyObject myObject) {
> this.myObjectList.add(myObject);
> }
>
> }
>
>
> This rule:
>
> rule "Sample rule"
> when
> CurrentDate( $now: now )
> $list: MyObjectList()
> $obj: MyObject(
> this memberOf $list,
> ( myDate == null ||
> myDate after[ 5d ] $now ) )
> then
> System.out.println( "Sample rule activated" );
> end
>
>
> Provokes the following error:
>
> Unable to Analyse Expression $list contains this && ( myDate == null ||
> after0.evaluate( myDate, $now ) ):
> [Error: unable to resolve method using strict-mode:
> com.sample.MyObject.after0()]
> [Near : {... ( myDate == null || after0.evaluate( myDate, $now ....}]
> ^ : [Rule name='Sample rule']
>
>
> This worked very well in Drools 5.3.0.Final.
>
> The strangest thing about this issue is that, if I change the || into a &&,
> compilation works correctly!
>
> Is there some configuration specific to Drools 5.4.0.Final that I've missed
> in the release notes?
>
> Thanks in advance for your help.
>
> Best,
> Alexis
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Trouble-using-operator-and-after-evaluator-in-constraints-in-5-4-0-Final-tp4019181.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> 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