[rules-users] Calling queries or collect() from functions

Miguel Paraz mparaz at gmail.com
Mon Nov 5 06:49:58 EST 2012


Hi,

On Wed, Oct 31, 2012 at 10:42 PM, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:
> Yes, you can create a query and call it in a function, as you'd call
> it in Java - see the Expert documentation.

I'm sorry, I could not find this syntax in the documentation - could
someone share the link?

> Alternatively, consider using an insertLogical as in your Rule1,
> putting the list into a simple wrapper class declared in DRL.
>
> Or simply use "extends Rule1" in all the rules needing the collected
> list, omitting the insert from Rule1.

These are OK. Thanks!

> I think you can omit the first pattern from Rule1.

Yes, this is correct.

Cheers,
Miguel

> On 31/10/2012, Miguel Paraz <mparaz at gmail.com> wrote:
>> Hi,
>> I have a rule like:
>>
>> rule "Rule1"
>>     when
>>         $fact: Fact1()
>>         $allFacts: ArrayList() from collect(Fact1())
>>
>>     then
>>         insert(new Fact2($allFacts.size()));
>> end
>>
>>
>> I want to compute $allFacts inside a function since I will use it across
>> different rules.
>> This doesn't work because it is not valid Java syntax:
>>
>> function int size() {
>>     ArrayList a = ArrayList() from collect(InQueuePredicate());
>>     return a.size();
>> }
>>
>> Could I put this in a named query, and call it from a function?
>>
>> Thanks!
>> Miguel
>>
> _______________________________________________
> 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