Re: [rules-users] Issue using global 'variable' with Drools 5.2 in DRL
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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Issue using global 'variable' with Drools 5.2 in DRL
If it a java.util.Date then drools supports comparing them out of the box so you can just do subObjcet.dateField = now. Just make sure you don't mix up instances of java.util.Date and java.sql.Timestamp (eg if you have jpa code fetching object from the db) as sun in their wisdom made it that you can't compare them with each other! Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Slorg1 Sent: 23 September 2011 13:54 To: rules-users@lists.jboss.org Subject: Re: [rules-users] Issue using global 'variable' with Drools 5.2 in DRL 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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Issue using global 'variable' with Drools 5.2 in DRL
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 slo...@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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Issue using global 'variable' with Drools 5.2 in DRL
Hi, Thank you guys, it now works (at least that part) for me! -- View this message in context: http://drools.46999.n3.nabble.com/Issue-using-global-variable-with-Drools-5-2-in-DRL-tp3360343p3362157.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Issue using global 'variable' with Drools 5.2 in DRL
Good evening, I am porting our project from Drools 5.1 to Drools 5.2 and I am running into a couple of issues. Most I solved except: It seems that our global variable is being completely ignored. I have declared the following after package imports : global java.util.Date now; When calling it in a rule: rule MyRule when EXPRESSION = now.time then // things to do end Then I get the following error at 'compile' time : Not possible to directly access the property 'time' of declaration 'now' since it is not a pattern I do not know what to make of it. I have tried to change it to now.getTime() without success. Thank you in advance for your help. -- View this message in context: http://drools.46999.n3.nabble.com/Issue-using-global-variable-with-Drools-5-2-in-DRL-tp3360343p3360343.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Issue using global 'variable' with Drools 5.2 in DRL
On 23 September 2011 00:26, Slorg1 slo...@percipiomedia.com wrote: global java.util.Date now; When calling it in a rule: rule MyRule when EXPRESSION = now.time then // things to do end This comparison isn't in an eval CE or within a pattern? As it is written it can't be correct, global or no global. -W ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users