Re: [rules-users] rules not wrking
You should read at least chapter 4 of http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html/index.html where eval() and everything else you can use in a rule is described. Using output statements on the left hand side of a rule is not a very good way of determining whether a rule fires or not. Using the KnowledgeRuntimeLogger (see section 3.3.6) might be a better way of seeing what goes on in your rule based system. There is no special class for methods you can call in an eval(). An import (in the .drl file) may be required if it is a static method. In any case, an expression used inside eval() must result in a boolean value. -W 2010/4/30 Puneet duggal > thanks for ur reply friend, > > can u tell me how to use eval() > and in which class do i have to > put my function which i have to call it from eval() function > > > > On 4/30/10, Esteban Aliverti wrote: >> >> You can't directly use java code inside the LHS of a rule. You can though >> use eval to call a java method inside your LHS. Also remember that you don't >> have to use ; in the patterns. >> >> 2010/4/30 Puneet duggal >> >>> frnds i have a rule >>> >>> and its not working and i for checking i have put a Sop in my when but >>> it not prints the >>> Inside Area_SqFt_1_10-01-09_12-31-14 >>> so how can we put SOP inside when clause. >>> >>> rule "Area_SqFt_1_10-01-09_12-31-14" >>> >>> date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 6 >>> >>> no-loop true >>> >>> when >>> >>> System.out.println("Inside Area_SqFt_1_10-01-09_12-31-14"); >>> >>> objectP2483 : Para_2483( (fid2335=="Block") && (fid2336==16) ); >>> >>> then >>> >>> System.out.println("Area_SqFt_1_10-01-09_12-31-14"); >>> >>> objectP2483.setFid31003(new Double(497)); end >>> >>> ___ >>> rules-users mailing list >>> rules-users@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/rules-users >>> >>> >> >> >> -- >> >> >> Esteban Aliverti >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rules not wrking
hi Esteban , My rule is something like this rule "Area_EstimatedRval1_10-01-09_12-31-14" date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 5 no-loop true when eval(BusinessLogic.gettest("inside Area_EstimatedRval1_10-01-09_12-31-14")) objectP2483 : Para_2483( (fid2329=="Accessible Attic" ||fid2329=="Mobile Home") && (fid2337=="Fiberglass (Blown)") ); then System.out.println("Area_EstimatedRval1_10-01-09_12-31-14"); objectP2483.setFid2339(objectP2483.getFid2338() * 2.2);update(objectP2483); end but its not going inside the BusinessLogic.gettest("inside Area_EstimatedRval1_10-01-09_12-31-14")) whats wrong in this ?? > > > On 5/1/10, Esteban Aliverti wrote: > > Please remember that rules' conditions are evaluated when you > insert/modify/retract a Fact and not when you call fireAllRules(). > > > On Fri, Apr 30, 2010 at 2:54 PM, John Peterson < > john.peterson.g...@statefarm.com> wrote: > >> If you really wanted to see your text string there, you might be able to >> invoke a method that takes that text string and prints it and then >> returns "true" in all cases. You'd most likely need to put it in an >> Eval as suggested below. >> >> >> >You can't directly use java code inside the LHS of a rule. You can >> though >> >use eval to call a java method inside your LHS. Also remember that you >> don't >> >have to use ; in the patterns. >> > >> >2010/4/30 Puneet duggal >> > >> >> frnds i have a rule >> >> >> >> and its not working and i for checking i have put a Sop in my when >> but >> >> it not prints the >> >> Inside Area_SqFt_1_10-01-09_12-31-14 >> >> so how can we put SOP inside when clause. >> >> >> >> rule "Area_SqFt_1_10-01-09_12-31-14" >> >> >> >> date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 6 >> >> >> >> no-loop true >> >> >> >> when >> >> >> >> System.out.println("Inside Area_SqFt_1_10-01-09_12-31-14"); >> >> >> >> objectP2483 : Para_2483( (fid2335=="Block") && (fid2336==16) ); >> >> >> >> then >> >> >> >> System.out.println("Area_SqFt_1_10-01-09_12-31-14"); >> >> >> >> objectP2483.setFid31003(new Double(497)); end >> >> >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > > > -- > > > Esteban Aliverti > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rules not wrking
hi john, My rule is something like this rule "Area_EstimatedRval1_10-01-09_12-31-14" date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 5 no-loop true when eval(BusinessLogic.gettest("inside Area_EstimatedRval1_10-01-09_12-31-14")) objectP2483 : Para_2483( (fid2329=="Accessible Attic" ||fid2329=="Mobile Home") && (fid2337=="Fiberglass (Blown)") ); then System.out.println("Area_EstimatedRval1_10-01-09_12-31-14"); objectP2483.setFid2339(objectP2483.getFid2338() * 2.2);update(objectP2483); end but its not going inside the BusinessLogic.gettest("inside Area_EstimatedRval1_10-01-09_12-31-14")) whats rung in this ?? On 4/30/10, John Peterson wrote: > > If you really wanted to see your text string there, you might be able to > invoke a method that takes that text string and prints it and then > returns "true" in all cases. You'd most likely need to put it in an > Eval as suggested below. > > > >You can't directly use java code inside the LHS of a rule. You can > though > >use eval to call a java method inside your LHS. Also remember that you > don't > >have to use ; in the patterns. > > > >2010/4/30 Puneet duggal > > > >> frnds i have a rule > >> > >> and its not working and i for checking i have put a Sop in my when > but > >> it not prints the > >> Inside Area_SqFt_1_10-01-09_12-31-14 > >> so how can we put SOP inside when clause. > >> > >> rule "Area_SqFt_1_10-01-09_12-31-14" > >> > >> date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 6 > >> > >> no-loop true > >> > >> when > >> > >> System.out.println("Inside Area_SqFt_1_10-01-09_12-31-14"); > >> > >> objectP2483 : Para_2483( (fid2335=="Block") && (fid2336==16) ); > >> > >> then > >> > >> System.out.println("Area_SqFt_1_10-01-09_12-31-14"); > >> > >> objectP2483.setFid31003(new Double(497)); end > >> > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rules not wrking
Please remember that rules' conditions are evaluated when you insert/modify/retract a Fact and not when you call fireAllRules(). On Fri, Apr 30, 2010 at 2:54 PM, John Peterson < john.peterson.g...@statefarm.com> wrote: > If you really wanted to see your text string there, you might be able to > invoke a method that takes that text string and prints it and then > returns "true" in all cases. You'd most likely need to put it in an > Eval as suggested below. > > > >You can't directly use java code inside the LHS of a rule. You can > though > >use eval to call a java method inside your LHS. Also remember that you > don't > >have to use ; in the patterns. > > > >2010/4/30 Puneet duggal > > > >> frnds i have a rule > >> > >> and its not working and i for checking i have put a Sop in my when > but > >> it not prints the > >> Inside Area_SqFt_1_10-01-09_12-31-14 > >> so how can we put SOP inside when clause. > >> > >> rule "Area_SqFt_1_10-01-09_12-31-14" > >> > >> date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 6 > >> > >> no-loop true > >> > >> when > >> > >> System.out.println("Inside Area_SqFt_1_10-01-09_12-31-14"); > >> > >> objectP2483 : Para_2483( (fid2335=="Block") && (fid2336==16) ); > >> > >> then > >> > >> System.out.println("Area_SqFt_1_10-01-09_12-31-14"); > >> > >> objectP2483.setFid31003(new Double(497)); end > >> > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > -- Esteban Aliverti ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rules not wrking
If you really wanted to see your text string there, you might be able to invoke a method that takes that text string and prints it and then returns "true" in all cases. You'd most likely need to put it in an Eval as suggested below. >You can't directly use java code inside the LHS of a rule. You can though >use eval to call a java method inside your LHS. Also remember that you don't >have to use ; in the patterns. > >2010/4/30 Puneet duggal > >> frnds i have a rule >> >> and its not working and i for checking i have put a Sop in my when but >> it not prints the >> Inside Area_SqFt_1_10-01-09_12-31-14 >> so how can we put SOP inside when clause. >> >> rule "Area_SqFt_1_10-01-09_12-31-14" >> >> date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 6 >> >> no-loop true >> >> when >> >> System.out.println("Inside Area_SqFt_1_10-01-09_12-31-14"); >> >> objectP2483 : Para_2483( (fid2335=="Block") && (fid2336==16) ); >> >> then >> >> System.out.println("Area_SqFt_1_10-01-09_12-31-14"); >> >> objectP2483.setFid31003(new Double(497)); end >> ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rules not wrking
thanks for ur reply friend, can u tell me how to use eval() and in which class do i have to put my function which i have to call it from eval() function On 4/30/10, Esteban Aliverti wrote: > > You can't directly use java code inside the LHS of a rule. You can though > use eval to call a java method inside your LHS. Also remember that you don't > have to use ; in the patterns. > > 2010/4/30 Puneet duggal > >> frnds i have a rule >> >> and its not working and i for checking i have put a Sop in my when but >> it not prints the >> Inside Area_SqFt_1_10-01-09_12-31-14 >> so how can we put SOP inside when clause. >> >> rule "Area_SqFt_1_10-01-09_12-31-14" >> >> date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 6 >> >> no-loop true >> >> when >> >> System.out.println("Inside Area_SqFt_1_10-01-09_12-31-14"); >> >> objectP2483 : Para_2483( (fid2335=="Block") && (fid2336==16) ); >> >> then >> >> System.out.println("Area_SqFt_1_10-01-09_12-31-14"); >> >> objectP2483.setFid31003(new Double(497)); end >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > > -- > > > Esteban Aliverti > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rules not wrking
You can't directly use java code inside the LHS of a rule. You can though use eval to call a java method inside your LHS. Also remember that you don't have to use ; in the patterns. 2010/4/30 Puneet duggal > frnds i have a rule > > and its not working and i for checking i have put a Sop in my when but > it not prints the > Inside Area_SqFt_1_10-01-09_12-31-14 > so how can we put SOP inside when clause. > > rule "Area_SqFt_1_10-01-09_12-31-14" > > date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 6 > > no-loop true > > when > > System.out.println("Inside Area_SqFt_1_10-01-09_12-31-14"); > > objectP2483 : Para_2483( (fid2335=="Block") && (fid2336==16) ); > > then > > System.out.println("Area_SqFt_1_10-01-09_12-31-14"); > > objectP2483.setFid31003(new Double(497)); end > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > -- Esteban Aliverti ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] rules not wrking
frnds i have a rule and its not working and i for checking i have put a Sop in my when but it not prints the Inside Area_SqFt_1_10-01-09_12-31-14 so how can we put SOP inside when clause. rule "Area_SqFt_1_10-01-09_12-31-14" date-effective "01-Oct-2009" date-expires "31-Dec-2014" salience 6 no-loop true when System.out.println("Inside Area_SqFt_1_10-01-09_12-31-14"); objectP2483 : Para_2483( (fid2335=="Block") && (fid2336==16) ); then System.out.println("Area_SqFt_1_10-01-09_12-31-14"); objectP2483.setFid31003(new Double(497)); end ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users