Filtering in if commands [message #1742092] |
Wed, 31 August 2016 10:58  |
Eclipse User |
|
|
|
I want to list all classes that are contained in the package "AirInterface" and use the following command:
[if (cl.qualifiedName.contains('AirInterface'))]<drop/>
Unfortunately this if command returns also classes that are contained in "AirInterfaceHsb" and "AirInterfaceDiversity" packages.
Is there a way to restrict the query to the package "AirInterface" only?
|
|
|
Re: Filtering in if commands [message #1742097 is a reply to message #1742092] |
Wed, 31 August 2016 12:10   |
Eclipse User |
|
|
|
There are several solutions. Here is one of them:
Package.allInstances()->any(name="AirInterface").ownedElement->select(oclIsKindOf(Class))
Note this query will return classes directly owned by the package, if you want to include those contained in its subpackages as well, just replace "owndElement" by "allOwnedElements()"
Yves
|
|
|
Re: Filtering in if commands [message #1742254 is a reply to message #1742097] |
Thu, 01 September 2016 07:09   |
Eclipse User |
|
|
|
Hallo Yves,
Thank you very much for your quick response.
I'm not able to insert the query you provided into my script; always get error messages.
Here my current script:
[for (cl:Class | Class.allInstances()->sortedBy(name))]<drop/>
[if (cl.qualifiedName.contains('AirInterface'))]<drop/>
[cl.insertClasses()/]
[/if]<drop/>
[/for]<drop/>
Can you please insert your query at the right position into my script.
Btw. I found out, that the term AirInterface needs to be surrounded by single quotes; not double quotes.
Regards
Bernd
|
|
|
|
Powered by
FUDForum. Page generated in 0.20004 seconds