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?
Thanks,
Edson
2008/3/1, Andrey Grin <andrey.grin(a)gmail.com>:
Hi,
I have two issues with float/double constants. In both cases dialect is
set to MVEL
Issue 1
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:
Example:
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
correctly:
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?
Issue 2
I have a rule:
rule "Determine min PRI for for PROD2" ruleflow-group
"budget_calculated_variables_appl"
when
$a: RetailApplication( )
StringVariable(name=="prodid", value matches CONST.PROD2)
then
insert(new NumberVariable("minPTI", 0.6, $a));
end
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
(runtime exception).
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
Thanks,
Andrey.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @