[rules-users] Inserting collection of facts in rule Consequence

techy techluver007 at gmail.com
Tue Feb 17 13:25:11 EST 2009


Thanks Steve.
But I would like to have a reusable function() in drools to retract
collection of facts.



Steven Williams-5 wrote:
> 
> I normally do something like
> 
> when
>     $creditContract : CreditContract()
>     $o : Applicant() from $creditContract.coApplicantArray
> then
>     insert($o);
> end
> 
> retract would be something like
> 
> when
>     $o : Applicant( )
>     CreditContract( coApplicantArray contains $o )
> then
>     retract($o);
> end
> 
> cheers
> Steve
> 
> 
> 
> On Tue, Feb 10, 2009 at 6:36 AM, <kfs2 at chryslerfinancial.com> wrote:
> 
>>
>> There may be a better way but I did it using a function as below:
>>
>> *function* *void* insertArray(WorkingMemory workingMemory, Object[]
>> array)
>> {
>>         *for* (*int* i=0;i<array.length;i++)
>>         {
>>                 workingMemory.*insert*(array[i]);
>>         }
>>         *return*;
>> }
>>
>> ...
>>
>> *rule* "StarCoApplicants" *ruleflow-group* "STAR"
>> *dialect* "mvel"
>>         *when*
>>                 $creditContract : CreditContract ()
>>         *then*
>>
>> insertArray(drools.workingMemory,$creditContract.coApplicantArray);
>>
>> *end*
>>
>>
>> Kent Symanzik
>>
>>
>>
>>  *techy <techluver007 at gmail.com>*
>> Sent by: rules-users-bounces at lists.jboss.org
>>
>> 02/09/2009 10:15 AM
>>  Please respond to
>> Rules Users List <rules-users at lists.jboss.org>
>>
>>   To
>> rules-users at lists.jboss.org
>>  cc
>>   Subject
>> Re: [rules-users] Inserting collection of facts in rule Consequence
>>
>>
>>
>>
>>
>> I would appreciate If someone can clarify this.
>>
>> Thanks in advance
>>
>>
>> techy wrote:
>> >
>> > Hello,
>> >
>> > Is there way to insert all facts from collection (similar to
>> > session.execute(collection)) in the rule consequence ?
>> >
>> > Thanks!
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Inserting-collection-of-facts-in-rule-Consequence-tp21814308p21914860.html
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> <http://www.nabble.com/Inserting-collection-of-facts-in-rule-Consequence-tp21814308p21914860.html>
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>    <https://lists.jboss.org/mailman/listinfo/rules-users>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Inserting-collection-of-facts-in-rule-Consequence-tp21814308p22063294.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list