Re: Re[rules-users] sult Lists from Decision Tables
This is what I was looking for. Thanks, I just wasn't making the connection between Variables in Decision Tables and Globals in the generated DRL. Bryan wasabifan wrote: > > Possibly. Is that set by the Variables keyword in Decision Tables? Then > in the Java code you just set the global variable by > session.setGlobal(string, object)? > -- View this message in context: http://www.nabble.com/Result-Lists-from-Decision-Tables-tp23749077p23762282.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: Re[rules-users] sult Lists from Decision Tables
Possibly. Is that set by the Variables keyword in Decision Tables? Then in the Java code you just set the global variable by session.setGlobal(string, object)? Michal Bali-2 wrote: > > Hi Bryan, > > Can you use globals for this ? > > Regards, > Michal > -- View this message in context: http://www.nabble.com/Result-Lists-from-Decision-Tables-tp23749077p23752966.html Sent from the drools - user 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] sult Lists from Decision Tables
I have worked directly with DRLs previously, but my new company would like to store their rules in decision tables. Basically, in the past, we would insert a custom object to maintain a list of results from the rules, which was pretty easy to do in a DRL. However, in decision tables, I have not found a good way to create a named parameter for that controlled list without making up a bogus condition (that really doesn't matter). Is there an easy way to pass an object to really only be used in the actions columns? Thanks, Bryan -- View this message in context: http://www.nabble.com/Result-Lists-from-Decision-Tables-tp23749077p23749077.html Sent from the drools - user 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] Date for 2 years ago
Not sure if it would help, but we have gotten around some Date comparison problems by using the getTime() method on the Date objects. Basically, it returns time in ms since 1970 (which works fine for comparison). I'm not sure if you can create a new Date object in the LHS of the rule. If you can, that date is set to now. So if you do that, you should be able to add 2 years in ms (2L * 365L * 24L * 60L * 60L * 1000L) and compare that with your date. If you can't create it in the LHS, you could always assert a current data object to represent the Date either now or 2 years from now. That being said, couldn't you do something like: when # $todaysDate either from asserted Date object for now, or a new Date() if can be done Reference(fromDate.time > ($todaysDate.time - (2L * 365L * 24L * 60L * 60L * 1000L))) then end BrianKE 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 > > end > > Thanks in advance, > Brian Enderle > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > -- View this message in context: http://www.nabble.com/Date-for-2-years-ago-tf4471163.html#a12784331 Sent from the drools - user 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] Existensial not question
That is great news. I misunderstood the behavior of the "exists" and "not". I thought it would only fire once, period. It wasn't a problem with our limitted test data, but I was thinking it would be a problem once we tested with large fact sets. Thanks Edson! Edson Tirelli-3 wrote: > >Bryan, > >I'm not sure I completely understood your scenario, but Drools supports > FOL and your scenario can be implemented whatever it is. > >I think the best way is giving you some examples: > > rule "Fires FOR EACH fact that does not have a corresponding Exception > Range" > when > Fact1($number : number) > not ExceptionRange(startRange <= $number, stopRange >= $number) > then > // do something > end > > > -- View this message in context: http://www.nabble.com/Existensial-not-question-tf4481066.html#a12782071 Sent from the drools - user 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] Arbitrary problem using OR?
Sure. Here is one example (though I think it may have an existential/universal not error as mentioned in another post): rule "6040 Pass CA Fees" when #conditions $status : ValidationPassFailStatus() exists ValidationControl(validationNo == 6040) CiLines($ciNo : ciNo, $ciLineNo : ciLineNo, $countryOrigin : countryOrigin) Country(country == $countryOrigin, canadianProvince != "", canadianProvince != "N") (CiLineFees(amtFee == 0, ciNo == $ciNo, ciLineNo == $ciLineNo) or not CiLineFees(ciNo == $ciNo, ciLineNo == $ciLineNo)) then #actions System.out.println("6040 Pass CA Fees"); $status.passSq(6040); end I have tried this with and without the parenthesis for explicitness. It errors out when inserting facts for the rule: java.lang.ClassCastException: com.kewill.icustoms.customs.rules.model.ValidationPassFailStatusShadowProxy at org.drools.base.com.kewill.icustoms.dbi.model.CiLines$getCountryOrigin.getValue(Unknown Source) at org.drools.base.extractors.BaseObjectClassFieldExtractor.getHashCode(BaseObjectClassFieldExtractor.java:139) at org.drools.base.ClassFieldExtractor.getHashCode(ClassFieldExtractor.java:173) at org.drools.rule.Declaration.getHashCode(Declaration.java:272) at org.drools.util.AbstractHashTable$SingleIndex.hashCodeOf(AbstractHashTable.java:489) at org.drools.util.TupleIndexHashTable.getOrCreate(TupleIndexHashTable.java:280) at org.drools.util.TupleIndexHashTable.add(TupleIndexHashTable.java:192) at org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:111) ... However, if I break this into two separate rules, it behaves as expected (with the possible existensial/universal logic problem I mention above). rule "6040 Pass CA Fees" when #conditions $status : ValidationPassFailStatus() exists ValidationControl(validationNo == 6040) CiLines($ciNo : ciNo, $ciLineNo : ciLineNo, $countryOrigin : countryOrigin) Country(country == $countryOrigin, canadianProvince != "", canadianProvince != "N") CiLineFees(amtFee == 0, ciNo == $ciNo, ciLineNo == $ciLineNo) then #actions System.out.println("6040 Pass CA Fees"); $status.passSq(6040); end rule "6040 Pass CA No Fees" when #conditions $status : ValidationPassFailStatus() exists ValidationControl(validationNo == 6040) CiLines($ciNo : ciNo, $ciLineNo : ciLineNo, $countryOrigin : countryOrigin) Country(country == $countryOrigin, canadianProvince != "", canadianProvince != "N") not CiLineFees(ciNo == $ciNo, ciLineNo == $ciLineNo) then #actions System.out.println("6040 Pass CA No Fees"); $status.passSq(6040); end Edson Tirelli-3 wrote: > > >As we speak, there is no known problem in the use of this functionality > in 4.0.1. > >Can you please provide an example of the problems you are finding? > >Thanks, > Edson > > > -- View this message in context: http://www.nabble.com/Arbitrary-problem-using-OR--tf4481210.html#a12779845 Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Arbitrary problem using OR?
In getting our business rules written, we used a lot of domain experts to help write our rules. I now have the exciting job of verifying and fixing these rules as needed. When possible, I had asked that they use OR statements in a single rule, as opposed to breaking them out into multiple rules for brefity and ease of maintenance. However, in trying to get these rules to function, I find myself time and time again having to break OR logic into multiple rules to get it to work (the || internal to objects seems to work okay). I have tried both prefix and infix OR. Is there some limit to the complexity of when OR will or will not work? I have tried using parenthesis to make the logic very explicit, but often breaking it into multiple rules seems to be the only remedy. Is there some principle to go by, or is this a matter of trial and error when rules must be broken into multiple rules in the DRL? My understanding was that the OR CE basically would be broken into multiple rules automagically, which is what I end up doing manually in the DRL. Have you heard of any problems with this functionality? -- View this message in context: http://www.nabble.com/Arbitrary-problem-using-OR--tf4481210.html#a12778131 Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Existensial not question
I have several rules I am working on that I am having problems implementing. Most of our tests are composed of at least one "pass" and one "fail" rule. Basically, there are some tests where exceptions need to be thrown based on a date or number being inside a range where these exceptions occur (causing a possible failure). The problem is that we are testing several objects, so using the existensial not, is problematic. For example, in the pass, if we write: rule "pass example" when Fact1($number : number) not ExceptionRange(startRange <= $number, stopRange >= $number) then System.out.println("Pass" + $number); end For the fail, it would be like: rule "fail example" when Fact1($number : number) ExceptionRange(startRange <= $number, stopRange >= $number) then System.out.println("Fail" + $number); end Is there a way to rewrite the pass rule, so that it checks the existence of a range satisfying each number from Fact1? If I understand not correctly, it will either pass once, and only once if ANY range matches at least one number from Fact1. Or it would pass for all Fact1's if any Fact1's match any exception range. A little clarification here would be appreciated, and if you know of a workaround to actually test for getting exactly one and only one pass or fail (exclusively) for each Fact1 asserted. Thanks, Bryan Rickman -- View this message in context: http://www.nabble.com/Existensial-not-question-tf4481066.html#a12777641 Sent from the drools - user 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] LHS functions not in eval()...
I did try calling it directly. I forget the exact error, but I would get an error while asserting (inserting) the data (I believe it was a class cast exception). I think we will end up adding custom accessor methods to our POJOs that return the properly formatted data (we were hoping to avoid this, as our POJOs are currently auto-generated...and this will add a manual process to maintaining our POJOs). Thanks for the feedback though! Bryan Edson Tirelli-3 wrote: > >Yes, the only way to call functions is inside eval or RHS. Although, > drools executes some time coercion. Did you tried a direct comparison? I'm > not positive it will work, but you may try. > -- View this message in context: http://www.nabble.com/LHS-functions-not-in-eval%28%29...-tf4362273.html#a12499304 Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] LHS functions not in eval()...
I am trying to write a function that takes a numeric value and returns a string. Basically, I have a numeric number I need to match to a string number (so I need to convert one to the other type). I wrote a function to do this, but it only seems to work in the RHS or inside an eval(). Is there a way to convert numerics to strings (or vice-versa) in the LHS not in an eval? Or is a big function inside the eval() the only way to do this? Thanks, Bryan -- View this message in context: http://www.nabble.com/LHS-functions-not-in-eval%28%29...-tf4362273.html#a12433462 Sent from the drools - user 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] comparisons on Java primitive wrapper class types
class MyObject { private Integer used; private Integer notUsed; // public setters/getters... } rule "1" when MyObject(used == 1) then // do something end rule "2" when UnrelatedObject(data == 5) MyObject(notUsed == 2) then // do something else end Basically, I am trying to create JUnit test cases to test each of the rules functionality. So I would instantiate and object, set the required data to fire a rule, assert the object and fire all rules. So when setting MyObject.used = 1, then asserting that fact...it appears that rule 2 would complain that notUsed is null (even though I do not have an asserted fact where UnrelatedObject(data == 5). Does this make sense? I know this is sort of pseudo code thrown together quickly, but I think that explains what I was experiencing. If not, I can go back to get some of the actual code, but that would be much longer. Thanks, Bryan Edson Tirelli-3 wrote: > > Can you please provide one example for us to understand better the > case? > -- View this message in context: http://www.nabble.com/comparisons-on-Java-primitive-wrapper-class-types-tf3481733.html#a9721787 Sent from the drools - user 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] comparisons on Java primitive wrapper class types
class MyObject { private Integer used; private Integer notUsed; // public setters/getters... } rule "1" when MyObject(used == 1) then // do something end rule "2" when UnrelatedObject(data == 5) MyObject(notUsed == 2) then // do something else end Basically, I am trying to create JUnit test cases to test each of the rules functionality. So I would instantiate and object, set the required data to fire a rule, assert the object and fire all rules. So when setting MyObject.used = 1, then asserting that fact...it appears that rule 2 would complain that notUsed is null (even though I do not have an asserted fact where UnrelatedObject(data == 5). Does this make sense? I know this is sort of pseudo code thrown together quickly, but I think that explains what I was experiencing. If not, I can go back to get some of the actual code, but that would be much longer. Thanks, Bryan Edson Tirelli-3 wrote: > >Brian, > >Can you please provide one example for us to understand better the > case? > > Thank you, > Edson > > 2007/3/28, wasabifan <[EMAIL PROTECTED]>: >> >> >> In creating a list of rules, I noticed when adding facts to my working >> memory >> it may cause errors if Integer or Long values are null (as they are >> attempting to do comparisons on null objects...even if other conditions >> previously listed in that particular rule eliminate this fact from that >> particular conflicting rule), however, I have not noticed this behavior >> for >> null String objects. Is this the expected behavior, or should they be >> defaulting to 0 in the comparisons (much like I am assuming the Strings >> must >> be defaulting to empty Strings)? >> >> Thanks for any clarification. I am using 3.1M1 if that is relevant as >> well. >> >> Bryan >> -- >> View this message in context: >> http://www.nabble.com/comparisons-on-Java-primitive-wrapper-class-types-tf3481733.html#a9718377 >> Sent from the drools - user mailing list archive at Nabble.com. >> >> ___ >> 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 3124-6000 > Mobile: +55 11 9218-4151 > 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 > > -- View this message in context: http://www.nabble.com/comparisons-on-Java-primitive-wrapper-class-types-tf3481733.html#a9721783 Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] comparisons on Java primitive wrapper class types
In creating a list of rules, I noticed when adding facts to my working memory it may cause errors if Integer or Long values are null (as they are attempting to do comparisons on null objects...even if other conditions previously listed in that particular rule eliminate this fact from that particular conflicting rule), however, I have not noticed this behavior for null String objects. Is this the expected behavior, or should they be defaulting to 0 in the comparisons (much like I am assuming the Strings must be defaulting to empty Strings)? Thanks for any clarification. I am using 3.1M1 if that is relevant as well. Bryan -- View this message in context: http://www.nabble.com/comparisons-on-Java-primitive-wrapper-class-types-tf3481733.html#a9718377 Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users