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 |
Vlad Acretoaie Messages: 95 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 |
Ed Willink Messages: 7655 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
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 14:45:16 GMT 2024
Powered by FUDForum. Page generated in 0.03349 seconds
|