The problem is not the "hashmap". Just read the error message:
[9,0]: unknown:9:0 mismatched token: [@122,385:388='then',<61>,9:0];
expecting type RIGHT_PAREN
You are missing a ) in your last condition, before the "then".
Having said that, your rule seems wrong to me:
* you should use a top level eval in the second condition
* you could benefit from the MVEL syntax to simplify your condition syntax
* there is no "eval" in the consequence. Just write plain code there.
rule xyz
dialect "mvel"
when
$a : RuleAttributes()
eval( ($a.values["AdultFare"] - $a.values["InfantFare"]) <
($a.values["ChildFare"] + $a.values["InfantFare"] ) )
then
$a.values["GrossFare"] = 500;
end
I did not tested, but should work fine.
[]s
Edson
2008/11/6 Nikhil_dev <k.nikhil(a)verchaska.com>
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......-tp20355904p2035590...
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @
www.jboss.com