Frequently I'm debating with myself whether to leave a little room for posters to reach some logical conclusion by themselves or to spoon-feed it all to them. ;-)
-W 2011/8/25 Esteban Aliverti <[email protected]> > Translation: If the LHS of your rules are going to use globals, make sure > to set them BEFORE you insert/update/retract any fact. :P > > Best Regards, > > XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > > Esteban Aliverti > - Developer @ http://www.plugtree.com > - Blog @ http://ilesteban.wordpress.com > > > > 2011/8/25 Wolfgang Laun <[email protected]> > >> Conditions are evaluated when facts are inserted, modified and deleted. >> -W >> >> >> 2011/8/25 Matthew Erler <[email protected]> >> >>> In Drools 5 I'm passing in two global Date objects and need to find the >>> difference in days between them. I've discovered that the function >>> parameters (fromDate and toDate in my case) are null in the condition when >>> the function is called, but when the function is called in the consequence >>> they have values. I can see that because the output of the following rule >>> is: >>> fromDate is null >>> toDate is null >>> I'm in dateDiff and the date diff is: 14 >>> >>> I'm guessing that Drools doesn't make globals t available at the point >>> that I need them. Can anyone confirm this and offer a solution? >>> >>> Here is the rule file itself: >>> >>> import java.util.Date; >>> import org.joda.time.DateMidnight; >>> import org.joda.time.Days; >>> >>> global java.util.Date fromDate; >>> global java.util.Date toDate; >>> >>> >>> rule "dateDiff" >>> dialect "mvel" >>> when >>> eval(getDaysBetweenStartAndEndDate(fromDate, toDate) < 10) >>> then >>> System.out.println( "I'm in dateDiff and the date diff is: " >>> + getDaysBetweenStartAndEndDate(fromDate, toDate)); >>> end >>> >>> >>> function int getDaysBetweenStartAndEndDate(Date fromDate, Date toDate) { >>> if (fromDate==null) System.out.println("fromDate is null"); >>> if (toDate==null) System.out.println("toDate is null"); >>> return Days.daysBetween(new DateMidnight(fromDate), new >>> DateMidnight(toDate)).getDays(); >>> } >>> >>> _______________________________________________ >>> rules-users mailing list >>> [email protected] >>> https://lists.jboss.org/mailman/listinfo/rules-users >>> >>> >> >> _______________________________________________ >> rules-users mailing list >> [email protected] >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > >
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
