RE: [rules-users] How to use not operator in drool.
Hi Edson Thanks for your reply. I guess we'll try and code in a work around for now. It would be great to have this feature though! :-) I've created a feature request in Jira. http://jira.jboss.com/jira/browse/JBRULES-1199 Regards, _ Arsalan Zaidi / Capgemini - India (FS SBU) / Mumbai Technical Architect Mobile Phone: +91 - 9892 8970 03 / www.capgemini.com http://www.capgemini.com/ Together: the Collaborative Business Experience _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli Sent: 14 September 2007 18:42 To: Rules Users List Subject: Re: [rules-users] How to use not operator in drool. Arsalan, Unfortunately Drools does not have a field constraint negation operator, mostly because when writing rules, it was not needed, since you can always negate the constraint itself. Although, I understand a agree with your use case. My suggestion is for you to open a JIRA feature request and we will include that as soon as possible in the product. Although, meanwhile, the only workaround I can see for your case is to translate the expression you are using directly into a java or mvel expression and write it inside an in-line eval. []s Edson 2007/9/14, Arsalan S. Zaidi [EMAIL PROTECTED]: Hi I'll try to explain the situation that Gaurav finds himself in. We're working on this problem together and so far, we haven't been able to crack it. We're using drools to handle the business rules for an application. The rules however, are not provided to us in a .drl file, rather, we get an XLS sheet from the analysts with rules in a different grammar. We're using ANTLR to read and parse these rules to generate the drools rules programmatically. However, we're running into problems with NOT. The input rules (in the non-drools business language) have a NOT operator which works like '!' in Java. It flips the Boolean around, so to speak. So: NOT((some sub expression which evaluates to TRUE)) == FALSE MVEL doesn't seem to support this. So how do we simulate it? If it were only being used with NOT IN, we could manage, but its use is completely arbitrary. Changes to the input rules or to the input rules grammar have been (ha ha) ruled out. Any help would be appreciated. Regards, _ Arsalan Zaidi / Capgemini - India (FS SBU) / Mumbai Technical Architect Mobile Phone: +91 - 9892 8970 03 / www.capgemini.com http://www.capgemini.com/ Together: the Collaborative Business Experience _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Anstis, Michael (M.) Sent: 13 September 2007 13:31 To: Rules Users List Subject: RE: [rules-users] How to use not operator in drool. What dialect do your rules use? You could also simplify the logic using DeMorgans Theorem (which might be troublesome to accomplish programmatically) I don't know whether your example is flawed as the brackets don't match, but assuming you mean something like this:- (NOT (G13.1 IN (1,2,3) OR (G250.8 = Y))) You can re-write this as (G13.1NOT IN (1,2,3) AND G250.8 != Y) With kind regards, Mike From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of JOSHI, GAURAV Sent: 13 September 2007 08:20 To: Rules Users List Subject: RE: [rules-users] How to use not operator in drool. Thank's for your sugession of using not in instead of not but my problem is that not can also come without in. Actually I am making a generator of rule file from expression like ((NOT (ENDS WITH (G10.2, ,))) ((NOT (G13.1 IN (1,2,3))) OR (G250.8 = Y))) Where G13.2, G250.8, G10.2 are variables coming from a map inserted in working memory. I am accessing these variables from map. My rules are as follows This rule is working fine. rule Editable_G10.3 when ((Map( this[G10.3] !=8))||(Map( this[G10.2] ==19))) then System.out.println(comming here-); End This is not working rule Mandatory_G10.3 when (not((Map( this[G10.3] !=8))||(Map( this[G10.2] ==19 Then System.out.println(comming here-); End In also tried following approaches: 1) eval(not((Map( this[G10.3] !=8))||(Map( this[G10.2] ==19 2) eval(!((Map(
[rules-users] Assigning variables in decision tables
Mark, You made a comment on my JIRA that I thought I'd post here for discussion: Mark Proctor commented on JBRULES-1155: --- anAnwer is a method/function that returns a boolean? Must admit I don't understand what you are trying to do there. Anyway if all you are trying to do is assign the results of a function/method call then why not just use an = assignment? BooleanAnswer = anAnswer(anAnswer.setAnswer(true)); Any valid java can used. What I'm really trying to do is simply return a boolean from a set of really complicated rules in my decision table. I run through the rules and if it passes, I return true. The reason I didn't do what you suggested above is b/c there is no documentation to suggest this is valid syntax and, after several postings to this list, no one responded to my requests on how to do this assignment. So, how do I do an assignment in a decision table to simply return a boolean? Otherwise, can you explain the syntax you posted to me. This doesn't look like any Java I've seen and I can't make heads or tails of how it should work. Thanks. Thom Hehl Sr. eJuror Architect * Office (859) 277-8800 x 144 * [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] ACS, Inc. Government Solutions 1733 Harrodsburg Road Lexington, KY 40504-3617 This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message and notify sender via e-mail at [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] or by telephone at 859-277-8800 ext. 144. Thank you. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Coding syntax differences
Let me preface my question by saying I'm new to both Java and drools so if it is silly or the answer is obvious, you know why. Given the two rules below, what, if any, is the difference between the two? rule Low Premium when p : Policy( sex == m premium 50.00 ) then p.setStatus( 32 ); end rule Low Premium when p: Policy( sex == m, premium 50.00 ) then p.setStatus( 32 ); end The first rule is from a .drl I coded and the second was generated from .dsl mapping. My specific question is about the when portion. Is there a difference between the two? Does the , represent and? If so, how would or be written or represented in the .dsl/.drl? Rod ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Assigning variables in decision tables
I think mic finally understand what you meant and commented in JIRA. Use a global, all you want is a way to retrieve some value from the rulebase, which is set/populated in the actions. This is no different from standard DRL. Mark Hehl, Thomas wrote: Mark, You made a comment on my JIRA that I thought I'd post here for discussion: Mark Proctor commented on JBRULES-11 55: --- anAnwer is a method/function that returns a boolean? Must admit I don't understand what you are trying to do there. Anyway if all you are trying to do is assign the results of a function/method call then why not just use an = assignment? BooleanAnswer = anAnswer(anAnswer.setAnswer(true)); Any valid java can used. What I'm really trying to do is simply return a boolean from a set of really complicated rules in my decision table. I run through the rules and if it passes, I return true. The reason I didn't do what you suggested above is b/c there is no documentation to suggest this is valid syntax and, after several postings to this list, no one responded to my requests on how to do this assignment. So, how do I do an assignment in a decision table to simply return a boolean? Otherwise, can you explain the syntax you posted to me. This doesn't look like any Java I've seen and I can't make heads or tails of how it should work. Thanks. **Thom Hehl*** *Sr. eJuror Architect **) Office (859) 277-8800 x 144** *** [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] *** ***ACS, Inc.** **Government Solutions** **1733 Harrodsburg Road*** **Lexington, KY 40504-3617*** **This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message and notify sender via e-mail at [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]_ or by telephone at 859-277-8800 ext. 144. Thank you.** ___ 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] Coding syntax differences
http://downloads.jboss.com/drools/docs/4.0.1.14754GA/html/index.html Section 6.5.2.1. []s Edson 2007/9/17, [EMAIL PROTECTED] [EMAIL PROTECTED]: Let me preface my question by saying I'm new to both Java and drools so if it is silly or the answer is obvious, you know why. Given the two rules below, what, if any, is the difference between the two? rule Low Premium when p : Policy( sex == m premium 50.00 ) then p.setStatus( 32 ); end rule Low Premium when p: Policy( sex == m, premium 50.00 ) then p.setStatus( 32 ); end The first rule is from a .drl I coded and the second was generated from .dsl mapping. My specific question is about the when portion. Is there a difference between the two? Does the , represent and? If so, how would or be written or represented in the .dsl/.drl? Rod ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli Software Engineer - JBoss Rules Core Developer Office: +55 11 3529-6000 Mobile: +55 11 9287-5646 JBoss, a division of Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Rule Inheritance support
Hello list. I needed some expert advice related to implementing Rule inheritance in Drools. I will still consider myself new to Drools and trying to go through all the source code currently. The requirement for rule inheritance that I have is as follows: A set of rules are defined/implemented on an entity acting as a template for other entities. Any entity created using template entity will inherit rules defined in template. There may be hundreds of child entities created from parent template entity. Inheritance here supports the following: 1. All enabled rules from template are also enabled on child entity. 2. Child entity can over-ride one or more of the rules defined in template. Child entity may also change rule settings/disable them. 3. Child entity can also extend rule-base by adding its own rules which are not defined in template. I know there has been mentioned in the list of not having support for rule inheritance in Drools yet, but no discussion of how to achieve it. So any insights will be greatly appreciated. Also one of the design questions here is should we use separate rule-base for each child entity as well as template entity (there can be potentially hundreds of child entities for a given template) or should we try to use only one rule-base and provide support for inheritance using only custom agenda filtering. Usage of custom agenda filter may help with performance as it won't require hundreds of rule-bases but may not be even feasible to what we are trying to accomplish here. Also it may result in other short-comings but I can't visualize it just yet. Thanks Kunal Shah Development www.sensorlogic.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] rule flow -- possible bug?
Thank you for explanations, it did clear up the picture for me, but I still didn't resolve the problem that I am having. Looks like problem happens when attributes are involved in a Split. Possible bug? So here is an example: I am inserting initially a simple TestValid class that has boolean hasError attribute = false; insert(new TestValid(false)); INIT ruleflow-group just prints out the facts : rule INIT ruleflow-group INIT no-loop when $v : TestValid() then System.out.println(INIT : HAS ERROR ? : + $v.isHasErrors()); end The Make Error ruleflow-group is activated when hasError attribute is flase in estValid fact : rule Make Error ruleflow-group Make Error no-loop when $v : TestValid(hasErrors == false) then System.out.println(Make Error!!!); $v.setHasErrors(true); retract($v); insert($v); end The Has Error? XOR Split has the following constraints: - TestValid(hasErrors == false) // goes to No Errors Action - TestValid(hasErrors == true) // goes to END The Actions Just print out information : - System.out.println(Init Action); - System.out.println(No Errors Action); When running example I was expecting to see the following events as seen on console: START Init Action INIT : HAS ERROR ? : false No Errors Action Make Error!!! Init Action INIT : HAS ERROR ? : true END Instead that is what I see: START Init Action INIT : HAS ERROR ? : false No Errors Action Make Error!!! Init Action INIT : HAS ERROR ? : true No Errors Action Init Action No Errors Action Init Action ... infinitely goes like this Now is this again expected behavior or a possible bug? If it is expected then how can I make decisions based on attribute of a fact in a Split... Thank you, -Sergey From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor Sent: Friday, September 14, 2007 8:37 PM To: Rules Users List Subject: Re: [rules-users] rule flow true, damn :) I did think of an attribute to re-activate any rules that are true, but not currently on the agenda - but not sure about it yet, would have to think on the negative effects some more. Mark Kris Verlaenen wrote: use the rule attribute lock-on-active to stop this behaviour, it stops a rule re-activating while the ruleflowgroup is active Well, this won't work for the same reason no-loop isn't working: if you use lock-on-active, it will make sure that the rule is not reactivated, so the execution of the node will end after one increment. But the lock-on-active makes sure that no activation is ever created, so, in the context of looping in ruleflow, even if the RuleSet node is activated again afterwards, it will never increment the integer again (as you prevented reactivation of the rule using lock-on-active), resulting in an endless loop in this case. Currently, as far as I know, the only thing that works is manually deactivating the ruleflow-group. Kris ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** ** LEGAL DISCLAIMER ** ** This E-mail message and any attachments may contain legally privileged, confidential or proprietary information. If you are not the intended recipient(s), or the employee or agent responsible for delivery of this message to the intended recipient(s), you are hereby notified that any dissemination, distribution or copying of this E-mail message is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete this E-mail message from your computer.image002.jpg___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Similarly Named DSL Rules Not Working
Brian, the order of the mappings is important, because DSL is a text match engine. So, always write your DSL Mapping file having the most restrictive mappings first. []s Edson 2007/9/17, Brian Enderle [EMAIL PROTECTED]: I have the following DSL entries: County is invalid for State [condition][]County is invalid for State=eval(StringUtils.isNotBlank ($i.getCntyCd())) and eval(!$i.getCntyCd().substring(0,2).equals($i.getStateCd ())) POB County is invalid for State [condition][]POB County is invalid for State=eval(StringUtils.isNotBlank ($i.getPobCntyCd())) and eval(!$i.getPobCntyCd().substring(0,2).equals ($i.getPobStateCd())) The rule in which I am using the DSL entry is as follows: rule LevelOne: Place Of Birth, County is invalid agenda-group LevelOne when There is a NwCitizenship - pobCntryCd equals MessageConstants.COUNTRY_CODE_US POB County is invalid for State then Report error end When I atempt to use the POB County... rule I get the following error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ruleBase' defined in class path resource [spring-beans.xml]: Invocation of init method failed; nested exception is org.drools.rule.InvalidRulePackage: [143,33]: unknown:143:33 Unexpected token '$i'[143,47]: unknown:143:47 mismatched token: [EMAIL PROTECTED],4726:4726=')',12,143:47]; expecting type THEN Caused by: org.drools.rule.InvalidRulePackage: [143,33]: unknown:143:33 Unexpected token '$i'[143,47]: unknown:143:47 mismatched token: [EMAIL PROTECTED],4726:4726=')',12,143:47]; expecting type THEN at org.drools.rule.Package.checkValidity(Package.java:420) at org.drools.common.AbstractRuleBase.addPackage (AbstractRuleBase.java:292) at com.sample.RuleBaseBeanFactory.afterPropertiesSet etc... However, if I change POB County to POBCounty (no space, only change the DSL call leaving the actual code the same) everything works. Can someone explain why the two rules cannot coexist with the space in POB County? Thanks, Brian Enderle ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli Software Engineer - JBoss Rules Core Developer Office: +55 11 3529-6000 Mobile: +55 11 9287-5646 JBoss, a division of Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Possible shadow proxy issue with JDK Dynamic proxies in 4.0.1?
Hello, After stumbling upon an issue with version 4.0.0 using memberOf, I decided to upgrade to version 4.0.1. After upgrading, my rules do not seem to fire correctly. In the past, I had discovered issues (prior to 4.0.0 release) relating to my use of JDK dynamic proxies as facts. The drools team developed a fix for my problem, and it involved searching for a base interface type to build the shadow proxy from when the class type is final (all JDK dynamic proxies are). This problem I'm seeing now seems very similar in behavior to what I saw before. Is there any change related to shadow proxies that went into 4.0.1? Thanks, -Chris West ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Eclipse RuleFlow editor
To have multiple connections into or out of a node you must use a split or a join, see the number guess example. Mark [EMAIL PROTECTED] wrote: I'm trying to create a ruleflow in eclipse but cannot create more than one connection. I have a Start node, 2 Ruleflowgroup nodes, and an End node. Using the connection tool I can connect the Start node to the only one of the rule nodes but can't make any connections after that. I get the connection plug symbol and a circle with a slash through it. I can't connect rule node to rule node or rule node to end node. I've tried using only a start, rule, and end node but it still only allow me to connect the start node to the rule node but nothing after that. What's the trick to this? What am I doing wrong? Thanks for any help Rod ___ 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] rule flow -- possible bug?
Sergey, I am actually getting your expected behaviour when I recreated your example here. So could you open up a JIRA and include the example as a self-contained eclipse project, or just email it to me? I'll take a look at what might be wrong / different. Kris - Original Message - From: Manukyan, Sergey To: Rules Users List Sent: Monday, September 17, 2007 9:12 PM Subject: RE: [rules-users] rule flow -- possible bug? Thank you for explanations, it did clear up the picture for me, but I still didn't resolve the problem that I am having. Looks like problem happens when attributes are involved in a Split. Possible bug? So here is an example: I am inserting initially a simple TestValid class that has boolean hasError attribute = false; insert(new TestValid(false)); INIT ruleflow-group just prints out the facts : rule INIT ruleflow-group INIT no-loop when $v : TestValid() then System.out.println(INIT : HAS ERROR ? : + $v.isHasErrors()); end The Make Error ruleflow-group is activated when hasError attribute is flase in estValid fact : rule Make Error ruleflow-group Make Error no-loop when $v : TestValid(hasErrors == false) then System.out.println(Make Error!!!); $v.setHasErrors(true); retract($v); insert($v); end The Has Error? XOR Split has the following constraints: - TestValid(hasErrors == false) // goes to No Errors Action - TestValid(hasErrors == true) // goes to END The Actions Just print out information : - System.out.println(Init Action); - System.out.println(No Errors Action); When running example I was expecting to see the following events as seen on console: START Init Action INIT : HAS ERROR ? : false No Errors Action Make Error!!! Init Action INIT : HAS ERROR ? : true END Instead that is what I see: START Init Action INIT : HAS ERROR ? : false No Errors Action Make Error!!! Init Action INIT : HAS ERROR ? : true No Errors Action Init Action No Errors Action Init Action . infinitely goes like this Now is this again expected behavior or a possible bug? If it is expected then how can I make decisions based on attribute of a fact in a Split. Thank you, -Sergey -- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor Sent: Friday, September 14, 2007 8:37 PM To: Rules Users List Subject: Re: [rules-users] rule flow true, damn :) I did think of an attribute to re-activate any rules that are true, but not currently on the agenda - but not sure about it yet, would have to think on the negative effects some more. Mark Kris Verlaenen wrote: use the rule attribute lock-on-active to stop this behaviour, it stops a rule re-activating while the ruleflowgroup is active Well, this won't work for the same reason no-loop isn't working: if you use lock-on-active, it will make sure that the rule is not reactivated, so the execution of the node will end after one increment. But the lock-on-active makes sure that no activation is ever created, so, in the context of looping in ruleflow, even if the RuleSet node is activated again afterwards, it will never increment the integer again (as you prevented reactivation of the rule using lock-on-active), resulting in an endless loop in this case. Currently, as far as I know, the only thing that works is manually deactivating the ruleflow-group. Kris -- ___rules-users mailing [EMAIL PROTECTED]://lists.jboss.org/mailman/listinfo/rules-users ** ** LEGAL DISCLAIMER ** ** This E-mail message and any attachments may contain legally privileged, confidential or proprietary information. If you are not the intended recipient(s), or the employee or agent responsible for delivery of this message to the intended recipient(s), you are hereby notified that any dissemination, distribution or copying of this E-mail message is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete this E-mail message from your computer. -- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Date for 2 years ago
I need to code a rule which checks that the begin date for an object is at least two years ago (from todays date). Is there an easy way to code this within Drools rule, something like: when Reference(fromDate (todaysDate - 2 years)) then Output error end Thanks in advance, Brian Enderle ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Date for 2 years ago
Not at the moment, easiest way is to use a function call in a return value. Mark Brian Enderle wrote: I need to code a rule which checks that the begin date for an object is at least two years ago (from todays date). Is there an easy way to code this within Drools rule, something like: when Reference(fromDate (todaysDate - 2 years)) then Output error end Thanks in advance, Brian Enderle ___ 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] Possible shadow proxy issue with JDK Dynamic proxies in 4.0.1?
Maybe some fixes broke this? can you test with trunk, and submit a jira with a self contained test if you still have a problem Mark Chris West wrote: Hello, After stumbling upon an issue with version 4.0.0 using memberOf, I decided to upgrade to version 4.0.1. After upgrading, my rules do not seem to fire correctly. In the past, I had discovered issues (prior to 4.0.0 release) relating to my use of JDK dynamic proxies as facts. The drools team developed a fix for my problem, and it involved searching for a base interface type to build the shadow proxy from when the class type is final (all JDK dynamic proxies are). This problem I'm seeing now seems very similar in behavior to what I saw before. Is there any change related to shadow proxies that went into 4.0.1? Thanks, -Chris West ___ 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] Tomcat 6 -Axis2 1.3
Hi, I am trying to deploy a web service that uses Drools 4.0.1 to Tomcat 6 and Axis2 1.3. Does anybody know how to do this on Tomcat 6/Axis2. I have tried to place all the drools' jars (and its dependencies) in the axis2 lib directory but I keep getting java.lang.NoClassDefFoundError for all my fact objects. I have even tried to use the org.drools.rule.MapBackedClassLoader to load all my fact objects manually like it's done in BRMSPackageBuilder without any luck. The only way to get the web service to work is to put my fact objects in the axis2 lib directory. One thing I haven't tried is to compiled all the rules to Java and then deploy those with my web service. Has anyone done this before or have any suggestions on how to get the drools compiler to find fact objects on Tomcat/Axis2? Thanks very much, Len Carlsen ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users