Home » Modeling » Epsilon » Getting all Classes in a UML model
Getting all Classes in a UML model [message #1549355] |
Tue, 06 January 2015 13:26 |
Vlad Acretoaie Messages: 95 Registered: April 2014 |
Member |
|
|
Hi,
I am trying to get all Classes (instances of UML::Classes::Kernel::Class) contained in a UML 2.5 model created using Papyrus. However, the results I am getting are somewhat confusing:
// Exception: Method 'allOfType' not found for: org.eclipse.epsilon.eol.types.EolModelElementType@1733f03
Source!Class.allOfType();
// Exception: Method 'allOfKind' not found for: org.eclipse.epsilon.eol.types.EolModelElementType@1a48835
Source!Class.allOfKind();
// Returns: Class1, Class1, EPackage, ENamedElement, EClassifier, Extend, EClass, EDataType, EEnum, EEnumLiteral, EOperation, EParameter, EStructuralFeature, EAttribute, EReference, ETypeParameter, EGenericType
Source!Class.allInstances();
// Returns: Class1, Class1, EPackage, ENamedElement, EClassifier, Extend, EClass, EDataType, EEnum, EEnumLiteral, EOperation, EParameter, EStructuralFeature, EAttribute, EReference, ETypeParameter, EGenericType
Source!Class.all();
I would have expected all of these methods to return two Classes, both named "Class1". These are the only Classes in my model.
I also tried the following:
// Exception: Undefined variable, type or model: 'Source!UML::Classes::Kernel::Class'
Source!UML::Classes::Kernel::Class.all();
// Exception: Undefined variable, type or model: 'Source!Classes::Kernel::Class'
Source!Classes::Kernel::Class.all();
Why are the operations in my first four examples returning different results (including exceptions), and why is the qualified name of Class reported as undefined?
I am attaching my test model for reference purposes.
Cheers,
Vlad
-
Attachment: cd1.uml
(Size: 1.35KB, Downloaded 173 times)
|
|
|
Re: Getting all Classes in a UML model [message #1551485 is a reply to message #1549355] |
Wed, 07 January 2015 17:02 |
|
I've used Source!uml::Class, and it produces the same results.
I've looked around in the debugger and I suspect that there's an Ecore UML profile being loaded implicitly by the UML EMF driver, in which Ecore basic types (such as an EClass) are included as instances of Stereotype, which is a kind of Class. EOL is producing correct but unexpected results, I'm afraid.
Apparently it has the "http://www.eclipse.org/uml2/schemas/Ecore/5" URI, but I can't find it in the EPackage Registry. Perhaps someone else knows more about the implementation details of UML within Eclipse.
For the time being, may I suggest checking that it doesn't belong to an UML profile?
for (elem in Source!uml::Class.allInstances()) {
if (not elem.eContainer().isKindOf(Source!uml::Profile)) {
"".println(elem);
}
}
|
|
| |
Goto Forum:
Current Time: Fri Apr 19 05:01:34 GMT 2024
Powered by FUDForum. Page generated in 0.02043 seconds
|