Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Retrieving only the "most specific" relationships of a Class
Retrieving only the "most specific" relationships of a Class [message #1450542] Wed, 22 October 2014 14:54 Go to next message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
Messages: 93
Registered: April 2014
Member
Hi,

Suppose I have a UML model conforming to the org.eclipse.uml2.uml metamodel. Suppose that this model contains a Class, a Property, and an ownedAttribute relationship between them.

At the Ecore level, the Class and the Property are EObjects, while the ownedAttribute is an EReference.

Given an EObject, one may want to retrieve all of its set EReferences. I can accomplish this using the following code snippet:

for (EReference eRef : myEObject.eClass().getEAllReferences()) {
    if (eObject.eIsSet(eRef)) {
        // found a relevant EReference
    }
}


Going back to the UML example above, this code snippet would identify all of the following EReferences (mentioned here by their name): ownedElement, ownedMember, member, feature, attribute, ownedAttribute, role.

My problem is the following: out of the identified EReferences, I would like to keep only ownedAttribute, since this relationship subsets all of the others according to the UML standard. However, the Ecore metamodel does not specify any kind of hierarchy between EReferences.

What approach could I use to filter out the more general EReferences that I am not interested in?

Cheers,
Vlad
Re: Retrieving only the "most specific" relationships of a Class [message #1450600 is a reply to message #1450542] Wed, 22 October 2014 16:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
HI

I or you are getting confused about meta levels.

Ecore (and EMOF and, prior to UML 2.5, UML Basic) are simple no
overlapping references, so no need for any hierarchy.

Full UML is very powerful/inefficient since there are
subsetted/redefined references. Providing moderately efficient support
for this via CacheAdapters is one of the main contributions of the
Eclipse UML2 project.

If you are using UML, for read access, you should use the reference that
is relevant to your purpose. For write access, using anything other than
the most refined/subsetted can cause trouble.

If you are using Ecore you can ignore the hassle.

If you are using UML converted to Ecore, the various subsets
relationships are available in EAnnotations and you will need to handle
them yourself. I am not aware of any helper routines.

Regards

Ed Willink



On 22/10/2014 15:54, Vlad Acretoaie wrote:
> Hi,
>
> Suppose I have a UML model conforming to the org.eclipse.uml2.uml
> metamodel. Suppose that this model contains a Class, a Property, and an
> ownedAttribute relationship between them.
>
> At the Ecore level, the Class and the Property are EObjects, while the
> ownedAttribute is an EReference.
>
> Given an EObject, one may want to retrieve all of its set EReferences. I
> can accomplish this using the following code snippet:
>
> for (EReference eRef : myEObject.eClass().getEAllReferences()) {
> if (eObject.eIsSet(eRef)) {
> // found a relevant EReference
> }
> }
>
> Going back to the UML example above, this code snippet would identify
> all of the following EReferences (mentioned here by their name):
> ownedElement, ownedMember, member, feature, attribute, ownedAttribute,
> role.
>
> My problem is the following: out of the identified EReferences, I would
> like to keep only ownedAttribute, since this relationship subsets all of
> the others according to the UML standard. However, the Ecore metamodel
> does not specify any kind of hierarchy between EReferences.
> What approach could I use to filter out the more general EReferences
> that I am not interested in?
>
> Cheers,
> Vlad
Re: Retrieving only the "most specific" relationships of a Class [message #1450611 is a reply to message #1450600] Wed, 22 October 2014 16:56 Go to previous message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
Messages: 93
Registered: April 2014
Member
Hi Ed,

Thank you for the answer. You are right about the confusion, unfortunately I didn't phrase my question very well.

Here is a greatly simplified phrasing: While working with a UML model, I was looking for a way to access all the references of an EObject which are not derived, but failed to make the connection between the Ecore concept of "derived" references and the UML standard which used the term "subsets".

In the meantime I found the (embarrassingly obvious) solution: using the isDerived() method of the EReference interface.

Cheers,
Vlad
Previous Topic:Anyone developing Professional Software using UML diagrams and Eclipse?
Next Topic:How to apply a profile to an Activity Diagram
Goto Forum:
  


Current Time: Fri Nov 16 21:54:19 GMT 2018

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

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

Back to the top