AQL: How to find the owner of a port?

I’m trying to create a template to generate a list of interfaces (exchanges) among similar items, for instance: Behavior Components on Physical Architecture.
I was able to find the AQL expression to filter all ports in ComponentExchanges in the PA perspective:
aql:self.containedPhysicalArchitectures.eAllContents(fa::ComponentExchange).source
aql:self.containedPhysicalArchitectures.eAllContents(fa::ComponentExchange).target
self -> is the SystemEngineering element from my project.
but I wasn’t able to get the name/ID of the owners of the ports I retrieved with this query. getSourcePart() and getTargetPart() doesn’t seem to get me anywhere… I checked the Capella reference and couldn’t find a hint of port property that could get me from port to owned component.
Is there any simple way of finding the owner of the port or do I have to list all Components and filter them with the port in question? (in the latter option, how can I do this?)

You have a EReference sourcePort and targetPort on ComponentExchange:
self.containedPhysicalArchitectures.eAllContents(fa::ComponentExchange).sourcePort
self.containedPhysicalArchitectures.eAllContents(fa::ComponentExchange).targetPort
Both will return a Sequence of fa::ComponentPort

Hi Yvan, thanks for your answer,
I was already able to list source and target ports of ComponentExchanges. What I really want is to find the Component that owns a specific port. The intent is to list the component exchanges and the source and target components (not the ports, since the readers of the docs will be familiar with component names).

Hello,
You can use the query “eContainer()” in order to navigate from the port toward it’s parent element = the component

Aurelien, that works perfectly, thanks!

Copyright © Eclipse Capella, the Eclipse Capella logo, Eclipse and the Eclipse logo are Trademarks of The Eclipse Foundation.