Add Operational Activity Issue

Hi all,
While using Python4Capella I am having an unexpected issue trying to add operational activities ‘oa’ to the Root Operational Activity. I’ve tried two methods, one from taking inspiration from another Forum page. Seems like the issue is with the OperationalActivity() class. I’m using Capella 6.1. Is anyone able to help?

Attempt 1:
oa = OperationalActivity()
op_root_activity.get_contained_operational_activities().add(oa)

Attempt 2 following Breakdown creation of operational Activities :
oa = OperationalActivity()
op_root_activity.get_java_object().getOwnedFunctions().add(oa)

Both result in the following error message associated with Object ‘oa’ has no attribute ‘_get_object_id’.

Attempt 1 error:
org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “workspace://Python4Capella/sample_scripts/add_activities.py”, line 116, in
convert_value(k, gw): convert_value(v, gw)
File “workspace://Python4Capella/sample_scripts/add_activities.py”, line 99, in create_activities_for_level
if isinstance(value, integer_types):
File “C:\6_1\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py”, line 1313, in call
args_command, temp_args = self._build_args(*args)
File “C:\6_1\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py”, line 1283, in _build_args
[get_command_part(arg, self.pool) for arg in new_args])
File “C:\6_1\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py”, line 1283, in
[get_command_part(arg, self.pool) for arg in new_args])
File “C:\6_1\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\protocol.py”, line 298, in get_command_part
command_part = REFERENCE_TYPE + parameter._get_object_id()
AttributeError: ‘OperationalActivity’ object has no attribute ‘_get_object_id’

Attempt 2 error:
org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “workspace://Python4Capella/sample_scripts/add_activities.py”, line 121, in
convert_value(v, gw) for v in value
File “workspace://Python4Capella/sample_scripts/add_activities.py”, line 101, in create_activities_for_level
return java.math.BigInteger(str(value))
File “C:\6_1\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py”, line 1313, in call
args_command, temp_args = self._build_args(*args)
File “C:\6_1\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py”, line 1283, in _build_args
[get_command_part(arg, self.pool) for arg in new_args])
File “C:\6_1\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_gateway.py”, line 1283, in
[get_command_part(arg, self.pool) for arg in new_args])
File “C:\6_1\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\protocol.py”, line 298, in get_command_part
command_part = REFERENCE_TYPE + parameter._get_object_id()
AttributeError: ‘SystemFunction’ object has no attribute ‘_get_object_id’

Best regards

Jack

Maybe you should try this on attempt 2: op_root_activity.get_java_object().getOwnedFunctions().add(oa.get_java_object())

That worked, thank you very much Stephane

You can have a look at the common errors you can encounter with Python4Capella for more details.