[rules-users] Sir, Seekin your's Help on Drool

Welsh, Armand AWelsh at StateStreet.com
Wed Apr 18 23:58:51 EDT 2012


As the others have stated, without some actual rules it is very difficult, if not near impossible to provide help. 

Inferring what you might be trying to do, here is an example of what I *think* you are trying to do:

CONDITION
	$pp: PremiumCalculatorFormBean ( )
	$maturity: Integer ( ) from getMaturityAge($pp)
	eval ( $maturity > 70 )

For this to work, you should change your Drools function to return Integer object.

Drawing further assumptions form your function, which is always going to return 0 as you have it written here, I will assume that age and premiumPaymentTerm are properties of PremiumCalculatorForBean class, you could do the same this without the function call like this:

CONDITION
	PremiumCalculatorFormBean ( $age: age, $term : premiumPaymentTerm)
	eval ( ($age + $term) > 70 )

or

CONDITION
	$pp: PremiumCalculatorFormBean ( )
	eval ( ($pp.age + $pp.premiumPaymentTerm) > 70 )

the difference is really just preference, and personal style.  
In the first example you capture the age and term into separate variable, and then you perform the math on those two varaibles.  In the second pp is capturing the PremiumCaclulatorFormBean object and the math is done on properties of that object.

In both examples, if you have two PremiumCalculatorFormBean objects in working memory, then this rule will fire twice, unless you use some control mechanism to force them to only fire once.

I hope this helps.  I suspect it may be on the right track, or at least let you see the proper syntax for define the LHS conditional constraints.

Armand

-----Original Message-----
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of San
Sent: Wednesday, April 18, 2012 5:24 AM
To: rules-users at lists.jboss.org
Subject: Re: [rules-users] Sir, Seekin your's Help on Drool

pp:PremiumCalculatorFormBean (fact in this case) contains 2 int fields age
and premiumPaymentTerm.

I need to validate (age+premiumPaymentTerm) sud nt b >70.

So in 1st condition column  i am calling a method 
 int getMaturityAge(pp) {
          int maturityAge=0;
          int age=0;
          int premiumPaymentTerm=0;
          maturityAge=age+premiumPaymentTerm;
         return maturityAge;
}

In the condition I write,  maturityAge(pp) > "$1" and provide 70 as the
param value.

Nw the error that I am gettin...

1) while writing the above condition , it is unable to resolve pp.
    ....no viable alternative at input 'pp' in rule "MaturityAge
Validation_38"

2) for testing purpose I call this method without any argument and returning
90.
    In his case also I am getting 

      ...no viable alternative at input ')' in rule "MaturityAge
Validation_38"
     ...mismatched input '>' expecting ')' in rule "MaturityAge
Validation_38"

In Action part I have put System.out.println("Maturity value sud be less
than 70 ")


--
View this message in context: http://drools.46999.n3.nabble.com/Re-rules-users-Sir-Seekin-your-s-Help-on-Drool-tp3919571p3919784.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list