invalid type with profile & stereotype [message #1767246] |
Tue, 04 July 2017 07:29  |
Eclipse User |
|
|
|
Hi,
I created a profile to extend some stereotypes: I'm able to access to their specific values with r.getValue(getAppliedStereotype('MyProfile::MySterotype'),...
Unfortunately, when I tried to iterate through these specific Stereotype, and I got an invalid Type error.
I guess I'm using either a wrong syntax, or something else shall be imported. The syntax I'm using is [for (e:MyProfile::MySterotype |... ]
Is this correct, or shall I always use the uml::Class ?
Samuel
|
|
|
Re: invalid type with profile & stereotype [message #1767248 is a reply to message #1767246] |
Tue, 04 July 2017 07:38   |
Eclipse User |
|
|
|
Hello
2 possibilities :
- Instead of MyProfile you have to put the nsprefix of your stereotypes. You can find them at the end of the file of your uml model (right click on the uml model > open with text editor > go to the end of the file), you would find something aPrefix:yourStereotype). You will also find the technical name of your stereotype
so :
instead of myprofile::myStereotype you have to insert prefix::technical Name
- if you don't generate code it is possible that Acceleo / OCL does not recognize the stereotype so you have to used e:ecore::EObject but you will not be able to use attributes easily
To have a clearer view can you explain what is the collection you are iterating on ?
|
|
|
Re: invalid type with profile & stereotype [message #1767310 is a reply to message #1767248] |
Tue, 04 July 2017 14:53   |
Eclipse User |
|
|
|
Thanks Tristan,
To clarify the collection I'm iterating on, MyStereotype is a generalization of a SysML Requirement type which is done in a profile project MyProfile.
I did create a new project which use this profile, and a diagram when I have 2 MyStereotype (one which is derived from the other, else if it's not compliant :-) )
The uml file reports:
<RootElement:MySteretotype xmi:id="_zSYf0GC-Eee6WO_ABP5n3A" base_Class="_y7lqEGC2Eee6WO_ABP5n3A"/>
<RootElement:MySteretotype xmi:id="_5V46p2C-Eee6WO_ABP5n3A" base_Class="_5V46YGC-Eee6WO_ABP5n3A"/>
[for (e:RootElement::MySteretotype ... gives an invalid type error
[for (e:ecore::EObject ... doesn't report an error
|
|
|
|
Re: invalid type with profile & stereotype [message #1767501 is a reply to message #1767355] |
Thu, 06 July 2017 14:00   |
Eclipse User |
|
|
|
Hello Tristan,
I update a bit my profile, but still in the same issue....
Name :
Prefix: [e.eClass().ePackage.nsPrefix.clean()/]
reports:
Name : MyStereotype
Prefix: RootElement
by updating the for loop with: [for (e:RootElement::MyStereotype | ...
I still have the invalid type :-(
|
|
|
Re: invalid type with profile & stereotype [message #1767552 is a reply to message #1767501] |
Fri, 07 July 2017 06:33   |
Eclipse User |
|
|
|
I think it is because you use a profile not registered in your platform.
What you can do is
- using getValue on the uml element :
yourUmlElement.getValue('stereotypeQN','attributeName')
- using the parent class of your stereotype
yourRequirementForInstance.name
yourRequirementForInstance.eGet (yourRequirementForInstance.eClass().eAllAttributes()->select (name = 'yourattribute')) <-- not sure about the syntax please test it in acceleo evaluator
Regards
|
|
|
Re: invalid type with profile & stereotype [message #1767701 is a reply to message #1767552] |
Mon, 10 July 2017 06:49   |
Eclipse User |
|
|
|
I'm currently able to display my attributes in case I filter directly in the diagram with the uml Class, with the getValue:
[t.getValue(getAppliedStereotype('RootElement::MyStereotype'),'text')/]
with t:uml::Class
I'm still blocked on how to retrieve this a uml::Class from a ecore::EObject or from a 'SysML::Requirements::Requirement' ...
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03413 seconds