Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to retrieve the DefaultValues of stereotype?(How to retrieve the DefaultValues of stereotype)
How to retrieve the DefaultValues of stereotype? [message #1021673] Wed, 20 March 2013 13:47 Go to next message
sabrina ing is currently offline sabrina ing
Messages: 39
Registered: February 2013
Member
Hi,

I'm modeling a real time operating system (RTOS) using Papyrus and using the Profile in Software Resource Modeling (SRM) of Standard MARTE.
I have an Element Class applied by the stereotype "SwSchedulableResource", this stereotype has attributes like (priorityElemnts, periodElements,...), I have assigned defaults values for some attributes of the "SwSchedulableResource" as show below:

priorityElements=[priorityValue, maxpriorityLevel, minPriorityLevel]
periodElements=[period]

I want to know how to retrieve the defaults values of the attribut priorityElements and periodElements.

I used
Stereotype st=myclass.getAppliedStereotypes().getAllAttributes(); 


But I don't know how to retrieve the Defaults Values.

Can you help me please.
Thanks in advance.
Re: How to retrieve the DefaultValues of stereotype? [message #1021706 is a reply to message #1021673] Wed, 20 March 2013 14:42 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. Damus
Messages: 809
Registered: July 2009
Senior Member
Hi, Mariem,

I don't understand what you mean by "retriev[ing] the Defaults Values".
You can't set the default values for the attributes of MARTE
stereotypes: the MARTE profiles are read-only.

You can set default values of attributes of classifiers in your model
that may have MARTE stereotypes applied, but those stereotypes are
immaterial.

Or, do you mean that you have set the values of these stereotype
attributes on some element in your model?

Do you need to access these values in an OCL constraint? A model
transformation? In Java code?

Cheers,

Christian


On 2013-03-20 13:47:06 +0000, Mariem Makni said:

> Hi,
>
> I'm modeling a real time operating system (RTOS) using Papyrus and
> using the Profile in Software Resource Modeling (SRM) of Standard MARTE.
> I have an Element Class applied by the stereotype
> "SwSchedulableResource", this stereotype has attributes like
> (priorityElemnts, periodElements,...), I have assigned defaults values
> for some attributes of the "SwSchedulableResource" as show below:
>
> priorityElements=[priorityValue, maxpriorityLevel, minPriorityLevel]
> periodElements=[period]
>
> I want to know how to retrieve the defaults values of the attribut
> priorityElements and periodElements.
>
> I used Stereotype st=myclass.getAppliedStereotypes().getAllAttributes();
>
> But I don't know how to retrieve the Defaults Values.
>
> Can you help me please.
> Thanks in advance.
Re: How to retrieve the DefaultValues of stereotype? [message #1021720 is a reply to message #1021706] Wed, 20 March 2013 15:12 Go to previous messageGo to next message
sabrina ing is currently offline sabrina ing
Messages: 39
Registered: February 2013
Member
Hi,

Thanks for your reply.

Yes,I need to access these values in Java code.

can you help me please



Re: How to retrieve the DefaultValues of stereotype? [message #1021741 is a reply to message #1021720] Wed, 20 March 2013 15:55 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. Damus
Messages: 809
Registered: July 2009
Senior Member
Hi, Mariem,

You didn't answer whether you need to access the default value of a
property or the value of a stereotype attribute.

The org.eclipse.uml2.uml.Property::getDefaultValue() method returns the
property's default value. This works for attributes of classes in you
model as well as for attributes of stereotypes in the MARTE profile.
In the latter case, you would have to get the Stereotype object from
the appropriate profile and get from it the Property (an
ownedAttribute) that you are interested in.

If you need to get the value of an attribute of a stereotype
application on some element in your model, use the
org.eclipse.uml2.uml.Element::getValue(Stereotype, String) method.

HTH,

Christian


On 2013-03-20 15:12:41 +0000, Mariem Makni said:

> Hi,
>
> Thanks for your reply.
>
> Yes,I need to access these values in Java code.
>
> can you help me please
Re: How to retrieve the DefaultValues of stereotype? [message #1022082 is a reply to message #1021741] Thu, 21 March 2013 08:57 Go to previous messageGo to next message
sabrina ing is currently offline sabrina ing
Messages: 39
Registered: February 2013
Member
Hi Christian,

Thanks for your help.

I tried to use org.eclipse.uml2.uml.Element::getValue(Stereotype, String) method to get the value of The attribute "priorityElements" of the stereotype "SwSchedulableResource" application but it doesn't works.


Stereotype appliedStereotype = p.getImportedPackage().getAppliedStereotype("MARTE::MARTE_DesignModel::SRM::SW_Concurrency::SwSchedulableResource");
		if (appliedStereotype != null) {
			TypedElement priorityElements = (TypedElement) p
					.getImportedPackage().getValue(appliedStereotype,"priorityElements");
			
		}


can you help me please

  • Attachment: figure.PNG
    (Size: 11.24KB, Downloaded 40 times)

[Updated on: Thu, 21 March 2013 09:02]

Report message to a moderator

Re: How to retrieve the DefaultValues of stereotype? [message #1022227 is a reply to message #1022082] Thu, 21 March 2013 14:05 Go to previous message
Christian W. Damus is currently offline Christian W. Damus
Messages: 809
Registered: July 2009
Senior Member
Hi, Mariem,

To say that it doesn't work is not useful. What happens that you did
not expect, or what does not happen that you expected? Is
'appliedStereotype' null? Is the 'priorityElements' null? Do you get
a ClassCastException? Do you get an IllegalArgumentException? In
either case, provide the stack trace or debug at the point where it is
thrown to determine why.

I would expect a ClassCastException because one of your previous
messages suggested that 'priorityElements' is a multi-valued attribute.
This means that its value is an EList, not a TypedElement.

Cheers,

Christian


On 2013-03-21 08:57:44 +0000, Mariem Makni said:

> Hi Christian,
>
> I tried to use org.eclipse.uml2.uml.Element::getValue(Stereotype,
> String) method to get the value of The attribute of a stereotype
> "SwSchedulableResource" application but It doesn't works.
>
> Stereotype appliedStereotype =
> p.getImportedPackage().getAppliedStereotype("MARTE::MARTE_DesignModel::SRM::SW_Concurrency::SwSchedulableResource");
>
> if (appliedStereotype != null) {
> TypedElement priorityElements = (TypedElement) p
> .getImportedPackage().getValue(appliedStereotype,"priorityElements");
>
> }
Previous Topic:Can I use 'self' in sequence diagram?
Next Topic:From UML 2 constraints to non callable invariants in Ecore
Goto Forum:
  


Current Time: Fri Oct 31 07:53:56 GMT 2014

Powered by FUDForum. Page generated in 0.09836 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software