Hi ,
i can suggest one more way to solve it. Dont create instance in when part.
Instead of better you convert that helper class method as static methods.
So that u can call that method directly . but before that u should import that helper class in drl file.
Or second way u can directly write a method in ur drl file itself.
Example :
import com.g2x.agility.leads.workflow.rulesengine.RuleUtilities;
rule"ConvertRule"
when
eval ( RuleUtilities.getStringToInteger( age) > 40)
// getStringToInteger(String age) is static method
then
System.out.print("XXXXName");
end
____________________________
DILIP KUMAR.M
--- On Tue, 2/12/08, vanshi <nilu.thakur@gmail.com> wrote:
From: vanshi <nilu.thakur@gmail.com> Subject: [rules-users] Inline eval problem! To: rules-users@lists.jboss.org Date: Tuesday, 2 December, 2008, 10:38 AM
I need to convert a variable from string to intger in the rule. That variable
here is rank, so, I create a helper class called 'Conversion' with just
one
function/method, which is supposed to convert the string argument passed to
it, to an integer and then I call that method in rule as inline eval.
What's
wrong here because this is not working and I don't want to change
'When'
part too much because it has 10 or so other variable with &&
connective,
which I've removed for clarity here. Any input would be appreciated much.
package harules;
import com.hibernate.Person;
import com.uhg.utils.Conversion;
rule "one"
salience 10
when
$con: Conversion();
pers: Person(age!= null , age >= 18 , eval($con.getInteger(rank) > 140))
then
System.out.println("Evaluated true");
end
//content of Conversion class
package com.utils;
public class Conversion {
public Integer getInteger(String s)
{
return Integer.parseInt(s);
}
}
--
View this message in context:
http://www.nabble.com/Inline-eval-problem%21-tp20786253p20786253.html
Sent from the drools - user mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
|