[rules-users] How to use contains with a function
Welsh, Armand
AWelsh at StateStreet.com
Wed Nov 23 13:06:41 EST 2011
Wrap in in ()'s like this:
$tc : TaskContext( times contains (getTimeByID(ETimeID.NOW)) )
I have not personally tried this exact scenario, but the concept is the same as other scenarios I use this for. The ()'s identifies that evaluation should be used here, except that it's not really an eval() because the contents don't returne true/false, but rather it's just java code to be processed, and the output can then be used in the evaluation.
I do this with matches like this:
LookupFact ( $lookupValue : value )
$sf : SomeFact ( value matches ("(?i)" + $lookupValue) )
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Hezi Stern
Sent: Wednesday, November 23, 2011 7:51 AM
To: rules-users at lists.jboss.org
Subject: [rules-users] How to use contains with a function
Hi all,
I encountered the following issue:
As an example TaskConectxt() holds a list of time related objects called times.
I would like to write a rule which ideally would filter the TaskContext according to a specific time object.
The problematic restriction is that this time object is derived using a helper function (imported), in this case called getTimeByID which received as input an enum ID of a time and returns the desired time object.
Ideally the rule would like something like this:
rule "verify time"
when
$tc: TaskContext(times contains getTimeByID(ETimeID.NOW))
then
//something
end
unfortunately this does not work.
Is there any way to call a function with a param?
Is there a better alternative method than this one?
Thanks,
Hezi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20111123/1848f47b/attachment.html
More information about the rules-users
mailing list