<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt">got it...<br>i guess ive been using drools 2.x for too long...since beta 2.0 beta 17...<br>any other way to do the or's?<br><br><div> </div>Joel G. Rivera-Gonzalez<br>PRT<br><br>"The first 90% of a project takes 90% of the time, the last 10% takes the other 90% of the time" - Murphy's Law<div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Edson Tirelli <tirelli@post.com><br>To: Rules Users List <rules-users@lists.jboss.org><br>Sent: Tuesday, January 9, 2007 8:12:05 PM<br>Subject: Re: [rules-users] About String..."==" same as ".equals"?<br><br><div> Joel,<br><br> No. Your mistake is on the mapping of objects x patterns. Let
me show <br>you an example:<br><br> If you write a rule like this:<br><br>rule "expensive muzzarela"<br>when<br> Cheese( type == "muzzarela", price > 50 )<br>then<br> // so something<br>end<br><br> You are saying the engine: "- match each SINGLE instance of Cheese <br>that is BOTH type == "muzzarela" AND whose price is greater than 50".<br><br> If you write a rule like this:<br><br>rule "one muzzarela and one expensive cheese"<br>when<br> Cheese( type == "muzzarela" )<br> Cheese( price > 50 )<br>then<br> // do something<br>end<br><br> You are saying the engine: "- match each PAIR of Cheese instances, <br>where the FIRST instance is of type == "muzzarela" and the SECOND <br>instance is of any cheese that has price greater than 50".<br><br> Do you see the difference?<br>
<br> So, if you do:<br><br>workingMemory.assert( new Cheese("muzzarela", 70) );<br>workingMemory.fireAllRules();<br><br> Only the first rule will fire, because the second rule requires 2 <br>objects, one matching each constraint.<br><br> If you do:<br><br>workingMemory.assert( new Cheese("muzzarela", 10) );<br>workingMemory.assert( new Cheese("brie", 70) );<br>workingMemory.fireAllRules();<br><br> Only the second rule will fire, because the first rule requires that <br>a single object match BOTH constraints.<br><br> So, the above has nothing to do with variable bindings, but to make <br>clear, you can bind variables to each of the patterns you write, but you <br>can't use the same variable name for different patterns as each pattern <br>will match a different object.<br><br> Also, please note that top level AND operator is optional as it is <br>already implicitly handled. So, the
bellow rule is IDENTICAL to the one <br>I wrote above:<br><br>rule "one muzzarela and one expensive cheese"<br>when<br> Cheese( type == "muzzarela" ) AND<br> Cheese( price > 50 )<br>then<br> // do something<br>end<br><br> I hope it clarified things a little bit. Let me know if you still <br>have questions.<br><br> []s<br> Edson<br><br><br>Joel G. Rivera-González wrote:<br><br>> i see...<br>> when 3.2 will be available?<br>> :-)<br>><br>> ok...<br>> so i'm writing the rules the wrong way?<br>> i need to put the and's on the same line separated by ','?<br>> i if wanted to the it the way i wrote the rules i would have to put a <br>> different name to each of the objects right? (mto1:MegaTransferObject <br>> mto2:MegaTransferObject, ect)<br>><br>> this is a little complicated and i dindt saw it on the <br>> documentation...where i
can read about it?<br>> i will rewrite the rules to match the right way...<br>><br>> thanks...<br>><br>><br>><br>><br>> <br>> Joel G. Rivera-Gonzalez<br>> PRT<br>><br>> "The first 90% of a project takes 90% of the time, the last 10% takes <br>> the other 90% of the time" - Murphy's Law<br>><br>><br>> ----- Original Message ----<br>> From: Edson Tirelli <tirelli@post.com><br>> To: Rules Users List <rules-users@lists.jboss.org><br>> Sent: Tuesday, January 9, 2007 6:44:22 PM<br>> Subject: Re: [rules-users] About String..."==" same as ".equals"?<br>><br>> Joel,<br>><br>> If it is the same object that you are trying to match against all of<br>> those constraints, just list all your constraints separated by ',' <br>> (comma):<br>><br>> rule "dtv_discount_request"<br>> when<br>> mto :
MegaTransferObject( orders_FkOrderTypeId ==<br>> Constants.NEW_COMPLETED_ORDER_TYPE,<br>> ct:other_ChannelType -> ( !<br>> ct.equalsIgnoreCase(Constants.CHANNEL_TYPE_RESELLER)),<br>> orders_FkChannelId !=<br>> Constants.ISP_CHANNEL_ID_PRW,<br>> orders_FkChannelId !=<br>>
Constants.ISP_CHANNEL_ID_TLD,<br>> orders_FkChannelId !=<br>> Constants.ISP_CHANNEL_ID_AOL,<br>> other_HasDtvDiscountRequest == false,<br>> pl:phoneList_GovernmentAccount -> ( (pl<br>> == null) || ( pl.equals(Constants.FLAG_NO))
),<br>> cp:customerProfile_DtvDiscount -> ( (cp<br>> == null) || ( cp.equals(Constants.FLAG_NO)) ),<br>> oa:other_AccountType -> ( ( oa == null)<br>> || ( oa.equals( Constants.PHONE_TYPE_RESIDENTIAL)) ) )<br>> then<br>> menu.add(new String[]{Constants.SERVICE_ASSURANCE_TREE_MENU_DSL,<br>> Constants.SERVICE_ASSURANCE_MENU_DTV_DISCOUNT_REQUEST});<br>> end<br>><br>><br>> Just remember:<br>><br>> * you must have one and only one pattern for each single object you want<br>> to match in
each rule, i.e., the mapping between patterns and object<br>> instances is always one-to-one.<br>><br>> * constraints are separated by ',' (comma), and ',' has an implicit<br>> meaning of AND between constraints<br>><br>> * version 3.0.x does not support OR between constraints, so the way<br>> around it is to use predicates like I demonstrated above. Version 3.2<br>> already has support for connective OR constraints.<br>><br>> I hope it helps.<br>><br>> []s<br>> Edson<br>><br>><br>> Joel G. Rivera-González wrote:<br>><br>> > i see...that would works...but now if you add stuff and make a rule<br>> > that look like this, the binding will not work...<br>> ><br>> > rule "dtv_discount_request"<br>> > when<br>> >
MegaTransferObject(orders_FkOrderTypeId ==<br>> > Constants.NEW_COMPLETED_ORDER_TYPE) and<br>> > not MegaTransferObject(ct:other_ChannelType -> <br>> > (ct.equalsIgnoreCase(Constants.CHANNEL_TYPE_RESELLER))) and<br>> > (not MegaTransferObject(orders_FkChannelId ==<br>> > Constants.ISP_CHANNEL_ID_PRW) and<br>> > not MegaTransferObject(orders_FkChannelId ==<br>> > Constants.ISP_CHANNEL_ID_TLD) and<br>> > not MegaTransferObject(orders_FkChannelId ==<br>> > Constants.ISP_CHANNEL_ID_AOL)) and<br>> > (MegaTransferObject(phoneList_GovernmentAccount == null) or<br>> > MegaTransferObject(phoneList_GovernmentAccount == <br>> Constants.FLAG_NO)) and<br>>
> (MegaTransferObject(customerProfile_DtvDiscount == null) or<br>> > MegaTransferObject(customerProfile_DtvDiscount == <br>> Constants.FLAG_NO)) and<br>> > (MegaTransferObject(other_AccountType == null) or<br>> > MegaTransferObject(other_AccountType ==<br>> > Constants.PHONE_TYPE_RESIDENTIAL)) and<br>> > MegaTransferObject(other_HasDtvDiscountRequest == false)<br>> > then<br>> > menu.add(new<br>> > String[]{Constants.SERVICE_ASSURANCE_TREE_MENU_DSL,<br>> > Constants.SERVICE_ASSURANCE_MENU_DTV_DISCOUNT_REQUEST});<br>> > end<br>> > <br>> > i was trying to bre creative and add megaTO: before all the<br>> > MegaTransferObject and it gave me the compilation error
you<br>> > mention...but only after the third megaTO:<br>> ><br>> ><br>> > Joel G. Rivera-Gonzalez<br>> > PRT<br>> ><br>> > "The first 90% of a project takes 90% of the time, the last 10% takes<br>> > the other 90% of the time" - Murphy's Law<br>> ><br>> ><br>> > ----- Original Message ----<br>> > From: Edson Tirelli <tirelli@post.com><br>> > To: Rules Users List <rules-users@lists.jboss.org><br>> > Sent: Tuesday, January 9, 2007 4:39:57 PM<br>> > Subject: Re: [rules-users] About String..."==" same as ".equals"?<br>> ><br>> > Joel,<br>> ><br>> > I just noticed in your last rule you do the binding to the same<br>> > variable:<br>> ><br>> > > megaTO:MegaTransferObject(other_AccountType == "RMS")<br>> >
> megaTO:MegaTransferObject(other_HasDtvDiscountRequest == <br>> false)<br>> ><br>> > I thought that feature was already disabled... :( it should give you<br>> > an error of duplicate variable declaration! is it not raising an error<br>> > when compiling the rule??<br>> ><br>> > The correct way of doing it if it is the same object is getting both<br>> > constraints in the same pattern:<br>> ><br>> > megaTO: MegaTransferObject( other_AccountType == "RMS",<br>> > other_HasDtvDiscountRequest == false)<br>> ><br>> > So, rules 1 and 2 are correct in not firing, since you would need 2<br>> > different objects to match the 2 patterns in them.<br>> > The mapping between patterns and objects is "one-to-one".<br>> ><br>>
> []s<br>> > Edson<br>> > <br>> ><br>> ><br>> > Joel G. Rivera-González wrote:<br>> ><br>> > > 1. i downloaded the latest release from the download page...<br>> > > 2. just one MTO...the returning arrayList should have arround 10 <br>> values.<br>> > ><br>> > > will do an example and (class and ruleFile) and send it to your <br>> email...<br>> > ><br>> > > thanks<br>> > > <br>> > > Joel G. Rivera-Gonzalez<br>> > > PRT<br>> > ><br>> > > "The first 90% of a project takes 90% of the time, the last 10% takes<br>> > > the other 90% of the time" - Murphy's Law<br>> > ><br>> > ><br>> > > ----- Original Message ----<br>> > > From: Edson Tirelli <tirelli@post.com><br>> > > To: Rules Users List
<rules-users@lists.jboss.org><br>> > > Sent: Tuesday, January 9, 2007 3:29:26 PM<br>> > > Subject: Re: [rules-users] About String..."==" same as ".equals"?<br>> > ><br>> > ><br>> > > Joel,<br>> > ><br>> > > Your rules seems to be correct.<br>> > > Questions:<br>> > ><br>> > > 1. What JBRules version are you using?<br>> > ><br>> > > 2. How many MTO instances are you asserting in the working memory, <br>> that<br>> > > would match each Pattern in your rule?<br>> > ><br>> > > It may be an issue with "or". Can you provide a self contained test<br>> > > for me to investigate?<br>> > ><br>> > > Thank you<br>> > > Edson<br>> > ><br>> > >
Joel G. Rivera-González wrote:<br>> > ><br>> > > > i have to be doing something wrong...but it make no sense...<br>> > > > a MegaTransferObject is asserted.<br>> > > ><br>> > > > case1: No rules fired.<br>> > > > rule "dtv_discount_request"<br>> > > > when<br>> > > > MegaTransferObject(other_AccountType == null) or<br>> > > > MegaTransferObject(other_AccountType ==<br>> > > > Constants.PHONE_TYPE_RESIDENTIAL)<br>> > > > MegaTransferObject(other_HasDtvDiscountRequest == false)<br>> > > > then<br>> > > > menu.add(new<br>> > > >
String[]{Constants.SERVICE_ASSURANCE_TREE_MENU_DSL,<br>> > > > Constants.SERVICE_ASSURANCE_MENU_DTV_DISCOUNT_REQUEST});<br>> > > > end<br>> > > ><br>> > > > case 2: no rule fired.<br>> > > ><br>> > > > rule "dtv_discount_request"<br>> > > > when<br>> > > > MegaTransferObject(other_AccountType == null) or<br>> > > > MegaTransferObject(other_AccountType == "RMS")<br>> > > > MegaTransferObject(other_HasDtvDiscountRequest == false)<br>> > > > then<br>> > > > menu.add(new<br>> > > > String[]{Constants.SERVICE_ASSURANCE_TREE_MENU_DSL,<br>> > > >
Constants.SERVICE_ASSURANCE_MENU_DTV_DISCOUNT_REQUEST});<br>> > > > end<br>> > > ><br>> > > > case 3: rule fired<br>> > > > <br>> > > > rule "dtv_discount_request"<br>> > > > when<br>> > > > megaTO:MegaTransferObject(other_AccountType == "RMS")<br>> > > > megaTO:MegaTransferObject(other_HasDtvDiscountRequest ==<br>> > false)<br>> > > > then<br>> > > > menu.add(new<br>> > > > String[]{Constants.SERVICE_ASSURANCE_TREE_MENU_DSL,<br>> > > > Constants.SERVICE_ASSURANCE_MENU_DTV_DISCOUNT_REQUEST});<br>> > > > end<br>> > > ><br>> > > > i really dont get it...<br>> > > > i must not be
getting something...<br>> > > > help...<br>> > > ><br>> > > ><br>> > > > Joel G. Rivera-Gonzalez<br>> > > > PRT<br>> > > ><br>> > > > "The first 90% of a project takes 90% of the time, the last 10% <br>> takes<br>> > > > the other 90% of the time" - Murphy's Law<br>> > > ><br>> > > ><br>> > > > ----- Original Message ----<br>> > > > From: Edson Tirelli <tirelli@post.com><br>> > > > To: Rules Users List <rules-users@lists.jboss.org><br>> > > > Sent: Tuesday, January 9, 2007 7:26:35 AM<br>> > > > Subject: Re: [rules-users] About String..."==" same as ".equals"?<br>> > > ><br>> > > ><br>> > > > Joel,<br>> > > ><br>> > > > This is the correct syntax and it works (at least we didn't
get a<br>> > > > report for it not working yet):<br>> > > ><br>> > > > Object(variable == Constants.value)<br>> > > ><br>> > > > Can you please elaborate about the problem you are having in <br>> order<br>> > > > for us to help solving it? If it is a bug we need to fix.<br>> > > ><br>> > > > Thank you,<br>> > > > Edson<br>> > > ><br>> > > > Joel G. Rivera-González wrote:<br>> > > ><br>> > > > > most (if not all) of my rules will have conditions like this:<br>> > > > > Object(variable == Constants.value)<br>> > > > > this is not working...<br>> > > > > BUT if i change the Constants.value to corresponding value <br>> from the<br>> > > > > constants class it will
work...<br>> > > > > is there any other way other than this Object(a:variable-> <br>> > > > > (a.equals(Constants.value)) to do it?<br>> > > > ><br>> > > > ><br>> > > > ><br>> > > > > <br>> > > > > Joel G. Rivera-Gonzalez<br>> > > > > PRT<br>> > > > ><br>> > > > > "The first 90% of a project takes 90% of the time, the last 10%<br>> > takes<br>> > > > > the other 90% of the time" - Murphy's Law<br>> > > > ><br>> > > ><br>> > ><br>> > <br>> >------------------------------------------------------------------------<br>> > > > ><br>> > > > >_______________________________________________<br>> > > > >rules-users mailing list<br>> > > > >rules-users@lists.jboss.org<br>> >
> > ><a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> > > > > <br>> > > > ><br>> > > ><br>> > > ><br>> > > > --<br>> > > > Edson Tirelli<br>> > > > Software Engineer - JBoss Rules Core Developer<br>> > > > Office: +55 11 3124-6000<br>> > > > Mobile: +55 11 9218-4151<br>> > > > JBoss, a division of Red Hat @ <a target="_blank" href="http://www.jboss.com">www.jboss.com</a> <<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>><br>> > <<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>> <<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>><br>> > > <<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>><br>> > >
><br>> > > ><br>> > > > _______________________________________________<br>> > > > rules-users mailing list<br>> > > > rules-users@lists.jboss.org<br>> > > > <a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> > > ><br>> > ><br>> > <br>> >------------------------------------------------------------------------<br>> > > ><br>> > > >_______________________________________________<br>> > > >rules-users mailing list<br>> > > >rules-users@lists.jboss.org<br>> > > ><a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> > > > <br>> > > ><br>> > ><br>> > ><br>> > > --<br>> > > Edson
Tirelli<br>> > > Software Engineer - JBoss Rules Core Developer<br>> > > Office: +55 11 3124-6000<br>> > > Mobile: +55 11 9218-4151<br>> > > JBoss, a division of Red Hat @ <a target="_blank" href="http://www.jboss.com">www.jboss.com</a> <br>> <<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>> <<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>><br>> > <<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>><br>> > ><br>> > ><br>> > > _______________________________________________<br>> > > rules-users mailing list<br>> > > rules-users@lists.jboss.org<br>> > > <a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> > ><br>> > <br>>
>------------------------------------------------------------------------<br>> > ><br>> > >_______________________________________________<br>> > >rules-users mailing list<br>> > >rules-users@lists.jboss.org<br>> > ><a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> > > <br>> > ><br>> ><br>> ><br>> > --<br>> > Edson Tirelli<br>> > Software Engineer - JBoss Rules Core Developer<br>> > Office: +55 11 3124-6000<br>> > Mobile: +55 11 9218-4151<br>> > JBoss, a division of Red Hat @ <a target="_blank" href="http://www.jboss.com">www.jboss.com</a> <<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>> <br>> <<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>><br>> ><br>> ><br>> >
_______________________________________________<br>> > rules-users mailing list<br>> > rules-users@lists.jboss.org<br>> > <a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> ><br>> >------------------------------------------------------------------------<br>> ><br>> >_______________________________________________<br>> >rules-users mailing list<br>> >rules-users@lists.jboss.org<br>> ><a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> > <br>> ><br>><br>><br>> -- <br>> Edson Tirelli<br>> Software Engineer - JBoss Rules Core Developer<br>> Office: +55 11 3124-6000<br>> Mobile: +55 11 9218-4151<br>> JBoss, a division of Red Hat @ <a target="_blank" href="http://www.jboss.com">www.jboss.com</a>
<<a target="_blank" href="http://www.jboss.com">http://www.jboss.com</a>><br>><br>><br>> _______________________________________________<br>> rules-users mailing list<br>> rules-users@lists.jboss.org<br>> <a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>><br>>------------------------------------------------------------------------<br>><br>>_______________________________________________<br>>rules-users mailing list<br>>rules-users@lists.jboss.org<br>><a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> <br>><br><br><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3124-6000<br> Mobile: +55 11 9218-4151<br> JBoss, a division of Red Hat @ <a target="_blank"
href="http://www.jboss.com">www.jboss.com</a><br><br><br>_______________________________________________<br>rules-users mailing list<br>rules-users@lists.jboss.org<br><a target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></div></div><br></div></div></body></html>