Don't forget when adding new objects; if you want them to be visible to the rules you'll need to call "insert(XXX)" or "insertLogical(XXX)"<br><br><div class="gmail_quote">2010/10/19 Minh Huon <span dir="ltr"><<a href="mailto:mhuon@dna20.com">mhuon@dna20.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;">
<div bgcolor="#ffffff" text="#000000">
You have something similar to what you want. If <b>resultState </b>is
a global variable, there is nothing stopping you from writing any
amount of java code you want in the consequence part. Create
whatever you want and then do <b>resultState.add(SOMEOBJECT);<br>
<br>
</b>You already perform a similar action with the code you have
already:<div class="im"><br>
frontAxleAttributes.put("Capacity" ,new
Double(c.attributes.Capacity));<br>
<br></div>
hth<br>
Minh<div><div></div><div class="h5"><br>
<br>
<br>
On 10/18/2010 2:58 PM, Navdeep Kumar wrote:
</div></div><blockquote type="cite"><div><div></div><div class="h5">Hi..
<div><br>
</div>
<div>After execution of each rule, i want to create a new object
of a particular class and want to add that to the list. i know
how to set the global list but i am not sure whether i can
create a new instance in the consequence of the rule.</div>
<div><br>
</div>
<div><br>
</div>
<div>here is the rule file and description that what i am trying
to do.</div>
<div><br>
</div>
<div>import java.util.Map;</div>
<div>global java.util.HashMap availablity;</div>
<div>global java.util.HashMap frontAxleAttributes;</div>
<div>global java.util.HashMap frontSuspensionAttributes;</div>
<div>global java.util.ArrayList resultState;</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>rule "FrontAxle:Capacity|FrontSuspension:Capacity"</div>
<div>dialect "mvel"</div>
<div><span style="white-space: pre-wrap;"> </span>when</div>
<div><span style="white-space: pre-wrap;"> </span>b:Feature(featureClass.name=="FrontSuspension") </div>
<div><span style="white-space: pre-wrap;"> </span>c:Feature(featureClass.name=="FrontAxle")</div>
<div><span style="white-space: pre-wrap;"> </span>eval(b.attributes.Capacity>=c.attributes.Capacity)</div>
<div><span style="white-space: pre-wrap;"> </span></div>
<div><span style="white-space: pre-wrap;"> </span>then</div>
<div><span style="white-space: pre-wrap;"> </span></div>
<div><span style="white-space: pre-wrap;"> </span>System.out.println(b.attributes.Capacity);</div>
<div><span style="white-space: pre-wrap;"> </span>frontAxleAttributes.put("Capacity"
,new Double(c.attributes.Capacity));</div>
<div><span style="white-space: pre-wrap;"> </span>frontSuspensionAttributes.put("Capacity",
new Double(b.attributes.Capacity));</div>
<div><span style="white-space: pre-wrap;"> </span></div>
<div><span style="white-space: pre-wrap;"> </span>frontAxleAttributes.put("Feature
Code",b.getCode());</div>
<div><span style="white-space: pre-wrap;"> </span>frontSuspensionAttributes.put("Feature
Code",c.getCode());</div>
<div><span style="white-space: pre-wrap;"> </span></div>
<div><span style="white-space: pre-wrap;"> </span>availablity.put(b.featureClass.getName+"-"+c.getFeatureClass().getName(),new
Double(b.attributes.Capacity));</div>
<div><span style="white-space: pre-wrap;"> </span></div>
<div><span style="white-space: pre-wrap;"> <b>
</b></span><b>// i want to create a new Object of a class
named AvailabilityRuleState and want to add that in the list
named resultState. </b></div>
<div><span style="white-space: pre-wrap;"><b> </b></span></div>
<div><span style="white-space: pre-wrap;"> </span></div>
<div><span style="white-space: pre-wrap;"> </span>end</div>
<div><span style="white-space: pre-wrap;"> </span> </div>
<div><br>
</div>
<div><span style="white-space: pre-wrap;"><b>//resultState
is a list of AvailabilityRuleState Class. Please do check
the global declaration if that is wrong.</b></span></div>
<div><br>
</div>
<div>will appreciate your help.</div>
<div><br>
</div>
<div>Thanks.</div>
</div></div><pre><fieldset></fieldset>
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
</div>
<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></blockquote></div><br>