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 "Assert List Contents"<br> when<br> $list : List(size > 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 "Validate ONFI final action - code 666"<br>
when<br>
RuleFlag(value == "Validate ONFI final action")<br>
a: PackageMovementInfo(actionCode == "666")<br>
b: ONFIAssignmentInfo(reviewType == "ES", subId == a.subId)<br>
ONFIReviewerInfo(notId == b.notId, revStatus == "CLO", reviewerRole == "PR") <br>
then<br>
result.addMessage(a, "You can't do action code 666..." );<br>
end<br><br><div class="gmail_quote">On Mon, Dec 14, 2009 at 9:21 AM, Warren, David [USA] <span dir="ltr"><<a href="mailto:warren_david@bah.com">warren_david@bah.com</a>></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 "Do we need to validate ONFI final action"<br>
when<br>
a : PackageMovementInfo( finalActionInd == "*", packageId == "AA")<br>
b : SubmissionsInfoForRules(subId == a.subId, amendment == false, onfiAssignmentId != null)<br>
then<br>
insert( new RuleFlag("Validate ONFI final action") );<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'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 "Validate ONFI final action - code 666"<br>
when<br>
RuleFlag(value == "Validate ONFI final action")<br>
a: PackageMovementInfo(actionCode == "666")<br>
b: ONFIAssignmentInfo(reviewType == "ES", subId == a.subId)<br>
$list : List( size > 0 )<br>
ONFIReviewerInfo(notId == b.notId, revStatus == "CLO", reviewerRole == "PR") from $list<br>
then<br>
result.addMessage(a, "You can't do action code 666..." );<br>
end<br>
<br>
What I need to do is either (1) load each element of the lists individually, or (2) rewrite "$list : List (size > 0)" 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>