[rules-users] RE : Identity Mode?

Geoffrey De Smet ge0ffrey.spam at gmail.com
Thu Jun 20 10:19:45 EDT 2013


Good idea, but that will make it fire twice if you insert 2 Persons A and B:
once for A-B and once for B-A.

I often use this instead:

Person ($id : id)
Person (id > $id)

On 20-06-13 16:13, Bruno FREUDENSPRUNG wrote:
> Hi,
>
> I think you are talking about the assert behavior:
>
> KnowledgeBaseConfiguration configuration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
> configuration.setOption(AssertBehaviorOption.EQUALITY);
>
> But I think you will have to add a condition like... :
>
> p1 : Person()
> Person(this != p1)
>
> ... to make it work like you intended.
>
> Regards,
>
> Bruno.
>
> ________________________________________
> De : rules-users-bounces at lists.jboss.org [rules-users-bounces at lists.jboss.org] de la part de rjr201 [rich.j.riley at gmail.com]
> Date d'envoi : jeudi 20 juin 2013 16:05
> À : rules-users at lists.jboss.org
> Objet : [rules-users] Identity Mode?
>
> If I have a rule such as:
>
> When
>     Person()
>     Person()
> Then
>     System.out.println("There are two people!")
> End
>
> I only want this to fire if there are two (or more) Person objects inserted
> into the session, however as default drools will fire even when there is
> just one Person object inserted (i.e. both Person patterns get matched to
> the same fact).
>
> I seem to remember there is a flag I can set that swaps between these two
> types of behavior, and seem to remember it's to do with Identity/Equality
> mode. However, I can't remember how or where to do this.
>
> Any help on this would be greatly appreciated..
>
> Cheers,
> Rich.
>
> P.S I realise that I could add constraints to the patterns to explicitly
> check that the facts aren't the same.. however I'd rather not have to do
> that as I'm trying to make it as simple as possible for users to create
> rules..
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Identity-Mode-tp4024428.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list