Yap, that or, in case you want to do it automatically for ALL your rules, you could use:
KnowledgeBaseConfiguration conf = ... conf.setOption( RemoveIdentitiesOption.YES ); Javadocs: http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/apidocs/org/drools/KnowledgeBaseConfiguration.html http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/apidocs/org/drools/conf/RemoveIdentitiesOption.html Edson 2009/11/6 Mark Proctor <[email protected]> > D Brock wrote: > > I have defined the following rule to detect when duplicate objects (in > this > > example, Widgets) exist. This always produces two matches, and therefore > > two messages. I understand why this occurs, but I would like for only > one > > message to be reported. I cannot retract one of the widgets after a > match > > b/c all are needed for additional rules matching. Is the a conventional > way > > for accomplishing the elimination of the reciprocal match? > > > > rule "Do not allow duplicate widgets" > > when > > $w : Widget( $name : name ) > > Widget( this != $w, name == $name ) > > then > > System.out.println( "Duplicate widgets found with name = " > + $name ); > > end > > > We are looking into a new conditional element that can achieve this. The > idea is when you use this CE, it ensures only a single permutation will > be propagated. In the meantime you can probably try something like: > > $w : Widget( $name : name ) > Widget( this != $w, hashCode < $w.hashCode, name == $name ) > > > > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
