Re: [rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Wolfgang - adding the dialect to the 'Functions' cell worked like a charm. Edson's solution did not work without the dialect mvel. So in this case MVEL is a must have. But then your suggestion to add the dialect next to the cell keyed Functions worked. Thanks again for your help. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2462063.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] How to write a rule that fires when it matches against specific facts in working memory.
Edson/Wolfgang, Thanks to your suggestions, I've got this working the way I need it using rules defined in a .drl file. I think I have just one hurdle left before I start working out how to get it working through decision tables - and that is how to specific 'mvel' dialect for decision tables. Edson as you pointed out, in order for me to send the value of $param to the accumulator, I should use mvel to create a list of the parameters (the $param and the fact being matched). I tried looking for ways to specify mvel and couldn't find how to set the dialect for rules defined in decision tables. Thanks, Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2432302.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] How to write a rule that fires when it matches against specific facts in working memory.
Edson, I did manage to use the 'CollectSetAccumulateFunction' as a template for the MatchAll and have also successfully 'called' the accumulate function from a rule written in a .drl file. But I'm stuck at one point - how to send the value of $param to the accumulate method ? From what I understand, the accumulate method is invoked for each fact - so if I write MatchAll( $o ) it will invoke the accumulate method and passing $o fact to the method via the 'Object value' parameter. So far so go, however, I'm stuck on how to pass the value of '$param' to the accumulate method (or any other method like init, getResult for that matter). One option I can think of is to change the definition of the Option fact to include a 'param' field and then write a rule that sets the value of that field to $param (so every Options param field would get set to the value of $param). I can then extract that in the accumulate method it self. But is there a better way that I might be missing ? Thanks in advance, Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2369936.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] How to write a rule that fires when it matches against specific facts in working memory.
Up to Drools 5, the accumulate function API supports only a single argument to the function, but that argument can be an array or a list. So what I do on my own implementations is to pass the $param as one element of the array and $o as the other. It is not ideal, but it is how you can do that in Drools 5. In Drools 6 I will change the API to support multiple parameters, but I've been postponing that because when I do it, it will break existing implementations of the interface. Anyway, if you are using the MVEL dialect, creating a list is as simple as wrapping it in [ ], as you could see in my previous e-mail. $options : List() from accumulate( $op : Option(), matchAll( [ ${param}, $op ] ) ) Edson 2011/1/29 groovenarula gnaru...@la-z-boy.com Edson, I did manage to use the 'CollectSetAccumulateFunction' as a template for the MatchAll and have also successfully 'called' the accumulate function from a rule written in a .drl file. But I'm stuck at one point - how to send the value of $param to the accumulate method ? From what I understand, the accumulate method is invoked for each fact - so if I write MatchAll( $o ) it will invoke the accumulate method and passing $o fact to the method via the 'Object value' parameter. So far so go, however, I'm stuck on how to pass the value of '$param' to the accumulate method (or any other method like init, getResult for that matter). One option I can think of is to change the definition of the Option fact to include a 'param' field and then write a rule that sets the value of that field to $param (so every Options param field would get set to the value of $param). I can then extract that in the accumulate method it self. But is there a better way that I might be missing ? Thanks in advance, Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2369936.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 -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Edson, That worked beautifully ! Drools is looking more and more promising for what we need to do. Thanks for all your help, Gurvinder -Original Message- From: Edson Tirelli-4 [via Drools - Java Rules Engine] [mailto:ml-node+2380361-572428564-9...@n3.nabble.com] Sent: Sat 1/29/2011 10:59 PM To: Gurvinder Narula1 Subject: Re: How to write a rule that fires when it matches against specific facts in working memory.   Up to Drools 5, the accumulate function API supports only a single argument to the function, but that argument can be an array or a list. So what I do on my own implementations is to pass the $param as one element of the array and $o as the other. It is not ideal, but it is how you can do that in Drools 5. In Drools 6 I will change the API to support multiple parameters, but I've been postponing that because when I do it, it will break existing implementations of the interface.   Anyway, if you are using the MVEL dialect, creating a list is as simple as wrapping it in [ ], as you could see in my previous e-mail. $options : List() from accumulate(     $op : Option(),     matchAll( [ ${param}, $op ] ) )    Edson 2011/1/29 groovenarula [hidden email] Edson, I did manage to use the 'CollectSetAccumulateFunction' as a template for the MatchAll and have also successfully 'called' the accumulate function from a rule written in a .drl file. But I'm stuck at one point - how to send the value of $param to the accumulate method ? From what I understand, the accumulate method is invoked for each fact - so if I write   MatchAll( $o ) it will invoke the accumulate method and passing $o fact to the method via the 'Object value' parameter. So far so go, however, I'm stuck on how to pass the value of '$param' to the accumulate method (or any other method like init, getResult for that matter). One option I can think of is to change the definition of the Option fact to include a 'param' field and then write a rule that sets the value of that field to $param (so every Options param field would get set to the value of $param). I can then extract that in the accumulate method it self. But is there a better way that I might be missing ? Thanks in advance, Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2369936.html http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2369936.html?by-user=t Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list [hidden email] https://lists.jboss.org/mailman/listinfo/rules-users --  Edson Tirelli  JBoss Drools Core Development  JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list [hidden email] https://lists.jboss.org/mailman/listinfo/rules-users If you reply to this email, your message will be added to the discussion below: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2380361.html To unsubscribe from How to write a rule that fires when it matches against specific facts in working memory., click here http://drools-java-rules-engine.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=2294599code=Z25hcnVsYTFAbGEtei1ib3kuY29tfDIyOTQ1OTl8MjAzMTM1NDY2Mw== . -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2381946.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] How to write a rule that fires when it matches against specific facts in working memory.
Hi, I finally noticed a forall keyword that might be useful (see section 5.1.4.1. Syntax of templates). Maybe can you try something like: [forall(){Option(code == $)}] Bruno. Bruno Freudensprung a écrit : Hi Gurvinder, I've just taken a look at chapter 5.1 of Drools Expert about decision tables but I've been unable to find out how to do that. If you find a solution, could you please post it here? I'm pretty sure I will need that as well ;-). Best regards, Bruno. groovenarula a écrit : Thanks for the options, Bruno and Wolfgang. But is there a more 'generic' way to do the matches ? The problem I have is that the # of instances that might match could vary. And I have to provide a means for the business users to be able to provide that 'option's code' using a decision table. Basically I need to be able to provide a construct that's would look something like : Options P1,P2 P1,P4,P5 So in the above decision table had 2 rules where in the first row represents a rule that matches against Options with Codes P1 and P2. And the second rule would match against options with codes P1, P4 and P5. Is it possible to represent this using Drools decision tables ? Thanks Gurvinder ___ 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] How to write a rule that fires when it matches against specific facts in working memory.
2011/1/27 Bruno Freudensprung bruno.freudenspr...@temis.com Hi, I finally noticed a forall keyword that might be useful (see section 5.1.4.1. Syntax of templates). Maybe can you try something like: [forall(){Option(code == $)}] This must be written as forall(){Option(code == $)} so that P1,P2,P3 yields Option(code == P1) Option(code == P2) Option(code == P3) But there's no way to produce the various binding variables that are required for writing the not CE, as in $o1: Option(code == P1) $o2: Option(code == P2) $o3: Option(code == P3) not Option( this != $o1, this != $o2, this != $o3 ) And even if there were, this would require two columns, which is clumsy. accumulate with a special function is the best approach. -W Bruno. Bruno Freudensprung a écrit : Hi Gurvinder, I've just taken a look at chapter 5.1 of Drools Expert about decision tables but I've been unable to find out how to do that. If you find a solution, could you please post it here? I'm pretty sure I will need that as well ;-). Best regards, Bruno. groovenarula a écrit : Thanks for the options, Bruno and Wolfgang. But is there a more 'generic' way to do the matches ? The problem I have is that the # of instances that might match could vary. And I have to provide a means for the business users to be able to provide that 'option's code' using a decision table. Basically I need to be able to provide a construct that's would look something like : Options P1,P2 P1,P4,P5 So in the above decision table had 2 rules where in the first row represents a rule that matches against Options with Codes P1 and P2. And the second rule would match against options with codes P1, P4 and P5. Is it possible to represent this using Drools decision tables ? Thanks Gurvinder ___ 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] How to write a rule that fires when it matches against specific facts in working memory.
Thanks for outlining the approach, Edson. Unfortunately, I'm a newbie using drools, so I just need some clarification on what you mean by 'matchAll is your own accumulate function with the semantics you described.' ? Do you mean that I have to create a 'custom' accumulate function ? Edson, if that's the case, then I'll try to search for example of creating a custom function. When I last searched, I did find an example on the Internet, however, I don't think I found details of how to make the function available to the rules engine (is it as simple as including the jar in the classpath or do I need to take addtional steps to use Matchall in drl ?) Can you please elaborate for the benefit of a noobie ? Thanks Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2354793.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] How to write a rule that fires when it matches against specific facts in working memory.
Accumulate functions are very well documented in the Expert manual. Look for a section titled Accumulate Functions. You could also use accumulate with all the steps in inline code, which is documented in the preceding section. -W On 26 January 2011 16:50, groovenarula gnaru...@la-z-boy.com wrote: Thanks for outlining the approach, Edson. Unfortunately, I'm a newbie using drools, so I just need some clarification on what you mean by 'matchAll is your own accumulate function with the semantics you described.' ? Do you mean that I have to create a 'custom' accumulate function ? Edson, if that's the case, then I'll try to search for example of creating a custom function. When I last searched, I did find an example on the Internet, however, I don't think I found details of how to make the function available to the rules engine (is it as simple as including the jar in the classpath or do I need to take addtional steps to use Matchall in drl ?) Can you please elaborate for the benefit of a noobie ? Thanks Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2354793.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 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Thanks Wolfgang. I found it. I Work on it and let you'll know how it goes. Sent from my iPhone On Jan 27, 2011, at 1:08 AM, Wolfgang Laun-2 [via Drools - Java Rules Engine] ml-node+2356705-1292265879-9...@n3.nabble.com wrote: Accumulate functions are very well documented in the Expert manual. Look for a section titled Accumulate Functions. You could also use accumulate with all the steps in inline code, which is documented in the preceding section. -W On 26 January 2011 16:50, groovenarula [hidden email] wrote: Thanks for outlining the approach, Edson. Unfortunately, I'm a newbie using drools, so I just need some clarification on what you mean by 'matchAll is your own accumulate function with the semantics you described.' ? Do you mean that I have to create a 'custom' accumulate function ? Edson, if that's the case, then I'll try to search for example of creating a custom function. When I last searched, I did find an example on the Internet, however, I don't think I found details of how to make the function available to the rules engine (is it as simple as including the jar in the classpath or do I need to take addtional steps to use Matchall in drl ?) Can you please elaborate for the benefit of a noobie ? Thanks Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2354793.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list [hidden email] https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list [hidden email] https://lists.jboss.org/mailman/listinfo/rules-users If you reply to this email, your message will be added to the discussion below: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2356705.html To unsubscribe from How to write a rule that fires when it matches against specific facts in working memory., click here. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2359225.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] How to write a rule that fires when it matches against specific facts in working memory.
I suggest you use this as a base for your implementation, as I think it will help you: https://github.com/droolsjbpm/droolsjbpm/blob/master/drools-core/src/main/java/org/drools/base/accumulators/CollectSetAccumulateFunction.java https://github.com/droolsjbpm/droolsjbpm/blob/master/drools-core/src/main/java/org/drools/base/accumulators/CollectSetAccumulateFunction.java Edson 2011/1/26 groovenarula gnaru...@la-z-boy.com Thanks Wolfgang. I found it. I Work on it and let you'll know how it goes. Sent from my iPhone On Jan 27, 2011, at 1:08 AM, Wolfgang Laun-2 [via Drools - Java Rules Engine] [hidden email]http://user/SendEmail.jtp?type=nodenode=2359225i=0 wrote: Accumulate functions are very well documented in the Expert manual. Look for a section titled Accumulate Functions. You could also use accumulate with all the steps in inline code, which is documented in the preceding section. -W On 26 January 2011 16:50, groovenarula [hidden email]http://user/SendEmail.jtp?type=nodenode=2356705i=0by-user=t wrote: Thanks for outlining the approach, Edson. Unfortunately, I'm a newbie using drools, so I just need some clarification on what you mean by 'matchAll is your own accumulate function with the semantics you described.' ? Do you mean that I have to create a 'custom' accumulate function ? Edson, if that's the case, then I'll try to search for example of creating a custom function. When I last searched, I did find an example on the Internet, however, I don't think I found details of how to make the function available to the rules engine (is it as simple as including the jar in the classpath or do I need to take addtional steps to use Matchall in drl ?) Can you please elaborate for the benefit of a noobie ? Thanks Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2354793.html?by-user=tby-user=t http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2354793.htmlhttp://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2354793.html?by-user=t Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list [hidden email]http://user/SendEmail.jtp?type=nodenode=2356705i=1by-user=t https://lists.jboss.org/mailman/listinfo/rules-users https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list [hidden email]http://user/SendEmail.jtp?type=nodenode=2356705i=2by-user=t https://lists.jboss.org/mailman/listinfo/rules-users https://lists.jboss.org/mailman/listinfo/rules-users -- If you reply to this email, your message will be added to the discussion below: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2356705.html?by-user=t http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2356705.htmlhttp://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2356705.html?by-user=t To unsubscribe from How to write a rule that fires when it matches against specific facts in working memory., click herehttp://drools-java-rules-engine.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=2294599code=Z25hcnVsYTFAbGEtei1ib3kuY29tfDIyOTQ1OTl8MjAzMTM1NDY2Mw==by-user=t. -- View this message in context: Re: How to write a rule that fires when it matches against specific facts in working memory.http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2359225.html Sent from the Drools - User mailing list archivehttp://drools-java-rules-engine.46999.n3.nabble.com/Drools-User-f47000.htmlat Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Edson, This surely looks like a great template to base my implementation - it looks like an great starting point. Gurvinder -Original Message- From: Edson Tirelli-4 [via Drools - Java Rules Engine] [mailto:ml-node+2359987-1512063982-9...@n3.nabble.com] Sent: Wed 1/26/2011 11:44 PM To: Gurvinder Narula1 Subject: Re: How to write a rule that fires when it matches against specific facts in working memory.   I suggest you use this as a base for your implementation, as I think it will help you: https://github.com/droolsjbpm/droolsjbpm/blob/master/drools-core/src/main/java/org/drools/base/accumulators/CollectSetAccumulateFunction.java https://github.com/droolsjbpm/droolsjbpm/blob/master/drools-core/src/main/java/org/drools/base/accumulators/CollectSetAccumulateFunction.java   Edson 2011/1/26 groovenarula [hidden email] Thanks Wolfgang. I found it. I Work on it and let you'll know how it goes. Sent from my iPhone On Jan 27, 2011, at 1:08 AM, Wolfgang Laun-2 [via Drools - Java Rules Engine] [hidden email] http://user/SendEmail.jtp?type=nodenode=2359225i=0 wrote: Accumulate functions are very well documented in the Expert manual. Look for a section titled Accumulate Functions. You could also use accumulate with all the steps in inline code, which is documented in the preceding section. -W On 26 January 2011 16:50, groovenarula [hidden email] http://user/SendEmail.jtp?type=nodenode=2356705i=0by-user=t wrote: Thanks for outlining the approach, Edson. Unfortunately, I'm a newbie using drools, so I just need some clarification on what you mean by 'matchAll is your own accumulate function with the semantics you described.' ? Do you mean that I have to create a 'custom' accumulate function ? Edson, if that's the case, then I'll try to search for example of creating a custom function. When I last searched, I did find an example on the Internet, however, I don't think I found details of how to make the function available to the rules engine (is it as simple as including the jar in the classpath or do I need to take addtional steps to use Matchall in drl ?) Can you please elaborate for the benefit of a noobie ? Thanks Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2354793.html?by-user=tby-user=tby-user=t http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2354793.html http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2354793.html?by-user=tby-user=t Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list [hidden email] http://user/SendEmail.jtp?type=nodenode=2356705i=1by-user=t https://lists.jboss.org/mailman/listinfo/rules-users https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list [hidden email] http://user/SendEmail.jtp?type=nodenode=2356705i=2by-user=t https://lists.jboss.org/mailman/listinfo/rules-users https://lists.jboss.org/mailman/listinfo/rules-users If you reply to this email, your message will be added to the discussion below: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2356705.html?by-user=tby-user=t http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2356705.html
Re: [rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Hi Gurvinder, I've just taken a look at chapter 5.1 of Drools Expert about decision tables but I've been unable to find out how to do that. If you find a solution, could you please post it here? I'm pretty sure I will need that as well ;-). Best regards, Bruno. groovenarula a écrit : Thanks for the options, Bruno and Wolfgang. But is there a more 'generic' way to do the matches ? The problem I have is that the # of instances that might match could vary. And I have to provide a means for the business users to be able to provide that 'option's code' using a decision table. Basically I need to be able to provide a construct that's would look something like : Options P1,P2 P1,P4,P5 So in the above decision table had 2 rules where in the first row represents a rule that matches against Options with Codes P1 and P2. And the second rule would match against options with codes P1, P4 and P5. Is it possible to represent this using Drools decision tables ? Thanks Gurvinder ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Given that your restriction is this 'options' and only them, at least one instance of each, and you need that in a generic way, best is for you to create your own accumulate function. For Drools 5.1.1 your template would look like: $options : List() from accumulate( $op : Option(), matchAll( [ ${param}, $op ] ) ) Where ${param} is the list of options the user type in the decision table cell and matchAll is your own accumulate function with the semantics you described. Edson 2011/1/21 groovenarula gnaru...@la-z-boy.com Thanks for the options, Bruno and Wolfgang. But is there a more 'generic' way to do the matches ? The problem I have is that the # of instances that might match could vary. And I have to provide a means for the business users to be able to provide that 'option's code' using a decision table. Basically I need to be able to provide a construct that's would look something like : Options P1,P2 P1,P4,P5 So in the above decision table had 2 rules where in the first row represents a rule that matches against Options with Codes P1 and P2. And the second rule would match against options with codes P1, P4 and P5. Is it possible to represent this using Drools decision tables ? Thanks Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2300564.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 -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Thanks for the options, Bruno and Wolfgang. But is there a more 'generic' way to do the matches ? The problem I have is that the # of instances that might match could vary. And I have to provide a means for the business users to be able to provide that 'option's code' using a decision table. Basically I need to be able to provide a construct that's would look something like : Options P1,P2 P1,P4,P5 So in the above decision table had 2 rules where in the first row represents a rule that matches against Options with Codes P1 and P2. And the second rule would match against options with codes P1, P4 and P5. Is it possible to represent this using Drools decision tables ? Thanks Gurvinder -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-write-a-rule-that-fires-when-it-matches-against-specific-facts-in-working-memory-tp2294599p2300564.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] How to write a rule that fires when it matches against specific facts in working memory.
I understand this so that there must be *exactly* 2 Option facts, and therefore: $o1: Option (code == P1) $o2: Option (code == P2) not Option( this != $o1, this != $o2 ) On 20 January 2011 14:33, Bruno Freudensprung bruno.freudenspr...@temis.com wrote: Hello, Maybe could you try the following rule? rule Matched Options when $o : Option (code == P1) Option (this != $o, code == P2) then System.out.println ( Priced using G/S ); end Best regards, Bruno. groovenarula a écrit : Hello, I have a fact called 'Option' : public class Option { private String code; private Item item; public String getCode() { return code; } public void setCode(String optionCode) { this.code = optionCode; } At any point in time, the working memory can have several Option instances with different code values. My rules need to fire specifically when the working memory contains a specific set of options. e.g. Rule 1 should fire if and only if the working memory contains 2 option instances one with code P1 and the other with P2 (order should not matter). I tried to use 'forall' as follows : rule Matched Options when forall ( Option ( code == P1 || code == P2 ) ) then //insert( new IsPriced( i ) ); System.out.println ( Priced using G/S ); end However, the rule above never fires. Maybe I should be taking a different approach. I'm still learning through how to create rules. So any help/suggestions on how to tackle the above will be appreciated. Thanks Gurvinder ___ 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