Error in MVEL execution (optimization?)
by ronalbury
I hardly got any viewers (and no responses) when I posted this just as "MVEL
Optimization" ... so I have changed the subject and re-posted (my apologies
if I just broke protocol).
I'm not sure how to explain this, other than it appears that MVEL is trying
to optimize the When conditions in my rules.
I have a utility class, Test, with a number of methods on it (including null
protected versions of Drools "in" and "matches"). Note that the valueInList
method can return null (e.g. if the product code is null), and the
getAgeAsInt method can also return null (if the age is null). I don't like
having to test if the result of the method is true, but I kept running into
null pointer errors in the Drools expression evaluation code and had to
adopt this convention.
Here are two example rules (one in Java dialect and one in MVEL dialect). I
realize that a list of one is a degenerate case for using 'inList', but it
should still work.
rule "Term 15Plus Max Age - Washington"
dialect "java"
when
$ea : EasyApp(
Test.valueInList($ea.getEaProductCode(),
"L15P")==true
&& Test.valueInList($ea.getEaIssueState(), "WA")==true
&& $ea.getPriIns_xmPerson().getAgeAsInt() > 65
)
then
$ea.addError(drools.getRule().getName());
end
rule "Term 20 Max Age - New Jersey"
when
$ea : EasyApp(
Test.valueInList(eaProductCode, "L20")==true
&& Test.valueInList(eaIssueState, "NJ")==true
&& priIns_xmPerson.ageAsInt > 64
)
then
$ea.addError(drools.getRule().getName());
end
I have approximately 30 different rules similar to those above. When I have
the rules written in MVEL, it appears to be only be evaluating one rule per
EasyApp injection (I have a log message when ever valueInList is called),
and I get bogus results. However, when I shift to java dialect then it
appears that the methods are called for each rule I have defined (as I would
have expected).
Can anyone tell me if I am doing something wrong, and explain why Drools is
behaving as it is?
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/Error-in-MVEL-execution-optimization-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
Error while using the Matrix type Decision Table
by Swaroop Oggu
Hi,
Iam trying to use the Matrix type decision table using CustomWorkbook.xls
example on Drools 5.1.0. Iam getting an error "Invalid Column header
(ACTION type),should be CONDITION or ACTION row no XX cellnum XX contain a
leading C or A identifier". The SRL is generating correctly though, Any way
to supress this error ?
Thanks
Swaroop
14 years, 8 months
drools-spring schema issues
by Stephen Masters
Hi folks,
According to the integration docs:
http://docs.jboss.org/drools/release/5.3.0.Final/droolsjbpm-integration-d...
... 3.3.1.3 shows the location of the schema to be:
http://drools.org/schema/drools-spring.xsd
Unfortunately, that seems to redirect me to the Drools home page rather than a schema.
I have previously been using:
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-containe...
... but this doesn't support <drools:agendaEventListener> as a child of the <drools:ksession> element. Neither does it support <drools:eventListeners> at the level above. I was hoping to be able to make use of these, as they look as though they should help me to rid myself of some code.
I did notice that there are 1.1.0 and 1.2.0 versions of the drools-spring schema, but neither of those supports this either. I'm generally unclear as to which I should be using.
So I guess I have two questions really...
Are these valid configuration elements to use? i.e. Is the documentation out of date? Are they still beta?
Assuming that they should be available, what schema location should I be using?
Many thanks for any pointers you can provide.
Steve
14 years, 8 months
MVEL performance penalty
by Wolfgang Laun
Drools 5.3.0 FINAL.
This experiment was inspired by code posted with the insinuation that MVEL
would "optimize" condition evaluation. - Consider this rule:
rule "Term - java"
dialect "java"
when
$ea : EasyApp( Test.valueInList( $ea.getProductCode(), "CAR" )==true
&& age < 0 )
then end
You'd expect that Test.valueInList() is called once per inserted EasyApp
fact, and this can be verified easily. - Now the same rule, with MVEL's
syntactic sugar:
rule "Term - mvel"
dialect "mvel"
when
$ea : EasyApp( Test.valueInList( productCode, "CAR" )==true
&& age < 0 )
then end
*Now Test.valueInList() is called twice for each inserted fact.*
Cheers
Wolfgang
14 years, 8 months
Retriving Rule Id in Rule Template
by srinivasasanda
Hi All,
How to retrieve the cell number(rule id) when i click the load template
data.
My actual requirement is,I created a rule template where i defined some
conditions and actions.Now,when i clicked the load template data,i filled
condition columns and action columns.
I added 4 rows in template data.Now there are 4 rules available which are
postfixed with ids(cell numbers).
Now,how can i get that cellnumbers(1,2,3,4) in then part of rule condition.
Please suggest me
--
View this message in context: http://drools.46999.n3.nabble.com/Retriving-Rule-Id-in-Rule-Template-tp36...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
Inserting rules from guvnor into database
by srinivasasanda
Hi All,
Greetings,
I would like to know how to insert the rules from guvnor into
database.Ofcourse,I retrieved the rules from guvnor through KnowledgePackage
classes and API and inserted manually through java code.
But,I should not need that.My requirement is whenever i created rule in the
guvnor and click save changes,my repository of rules must be inserted into
database(mysql or postgres).How can i achieve that.Please suggest me.How can
i achieve that.
Thanks in Advance
--
View this message in context: http://drools.46999.n3.nabble.com/Inserting-rules-from-guvnor-into-databa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
Uable to reolve type
by gg
This is my rules file and its throwing this error:
[ isContained : unable to resolve type while building function
]
--------------------------------------------------------------------------------
package com.sample
import com.sample.DroolsTest.Message;
import com.sample.DroolsTest.Result;
import com.sample.DroolsTest.Discount;
import java.util.Arrays;
import java.util.List;
function boolean isContained(List<String> plist, List<String> clist){
boolean found = true;
for(String s : clist){
if (!plist.contains(s)){
found = false;
}
}
return found;
}
rule "GoodBye"
when
m : Message(ls:ls, pids: productIds)
l : List() from ls
eval(isContained(pids,l))
then
System.out.println( "found" );
end
Thanks,
--GG
--
View this message in context: http://drools.46999.n3.nabble.com/Uable-to-reolve-type-tp3634048p3634048....
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
Function Mismatch <eof>
by gg
I have written this in my rules file: But I getting this error :
[29,0]: [ERR 102] Line 29:0 mismatched input '<eof>' in function
"isContained"
[0,0]: Parser returned a null Package
-----------------------------------------------------------------------------
function boolean isContained(List<String> plist, List<String> clist){
boolean found = true;
for(String s : clist){
if (!plist.contains(s)){
found = false;
}
return found;
}
rule "GoodBye"
when
m : Message(ls:ls, pids: productIds)
l : List() from ls
eval(isContained(pids,l))
then
System.out.println( "found" );
end
--
View this message in context: http://drools.46999.n3.nabble.com/Function-Mismatch-eof-tp3634033p3634033...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months