Looks like bugs. The first one is probably in drools code, while the
second one is on mvel.
Can you please open a jira for them?
2008/3/1, Andrey Grin <andrey.grin(a)gmail.com>:
I have two issues with float/double constants. In both cases dialect is
set to MVEL
If I use a comparison operator with the Double value it doesn't seem to
work correctly w/o brackets in the right part of the expression:
I have a condition like:
NumberVariable( owner == $a, name == "PTI", value > 0.5)
In the class NumberVariable the method getValue() is declared as follows:
public Number getValue();
In the working memory I have an instance with name == "PTI" and value ==
0.9633716684527102 ( actual type of the value is Double).
And the rule consequence is not executed.
If I change it and add brackets around the constant everything works
NumberVariable( owner == $a, name == "PTI", value > (0.5) )
There is similar example in drools documentation (w/o brackets):
Cheese( type == "stilton", price < 10, age == "mature" )
I assume that in this example the property has a primitive type and in my
case autoboxing is involved, but why brackets are necessary in my case?
I have a rule:
rule "Determine min PRI for for PROD2" ruleflow-group
$a: RetailApplication( )
StringVariable(name=="prodid", value matches CONST.PROD2)
insert(new NumberVariable("minPTI", 0.6, $a));
Initially I had only one constructor for NumberVariable:
public NumberVariable(String pName, Number pValue, Object pOwner)
But MVEL couldn't find this constructor when "then" part was executed
The problem was solved when I added another constructor:
public NumberVariable(String pName, float pValue, Object pOwner)
Java compiler accepts identical code when only first constructor is there:
NumberVariable nv = new NumberVariable("minPTI", 0.6, null);
Drools version: 4.04, Java version: 1.6
rules-users mailing list
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @