Re: [rules-users] Function call in LHS
Hi I am trying to cal a local function getMaturityAge() in the decision table condition column like RuleTable MaturityAge Validation CONDITION ACTION pp:PremiumCalculatorFormBean getMaturityAge() $1 System.out.println(invalid maturity age); Premium Payment Term Print out message? 70 X The method is defined localy using functions key word. And moreover whenever I trying to pass pp as the argument to my functions, its not able to find pp. I am getting cud not parse knowledge error. can anyone pz help me out. -- View this message in context: http://drools.46999.n3.nabble.com/Function-call-in-LHS-tp56345p3919318.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Function call from LHS in Drools
Thanks a lot Wolfgang. Regards, Akash From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: Monday, January 17, 2011 9:27 PM To: Rules Users List Subject: Re: [rules-users] Function call from LHS in Drools when System ($users: users) $user : User () from $users eval ( SuperUser.equals( HelperFunction.getUserType($user) ) ) You just cannot bind the result of a method/function call to a variable. Inside eval, you are in Java country, so don't use ==. -W 2011/1/17 Mohod, Akash akash.mo...@morganstanley.commailto:akash.mo...@morganstanley.com Hi, I want to do something like this in my rule : - when System ($users: users) $user : User () from $users $userType : HelperFunction.getUserType($user) eval($userType == SuperUser) then System.out.println( User Type is + $userType); end The idea is I want to get the type of user using a static function call in the LHS. Is it possible to do so in the LHS. I am using Drools 5.1 . Regards, Akash NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing. ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Function call from LHS in Drools
Hi, I want to do something like this in my rule : - when System ($users: users) $user : User () from $users $userType : HelperFunction.getUserType($user) eval($userType == SuperUser) then System.out.println( User Type is + $userType); end The idea is I want to get the type of user using a static function call in the LHS. Is it possible to do so in the LHS. I am using Drools 5.1 . Regards, Akash -- NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Function call from LHS in Drools
when System ($users: users) $user : User () from $users eval ( “SuperUser”.equals( * HelperFunction.getUserType($user)* ) ) You just cannot bind the result of a method/function call to a variable. Inside eval, you are in Java country, so don't use ==. -W 2011/1/17 Mohod, Akash akash.mo...@morganstanley.com Hi, I want to do something like this in my rule : - when System ($users: users) $user : User () from $users *$userType : HelperFunction.getUserType($user)* eval($userType == “SuperUser”) then System.out.println(“ User Type is ” + $userType); end The idea is I want to get the type of user using a static function call in the LHS. Is it possible to do so in the LHS. I am using Drools 5.1 . Regards, Akash -- NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing. ___ 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] Function call in LHS
Hello, I am new to Drools. I have downloaded and installed Drools 4.0.7. After having read the documentation, I saw that it is possible to create function in the .drl file. I succeed in creating a function, calling it in the LHS with eval() instruction or in the RHS. But, is it possible to call a function in the LHS out of an eval() ? For example, I would like to use a pattern such as : $tmp : MyClass( name == MyFunction() ) Thanks in advance. Regards. JB ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Function call in LHS
only inside an eval or return value. Mark BINET JEAN-BAPTISTE wrote: Hello, I am new to Drools. I have downloaded and installed Drools 4.0.7. After having read the documentation, I saw that it is possible to create function in the .drl file. I succeed in creating a function, calling it in the LHS with eval() instruction or in the RHS. But, is it possible to call a function in the LHS out of an eval() ? For example, I would like to use a pattern such as : $tmp : MyClass( name == MyFunction() ) Thanks in advance. Regards. JB ___ 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] function call
I try and change the dialect but it doesn't work rule Your First Rule dialect mvel when then drools.rule.dialect=java System.out.println(drools.getRule().getDialect()); System.out.println(ok+func()); end the package still invalid : * (1,6) unable to resolve method using strict-mode: java.lang.Object.func(...) * (1,6) unable to resolve method using strict-mode: java.lang.Object.func(...) hypnosat7 wrote: Hi, I have a simple rule : function String isTrue() { return true; } rule new rule dialect mvel when eval(true) then System.out.println(passe+isTrue()); end But it seems impossible to call function's : org.mvel.PropertyAccessException: failed to access property: System.out.println(passe+isTrue()) in: null at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:137) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96) at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194) at org.mvel.MVELRuntime.execute(MVELRuntime.java:87) at org.mvel.MVEL.executeDebugger(MVEL.java:327) at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:43) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392) at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:37) Caused by: org.mvel.PropertyAccessException: null pointer exception in property: isTrue() at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:143) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96) at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194) at org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20) at org.mvel.MVELRuntime.execute(MVELRuntime.java:87) at org.mvel.CompiledExpression.getValue(CompiledExpression.java:98) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:421) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109) ... 10 more Caused by: java.lang.NullPointerException at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:429) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109) ... 17 more org.drools.spi.ConsequenceException: org.mvel.PropertyAccessException: failed to access property: System.out.println(passe+isTrue()) in: null at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:549) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392) at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:37) Caused by: org.mvel.PropertyAccessException: failed to access property: System.out.println(passe+isTrue()) in: null at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:137) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96) at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194) at org.mvel.MVELRuntime.execute(MVELRuntime.java:87) at org.mvel.MVEL.executeDebugger(MVEL.java:327) at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:43) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545) ... 4 more Caused by: org.mvel.PropertyAccessException: null pointer exception in property: isTrue() at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:143) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96) at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194) at org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20) at org.mvel.MVELRuntime.execute(MVELRuntime.java:87) at
Re: [rules-users] function call
unfortunately not, due to the build life cycle and classpath issues mvel cannot call functions defined in the DRL, although it can call normal static methods of existing classes ok. Mark Edson Tirelli wrote: I believe this problem is already fixed in trunk. You can download latest build from here: http://cruisecontrol.jboss.com/cc/artifacts/jboss-rules http://cruisecontrol.jboss.com/cc/artifacts/jboss-rules []s Edson 2007/8/29, hypnosat7 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]: I try and change the dialect but it doesn't work rule Your First Rule dialect mvel when then drools.rule.dialect=java System.out.println(drools.getRule().getDialect()); System.out.println(ok+func()); end the package still invalid : * (1,6) unable to resolve method using strict-mode: java.lang.Object.func(...) * (1,6) unable to resolve method using strict-mode: java.lang.Object.func(...) hypnosat7 wrote: Hi, I have a simple rule : function String isTrue() { return true; } rule new rule dialect mvel when eval(true) then System.out.println (passe+isTrue()); end But it seems impossible to call function's : org.mvel.PropertyAccessException: failed to access property: System.out.println(passe+isTrue()) in: null at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:137) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor (ReflectiveAccessorOptimizer.java:96) at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:194) at org.mvel.MVELRuntime.execute(MVELRuntime.java:87) at org.mvel.MVEL.executeDebugger (MVEL.java:327) at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:43) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545) at org.drools.common.DefaultAgenda.fireNextItem (DefaultAgenda.java:509) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java :392) at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:37) Caused by: org.mvel.PropertyAccessException: null pointer exception in property: isTrue() at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain (ReflectiveAccessorOptimizer.java:143) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:96) at org.mvel.ASTNode.getReducedValueAccelerated (ASTNode.java:194) at org.mvel.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:20) at org.mvel.MVELRuntime.execute(MVELRuntime.java:87) at org.mvel.CompiledExpression.getValue (CompiledExpression.java:98) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:421) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain (ReflectiveAccessorOptimizer.java:109) ... 10 more Caused by: java.lang.NullPointerException at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java :429) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:109) ... 17 more org.drools.spi.ConsequenceException: org.mvel.PropertyAccessException : failed to access property: System.out.println(passe+isTrue()) in: null at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:549) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430) at org.drools.common.AbstractWorkingMemory.fireAllRules (AbstractWorkingMemory.java:392) at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:37) Caused by: org.mvel.PropertyAccessException: failed to access property: System.out.println (passe+isTrue()) in: null at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:137) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor (ReflectiveAccessorOptimizer.java:96) at
Re: [rules-users] function call
Hi, Mark just told me there is a problem with MVEL calling functions... I believe he is working on that... []s Edson 2007/8/29, hypnosat7 [EMAIL PROTECTED]: I still have the same problem : * (1,6) unable to resolve method using strict-mode: java.lang.Object.func(...) * (1,6) unable to resolve method using strict-mode: java.lang.Object.func(...) package validity :false org.drools.rule.InvalidRulePackage: Unable to build expression for 'consequence' ' drools.rule.dialect=java System.out.println(drools.getRule().getDialect()); System.out.println(ok+func()); ' : [Rule name=Your First Rule, agendaGroup=MAIN, salience=0, no-loop=false] at org.drools.rule.Package.checkValidity(Package.java:416) at org.drools.common.AbstractRuleBase.addPackage( AbstractRuleBase.java:292) at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:34) my rule : rule Your First Rule dialect mvel when eval(true) then drools.rule.dialect=java System.out.println(drools.getRule().getDialect()); System.out.println(ok+func()); end Edson Tirelli-3 wrote: I believe this problem is already fixed in trunk. You can download latest build from here: http://cruisecontrol.jboss.com/cc/artifacts/jboss-rules []s Edson 2007/8/29, hypnosat7 [EMAIL PROTECTED]: I try and change the dialect but it doesn't work rule Your First Rule dialect mvel when then drools.rule.dialect=java System.out.println(drools.getRule().getDialect()); System.out.println(ok+func()); end the package still invalid : * (1,6) unable to resolve method using strict-mode: java.lang.Object.func(...) * (1,6) unable to resolve method using strict-mode: java.lang.Object.func(...) hypnosat7 wrote: Hi, I have a simple rule : function String isTrue() { return true; } rule new rule dialect mvel when eval(true) then System.out.println(passe+isTrue()); end But it seems impossible to call function's : org.mvel.PropertyAccessException: failed to access property: System.out.println(passe+isTrue()) in: null at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain( ReflectiveAccessorOptimizer.java:137) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor (ReflectiveAccessorOptimizer.java:96) at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java :194) at org.mvel.MVELRuntime.execute(MVELRuntime.java:87) at org.mvel.MVEL.executeDebugger(MVEL.java:327) at org.drools.base.mvel.MVELConsequence.evaluate( MVELConsequence.java:43) at org.drools.common.DefaultAgenda.fireActivation( DefaultAgenda.java:545) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java :509) at org.drools.common.AbstractWorkingMemory.fireAllRules( AbstractWorkingMemory.java:430) at org.drools.common.AbstractWorkingMemory.fireAllRules( AbstractWorkingMemory.java:392) at mcmipih.rules.demo.service.TestDraft.main(TestDraft.java:37) Caused by: org.mvel.PropertyAccessException: null pointer exception in property: isTrue() at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain( ReflectiveAccessorOptimizer.java:143) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor (ReflectiveAccessorOptimizer.java:96) at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java :194) at org.mvel.ast.BinaryOperation.getReducedValueAccelerated( BinaryOperation.java:20) at org.mvel.MVELRuntime.execute(MVELRuntime.java:87) at org.mvel.CompiledExpression.getValue(CompiledExpression.java :98) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod( ReflectiveAccessorOptimizer.java:421) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain( ReflectiveAccessorOptimizer.java:109) ... 10 more Caused by: java.lang.NullPointerException at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod( ReflectiveAccessorOptimizer.java:429) at org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain( ReflectiveAccessorOptimizer.java:109) ... 17 more org.drools.spi.ConsequenceException: org.mvel.PropertyAccessException : failed to access property: System.out.println(passe+isTrue()) in: null at org.drools.common.DefaultAgenda.fireActivation( DefaultAgenda.java:549) at
[rules-users] Function Call in LHS
Hello guys! This is my first question for the list. I've defined a function in my DRL file to evaluate if a user can do a specific operation in my system. This function returns a boolean result. My question is if I can use this function in the test of LHS. For example: rule Cliente pode alugar when eval(teste) then System.out.println(XX); end function boolean teste( ) { return true; } Please, if anybody has some help, send me. Thanks! Rafael Alcemar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Function Call in LHS
You should also use the parentheses for functions, as in normal Java code: eval ( teste() ) Of course you can add parameters etc. to your functions like this as well. Kris - Original Message - From: Rafael Alcemar To: rules-users@lists.jboss.org Sent: Friday, August 17, 2007 4:02 PM Subject: [rules-users] Function Call in LHS Hello guys! This is my first question for the list. I've defined a function in my DRL file to evaluate if a user can do a specific operation in my system. This function returns a boolean result. My question is if I can use this function in the test of LHS. For example: rule Cliente pode alugar when eval(teste) then System.out.println(XX); end function boolean teste( ) { return true; } Please, if anybody has some help, send me. Thanks! Rafael Alcemar -- ___ 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