[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.modeling.mdt.uml2.ocl] Re: meaning of OCL getAppliedSubstereotype() ?
|
- From: "Christian W. Damus" <cdamus@xxxxxxxxxx>
- Date: Fri, 17 Nov 2006 17:26:29 -0500
- Followup-to: eclipse.modeling.mdt.uml2.ocl
- Newsgroups: eclipse.modeling.mdt.uml2.ocl
- Organization: IBM Canada (Rational Software)
- User-agent: KNode/0.7.2
Hi, Andy,
See some responses, in-line.
HTH,
Christian
Andreas Maier wrote:
> Hi,
> I am trying to understand what the OCL function
> getAppliedSubstereotype() does, because it looks like I can make use of
> it in some scenario.
This isn't so much an OCL operation as it is a UML operation that is
available to OCL because it is a "query." :-)
>
> The Eclipse UML2 description of the corresponding Java function reads:
>
> -------------------------
> getAppliedSubstereotype
>
> public Stereotype getAppliedSubstereotype( Stereotype stereotype,
> String qualifiedName)
>
> Retrieves the substereotype of the specified stereotype with the
> specified qualified name that is applied to this element, or null if no
> such stereotype is applied.
> -------------------------
>
> Here are my questions:
>
> 1. What is a "substereotype" ? A stereotype that is a specialization of
> another stereotype ?
Exactly.
> 2. I was trying to use the OCL function in a scenario where I am in a
> Class (OCL Context-wise), and want to go to a "substereotype" (using the
> assumption from above on what it is) of a stereotype that extends Class:
>
> - Stereotype "CIM_Class" extends Class, and inherits from Stereotype
> "CIM_Qualifier_Abstract"
>
> - The OCL constraint is owned by Stereotype "CIM_Class", and I tried
> (using some extra "let" expressions in order to test any intermediate
> results, due to lack of an OCL debugger ;-)
>
> -------------------
> let mes : Stereotype =
> self.base_Class.getAppliedStereotype('CIM::CIM_Class')
> in
> let qts : Stereotype =
> self.base_Class.getAppliedSubstereotype( mes,
> 'CIM::CIM_Qualifier_Abstract')
> in
> mes <> null and mes.name = 'CIM_Class' /* (1) */
> and qts <> null and qts.name = 'CIM_Qualifier_Abstract' /* (2) */
> -------------------
>
> The expression in line (1) succeeds, but the one in line (2) fails, so
> it seems I am either using this function in a wrong way, or it does not
> work as expected.
Yes, I think you are using it the wrong way :-)
You would want to do:
and qts <> null and qts.name = 'CIM_Class'
because CIM_Class is the specialization of CIM_Qualifier_Abstract that is
applied. But, there's no reason to do this, because you already know (by
virtue of evaluating the constraint) that CIM_Class is applied.
>
> I am aware that the generalization direction in my example is just the
> other way around, i.e. the OCL attempts to go to the super-stereotype,
> and that may already be the answer why it does not work. However I am
> having trouble to imagine a scenario where one would use the function to
> go to the sub-stereotype of one that was applied. Would the properties
> of such a sub-stereotype also be on the element that is extended by the
> super-stereotype ?
Right, you don't need to do any of this getAppliedSubstereotype, because the
specializing stereotype inherits all of the features of its general
stereotype(s). All of the CIM_Qualifier_Abstract properties should be
directly accessible.
It's good that you're having trouble imagining a scenario in which the
super-stereotype has dependencies on particular sub-stereotypes, because
that would be an OO design mistake (dependency inversion)! :-)
>
> Andy