Class CollectionChangeRecord

All Implemented Interfaces:
Serializable, ChangeRecord, CollectionChangeRecord
Direct Known Subclasses:
AggregateCollectionChangeRecord, EISCollectionChangeRecord, EISOrderedCollectionChangeRecord

public class CollectionChangeRecord extends DeferrableChangeRecord implements CollectionChangeRecord

Purpose: This class holds the record of the changes made to a collection attribute of an object.

Description: Collections must be compared to each other and added and removed objects must be recorded separately.

See Also:
  • Field Details

    • addObjectList

      protected Map<ObjectChangeSet,ObjectChangeSet> addObjectList
      Contains the added values to the collection and their corresponding ChangeSets.
    • orderedAddObjects

      protected List<ObjectChangeSet> orderedAddObjects
      Contains the added values to the collection and their corresponding ChangeSets in order.
    • orderedAddObjectIndices

      protected Map<ObjectChangeSet,Integer> orderedAddObjectIndices
      Contains the added values index to the collection.
    • orderedChangeObjectList

      protected List<OrderedChangeObject> orderedChangeObjectList
      Contains OrderedChangeObjects representing each change made to the collection.
    • orderedRemoveObjects

      protected Map<Integer,ObjectChangeSet> orderedRemoveObjects
      Contains the removed values to the collection and their corresponding ChangeSets.
    • orderedRemoveObjectIndices

      protected transient List<Integer> orderedRemoveObjectIndices
      Contains the removed values index to the collection.
    • addOverFlow

      protected transient List<ObjectChangeSet> addOverFlow
      Contains a list of extra adds. These extra adds are used by attribute change tracking to replicate behavior when someone adds the same object to a list and removes it once. In this case the object should still appear once in the change set.
    • removeObjectList

      protected Map<ObjectChangeSet,ObjectChangeSet> removeObjectList
      Contains the removed values from the collection and their corresponding ChangeSets.
    • orderHasBeenRepaired

      protected boolean orderHasBeenRepaired
      Indicates whether IndirectList's order has been repaired.
  • Constructor Details

    • CollectionChangeRecord

      public CollectionChangeRecord()
      This default constructor.
    • CollectionChangeRecord

      public CollectionChangeRecord(ObjectChangeSet owner)
      Constructor for the ChangeRecord representing a collection mapping
      Parameters:
      owner - the changeSet that uses this record
  • Method Details

    • addAdditionChange

      public void addAdditionChange(Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session)
      This method takes a Map of objects, converts these into ObjectChangeSets.
    • addOrderedAdditionChange

      public void addOrderedAdditionChange(List<Object> orderedObjectsToAdd, Map<Object,Integer> objectChangesIndices, UnitOfWorkChangeSet changeSet, AbstractSession session)
      This method takes a list of objects and converts them into ObjectChangeSets. This method should only be called from a ListContainerPolicy. Additions to the list are made by index, hence, the second Map of objectChangesIndices.
    • addOrderedRemoveChange

      public void addOrderedRemoveChange(List<Integer> indicesToRemove, Map objectChanges, UnitOfWorkChangeSet changeSet, AbstractSession session)
      This method takes a map of objects and converts them into ObjectChangeSets. This method should only be called from a ListContainerPolicy. Deletions from the list is made by index, hence, the second Vector of indicesToRemove.
    • addRemoveChange

      public void addRemoveChange(Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session)
      This method takes a Map of objects, converts these into ObjectChangeSets.
    • getAddObjectList

      public Map<ObjectChangeSet,ObjectChangeSet> getAddObjectList()
      ADVANCED: This method returns the collection of ChangeSets that were added to the collection.
      Specified by:
      getAddObjectList in interface CollectionChangeRecord
      Returns:
      java.util.Vector
    • getAddOverFlow

      public List<ObjectChangeSet> getAddOverFlow()
      Returns a list of extra adds. These extra adds are used by attribute change tracking to replicate behavior when someone adds the same object to a list and removes it once. In this case the object should still appear once in the change set.
    • getRemoveObjectList

      public Map<ObjectChangeSet,ObjectChangeSet> getRemoveObjectList()
      PUBLIC: This method returns the Map that contains the removed values from the collection and their corresponding ChangeSets.
      Specified by:
      getRemoveObjectList in interface CollectionChangeRecord
      Returns:
      java.util.Vector
    • hasChanges

      public boolean hasChanges()
      PUBLIC: Returns true if the change set has changes.
      Specified by:
      hasChanges in interface CollectionChangeRecord
      Returns:
      boolean
    • mergeRecord

      public void mergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)
      This method will be used to merge one record into another.
      Specified by:
      mergeRecord in class ChangeRecord
    • setAddObjectList

      public void setAddObjectList(Map<ObjectChangeSet,ObjectChangeSet> objectChangesList)
      Sets the Added objects list.
    • setRemoveObjectList

      public void setRemoveObjectList(Map<ObjectChangeSet,ObjectChangeSet> objectChangesList)
      Sets the removed objects list.
    • updateReferences

      public void updateReferences(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)
      This method will be used to update the objectsChangeSets references.
      Specified by:
      updateReferences in class ChangeRecord
    • getOrderedAddObjects

      public List<ObjectChangeSet> getOrderedAddObjects()
      This method returns the collection of ChangeSets in the order they were added to the collection. This list includes those objects that were moved within the collection.
    • getOrderedAddObjectIndex

      public Integer getOrderedAddObjectIndex(ObjectChangeSet changes)
      This method returns the index of an object added to the collection.
    • getOrderedAddObjectIndices

      public Map<ObjectChangeSet,Integer> getOrderedAddObjectIndices()
      This method returns the collection of ChangeSets that they were added to the collection.
    • getOrderedChangeObjectList

      public List<OrderedChangeObject> getOrderedChangeObjectList()
      This method returns the Vector of OrderedChangeObjects. These objects represent all changes made to the collection, and their order in the vector represents the order they were performed.
    • getOrderedRemoveObjectIndices

      public List<Integer> getOrderedRemoveObjectIndices()
      This method returns the ordered list of indices to remove from the collection.
    • getOrderedRemoveObject

      public Object getOrderedRemoveObject(Integer index)
      This method returns the index of an object removed from the collection.
    • getOrderedRemoveObjects

      public Map<Integer,ObjectChangeSet> getOrderedRemoveObjects()
      This method returns the collection of ChangeSets of objects removed from the collection.
    • setOrderedAddObjectIndices

      public void setOrderedAddObjectIndices(Map<ObjectChangeSet,Integer> orderedAddObjectIndices)
      Sets collection of ChangeSets (and their respective index) that they were added to the collection.
    • setOrderedAddObjects

      public void setOrderedAddObjects(List<ObjectChangeSet> orderedAddObjects)
      Sets collection of ChangeSets that they were added to the collection.
    • setOrderedChangeObjectList

      public void setOrderedChangeObjectList(List<OrderedChangeObject> orderedChangeObjectList)
    • setOrderedRemoveObjects

      public void setOrderedRemoveObjects(Map<Integer,ObjectChangeSet> orderedRemoveObjects)
      Sets collection of ChangeSets that they were removed from the collection.
    • getCurrentIndexesOfOriginalObjects

      public List<Integer> getCurrentIndexesOfOriginalObjects(List newList)
      The same size as original list, at the i-th position holds the index of the i-th original object in the current list (-1 if the object was removed): for example: {0, -1, 1, -1, 3} means that: previous(0) == current(0); previous(1) was removed; previous(2) == current(1); previous(3) was removed; previous(4) == current(3);
    • internalRecreateOriginalCollection

      public void internalRecreateOriginalCollection(Object currentCollection, AbstractSession session)
      Recreates the original state of currentCollection.
      Specified by:
      internalRecreateOriginalCollection in class DeferrableChangeRecord
    • setOrderHasBeenRepaired

      public void setOrderHasBeenRepaired(boolean hasBeenRepaired)
    • orderHasBeenRepaired

      public boolean orderHasBeenRepaired()
    • clearChanges

      public void clearChanges()
      Clears info about added / removed objects set by change tracker.
      Specified by:
      clearChanges in class DeferrableChangeRecord