Check stereotype applications via static profile [message #1852920] |
Fri, 10 June 2022 15:24 |
|
In order to check stereotype applications in a UML context, I've successfully defined the following query that take the name of a stereotype as parameter
context Element
-- check, whether a stereotype is applied by providing its name
def: hasStereo(stName : String) : Boolean =
getAppliedStereotypes()->select(name = stName)->notEmpty()
As the name of a stereotype could be spelled wrongly, I'd rather like to use a static profile instead, i.e. import the generated ecore of that profile (the Papyrus SW Designer C/C++ profile). The following query works for a specific stereotype by using its qualified name.
-- check, if the <<Ptr>> stereotype from the C/C++ profile is applied
def: hasPtrStereo(): Boolean =
getStereotypeApplications()->select(oclIsKindOf(C_Cpp::Ptr))->notEmpty()
Now, I'd like to make the query more generic by adding the Stereotype to check as a parameter. However, I could not determine the type to use for the parameter (it's apparently not "Type") and/or a suitable condition in the select clause. Any hints on this?
def: hasStereo(stType : Type): Boolean =
getStereotypeApplications()->select(oclIsKindOf(stType))->notEmpty()
|
|
|
|
|
|
Re: Check stereotype applications via static profile [message #1852956 is a reply to message #1852932] |
Mon, 13 June 2022 07:51 |
|
Hi Ed,
thanks for your responses. I get an error if I use the extension_Ptr (or extension_Create) when opening it with the OCL xtext editor in an Eclipse 2022-03. Maybe I'm missing some declaration in the header, therefore I list the whole beginning of my .ocl file. In the code below, I use the similar example of the <<Create>> stereotype, as it is part of the standard profile, i.e. does not need additional plugins:
import 'platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore'
import 'platform:/plugin/org.eclipse.uml2.uml.profile.standard/model/Standard.ecore'
package UML
context Operation
def: hasCreateStereo(): Boolean = self.extension_Create->notEmpty()
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04137 seconds