[rules-users] Re: from collect (processed = true/false) always compute same result

Thorsten Traegenap traegenap at ttc-informatik.de
Mon Dec 29 11:28:02 EST 2008


I´am sorry, my mistake.... (forget this)

Wrong use / understanding of shadow facts. Some fields are final, 
changed this and everything working well.

Thorsten

> Hi,
> 
> in the beginning I inserted a couple of not processed customers in my 
> workingmemory (#total = #not processed, #processed = 0). During the 
> rules 1-9 a part ot these customers will be processed (call 
> $customer.setProcessed(true) and udpate($customer) the wm).
> 
> Rule 10 + 11 should sort the customers. The result of rule 10 looks 
> perfect, the list just contain the processes customers. The result of 
> rule 11 looks bad, all customers in the wm are in the result. (#total  = 
> #not processed + #processed)
> 
> Rule 11 is activated as last one, in the insert process all customers 
> are not processed, then I try to change the customer objects in the 
> working memory (rule 1-9). The output produced in the for-loop shows 
> that already processed customers are in the list, which should only 
> contain not processed customers.
> 
> What is wrong, where I made my mistake?
> 
> best wishes+Thanks a lot.
> Thorsten Trägenap
> 
> rule "#10"
>     salience 46
>     when
>         $kunden : ArrayList() from collect (Customer(processed == true))
>     then
>         System.err.println("customers already processed " + 
> $kunden.size() + " " + $kunden);
> end
> 
> 
> rule "#11"
>     salience 47
>     when
>         $cust : ArrayList() from collect (Customer(processed == false))
>     then
>         System.err.println("Customer to process " + $cust.size() + " " + 
> $cust);
>         for (int i = 0; i < $cust.size(); i++) {
>             Customer c = (Customer)$cust.get(i);
>             if (c.getProcessed()) System.err.println("Why i am here: " + 
> c);
>         }
> end
> 
> 
> _______________________________________________
> 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