Given the functionality for deep copy, this is a complex operation, particularly on the boundary conditions around the recursion. This trace is terse, and is internals documentation: it presumes you are reading the code.
This uses the BusLogicIntro jUnit test
Purchaseorder_clone_test#clonePurchaseorder(). Recall this initiates the test by setting
doClone = true, and issuing the update. This activates the
String deepCopy = [
Purchaseorder clonedPO = BusinessLogic.insertChildFrom(
Finally, recall there is a self-relationship from PO to cloned PO, to support this operation. From a business sense, it might be useful to find the source a clone PO, or conversely the POs cloned from a source.
creates NewPO[# 6]
copyAttributesFromTo (SourcePO => NewPO, doSave (NewPO)]
copy Scalar attributes - includes null parent role properties (eg, customer)
deepCopyCollections (here, lineItems)
For eachRow (lineitems for SourcePO)
new Instance (eg, lineitem)
attachChildToParent (eg, to NewPO)
copyAttributesFromTo (oldLineItem =>newLineItem, doSave) // recurse