[rules-users] Collect all occurrences of resulting data.

Wolfgang Laun wolfgang.laun at gmail.com
Mon Apr 21 11:46:50 EDT 2014


I recommend at most 3 levels of salience, and only if you have a
very limited scenario of insert / fire.

Alternatively, you can use agenda groups.

If I understand you correctly, you have some rules that execute
"Before" and others that should execute "After". In your .drl,

activation-group "Before"
rule ... when ... then ... end ... rule ... when ... then ... end
activation-group "After"
rule ... when ... then ... end ... rule ... when ... then ... end

You can set (the group "Before" before you insert facts, call
fireAllRules, set "After" and fire again; then start over again. - See
the Expert manual for some more about activation groups.

Setting the agenda group from Java takes a little digging in the API doc:
   session.getAgenda().getAgendaGroup( "Before" ).setFocus();

-W



On 21/04/2014, Ephemeris Lappis <ephemeris.lappis at gmail.com> wrote:
> Hello.
>
> Thanks for this advice.
>
> I've tried it with a small test case, and it actually works fine : the
> collecting rule seems to be fired at the end.
>
> Nonetheless, I'm not confident at all with salience, since in my real
> use case I have many rules before and after that, and I worry that
> salience might move the problem elsewhere, and values must be set to all
> of them to ensure they're all executed according to the expected order.
>
> At this moment, the rules before the collecting rule also produce facts
> that are expected by the rules that follow it, and, I suppose, it's for
> that reason that all the ending part of the job is executed after the
> correct collection of the intermediary results.
>
> Another alternative ?
>
> Thanks again.
>
> Regards
>
>
>
> Ephemeris Lappis
>
> Le 21/04/2014 13:11, laune [via Drools] a écrit :
>> This is one of the (rare) cases where I'd advocate salience.
>>
>> rule "Collect results when complete"
>> salience -999999
>>     when
>>                 $all : List from collect(Result())
>>     then
>>             ...do something with $all...
>> end
>>
>> -W
>>
>>
>> On 21/04/2014, Ephemeris Lappis <[hidden email]
>> </user/SendEmail.jtp?type=node&node=4029298&i=0>> wrote:
>>
>> > Hello.
>> >
>> > I'm looking for the better way to write a rule that collects data
>> only when
>> > they have been all processed.
>> >
>> > For example, two input objects classes as facts : *Data* and
>> *Category*.
>> >
>> > I declare a local type to memorize the result of the evaluation for
>> each
>> > pair of fact.
>> >
>> >
>> >
>> > Some rule evaluates the Cartesian product of all *Data* by all
>> *Category* :
>> >
>> >
>> >
>> > Now I want to collect all the results, but only when the previous
>> rule has
>> > been fired for all the data.
>> > Something like :
>> >
>> >
>> >
>> > Any advice ?
>> >
>> > Thanks in advance for your help.
>> >
>> > Regards.
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> >
>> http://drools.46999.n3.nabble.com/Collect-all-occurrences-of-resulting-data-tp4029296.html
>> > Sent from the Drools: User forum mailing list archive at Nabble.com.
>> > _______________________________________________
>> > rules-users mailing list
>> > [hidden email] </user/SendEmail.jtp?type=node&node=4029298&i=1>
>> > https://lists.jboss.org/mailman/listinfo/rules-users
>> >
>> _______________________________________________
>> rules-users mailing list
>> [hidden email] </user/SendEmail.jtp?type=node&node=4029298&i=2>
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>> ------------------------------------------------------------------------
>> If you reply to this email, your message will be added to the
>> discussion below:
>> http://drools.46999.n3.nabble.com/Collect-all-occurrences-of-resulting-data-tp4029296p4029298.html
>>
>>
>> To unsubscribe from Collect all occurrences of resulting data., click
>> here
>> <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4029296&code=ZXBoZW1lcmlzLmxhcHBpc0BnbWFpbC5jb218NDAyOTI5Nnw0OTQyMjM2NDI=>.
>> NAML
>> <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>>
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Collect-all-occurrences-of-resulting-data-tp4029296p4029300.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list