forall/from/eval/contains: odd DRL syntax error
by Wolfgang Laun
A rule has to ascertain that all elements in a List<ElemBoxStatus>in a
Collector occur in the matching BoxResponse's Set<ElemBoxStatus>. There is
just one BoxResponse per Collector.
This here works fine:
rule matchCollectorResponse
when
$c : Collector( $ebsList : elemBoxStatusList, $gsSet :
globalStatusSet )
$b : BoxResponse( collector == $c, globalStatusSet == $gsSet,
$ebsSet : elemBoxStatusSet )
forall( $ebs : ElemBoxStatus() from $ebsList
BoxResponse( collector == $c, elemBoxStatusSet contains $ebs
) )
then
...
end
Thinking that $ebs is already available from the second pattern ($b:...), I
tried
rule matchCollectorResponse
when
$c : Collector( $ms : message, $ebsList : elemBoxStatusList, $gsSet
: globalStatusSet )
$b : BoxResponse( collector == $c, globalStatusSet == $gsSet,
$ebsSet : elemBoxStatusSet )
forall( $ebs : ElemBoxStatus() from $ebsList
eval( $ebsSet.contains( $ebs ) ) )
then
...
end
but the compiler came back with
Line ...:55 no viable alternative at input '$ebs' in rule
matchCollectorResponse in pattern eval
Defining a suitable function isIn(...) and using this within eval() produces
the same result. This
and other experiments seems to indicate that bindings in the first pattern
of forall() are not
passed in to an eval() later in the forall.
JIRA?
-W
16 years, 9 months
question on drools and method calls on facts
by Garner, Shawn
I'm under the impression that in the action clause of a rule you should only do one of the following:
1) Set a property on a Fact
2) Retract a Fact
3) Insert (Assert) a new Fact
4) Modify an existing Fact
However in some of the examples in the documentation it shows calling methods other than bean property getters and setters.
I was wondering if what other peoples opinions are on whether you should be doing more than the 4 things I listed above in a then clause of a rule.
Thanks,
SG
-----Message Disclaimer-----
This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to Connect(a)principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.
Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.
While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to provide
general information about the subject matter covered and is provided with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to legal,
tax, or accounting obligations and requirements.
16 years, 9 months
When MinaTaskClient.complete throw NullPointerException
by liuzhikun
Hi.
I use human task in JPA,when i call MinaTaskClient.complete throw below error:
java.lang.NullPointerException
at org.drools.persistence.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:83)
at org.drools.process.workitem.wsht.WSHumanTaskHandler$GetCompletedTaskResponseHandler.execute(WSHumanTaskHandler.java:282)
at org.drools.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:67)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:752)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)2009-9-2 13:50:26 org.apache.mina.filter.logging.LogLevel$4 log
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:379)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:173)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:616)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:408)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:578)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:540)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:532)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:58)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:857)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
16 years, 9 months
how to use 'extend' keyword in Rule Engine
by Pardeep.Ruhil@lntinfotech.com
Hi,
I want to use the condition of Rule 1 in Rule 2.
So for this I got to know that extend keyword will be used.
But in the documentation I have not get any details of the same.
So can you please tell me how to use extends keyword in Rule.
Thanks & Regards
Pardeep Ruhil
L&T Infotech Ltd
Mumbai
Ph: +919820283884
Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com
This Document is classified as:
L&T Infotech Proprietary L&T Infotech Confidential L&T Infotech
Internal Use Only L&T Infotech General Business
This Email may contain confidential or privileged information for the
intended recipient (s) If you are not the intended recipient, please do
not use or disseminate the information, notify the sender and delete it
from your system.
______________________________________________________________________
16 years, 9 months
DRools 5 with spring 2.5.6
by Damien Feugas
Hi Everyone.
I'm new to Drools 5, and I'd like to use it in a spring project.
Basically, I want to load a knowledge base in a "Service" Spring object, and
use it as a dependency in others treatment objects.
Google serves me several sites on how to use Spring and previous Drools
releases, but nothing really up to date.
"Spring-modules", a kind of Spring extension wich provided a Drools
integration is deprecated.
Is there any simple way to use both Spring 2.5.6 and Drools 5.0.1 ?
Thank you in advance.
16 years, 9 months
Re: [rules-users] Trouble getting Dynamic Salience working
by Greg Barton
I hope you're not going through all of that trouble just to get the functionality from that concrete example. You get that for free with Drools' default conflict resolution, which includes "specificity." Specificity means that rules with the more specific conditions, and all else equal, are fired first. So between these two rules, only the CheeseSausagePepperoniPepper one fires:
rule "CheeseOnly"
when
p : Pizza( )
t1: Topping( pizza == p, name == "cheese" )
then
System.out.println( "Eating cheese pizza" );
retract( t1 );
retract( p );
end
rule "CheeseSausagePepperoniPepper"
when
p : Pizza( )
t1: Topping( pizza == p, name == "cheese" )
t2: Topping( pizza == p, name == "sausage" )
t3: Topping( pizza == p, name == "pepperoni" )
t4: Topping( pizza == p, name == "pepper" )
then
System.out.println( "Eating cheese sausage pepperoni pepper pizza" );
retract( t4 );
retract( t3 );
retract( t2 );
retract( t1 );
retract( p );
end
See the attached project.
--- On Tue, 9/1/09, Bill Tarr <javatestcase(a)yahoo.com> wrote:
> From: Bill Tarr <javatestcase(a)yahoo.com>
> Subject: [rules-users] Trouble getting Dynamic Salience working
> To: rules-users(a)lists.jboss.org
> Date: Tuesday, September 1, 2009, 7:28 PM
> We have a winner! Many thanks
> Michal, hope I can return the favor one day.
>
> salience ( return getSalience4() )
>
> for the record, my function looks something like (after
> tempate evaluation):
>
> <pre>
> function int getSalience4(){
> int salience = 0;
> if("VALUE"=="VALUE") salience += 1000;
>
> return salience;
> }
> </pre>
>
> I think the combination activation-group and dynamic
> salience for rule-template projects are pretty useful.
>
> Just for anyone interested, the tempate code looks
> something like this:
>
> <pre>
> rule "Some Rule_(a){row.rowNumber}"
>
> activation-group "@{PARAM1}-@{PARAM2}"
> salience ( return getSalience(a){row.rowNumber}() )
> </pre>
>
> where PARAM1 and PARAM2 make up a kind of key. I only want
> to execute one rule that matches that key, no matter how
> many options there are.
>
> Rules that have additional parameters get higher salience
> than rules with less parameters, so here is my function.
>
> <pre>
> function int getSalience(a){row.rowNumber}(){
> int salience = 0;
> if("@{PARAM3}"=="@{PARAM3}") salience += 1000;
> if("@{PARAM4}"=="@{PARAM4}") salience += 1000;
> return salience;
> }
> </pre>
>
> A concrete example could be pizza. So there are 3 types
> of pizza, all are grouped in the same activation-group.
>
> cheese, pepperoni
> cheese, pepperoni, sausage
> cheese, pepperoni, meatball, pepper
>
> Any cheese and pepperoni pizza should could match all these
> rules, but more toppings is always better for me.
>
> So cheese, pepperoni, onion, pepper getts a salience of
> 2000, and is the only rule evaluated.
>
>
>
> On Tue Sep 1 18:39:13 EDT 2009, Michal Bali michalbali at
> gmail.com wrote:
>
> does this work?
> salience ( return getSalience() )
>
> or this:
>
> salience ( getSalience();)
>
>
> On Tue, Sep 1, 2009 at 6:50 PM, Bill Tarr <javatestcase
> at yahoo.com> wrote:
>
> > Possibily just a simple MVEL error, but I've been
> struggling for a while
> > and thought I'd see if anyone could help.
> >
> > I just want to run a logic test to determine salience
> for some rules I am
> > generating with rules-templates. Even after making
> the logical test "true"
> > I can't get any of variation to compile.
> >
> > (true ? "1000" : "0")
> > **produces**
> > Unable to build expression for 'salience' : not a
> statement, or badly
> > formed structure
> >
> > ( true ? 1000 : 0)
> > **produces**
> > Unable to build expression for 'salience' : invalid
> number literal: 1000
> >
> > salience ( getSalience() )
> > ...
> > function int getSalience(){return 0;}
> > **produces**
> > Unable to build expression for 'salience' :
> org.mvel2.util.MethodStub
> > cannot be cast to java.lang.Class'(
> getSalienceNONCDW() )'
> >
> > Seems like I am missing something simple, but I've
> tried many variations on
> > the above, and have been unable to find any working
> examples of using a
> > logical test in salience, so if anyone has any
> direction it would be greatly
> > appreciated.
> >
> > Thanks!
> >
> > Bill
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
16 years, 9 months
Drools Expert API
by Swapnil Raverkar
Hi All,
I am a newbie and just started using Drools 5.
My question is that why there is no documentation provided for classes such
as *org.drools.compiler.PackageBuilder*, *org.drools.RuleBase* which are
part of Drools Expert in the main Javadocs ?
Or the javadocs are only for Drools API?
Cheers,
Swapnil
16 years, 10 months
AgendaGroup Focus
by Chandana Pingle
Hi all,
How do i check if an agenda group has the focus from my java test class
Thanks
chandana
16 years, 10 months
Trouble getting Dynamic Salience working
by Bill Tarr
We have a winner! Many thanks Michal, hope I can return the favor one day.
salience ( return getSalience4() )
for the record, my function looks something like (after tempate evaluation):
<pre>
function int getSalience4(){
int salience = 0;
if("VALUE"=="VALUE") salience += 1000;
return salience;
}
</pre>
I think the combination activation-group and dynamic salience for rule-template projects are pretty useful.
Just for anyone interested, the tempate code looks something like this:
<pre>
rule "Some Rule_(a){row.rowNumber}"
activation-group "@{PARAM1}-@{PARAM2}"
salience ( return getSalience(a){row.rowNumber}() )
</pre>
where PARAM1 and PARAM2 make up a kind of key. I only want to execute one rule that matches that key, no matter how many options there are.
Rules that have additional parameters get higher salience than rules with less parameters, so here is my function.
<pre>
function int getSalience(a){row.rowNumber}(){
int salience = 0;
if("@{PARAM3}"=="@{PARAM3}") salience += 1000;
if("@{PARAM4}"=="@{PARAM4}") salience += 1000;
return salience;
}
</pre>
A concrete example could be pizza. So there are 3 types of pizza, all are grouped in the same activation-group.
cheese, pepperoni
cheese, pepperoni, sausage
cheese, pepperoni, meatball, pepper
Any cheese and pepperoni pizza should could match all these rules, but more toppings is always better for me.
So cheese, pepperoni, onion, pepper getts a salience of 2000, and is the only rule evaluated.
On Tue Sep 1 18:39:13 EDT 2009, Michal Bali michalbali at gmail.com wrote:
does this work?
salience ( return getSalience() )
or this:
salience ( getSalience();)
On Tue, Sep 1, 2009 at 6:50 PM, Bill Tarr <javatestcase at yahoo.com> wrote:
> Possibily just a simple MVEL error, but I've been struggling for a while
> and thought I'd see if anyone could help.
>
> I just want to run a logic test to determine salience for some rules I am
> generating with rules-templates. Even after making the logical test "true"
> I can't get any of variation to compile.
>
> (true ? "1000" : "0")
> **produces**
> Unable to build expression for 'salience' : not a statement, or badly
> formed structure
>
> ( true ? 1000 : 0)
> **produces**
> Unable to build expression for 'salience' : invalid number literal: 1000
>
> salience ( getSalience() )
> ...
> function int getSalience(){return 0;}
> **produces**
> Unable to build expression for 'salience' : org.mvel2.util.MethodStub
> cannot be cast to java.lang.Class'( getSalienceNONCDW() )'
>
> Seems like I am missing something simple, but I've tried many variations on
> the above, and have been unable to find any working examples of using a
> logical test in salience, so if anyone has any direction it would be greatly
> appreciated.
>
> Thanks!
>
> Bill
16 years, 10 months
Trouble getting Dynamic Salience working
by Bill Tarr
Possibily just a simple MVEL error, but I've been struggling for a while and thought I'd see if anyone could help.
I just want to run a logic test to determine salience for some rules I am generating with rules-templates. Even after making the logical test "true" I can't get any of variation to compile.
(true ? "1000" : "0")
**produces**
Unable to build expression for 'salience' : not a statement, or badly formed structure
( true ? 1000 : 0)
**produces**
Unable to build expression for 'salience' : invalid number literal: 1000
salience ( getSalience() )
...
function int getSalience(){return 0;}
**produces**
Unable to build expression for 'salience' : org.mvel2.util.MethodStub cannot be cast to java.lang.Class'( getSalienceNONCDW() )'
Seems like I am missing something simple, but I've tried many variations on the above, and have been unable to find any working examples of using a logical test in salience, so if anyone has any direction it would be greatly appreciated.
Thanks!
Bill
16 years, 10 months