Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL<->EMF 'impedance mismatch' with specific association validation?
OCL<->EMF 'impedance mismatch' with specific association validation? [message #36566] Sun, 09 September 2007 20:02 Go to next message
Andreas Werner is currently offline Andreas WernerFriend
Messages: 55
Registered: July 2009
Member
Hi newsgroup,

I have this problem:
Given a UML metamodel with two classes A and B and a class X that has an
association with A and B respectively. In the derived Ecore model X will
play the role of an association.
I want to assure via an OCL constraint that any instance of A can be referenced
by only one instance of X at the same time.

For me there are only two possibilities to imagine, but both don't work :( :

1) The association from X to A is binary. Then I am able to define a constraint
in OCL with A as context, but the Ecore model doesn't create any properties
in A and X reflecting the association ends!

2) The association from X to A is just navigable in the direction of A. Then
X has a property for A in the Ecore model, but I can't get an OCL constraint,
because I am only able to create a constraint in the context of X.

Are there other ways, or do I miss something?

ocl::allInstances() is not available, right?

Andreas

PS: Hope my problem is clear enough!? Tell me, if not, please.
Re: OCL<->EMF 'impedance mismatch' with specific association validation? [message #36600 is a reply to message #36566] Mon, 10 September 2007 14:04 Go to previous messageGo to next message
Andreas Werner is currently offline Andreas WernerFriend
Messages: 55
Registered: July 2009
Member
Ok, I've solved this issue.

The trick is to use a binary association in the metamodel, but the attributes
of the association must be moved into the referenced classes... Didn't know
this is possible. In Ecore you get the same as in Solution1 mentioned, but
with the 'Opposite' property set.

Regards, Andreas

> Hi newsgroup,
>
> I have this problem:
> Given a UML metamodel with two classes A and B and a class X that has
> an
> association with A and B respectively. In the derived Ecore model X
> will
> play the role of an association.
> I want to assure via an OCL constraint that any instance of A can be
> referenced
> by only one instance of X at the same time.
> For me there are only two possibilities to imagine, but both don't
> work :( :
>
> 1) The association from X to A is binary. Then I am able to define a
> constraint in OCL with A as context, but the Ecore model doesn't
> create any properties in A and X reflecting the association ends!
>
> 2) The association from X to A is just navigable in the direction of
> A. Then X has a property for A in the Ecore model, but I can't get an
> OCL constraint, because I am only able to create a constraint in the
> context of X.
>
> Are there other ways, or do I miss something?
>
> ocl::allInstances() is not available, right?
>
> Andreas
>
> PS: Hope my problem is clear enough!? Tell me, if not, please.
>
Re: OCL<->EMF 'impedance mismatch' with specific association validation? [message #36803 is a reply to message #36600] Tue, 11 September 2007 20:36 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Andreas,

We do have allInstances() in MDT OCL. By default, it finds all instances in
the context Resource, but this can be overridden by a client-provided
"context map." See the EvaluationEnvironment API for details.

Since 1.1, MDT OCL is also able to navigate non-navigable association ends
when you generate code from UML (not from Ecore) because UML has a
first-class Association concept. It does not yet support navigating
unnamed association ends, but I hope to find time to do that in the 1.2
release. For now, as long as you name a non-navigable end (i.e., one that
doesn't generate a Java field), you should be able to navigate it in OCL.

Cheers,

Christian


Andreas Werner wrote:

> Ok, I've solved this issue.
>
> The trick is to use a binary association in the metamodel, but the
> attributes of the association must be moved into the referenced classes...
> Didn't know this is possible. In Ecore you get the same as in Solution1
> mentioned, but with the 'Opposite' property set.
>
> Regards, Andreas
>
>> Hi newsgroup,
>>
>> I have this problem:
>> Given a UML metamodel with two classes A and B and a class X that has
>> an
>> association with A and B respectively. In the derived Ecore model X
>> will
>> play the role of an association.
>> I want to assure via an OCL constraint that any instance of A can be
>> referenced
>> by only one instance of X at the same time.
>> For me there are only two possibilities to imagine, but both don't
>> work :( :
>>
>> 1) The association from X to A is binary. Then I am able to define a
>> constraint in OCL with A as context, but the Ecore model doesn't
>> create any properties in A and X reflecting the association ends!
>>
>> 2) The association from X to A is just navigable in the direction of
>> A. Then X has a property for A in the Ecore model, but I can't get an
>> OCL constraint, because I am only able to create a constraint in the
>> context of X.
>>
>> Are there other ways, or do I miss something?
>>
>> ocl::allInstances() is not available, right?
>>
>> Andreas
>>
>> PS: Hope my problem is clear enough!? Tell me, if not, please.
>>
Previous Topic:new to ocl - how to check ocl on uml model
Next Topic:Context environments, package environments , variables, return types, doc
Goto Forum:
  


Current Time: Fri Apr 19 19:52:13 GMT 2024

Powered by FUDForum. Page generated in 0.03088 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top