How to obtain the logical components corresponding to component exchanges

Hello, everyone. Is it possible to get the logical components from a component exchange.
In fact, I can already list all the component exchanges of the Logical Architecture diagram using the following script. For example, component exchanges 1, 2, and 3 in Figure 1.

diagram_name = “xxx"
for diag in JavaList(org.eclipse.sirius.business.api.dialect.DialectManager.INSTANCE.getAllRepresentationDescriptors(model.session),Diagram):
    if diag.get_name() == diagram_name:
        for comp in diag.get_represented_elements():
            if isinstance(subcom, ComponentExchange):
                print(subcom.get_name())


However, an error (Figure 3) occurred when I attempted to list both component exchanges and logical components (For example, Component Exchange 2; Logical Component B; Logical Component A in Figure 2)using the script described below.

LogicalComponent2ComponentExchange=subcom.get_name() + ";" + subcom.get_connected_components()



It is worth mentioning that when we obtained the CommunicationMean corresponding to the Operational Entity before, the following script was feasible, but it is not applicable to the current problem.

OperationalEntity2CommunicationMean=com.get_name()+ ";" + com.get_source_entity().get_name()+";" + com.get_target_entity().get_name()

You are trying to concatenate String with a JavaList. You first need to convert your JavaList to a String. You can use str().

LogicalComponent2ComponentExchange=subcom.get_name() + ";" + str(subcom.get_connected_components())

Note that there was a bug in the implermentation of JavaList that always shows the list as empty (see this issue for more details). The bug has been fixed in version 1.3.0.

Thank you for your answer. I found that I am still using Python4Capella version 1.2.0. I will upgrade to the version you suggested and try again.
Thanks again!
Python4Capella

2 Likes