[rules-users] Issue using global 'variable' with Drools 5.2 in DRL
Wolfgang Laun
wolfgang.laun at gmail.com
Fri Sep 23 11:04:08 EDT 2011
Please follow Thomas' advice.
That now.time worked in 5.1.1 was actually an "accident", as it
contradicted the specs. I'm not sure whether this behaviour is going to be
reinstated.
If you do need to do the comparison on long (milliseconds since the epoch)
values you'd have to do
subObject.dateField.time >= (now.getTime())
which works in 5.1.1, 5.2.0 and 5.3.0.so.far. (Being able to omit the
parentheses was promised for 5.2.0; hopefully we'll have it in 5.3.0.)
-W
On 23 September 2011 14:54, Slorg1 <slorg1 at percipiomedia.com> wrote:
> Hi Wolfgang,
>
> Thank you for answering, here is the rule rewritten but closer to reality:
>
> // package
>
> // imports
>
> global java.util.Date now;
>
> rule "MyRule"
> salience 5
> when
> // Prevent rule activation for other offer types.
> MyObject(type == Type.TYPE_SOUGHT)
>
> $candidate : Candidate(
> subObject.dateField != null && subObject.dateField.time >=
> now.time)
> then
> // do something
> end
>
> A value for 'now' being set like so:
> session.setGlobal("now", new Date()); // Date being the java.util.Date.
>
> But I do not think that matters because 'compilation' fails at this point.
>
> Thank you in advance for your time.
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Issue-using-global-variable-with-Drools-5-2-in-DRL-tp3360343p3361770.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110923/f085b426/attachment.html
More information about the rules-users
mailing list