Mark,
 
We might not be using 4.0 so soon. The business is still to make a decision on that. In these scenarios what is way out to effectively code such kind of a scenarios.
 
If i make all my class attributes to be objects ( Double), then in the rule conditions i cannot use something like
 
1. attrib * 1.5, because it fails saying * cannot be applied to Double and double
2. attrib.doubleValue() * 1.5 isnt working. Complains that doubleValue() is not defined in java.lang.Object. attrib has been declared as Double in my object. 
3. I havent tried a full analysis, but calling a function which does this calculation cant be called from the other half of the predicate. If say attrib2 > multiply(attrib1.doubleValue(), 1.5). It complains of not being able to resolve "multiply".
 
I have specifically observed difficulty to work things for the part coming after a > or a< etc. THe work around which i tried is
emi: EMIObject ( businessProfit1 > (businessProfit2 * 1.5) ) - This wont work
i have another variable in EMIObject, whic is declared double bp = businessProfit2 * 1.5;
and then
emi: EMIObject ( businessProfit1 > bp ). This works, but i am forced to move some logic to the business object which should not be the case.
 
Let me know if there is a better way! Or am i missing any basics over here?
 
Any inputs are very useful.
 
Thanks
Natraj

 
On 7/18/07, Mark Proctor <mproctor@codehaus.org> wrote:
I believe all your requests are in 4.0, give that a try. For 2.0.6 you'll have to unwrap
> (bpl.doubleValue() * 1.5 )

Mark
Natraj Gudla wrote:
Hi All,
 
I am using Drools 3.0.6 and unable to perform some simple form of multiplication. I want to compare an object field with another field multiplied by a factor.
 

rule

"Calculate Business profit,1"
when

EMIAgainstProperty ( bp1 : businessProfit1 )
emi : EMIAgainstProperty ( businessProfit2 > (bp1*1.5) )
then
emi.setBusinessProfit((emi.getBusinessProfit1()+emi.getBusinessProfit2())/2);
end

I get an error on creation of the package that * is undefined for Double and double. I understand this is because Drools does an auto box on primitive type variables. But is there a work around to do simpler comparisons like this, especially on the right hand side of the condition. some thing like [ variable * constantValue ].

Also, i am forced to do a declaration for businessProfit1, and use in the comparison below. I am not able to compare two fields of the same object directly.

some thing like businessProfit2 > businessProfit1 does not work, why is this so? Any one has faced these problems earlier?

Thanks
Natraj


_______________________________________________ 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