stereotype's property [message #28380] |
Wed, 20 June 2007 19:20 |
Eclipse User |
|
|
|
Originally posted by: asma.charfi.com
Hi,
I have a stereotype named A with an attribute named origin,
I want to get origin's value in my model (I have to specify a constraint on
this value)
so when I apply my stereotype to my connector (this stereotype extends the
meta class Connector) I added the value using the properties menu when I
select myconnector :(I get a new submenu (other than UML in my proprerties
menu) which has the same name of my stereotype (A))
I try this OCL expression but it did not work:
context = myconnecter
self.getValue(self.getAppliedStereotype('A'),'origin')
it returns Invalid Class.
my defaut value is (0,0) (defined in the stereotype A) this Expression
works:
self.getAppliedStereotype().attribute->select(name='origin').default
it returns (0,0)
So how could I get the value of my property?
thanks
asma
|
|
|
Re: stereotype's property [message #28416 is a reply to message #28380] |
Wed, 20 June 2007 13:35 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Asma,
If you are using the Ecore environment, then the best way is to use the
non-conformant getAppliedStereotype(...) API. This requires the
*qualified* stereotype name:
self.getValue(self.getAppliedStereotype('MyProfile::A'),'ori gin')
(assuming that your profile is named "MyProfile.")
However, using the UML environment, you can use OCL's ability to navigate
non-navigable association ends (a metaclass Extension is an Association):
self.extension_A.origin
You can check first that the A stereotype is applied by doing:
not self.extension_A.oclIsUndefined()
HTH,
Christian
charfi asma wrote:
> Hi,
> I have a stereotype named A with an attribute named origin,
> I want to get origin's value in my model (I have to specify a constraint
> on this value)
> so when I apply my stereotype to my connector (this stereotype extends the
> meta class Connector) I added the value using the properties menu when I
> select myconnector :(I get a new submenu (other than UML in my proprerties
> menu) which has the same name of my stereotype (A))
>
> I try this OCL expression but it did not work:
> context = myconnecter
> self.getValue(self.getAppliedStereotype('A'),'origin')
> it returns Invalid Class.
> my defaut value is (0,0) (defined in the stereotype A) this Expression
> works:
> self.getAppliedStereotype().attribute->select(name='origin').default
> it returns (0,0)
>
> So how could I get the value of my property?
>
> thanks
> asma
|
|
|
Re: stereotype's property [message #28450 is a reply to message #28416] |
Thu, 21 June 2007 00:46 |
Eclipse User |
|
|
|
Originally posted by: asma.charfi.com
Hi christian,
thank you very much! it works with the second suggestion:
self.getValue(self.getAppliedStereotype('a::A'),'origin')
I used the ocl console to check my constraint before adding it to the model
(new constraint...)
so I writed my constraint in the ocl console (I used ocl 1.1M7) and it
worked normally (it used ecore environement)
I saw that get getAppliedStereotype() needs a qualified name but I did not
know what that means ;)
Now, I added the constraint to my model and I validate (it works perfectly
cause I used ecore environement)
thank you again christian ;-)
"Christian W. Damus" <cdamus@ca.ibm.com> a
|
|
|
Powered by
FUDForum. Page generated in 0.03228 seconds