If you need to reason over the contents of the list, I would probably write a generic rule that will insert each element from a list into Working Memory<br><br>rule &quot;Assert List Contents&quot;<br>   when<br>          $list : List(size &gt; 0)<br>
          $obj : Object() from $list<br>   then<br>       insert($obj);<br>end<br><br>Then write the other rules specific to the items in the list<br><br>rule &quot;Validate ONFI final action - code 666&quot;<br>
when<br>
RuleFlag(value == &quot;Validate ONFI final action&quot;)<br>
a: PackageMovementInfo(actionCode == &quot;666&quot;)<br>
b: ONFIAssignmentInfo(reviewType == &quot;ES&quot;, subId == a.subId)<br>
ONFIReviewerInfo(notId == b.notId, revStatus == &quot;CLO&quot;, reviewerRole == &quot;PR&quot;) <br>
then<br>
result.addMessage(a, &quot;You can&#39;t do action code 666...&quot; );<br>
end<br><br><div class="gmail_quote">On Mon, Dec 14, 2009 at 9:21 AM, Warren, David [USA] <span dir="ltr">&lt;<a href="mailto:warren_david@bah.com">warren_david@bah.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I am trying to write a rule whose consequence loads several lists into the session.  Each list contains a different type of class.  What I would like to do (need to do as far as I can tell) is loop through the list and insert each element individually, rather than inserting the list as a whole.  Is ther a way to do this in DRL?<br>

<br>
Here is my example rule:<br>
rule &quot;Do we need to validate ONFI final action&quot;<br>
when<br>
  a : PackageMovementInfo( finalActionInd == &quot;*&quot;, packageId == &quot;AA&quot;)<br>
  b : SubmissionsInfoForRules(subId == a.subId, amendment == false, onfiAssignmentId != null)<br>
then<br>
  insert( new RuleFlag(&quot;Validate ONFI final action&quot;) );<br>
  insert( onfiService.getONFIAssignment(b.getSubId()) );<br>
  insert( onfiService.getONFIReviewers(b.getOnfiAssignmentId()) );<br>
  insert( onfiService.getONFIAttachments(b.getOnfiAssignmentId()) );<br>
end<br>
<br>
The last two insert statements insert lists.  A problem occurs in subsequent rules if I try to evaluate the contents of the lists.  I&#39;ve been getting a ClassCastException when lists are present for both the reviewers and attachments, because they are not the same class.   Here is an example rule that causes a ClassCastException:<br>

<br>
rule &quot;Validate ONFI final action - code 666&quot;<br>
when<br>
RuleFlag(value == &quot;Validate ONFI final action&quot;)<br>
a: PackageMovementInfo(actionCode == &quot;666&quot;)<br>
b: ONFIAssignmentInfo(reviewType == &quot;ES&quot;, subId == a.subId)<br>
$list : List( size &gt; 0 )<br>
ONFIReviewerInfo(notId == b.notId, revStatus == &quot;CLO&quot;, reviewerRole == &quot;PR&quot;) from $list<br>
then<br>
result.addMessage(a, &quot;You can&#39;t do action code 666...&quot; );<br>
end<br>
<br>
What I need to do is either (1) load each element of the lists individually, or (2) rewrite &quot;$list : List (size &gt; 0)&quot; to only pick up lists of a particular class.<br>
Is there a way to do either of these things from DRL?  Or do I need to handle the loading outside of my rules (in the Java class that calls the rules).<br>
<br>
Thank you,<br>
David Warren<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>
</blockquote></div><br>