org.plasma.sdo.helper
Class PlasmaCopyHelper

java.lang.Object
  extended by org.plasma.sdo.helper.PlasmaCopyHelper
All Implemented Interfaces:
CopyHelper

public class PlasmaCopyHelper
extends Object
implements CopyHelper

Copy utilities class.

Note that copied data objects have the same data properties as the source but have new (and therefore different) underlying UUID and other management properties which are not defined within the source Type. Use copied data objects to help automate and save save effort when creating NEW data objects. To simply link/add and existing data object to a new data graph, first use DataObject.detach() to remove it from its graph. Than add it to a another graph.


Field Summary
static PlasmaCopyHelper INSTANCE
           
 
Method Summary
 DataObject copy(DataObject dataObject)
          Create a deep copy of the DataObject tree.
 DataObject copy(DataObject dataObject, Type[] referenceTypes)
          Create a deep copy of the DataObject tree while exempting all DataObject nodes with an SDO type found in the given reference Types array.
 DataObject copyShallow(DataObject dataObject)
          Create a shallow copy of the DataObject dataObject: Creates a new DataObject copiedDataObject with the same values as the source dataObject for each property where property.getType().isDataType() is true.
static PlasmaCopyHelper instance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static PlasmaCopyHelper INSTANCE
Method Detail

instance

public static PlasmaCopyHelper instance()

copyShallow

public DataObject copyShallow(DataObject dataObject)
Create a shallow copy of the DataObject dataObject: Creates a new DataObject copiedDataObject with the same values as the source dataObject for each property where property.getType().isDataType() is true. The value of such a Property in copiedDataObject is: dataObject.get(property) for single-valued Properties (copiedDataObject.get(property) equals() dataObject.get(property)), or a List where each member is equal to the member at the same index in dataObject for multi-valued Properties copiedDataObject.getList(property).get(i) equals() dataObject.getList(property).get(i) The copied Object is unset for each Property where property.getType().isDataType() is false since they are not copied. Read-only properties are copied. A copied object shares metadata with the source object sourceDO.getType() == copiedDO.getType() If a ChangeSummary is part of the source DataObject the copy has a new, empty ChangeSummary. The Logging state in the source ChangeSummary is not replicated in the target ChangeSummary. All copied data objects are in a 'created' state ready to be used for insert operations.

Note that copied data objects have the same data properties as the source but have new (and therefore different) underlying UUID and other management properties which are not defined within the source Type. Use copied data objects to help automate and save save effort when creating NEW data objects. To simply link/add and existing data object to a new data graph, first use DataObject.detach() to remove it from its graph. Than add it to a another graph.

Specified by:
copyShallow in interface CopyHelper
Parameters:
dataObject - to be copied
Returns:
copy of dataObject

copy

public DataObject copy(DataObject dataObject)
Create a deep copy of the DataObject tree. Copies the dataObject and all its contained DataObjects recursively. Values of Properties are copied as in shallow copy, and values of Properties where property.getType().isDataType() is false are copied where each value copied must be a DataObject contained by the source dataObject. If a DataObject is outside the DataObject tree and the property is bidirectional, then the DataObject is skipped. If a DataObject is outside the DataObject tree and the property is unidirectional, then the same DataObject is referenced. Read-only properties are copied. If any DataObject referenced is not in the containment tree an IllegalArgumentException is thrown. The Logging state in the source ChangeSummary is not replicated in the target ChangeSummary. All copied data objects are in a 'created' state ready to be used for insert operations.

Note that copied data objects have the same data properties as the source but have new (and therefore different) underlying UUID and other management properties which are not defined within the source Type. Use copied data objects to help automate and save save effort when creating NEW data objects. To simply link/add and existing data object to a new data graph, first use DataObject.detach() to remove it from its graph. Than add it to a another graph.

Specified by:
copy in interface CopyHelper
Parameters:
dataObject - to be copied.
Returns:
copy of dataObject
Throws:
IllegalArgumentException - if any referenced DataObject is not part of the containment tree.

copy

public DataObject copy(DataObject dataObject,
                       Type[] referenceTypes)
Create a deep copy of the DataObject tree while exempting all DataObject nodes with an SDO type found in the given reference Types array. For all "reference" types found in the source graph, these are not copied but "re-parented" to the target graph and not added to the change summary. Reference nodes are not removed from the source graph. Copies the dataObject and all its contained DataObjects recursively. Values of Properties are copied as in shallow copy, and values of Properties where property.getType().isDataType() is false are copied where each value copied must be a DataObject contained by the source dataObject. If a DataObject is outside the DataObject tree and the property is bidirectional, then the DataObject is skipped. If a DataObject is outside the DataObject tree and the property is unidirectional, then the same DataObject is referenced. Read-only properties are copied. If any DataObject referenced is not in the containment tree an IllegalArgumentException is thrown. The Logging state in the source ChangeSummary is not replicated in the target ChangeSummary. All copied data objects are in a 'created' state ready to be used for insert operations.

Note that copied data objects have the same data properties as the source but have new (and therefore different) underlying UUID and other management properties which are not defined within the source Type. Use copied data objects to help automate and save save effort when creating NEW data objects. To simply link/add and existing data object to a new data graph, first use DataObject.detach() to remove it from its graph. Than add it to a another graph.

Parameters:
dataObject - to be copied.
referenceTypes - an array of types which are
Returns:
copy of dataObject
Throws:
IllegalArgumentException - if any referenced DataObject is not part of the containment tree.


Copyright © 2014. All rights reserved.