All Implemented Interfaces:
Serializable, Cloneable

public class CopyGroup extends AttributeGroup
Purpose: Define how an object is to be copied.

Description: This is for usage with the object copying feature, not the unit of work. This is useful for copying an entire object graph as part of the host application's logic.

Responsibilities:

  • Indicate through CASCADE levels the depth relationships will copied.
  • Indicate if PK attributes should be copied with existing value or should be reset.
  • Copies only the attributes found in the group.
See Also:
  • Field Details

    • shouldResetPrimaryKey

      protected boolean shouldResetPrimaryKey
    • shouldResetVersion

      protected boolean shouldResetVersion
    • session

      protected transient AbstractSession session
    • copies

      protected Map copies
    • depth

      protected int depth
      Policy depth that determines how the copy will cascade to the object's related parts
    • NO_CASCADE

      public static final int NO_CASCADE
      Depth level indicating that NO relationships should be included in the copy. Relationships that are not copied will include the default value of the object's instantiation policy
      See Also:
    • CASCADE_PRIVATE_PARTS

      public static final int CASCADE_PRIVATE_PARTS
      Depth level indicating that only relationships with mapping indicated privately- owned should be copied
      See Also:
    • CASCADE_ALL_PARTS

      public static final int CASCADE_ALL_PARTS
      Depth level indicating that all relationships with mappings should be used when building the copied object graph
      See Also:
    • CASCADE_TREE

      public static final int CASCADE_TREE
      Depth level indicating that only the attributes found in the attribute group should be copied
      See Also:
  • Constructor Details

    • CopyGroup

      public CopyGroup()
      PUBLIC: By default only copy the attributes found in the attribute group and don't null primary keys.
    • CopyGroup

      public CopyGroup(String name)
      PUBLIC: By default only copy the attributes found in the attribute group and don't null primary keys.
  • Method Details

    • cascadeAllParts

      public void cascadeAllParts()
      PUBLIC: Set if the copy should cascade all relationships when copying the object(s).
    • cascadePrivateParts

      public void cascadePrivateParts()
      PUBLIC: Set if the copy should cascade only those relationships that are configured as privately-owned.
    • cascadeTree

      public void cascadeTree()
      PUBLIC: Set if the copy should cascade only those attributes that are found in the group.
    • dontCascade

      public void dontCascade()
      PUBLIC: Set if the copy should not cascade relationships when copying the object(s)
    • getCopies

      public Map getCopies()
      INTERNAL: Get the session.
    • getDepth

      public int getDepth()
      INTERNAL: Return the cascade depth.
    • getSession

      public AbstractSession getSession()
      INTERNAL: Return the session.
    • setCopies

      public void setCopies(Map newCopies)
      INTERNAL: Set the copies.
    • setDepth

      public void setDepth(int newDepth)
      INTERNAL: Set the cascade depth.
    • setSession

      public void setSession(AbstractSession newSession)
      INTERNAL: Set the session.
    • setShouldResetPrimaryKey

      public void setShouldResetPrimaryKey(boolean newShouldResetPrimaryKey)
      PUBLIC: Set if the primary key should be reset to null.
    • setShouldResetVersion

      public void setShouldResetVersion(boolean newShouldResetVersion)
      PUBLIC: Set if the version should be reset to null.
    • shouldCascade

      public boolean shouldCascade()
      PUBLIC: Return true if has been configured to CASCADE_ALL_PARTS or CASCADE_PRIVATE_PARTS.
    • shouldCascadeAllParts

      public boolean shouldCascadeAllParts()
      PUBLIC: Return true if should CASCADE_ALL_PARTS
    • shouldCascadePrivateParts

      public boolean shouldCascadePrivateParts()
      PUBLIC: Return true if should CASCADE_PRIVATE_PARTS
    • shouldCascadeTree

      public boolean shouldCascadeTree()
      PUBLIC: Return true if should CASCADE_TREE
    • shouldResetPrimaryKey

      public boolean shouldResetPrimaryKey()
      PUBLIC: Return if the primary key should be reset to null.
    • shouldResetVersion

      public boolean shouldResetVersion()
      PUBLIC: Return if the version should be reset to null.
    • toStringAdditionalInfo

      protected String toStringAdditionalInfo()
      INTERNAL:
      Overrides:
      toStringAdditionalInfo in class CoreAttributeGroup<AttributeItem,ClassDescriptor>
    • addAttribute

      public void addAttribute(String attributeNameOrPath, CoreAttributeGroup group)
      Description copied from class: CoreAttributeGroup
      Add a basic attribute or nested attribute with each String representing an attribute on the path to what needs to be included in the AttributeGroup.

      Example: group.addAttribute("firstName", group1);
      group.addAttribute("manager.address", group2);
      Note that existing group corresponding to attributeNameOrPath will be overridden with the passed group.

      Overrides:
      addAttribute in class CoreAttributeGroup<AttributeItem,ClassDescriptor>
      Parameters:
      attributeNameOrPath - A simple attribute, array or attributes forming a path
      group - - an AttributeGroup to be added.
    • addAttribute

      public void addAttribute(String attributeNameOrPath, CopyGroup group)
    • isCopyGroup

      public boolean isCopyGroup()
      Description copied from class: AttributeGroup
      INTERNAL: This method is used internally when converting to a copy group.
      Overrides:
      isCopyGroup in class AttributeGroup
    • clone

      public CopyGroup clone()
      Overrides:
      clone in class AttributeGroup
    • getGroup

      public CopyGroup getGroup(String attributeNameOrPath)
      Returns CopyGroup corresponding to the passed (possibly nested) attribute.
      Overrides:
      getGroup in class AttributeGroup
    • newGroup

      protected CopyGroup newGroup(String name, CoreAttributeGroup parent)
      Description copied from class: AttributeGroup
      Subclass may create different types.
      Overrides:
      newGroup in class AttributeGroup