Thanks, I have resolved the problem with some modified to the Drools source, maybe you can take a loot at my blog: <a href="http://wangzaixiang.blogspot.com">wangzaixiang.blogspot.com</a>, (In chinese, but i post some source code)<br>
<br><div class="gmail_quote">On Sat, Mar 27, 2010 at 8:23 AM, Peter Butler <span dir="ltr"><<a href="mailto:peter.butler@141.com">peter.butler@141.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Wang<br>
<br>
I've done something similar with questions in an insurance application.<br>
I found it easiest to split the map entries up into separate objects and<br>
put them all into working memory:<br>
<br>
class Answer {<br>
String questionCode;<br>
String answer;<br>
AnswerSet answerSet;<br>
// ...getters and setters omitted<br>
}<br>
<br>
class AnswerSet {<br>
String answerSetCode;<br>
List<Answer> answers;<br>
}<br>
<br>
The rule looks something like:<br>
<br>
when<br>
set1 : AnswerSet(code == 'answerSet1')<br>
answer1 : Answer(questionCode == 'question1', answer == "100", answerSet<br>
== set1)<br>
answer2 : Answer(questionCode == 'question2', answer == '200', answerSet<br>
== set1)<br>
then<br>
answer1.hidden = true<br>
<br>
These are also easy to convert into a DSL. The "answerSet" in the rule<br>
is used to make sure both answers have come from the same set of answers<br>
(if that's important to you).<br>
<br>
I did read somewhere in the docs that MVEL can handle maps in the same<br>
way as beans, but I'm not sure if this is correct.<br>
<br>
Cheers<br>
<font color="#888888"><br>
Peter<br>
</font><div><div></div><div class="h5"><br>
王在祥 wrote:<br>
> I have a requirement of run rules on dynamic map instead of POJO, for<br>
> example:<br>
><br>
> *when<br>
> Map(* TransCode == "LOGIN" , userName == "wangzx", password == "123456" )<br>
> *then<br>
> doSth1()<br>
><br>
> when<br>
> Map( *TransCode = "SaveOrder" userName == "wangzx" category == "Book")<br>
> *then<br>
> doSth2()<br>
><br>
> *<br>
> the Fact is not a Java Bean, but a dynamic map<String, Object>, so the<br>
> TransCode == "Login" is what we means map("TransCode") == "Login".<br>
><br>
> By using map insteam of POJO, we can build a rules run on the message<br>
> dispatch, since there is a lot of Message Types, and each message type<br>
> has different schema, so using dynamic types is more flexible than POJO.<br>
><br>
> Can someone tell me how can it be supported in drools? Very thanks.<br>
</div></div>> ------------------------------------------------------------------------<br>
<div><div></div><div class="h5">><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>
><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>
</div></div></blockquote></div><br>