<br> The problem is not the "hashmap". Just read the error message:<br><br>[9,0]: unknown:9:0 mismatched token: [@122,385:388='then',<61>,9:0]; expecting type RIGHT_PAREN<br>
<br> You are missing a ) in your last condition, before the "then".<br><br> Having said that, your rule seems wrong to me:<br><br>* you should use a top level eval in the second condition<br>* you could benefit from the MVEL syntax to simplify your condition syntax<br>
* there is no "eval" in the consequence. Just write plain code there.<br><br>rule xyz<br>dialect "mvel"<br>when<br>
$a : RuleAttributes()<br>
eval( ($a.values["AdultFare"] - $a.values["InfantFare"]) < ($a.values["ChildFare"] + $a.values["InfantFare"] ) )<br>then<br> $a.values["GrossFare"] = 500;<br>
end<br>
<br> I did not tested, but should work fine.<br> <br> []s<br> Edson <br><br><br><div class="gmail_quote">2008/11/6 Nikhil_dev <span dir="ltr"><<a href="mailto:k.nikhil@verchaska.com">k.nikhil@verchaska.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Below is the drl file<br>
<br>
package com.vtech.ruleengine.module.rulemanagermodule<br>
import com.vtech.ruleengine.module.rulemanagermodule.RuleAttributes;<br>
import java.util.Map;<br>
rule "Rule_dec_1"<br>
dialect "mvel"<br>
when<br>
$a : RuleAttributes()<br>
m : RuleAttributes ( eval( ($a.getValues().get("AdultFare") -<br>
$a.getValues().get("InfantFare")) < ($a.getValues().get("ChildFare") +<br>
$a.getValues().get("InfantFare") ) )<br>
then<br>
eval($a.getValues().put("GrossFare", 500))<br>
end<br>
<br>
<br>
Follwing is the way i am using drrols<br>
<br>
final StatefulSession ruleStateSession =<br>
ruleBase.newStatefulSession();<br>
<br>
ruleStateSession.addEventListener( new DebugAgendaEventListener()<br>
);<br>
ruleStateSession.addEventListener( new<br>
DebugWorkingMemoryEventListener() );<br>
<br>
RuleAttributes objRuleattri = new<br>
RuleAttributes((HashMap<String, Object>)_hmListBean);<br>
<br>
ruleStateSession.insert(objRuleattri);<br>
<br>
ruleStateSession.fireAllRules();<br>
<br>
Note : RuleAttributes is a class where i set getter and setter for hashmap<br>
<br>
Below is the error message that i get :<br>
<br>
[9,0]: unknown:9:0 mismatched token: [@122,385:388='then',<61>,9:0];<br>
expecting type RIGHT_PAREN<br>
ERROR 1 ::getCause::: null<br>
ERROR 2 ::getLocalizedMessage::: Unable to compile drl<br>
ERROR 3 ::getMessage::: Unable to compile drl<br>
ERROR 4 ::toString::: java.lang.RuntimeException: Unable to compile drl<br>
Gross VAlue ::::: 0<br>
java.lang.RuntimeException: Unable to compile drl<br>
<br>
It will be very helpful is anyone of you rectify my mistake or tell me any<br>
other way to use Hashmap in drl file.<br>
I am using hashmap, since variable in my application varies hence cannot<br>
define fixed Bean structure.<br>
<br>
<br>
<br>
-----<br>
Regards,<br>
:working:Nikhil<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Using-Hashmap-in-drl-files......-tp20355904p20355904.html" target="_blank">http://www.nabble.com/Using-Hashmap-in-drl-files......-tp20355904p20355904.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>