Thanks, Steven, Scott,
yes, that worked. The reason I did not do it in the first place is because I was looking
for examples of variable declaration in RHS and the only one I found was the
PetStore.drl:
then
System.out.println( "Adding free Fish Food Sample to cart" );
purchase = new Purchase($order, $fishFoodSample);
insert( purchase );
$order.addItem( purchase );
Since the 'purchase' object was not declared using Java syntax I assumed that is
the Drools syntax... Maybe it's a typo in the example? I did not run it myself.
Anyway, it works now :-)
Thanks!
Marina
----- Original Message ----
From: Scott Burrows <scottjburrows(a)gmail.com>
To: Rules Users List <rules-users(a)lists.jboss.org>
Sent: Thursday, July 3, 2008 8:10:35 AM
Subject: Re: [rules-users] how to find the rule name
The RHS of the rule uses Java syntax, so you need to declare all vars. You need to
declare "rulename" as a String.
Scott Burrows
407-739-7752
On Wed, Jul 2, 2008 at 5:09 PM, Marina <ppine7(a)yahoo.com> wrote:
Hello,
I need to know the rule name of the rule that fired in the consequence part of the rule. I
tried something like the following, just trying to see if I can get it this way:
package mode.simple;
import java.lang.String;
import java.util.List;
import com.emptoris.ecm.domain.ContractRulesData;
global java.util.Set approverList;
rule "testOR_1"
dialect "java"
when
$data : ContractRulesData (sum > 500 || name matches ".*important")
then
approverList.add("approver3, approver4, Level5");
ruleName = drools.getRule().getName();
System.out.println(ruleName + " is TRUE");
end
When I'm trying to compile the rule, I'm getting the following error:
Builder errors:
Rule Compilation error : [Rule name=testOR_1, agendaGroup=MAIN, salience=0,
no-loop=false]
mode/simple/Rule_testOR_1_0.java (8:391) : ruleName cannot be resolved
mode/simple/Rule_testOR_1_0.java (9:452) : ruleName cannot be resolved
java.lang.RuntimeException: Unable to compile rules file: testOR_1.drl
I must be doing something wrong here... ?
thanks!
Marina
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users