Dear all,
I want to automate moving logical functions (LF) from a logical component (LC) into another logical component in the Logical Architecture section. With a lot of reverse engineering I’ve gotten something like this to work:
# Assumed variables
# source_lc: source LC to move LF from (type LogicalComponent)
# target_lc: target LC to move LF into (type LogicalComponent)
# source_lf: LF to move, allocated to source_lc (type LogicalFunction)
# Also assumed this is engulfed in standard model.start_transaction() try/except block, followed by model.save()
fas = source_lc.get_owned_functional_allocation()
# get functional allocation corresponding to source_lf
fa = None
for x in fas:
if x.get_target_element() == source_lf:
fa = x
break
if not fa:
raise ValueError
fa.set_source_element(target_lc)
Although this does assign the source_lf
to target_lc
, it is not “owned” by target_lc
, in the sense that if I run target_lc.get_owned_functional_allocation()
a posteriori (in a second execution), the LF which was source_lf
does not show up in the list. It does show up in target_lc.get_functional_allocations()
, which appears to include the not “owned” allocations, whatever that means. Also, when I do the moving manually in Capella (on a LAB diagram), this is not an issue and source_lf
shows up in the formerly mentioned owned allocations.
How do you implement a full/extensive move onto the owned allocations? I’ve tried {removing,adding} from {target_lc,source_lc}.get_functional_allocations()
with Python and Java APIs (i.e. using get_java_object()
and lower level functions as well), but the operation is not supported (list is read-only).
Thank you in advance for any tip,
J