Class CollectionChangeRecord
- java.lang.Object
-
- org.eclipse.persistence.internal.sessions.ChangeRecord
-
- org.eclipse.persistence.internal.sessions.DeferrableChangeRecord
-
- org.eclipse.persistence.internal.sessions.CollectionChangeRecord
-
- All Implemented Interfaces:
java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<ObjectChangeSet,ObjectChangeSet>addObjectListContains the added values to the collection and their corresponding ChangeSets.protected java.util.List<ObjectChangeSet>addOverFlowContains a list of extra adds.protected java.util.Map<ObjectChangeSet,java.lang.Integer>orderedAddObjectIndicesContains the added values index to the collection.protected java.util.List<ObjectChangeSet>orderedAddObjectsContains the added values to the collection and their corresponding ChangeSets in order.protected java.util.List<OrderedChangeObject>orderedChangeObjectListContains OrderedChangeObjects representing each change made to the collection.protected java.util.List<java.lang.Integer>orderedRemoveObjectIndicesContains the removed values index to the collection.protected java.util.Map<java.lang.Integer,ObjectChangeSet>orderedRemoveObjectsContains the removed values to the collection and their corresponding ChangeSets.protected booleanorderHasBeenRepairedIndicates whether IndirectList's order has been repaired.protected java.util.Map<ObjectChangeSet,ObjectChangeSet>removeObjectListContains the removed values from the collection and their corresponding ChangeSets.-
Fields inherited from class org.eclipse.persistence.internal.sessions.DeferrableChangeRecord
isDeferred, latestCollection, originalCollection
-
Fields inherited from class org.eclipse.persistence.internal.sessions.ChangeRecord
attribute, mapping, owner
-
-
Constructor Summary
Constructors Constructor Description CollectionChangeRecord()This default constructor.CollectionChangeRecord(ObjectChangeSet owner)Constructor for the ChangeRecord representing a collection mapping
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAdditionChange(java.util.Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a Map of objects, converts these into ObjectChangeSets.voidaddOrderedAdditionChange(java.util.List<java.lang.Object> orderedObjectsToAdd, java.util.Map<java.lang.Object,java.lang.Integer> objectChangesIndices, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a list of objects and converts them into ObjectChangeSets.voidaddOrderedRemoveChange(java.util.List<java.lang.Integer> indicesToRemove, java.util.Map objectChanges, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a map of objects and converts them into ObjectChangeSets.voidaddRemoveChange(java.util.Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a Map of objects, converts these into ObjectChangeSets.voidclearChanges()Clears info about added / removed objects set by change tracker.java.util.Map<ObjectChangeSet,ObjectChangeSet>getAddObjectList()ADVANCED: This method returns the collection of ChangeSets that were added to the collection.java.util.List<ObjectChangeSet>getAddOverFlow()Returns a list of extra adds.java.util.List<java.lang.Integer>getCurrentIndexesOfOriginalObjects(java.util.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);java.lang.IntegergetOrderedAddObjectIndex(ObjectChangeSet changes)This method returns the index of an object added to the collection.java.util.Map<ObjectChangeSet,java.lang.Integer>getOrderedAddObjectIndices()This method returns the collection of ChangeSets that they were added to the collection.java.util.List<ObjectChangeSet>getOrderedAddObjects()This method returns the collection of ChangeSets in the order they were added to the collection.java.util.List<OrderedChangeObject>getOrderedChangeObjectList()This method returns the Vector of OrderedChangeObjects.java.lang.ObjectgetOrderedRemoveObject(java.lang.Integer index)This method returns the index of an object removed from the collection.java.util.List<java.lang.Integer>getOrderedRemoveObjectIndices()This method returns the ordered list of indices to remove from the collection.java.util.Map<java.lang.Integer,ObjectChangeSet>getOrderedRemoveObjects()This method returns the collection of ChangeSets of objects removed from the collection.java.util.Map<ObjectChangeSet,ObjectChangeSet>getRemoveObjectList()PUBLIC: This method returns the Map that contains the removed values from the collection and their corresponding ChangeSets.booleanhasChanges()PUBLIC: Returns true if the change set has changes.voidinternalRecreateOriginalCollection(java.lang.Object currentCollection, AbstractSession session)Recreates the original state of currentCollection.voidmergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)This method will be used to merge one record into another.booleanorderHasBeenRepaired()voidsetAddObjectList(java.util.Map<ObjectChangeSet,ObjectChangeSet> objectChangesList)Sets the Added objects list.voidsetOrderedAddObjectIndices(java.util.Map<ObjectChangeSet,java.lang.Integer> orderedAddObjectIndices)Sets collection of ChangeSets (and their respective index) that they were added to the collection.voidsetOrderedAddObjects(java.util.List<ObjectChangeSet> orderedAddObjects)Sets collection of ChangeSets that they were added to the collection.voidsetOrderedChangeObjectList(java.util.List<OrderedChangeObject> orderedChangeObjectList)voidsetOrderedRemoveObjects(java.util.Map<java.lang.Integer,ObjectChangeSet> orderedRemoveObjects)Sets collection of ChangeSets that they were removed from the collection.voidsetOrderHasBeenRepaired(boolean hasBeenRepaired)voidsetRemoveObjectList(java.util.Map<ObjectChangeSet,ObjectChangeSet> objectChangesList)Sets the removed objects list.voidupdateReferences(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)This method will be used to update the objectsChangeSets references.-
Methods inherited from class org.eclipse.persistence.internal.sessions.DeferrableChangeRecord
getLatestCollection, getOldValue, getOldValue, getOriginalCollection, isDeferred, recreateOriginalCollection, setIsDeferred, setLatestCollection, setOriginalCollection
-
Methods inherited from class org.eclipse.persistence.internal.sessions.ChangeRecord
getAttribute, getMapping, getOwner, prepareForSynchronization, setAttribute, setMapping, setOwner, toString, updateChangeRecordWithNewValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.persistence.sessions.changesets.ChangeRecord
getAttribute, getOldValue, getOwner
-
-
-
-
Field Detail
-
addObjectList
protected java.util.Map<ObjectChangeSet,ObjectChangeSet> addObjectList
Contains the added values to the collection and their corresponding ChangeSets.
-
orderedAddObjects
protected java.util.List<ObjectChangeSet> orderedAddObjects
Contains the added values to the collection and their corresponding ChangeSets in order.
-
orderedAddObjectIndices
protected java.util.Map<ObjectChangeSet,java.lang.Integer> orderedAddObjectIndices
Contains the added values index to the collection.
-
orderedChangeObjectList
protected java.util.List<OrderedChangeObject> orderedChangeObjectList
Contains OrderedChangeObjects representing each change made to the collection.
-
orderedRemoveObjects
protected java.util.Map<java.lang.Integer,ObjectChangeSet> orderedRemoveObjects
Contains the removed values to the collection and their corresponding ChangeSets.
-
orderedRemoveObjectIndices
protected transient java.util.List<java.lang.Integer> orderedRemoveObjectIndices
Contains the removed values index to the collection.
-
addOverFlow
protected transient java.util.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 java.util.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 Detail
-
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 Detail
-
addAdditionChange
public void addAdditionChange(java.util.Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a Map of objects, converts these into ObjectChangeSets.
-
addOrderedAdditionChange
public void addOrderedAdditionChange(java.util.List<java.lang.Object> orderedObjectsToAdd, java.util.Map<java.lang.Object,java.lang.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(java.util.List<java.lang.Integer> indicesToRemove, java.util.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(java.util.Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a Map of objects, converts these into ObjectChangeSets.
-
getAddObjectList
public java.util.Map<ObjectChangeSet,ObjectChangeSet> getAddObjectList()
ADVANCED: This method returns the collection of ChangeSets that were added to the collection.- Specified by:
getAddObjectListin interfaceCollectionChangeRecord- Returns:
- java.util.Vector
-
getAddOverFlow
public java.util.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 java.util.Map<ObjectChangeSet,ObjectChangeSet> getRemoveObjectList()
PUBLIC: This method returns the Map that contains the removed values from the collection and their corresponding ChangeSets.- Specified by:
getRemoveObjectListin interfaceCollectionChangeRecord- Returns:
- java.util.Vector
-
hasChanges
public boolean hasChanges()
PUBLIC: Returns true if the change set has changes.- Specified by:
hasChangesin interfaceCollectionChangeRecord- 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:
mergeRecordin classChangeRecord
-
setAddObjectList
public void setAddObjectList(java.util.Map<ObjectChangeSet,ObjectChangeSet> objectChangesList)
Sets the Added objects list.
-
setRemoveObjectList
public void setRemoveObjectList(java.util.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:
updateReferencesin classChangeRecord
-
getOrderedAddObjects
public java.util.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 java.lang.Integer getOrderedAddObjectIndex(ObjectChangeSet changes)
This method returns the index of an object added to the collection.
-
getOrderedAddObjectIndices
public java.util.Map<ObjectChangeSet,java.lang.Integer> getOrderedAddObjectIndices()
This method returns the collection of ChangeSets that they were added to the collection.
-
getOrderedChangeObjectList
public java.util.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 java.util.List<java.lang.Integer> getOrderedRemoveObjectIndices()
This method returns the ordered list of indices to remove from the collection.
-
getOrderedRemoveObject
public java.lang.Object getOrderedRemoveObject(java.lang.Integer index)
This method returns the index of an object removed from the collection.
-
getOrderedRemoveObjects
public java.util.Map<java.lang.Integer,ObjectChangeSet> getOrderedRemoveObjects()
This method returns the collection of ChangeSets of objects removed from the collection.
-
setOrderedAddObjectIndices
public void setOrderedAddObjectIndices(java.util.Map<ObjectChangeSet,java.lang.Integer> orderedAddObjectIndices)
Sets collection of ChangeSets (and their respective index) that they were added to the collection.
-
setOrderedAddObjects
public void setOrderedAddObjects(java.util.List<ObjectChangeSet> orderedAddObjects)
Sets collection of ChangeSets that they were added to the collection.
-
setOrderedChangeObjectList
public void setOrderedChangeObjectList(java.util.List<OrderedChangeObject> orderedChangeObjectList)
-
setOrderedRemoveObjects
public void setOrderedRemoveObjects(java.util.Map<java.lang.Integer,ObjectChangeSet> orderedRemoveObjects)
Sets collection of ChangeSets that they were removed from the collection.
-
getCurrentIndexesOfOriginalObjects
public java.util.List<java.lang.Integer> getCurrentIndexesOfOriginalObjects(java.util.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(java.lang.Object currentCollection, AbstractSession session)Recreates the original state of currentCollection.- Specified by:
internalRecreateOriginalCollectionin classDeferrableChangeRecord
-
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:
clearChangesin classDeferrableChangeRecord
-
-