Re: OCL question
Thanks for your comments. I still have some doubts. Please, find below my comments.
> 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.
You might be right. However, I have two concerns:
1- In the collaboration the roles are not bound to any classifier. It is the collaboration use that defines such binding. When you say
"buyer<>seller", should this be interpreted as "the object to which the seller role will be bound should be different of the object to
which the buyer role will be bound"? Note that I say "will be bound", because that binding does not exist in the context of the
2- Would not such constraint affect all uses of the Sale collaboration? What if I just want to impose "buyer<>seller" in the case the
collaboration is bound to a Person classifier? So, for example, we could still have buyer=seller if Sale is bound to a e.g. Machine
This is why I was trying to impose the constraint in the context of the collaboration use. I guess, anyway, that I cannot use the
collaboration use as context, since it is just a NamedElement.
> By the way, your use of roleBinding is incorrect, because you mix the metamodel
> with the model.
Thanks for your correction. This is actually my first attempt at using OCL and I have still some problems using it.
Since the role bindings are UML Dependencies and not associations, how can we navigate through them with OCL?
> Kind regards, Anneke Kleppe
> Humberto Castejon wrote:
>> Hi again!
>> I attach a diagram that may help to better understand my question.
>> Humberto Castejon wrote:
>>> 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!
Received on Sun 24 Feb 2008 - 18:26:59 GMT