[rules-users] Calling queries or collect() from functions
Wolfgang Laun
wolfgang.laun at gmail.com
Wed Oct 31 10:42:09 EDT 2012
Yes, you can create a query and call it in a function, as you'd call
it in Java - see the Expert documentation.
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.
I think you can omit the first pattern from Rule1.
-W
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
>
More information about the rules-users
mailing list