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