<br> Dirk,<br><br> This should work:<br><br> $rli_list : RecordSet( this != $npi.relatedRLIs )<br><br> If it is not working, may I ask you please to open a JIRA?<br><br> []s<br> Edson<br><br><br><div><span class="gmail_quote">2008/1/25, Dirk Bergstrom <<a href="mailto:dirk@juniper.net">dirk@juniper.net</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I collect objects of type RLI that are related to instances of type NPI, and<br>"attach" them to their NPIs, and (in a later agenda group) collect subsets of<br>RLIs based on attributes of RLIs, NPIs, and other objects. In the first agenda<br>
group, I need to update() the NPI object after the new list of RLIs is attached,<br>but I only want to do this when a *new* list is attached.<br><br>The only way I can find to do this requires an eval. Is there a better way?<br>
<br>Here's the rule that I have now. This works:<br><br>rule "RLIs for NPI"<br> agenda-group "010"<br> lock-on-active true<br> salience 50<br>when<br> $npi : NPIRecord( )<br> $rli_list : RecordSet( eval( ! $rli_list.equals($npi.getRelatedRLIs())) ) from<br>
collect( RLIRecord( npi_program == $npi.synopsis ) )<br>then<br> $npi.setRelatedRecords($rli_list, DataSource.RLI);<br> update($npi);<br>end<br><br>I'd like to write something like this:<br><br>...<br> $rli_list : RecordSet( $rli_list != $npi.relatedRLIs ) from<br>
...<br><br>But that doesn't compile. To get around that, I added a method called<br>getContents to RecordSet that just returns "this", so I could write:<br><br>...<br> $rli_list : RecordSet( contents != $npi.relatedRLIs ) from<br>
...<br><br>But that always returns true. Best I can tell, it gets compiled into an<br>inequality test, as opposed to a call to equals(), and the new list is never the<br>same object as the old list, even though they may have the same contents.<br>
<br>I also tried this (setRelatedRecords returns true if the list is different):<br><br>...<br>then<br> $npi.setRelatedRecords($rli_list, DataSource.RLI) && update($npi);<br>end<br><br>But that won't compile at all.<br>
<br>--<br>Dirk Bergstrom <a href="mailto:dirk@juniper.net">dirk@juniper.net</a><br>_____________________________________________<br>Juniper Networks Inc., Computer Geek<br>Tel: 408.745.3182 Fax: 408.745.8905<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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>