More on stereotypes [message #1709743] |
Wed, 30 September 2015 16:27  |
Eclipse User |
|
|
|
Hi
I have stereotype containing a property (triggerConditionList) which is a String[1..*].
Reusing some of the information from a previous post from Scott Mansfield, here is what I use:
[for (cl:uml::Signal | element.ownedElement->filter(Signal))]<drop/>
[cl.name/] notification
[for (st:uml::Stereotype | cl.getAppliedStereotypes())]<drop/>
• [st.name/]
[for (oa:uml::Property|st.ownedAttribute)]<drop/>
[if (not oa.name.contains('base'))][oa.name/]: [if (not cl.getValue(st, oa.name).oclIsUndefined())][if oa.name.contains(' triggerConditionList')][cl.getValue(st, oa.name).oclAsType(String)/] [else][cl.getValue(st, oa.name).oclAsType(EnumerationLiteral).name/][/if][else]<drop/>[/if]
[/if] <drop/>
[/for]<drop/>
[/for]<drop/>
This was working for a single string, but does not seem to work for a list and I still don;t really know how to loop on the values,
Any idea?
Best regards,
MArc
|
|
|
|
Re: More on stereotypes [message #1709788 is a reply to message #1709761] |
Thu, 01 October 2015 07:03   |
Eclipse User |
|
|
|
Thanks, it works and I have now the list, but it is on a single line, just separated by blanks.
I would have prefered one line per condition.
Any way to do that?
Thanks,
Marc
|
|
|
Re: More on stereotypes [message #1709792 is a reply to message #1709788] |
Thu, 01 October 2015 07:22   |
Eclipse User |
|
|
|
The result of the expression is a sequence of String so you can iterate on it, do some filter ...
instead of [s/] maybe you should call [s.clean()/] if there are some special characters in your stereotype values
[for (s : String | Sequence{cl.getValue(st, oa.name)}->flatten().oclAsType(String))]
[s/]
[/for]
|
|
|
|
|
|
Re: More on stereotypes [message #1723146 is a reply to message #1723084] |
Fri, 12 February 2016 07:31   |
Eclipse User |
|
|
|
This query works for a single value:
[if oa.name.contains('test')]testCategory: [p.getValue(st, oa.name).oclAsType(EnumerationLiteral).name/]
Here the queries that I try for the list (among others) which didn't work:
[if oa.name.contains('test')]testCategory : [for (e : EnumerationLiteral | Sequence{p.getValue(st, oa.name)}->flatten().oclAsType(EnumerationLiteral))]<drop/> [e.clean()/]
[if oa.name.contains('test')]testCategory : [for (e : EnumerationLiteral | Sequence{p.getValue(st, oa.name)}->flatten().oclAsType(EnumerationLiteral).name)]<drop/> [e.clean()/]
Here the profile definition:
+ testCategory : CfsRfsProfile::TestCategory [1..*] = BIP
where TestCategory is an Enumeration with some Literals.
Regards
Bernd
|
|
|
Re: More on stereotypes [message #1723871 is a reply to message #1723146] |
Thu, 18 February 2016 16:10   |
Eclipse User |
|
|
|
Hi Bernd,
Your query was quite ok, with only 2 things to modify:
- type for Stereotype attribute Enumeration literal is "ecore::EEnumLiteral" instead of "EnumerationLiteral"
- type of your variable "e" can be either EEnumLiteral if you remove the ".name" from the query or String if you keep this part
So the following query should work :
[if oa.name.contains('test')]testCategory : [for (e : ecore::EEnumLiteral| Sequence{p.getValue(st, oa.name)}->flatten().oclAsType(ecore::EEnumLiteral))]<drop/> [e.name.clean()/]
Best regards,
Anne
|
|
|
|
Powered by
FUDForum. Page generated in 0.04822 seconds