Re: OCL question

Re: OCL question

From: Anneke Kleppe <>
Date: Sun, 24 Feb 2008 12:50:06 +0100
Message-ID: <>
Hi Humberto,

I do not know a lot about collaborations, but I would say that your 
problem could be specified very simply:

context Sale
inv: buyer <> seller

Because a collaboration is a classifier, it can be used as context, and 
because collaboration roles are a subset of (classifier) roles, they can 
be used in the same manner as associations.

By the way, your use of roleBinding is incorrect, because you mix the 
metamodel with the model.

Kind regards, Anneke Kleppe

Humberto Castejon wrote:
> Hi again!
> I attach a diagram that may help to better understand my question.
> Cheers,
> Humberto
> Humberto Castejon wrote:
>> Hi!
>> I have some problems using OCL together with collaborations and 
>> collaboration uses. I would be very grateful if you oculd help me 
>> with the following.
>> Imagine we have a Sale collaboration with two roles: buyer and 
>> seller. Now, by means of a collaboration use, we bind both roles to 
>> the same classifier, namely Person. An instance of Person may then 
>> behave either as a seller or as a buyer in a Sale collaboration. 
>> However, we do not want the same instance of Person to play both the 
>> seller and the buyer roles in the same occurrence of a Sale 
>> collaboration (i.e. we do not want a person to sell to herself).
>> Would the following OCL invariant, specified in the context of the 
>> collaboration use, be correct?
>> Context s:Sale
>> inv s.roleBinding->forAll(b1, b2 | 
>> b1.client.allInstances->forall(Person p1 | 
>> b2.client.allInstances->forall(Person p2 | p1 <> p2)))
>> Thanks for you help!
>> Cheers,
>> Humberto
> ------------------------------------------------------------------------
Received on Sun 24 Feb 2008 - 11:50:06 GMT