Hi All,
Thanks!
Steven's solution works fine. Thanks Man!
But when the V3.2 will be release? Now even checkout the latest codes from SVN, it still does not support "from". (the Version is 3.0.2, even older than 3.0.4).
 
Thanks
 
Best Regards
Weily Li

 
On 11/13/06, Edson Tirelli <[EMAIL PROTECTED]> wrote:

  Steven,

  You are right that predicates are potentially better and usually
should be used instead of eval().
  Predicates that do not use previously bound variables will indeed be
added to the alpha nodes (otherwise will be added to the beta nodes),
moving them up in the network, making your network more restrictive and
potentially more efficient. Also, the use of eval() will cause the
creation of an EvalNode in the network, making network bigger and more
resource consuming, and also potentially reducing performance.
  The only mistake is that the whole "when" (LHS) part of your rule
(including regular patterns, predicates, evals, etc) are evaluated when
working memory actions (assert/modify/retract) are performed. What is
only executed on fireAllRules() time is the "then" part (RHS) of your rule.

  []s
  Edson

Steven Williams wrote:

> a nicer way would be
> when
>     loanBO : LoanBO(la : loanAmount -> (la.getAmountDoubleValue () >
> 980.0) )
>
> If I'm not mistaken this keeps the evaluation of the condition in the
> alpha memory instead of the beta memory which basically means it is
> evaluated when the object is asserted instead of when fireAllRules is
> called. Somebody please correct me if this is incorrect.
>
> On 11/13/06, *Ali Abdel-Aziz Ali* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     Ok thanx everybody,
>
>     I used eval to solve my own problem
>
>     rule "test"
>     when
>         loanBO : LoanBO()
>         eval ( loanBO.getLoanAmount ().getAmountDoubleValue() > 980.0 )
>     then
>         // anything
>     end
>
>     Thank you all.
>
>
>     On 11/13/06, *Ali Abdel-Aziz Ali * < [EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>> wrote:
>
>         When I tried this code snippet in a similar case
>         it gives me org.drools.rule.InvalidRulePackage: unknown:yy:xx
>         Unexpected token 'loanBO'
>
>         this is my Bean Classes
>
>         class LoabBO {
>             private Money loanAmount;
>             public Money getLoanAmount() {
>                 return loanAmount;
>             }
>
>             void setLoanAmount(Money loanAmount) {
>                 this.loanAmount = loanAmount;
>             }
>         }
>
>         class Money {
>             private final BigDecimal amount;
>             public double getAmountDoubleValue() {
>                 return amount.doubleValue();
>             }
>         }
>
>         and this is my drl code
>
>         rule "test"
>         when
>             loanBO : LoanBO()
>             money : Money( amountDoubleValue > 980.0) from
>         loanBO.getLoanAmount()
>         then
>             // anything
>         end
>
>
>         On 11/10/06, *Edson Tirelli* < [EMAIL PROTECTED]
>         <mailto:[EMAIL PROTECTED]> > wrote:
>
>                Using 3.0.x version, Steven's suggestion is probably
>             the best. Using
>             the new version, you can use "from" as Geoffrey suggested.
>             Something
>             like that:
>
>             when
>                $p: Party()
>                $c: Contact() from p.getContacts()
>                $t : ContactType( name == "mobile" ) from
>             $c.getContactType()
>             then
>                //
>             end
>
>             Geoffrey Wiseman wrote:
>
>> This is also a textbook case of where 'from' should work,
>             from what
>> I've seen - although I don't think that's been released
>             yet.  Someone
>> else could tell you more.
>>
>> On 11/10/06, * Steven Williams*
>             <[EMAIL PROTECTED]
>             <mailto:[EMAIL PROTECTED]>
>> <mailto: [EMAIL PROTECTED]
>             <mailto:[EMAIL PROTECTED]>>> wrote:
>>
>>     Hi Weily,
>>
>>     one way I think would work is
>>
>>     //explode party contracts
>>     when
>>         p : Party(c : contracts)
>>     then
>>         for(Iterator it = c.iterator();it.hasNext();) {
>>             assert( it.next());
>>         }
>>     end
>>
>>     when
>>         c : Contract(ct : contractType -> (ct.getName
>             ().equals("mobile")))
>>         p : Party(contracts contains c)
>>     then
>>         ....
>>
>>
>>     On 11/10/06, * weily li* < [EMAIL PROTECTED]
>             <mailto: [EMAIL PROTECTED]>
>>     <mailto:[EMAIL PROTECTED]
>             <mailto:[EMAIL PROTECTED]>>> wrote:
>>
>>         Here is such scenario.
>>         First I create a party instance, which has a Set
>             attribute.
>>         The set contains all avariable contact mechnism
>             for the party.
>>         Here is the Bean class:
>>
>>         public class Party{
>>          private Set contracts;
>>         }
>>
>>         public   class Contact {
>>          private ContactType contactType;
>>          private String contactValue;
>>
>>         }
>>
>>         public   class ContactType {
>>          private String name;
>>          private String comments;
>>         }
>>
>>
>>         Now at rule, I want to select these Parties whose
>             contact type
>>         support mobile phone..
>>         Could you share such a sample ?
>>
>>         Thanks
>>         Best Regards
>>         Weily
>>
>>
>>
>>
>>
>>     --
>>     Steven Williams
>>
>>     Supervising Consultant
>>
>>     Object Consulting
>>     Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
>>     [EMAIL PROTECTED]
>             <mailto:[EMAIL PROTECTED]>
>>     <mailto: [EMAIL PROTECTED]
>             <mailto:[EMAIL PROTECTED]>>
>>     www.objectconsulting.com.au
>             <http://www.objectconsulting.com.au> <
>             http://www.objectconsulting.com.au >
>>
>>     consulting | development | training | support
>>     our experience makes the difference
>>
>>
>>
>>
>> --
>> Geoffrey Wiseman
>
>
>
>             --
>               ---
>               Edson Tirelli
>               Software Engineer - JBoss Rules Core Developer
>               Office: +55 11 3124-6000
>               Mobile: +55 11 9218-4151
>               JBoss, a division of Red Hat @ www.jboss.com
>             <http://www.jboss.com >
>
>               IT executives: Red Hat still #1 for value
>               http://www.redhat.com/promo/vendor/
>             < http://www.redhat.com/promo/vendor/>
>
>
>             ---------------------------------------------------------------------
>
>             To unsubscribe from this list please visit:
>
>                 http://xircles.codehaus.org/manage_email
>             <http://xircles.codehaus.org/manage_email >
>
>
>
>
>         --
>         Ali Abdel-Aziz
>         http://www.aliabdelaziz.com
>         http://aabdelaziz.blogspot.com
>
>
>
>
>     --
>     Ali Abdel-Aziz
>     http://www.aliabdelaziz.com
>     http://aabdelaziz.blogspot.com
>
>
>
>
> --
> Steven Williams
>
> Supervising Consultant
>
> Object Consulting
> Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> www.objectconsulting.com.au <http://www.objectconsulting.com.au>
>
> consulting | development | training | support
> our experience makes the difference



--
---
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @ www.jboss.com

IT executives: Red Hat still #1 for value
http://www.redhat.com/promo/vendor/


---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to