I receive the following error when trying to add system functions under the Root System Function instead of alongside it:
java.lang.UnsupportedOperationException
at org.eclipse.emf.common.util.BasicEList$UnmodifiableEList.add(BasicEList.java:908)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
at py4j.Gateway.invoke(Gateway.java:282)
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.$Proxy30.executeScript(Unknown Source)
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.internalExecute(Py4jScriptEngine.java:240)
at org.eclipse.ease.lang.python.py4j.internal.Py4jScriptEngine.execute(Py4jScriptEngine.java:227)
at org.eclipse.ease.AbstractScriptEngine.inject(AbstractScriptEngine.java:189)
at org.eclipse.ease.AbstractScriptEngine.run(AbstractScriptEngine.java:242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
This is the code which caused the issue, the variable new_FuncNames is just a list of Strings:
model.start_transaction()
try:
for value in new_FuncNames:
# create a SystemFunction
sf = SystemFunction()
#set its name
print("* Create a new system function with name " + value )
sf.set_name(value)
#add the new SystemFunction
OwnedFunc = se.get_system_analysis().get_system_function_pkg().get_owned_system_functions().get(0).get_contained_system_functions()
OwnedFunc.add(sf)
except:
# if something went wrong we rollback the transaction
model.rollback_transaction()
raise
else:
# if everything is ok we commit the transaction
model.commit_transaction()
# save the Capella model
model.save()