Receiving and Providing instance roles

Hi,

In trying to figure out what Instance roles my sequence messages come from, I try the following in python4Capella:

sequence_msg = d.get_invoking_sequence_messages();
  for s in sequence_msg:
    print(s.get_receiving_instance_role())

However, I get the error saying :

py4j.protocol.Py4JError: An error occurred while calling 06545.getReceivingInstanceRole. Trace:
py4j.Py4JException: Method getReceivingInstanceRole([]) does not exist
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
	at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
	at py4j.Gateway.invoke(Gateway.java:274)
	at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
	at py4j.commands.CallCommand.execute(CallCommand.java:79)
	at py4j.ClientServerConnection.sendCommand(ClientServerConnection.java:244)
	at py4j.CallbackClient.sendCommand(CallbackClient.java:384)
	at py4j.CallbackClient.sendCommand(CallbackClient.java:356)
	at py4j.reflection.PythonProxyHandler.invoke(PythonProxyHandler.java:106)
	at com.sun.proxy.$Proxy27.executeScript(Unknown Source)
	at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.internalExecute(Py4jScriptEngine.java:236)
	at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.execute(Py4jScriptEngine.java:226)
	at org.eclipse.ease.AbstractScriptEngine.inject(AbstractScriptEngine.java:245)
	at org.eclipse.ease.AbstractScriptEngine.run(AbstractScriptEngine.java:309)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Which makes me think the method is not implemented rather than me using it wrong. Any tips? They are greatly appreciated!

The method getReceivingInstanceRole() doesn’t exist in the Java class. You can replace the sending/receiving methods with the following code in the capella.py file:

    def get_sending_instance_role(self):
        """
        """
        part =  self.get_java_object().getSendingPart()
        if part is None:
            return part
        else:
            value = part.getType()
            if value is None:
                return value
            else:
                e_object_class = getattr(sys.modules["__main__"], "EObject")
                specific_cls = e_object_class.get_class(value)
                return specific_cls(value)
    def get_receiving_instance_role(self):
        """
        """
        part =  self.get_java_object().getReceivingPart()
        if part is None:
            return part
        else:
            value = part.getType()
            if value is None:
                return value
            else:
                e_object_class = getattr(sys.modules["__main__"], "EObject")
                specific_cls = e_object_class.get_class(value)
                return specific_cls(value)

I opened the following issue:

Hi Yvan,
Thanks for the reply! It all seems to work now.
May I ask where I could have found both the getSendingPart() and getReceivingPart() functions? They look like they belong to the java object, but how can I inspect that? That would certainly speed up development.
Thanks in advance!

Daan Hendriks

Both methods are declared in the Java implementation of Capella:

The Capella metamodel code is in this plugin for more details.

Very nice, I had not yet found this.
Thanks a lot!