[rules-users] Using Hashmap in drl files......
Nikhil_dev
k.nikhil at verchaska.com
Thu Nov 6 01:47:02 EST 2008
Below is the drl file
package com.vtech.ruleengine.module.rulemanagermodule
import com.vtech.ruleengine.module.rulemanagermodule.RuleAttributes;
import java.util.Map;
rule "Rule_dec_1"
dialect "mvel"
when
$a : RuleAttributes()
m : RuleAttributes ( eval( ($a.getValues().get("AdultFare") -
$a.getValues().get("InfantFare")) < ($a.getValues().get("ChildFare") +
$a.getValues().get("InfantFare") ) )
then
eval($a.getValues().put("GrossFare", 500))
end
Follwing is the way i am using drrols
final StatefulSession ruleStateSession =
ruleBase.newStatefulSession();
ruleStateSession.addEventListener( new DebugAgendaEventListener()
);
ruleStateSession.addEventListener( new
DebugWorkingMemoryEventListener() );
RuleAttributes objRuleattri = new
RuleAttributes((HashMap<String, Object>)_hmListBean);
ruleStateSession.insert(objRuleattri);
ruleStateSession.fireAllRules();
Note : RuleAttributes is a class where i set getter and setter for hashmap
Below is the error message that i get :
[9,0]: unknown:9:0 mismatched token: [@122,385:388='then',<61>,9:0];
expecting type RIGHT_PAREN
ERROR 1 ::getCause::: null
ERROR 2 ::getLocalizedMessage::: Unable to compile drl
ERROR 3 ::getMessage::: Unable to compile drl
ERROR 4 ::toString::: java.lang.RuntimeException: Unable to compile drl
Gross VAlue ::::: 0
java.lang.RuntimeException: Unable to compile drl
It will be very helpful is anyone of you rectify my mistake or tell me any
other way to use Hashmap in drl file.
I am using hashmap, since variable in my application varies hence cannot
define fixed Bean structure.
-----
Regards,
:working:Nikhil
--
View this message in context: http://www.nabble.com/Using-Hashmap-in-drl-files......-tp20355904p20355904.html
Sent from the drools - user mailing list archive at Nabble.com.
More information about the rules-users
mailing list