/** * INTERNAL: * Creates a CollectionChangeEvent for the container */ @Override public CollectionChangeEvent createChangeEvent(Object collectionOwner, String propertyName, Object collectionChanged, Object elementChanged, int changeType, Integer index, boolean isChangeApplied) { if (elementChanged instanceof Map.Entry) { return new MapChangeEvent(collectionOwner,propertyName, collectionChanged, ((Map.Entry)elementChanged).getKey(), ((Map.Entry)elementChanged).getValue(), changeType, isChangeApplied); } return super.createChangeEvent(collectionOwner, propertyName, collectionChanged, elementChanged, changeType, index, isChangeApplied); }
/** * This method is used to bridge the behavior between Attribute Change Tracking and * deferred change tracking with respect to adding the same instance multiple times. * Each ContainerPolicy type will implement specific behavior for the collection * type it is wrapping. These methods are only valid for collections containing object references */ public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord){ Object key = null; //This is to allow non-MapChangeEvent. Not sure how one could get here, but wasn't willing to remove the chance that it could if (event.getClass().equals(ClassConstants.MapChangeEvent_Class)){ key = ((MapChangeEvent)event).getKey(); } if (event.getChangeType() == CollectionChangeEvent.ADD) { recordAddToCollectionInChangeRecord(changeSet, collectionChangeRecord); changeSet.setNewKey(key); } else if (event.getChangeType() == MapChangeEvent.REMOVE) { recordRemoveFromCollectionInChangeRecord(changeSet, collectionChangeRecord); changeSet.setOldKey(key); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } }
/** * This method is used to bridge the behavior between Attribute Change Tracking and * deferred change tracking with respect to adding the same instance multiple times. * Each ContainerPolicy type will implement specific behavior for the collection * type it is wrapping. These methods are only valid for collections containing object references */ @Override public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord){ Object key = null; //This is to allow non-MapChangeEvent. Not sure how one could get here, but wasn't willing to remove the chance that it could if (event.getClass().equals(ClassConstants.MapChangeEvent_Class)){ key = ((MapChangeEvent)event).getKey(); } if (event.getChangeType() == CollectionChangeEvent.ADD) { recordAddToCollectionInChangeRecord(changeSet, collectionChangeRecord); changeSet.setNewKey(key); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { recordRemoveFromCollectionInChangeRecord(changeSet, collectionChangeRecord); changeSet.setOldKey(key); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } }
/** * INTERNAL: * Creates a CollectionChangeEvent for the container */ @Override public CollectionChangeEvent createChangeEvent(Object collectionOwner, String propertyName, Object collectionChanged, Object elementChanged, int changeType, Integer index, boolean isChangeApplied) { if (elementChanged instanceof Map.Entry) { return new MapChangeEvent(collectionOwner,propertyName, collectionChanged, ((Map.Entry)elementChanged).getKey(), ((Map.Entry)elementChanged).getValue(), changeType, isChangeApplied); } return super.createChangeEvent(collectionOwner, propertyName, collectionChanged, elementChanged, changeType, index, isChangeApplied); }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ @Override public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event != null ) { //Letting the mapping create and add the ChangeSet to the ChangeRecord rather // than the policy, since the policy doesn't know how to handle DirectCollectionChangeRecord. // if ordering is to be supported in the future, check how the method in CollectionMapping is implemented Object key = null; if (event.getClass().equals(ClassConstants.MapChangeEvent_Class)){ key = ((MapChangeEvent)event).getKey(); } if (event.getChangeType() == CollectionChangeEvent.ADD) { addToCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { removeFromCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } } }
/** * Raise the add change event and relationship maintainence. */ protected void raiseAddChangeEvent(Object key, Object value) { if (hasTrackedPropertyChangeListener()) { _persistence_getPropertyChangeListener().propertyChange(new MapChangeEvent(this, getTrackedAttributeName(), this, key, value, CollectionChangeEvent.ADD, true)); } // this is where relationship maintenance would go }
/** * This method is used to bridge the behavior between Attribute Change Tracking and * deferred change tracking with respect to adding the same instance multiple times. * Each ContainerPolicy type will implement specific behavior for the collection * type it is wrapping. These methods are only valid for collections containing object references */ @Override public void recordUpdateToCollectionInChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, CollectionChangeRecord collectionChangeRecord){ Object key = null; //This is to allow non-MapChangeEvent. Not sure how one could get here, but wasn't willing to remove the chance that it could if (event.getClass().equals(ClassConstants.MapChangeEvent_Class)){ key = ((MapChangeEvent)event).getKey(); } if (event.getChangeType() == CollectionChangeEvent.ADD) { recordAddToCollectionInChangeRecord(changeSet, collectionChangeRecord); changeSet.setNewKey(key); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { recordRemoveFromCollectionInChangeRecord(changeSet, collectionChangeRecord); changeSet.setOldKey(key); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } }
/** * Raise the remove change event. */ protected void raiseRemoveChangeEvent(Object key, Object value) { if (hasTrackedPropertyChangeListener()) { _persistence_getPropertyChangeListener().propertyChange(new MapChangeEvent(this, getTrackedAttributeName(), this, key, value, CollectionChangeEvent.REMOVE, true)); } // this is where relationship maintenance would go }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event != null ) { //Letting the mapping create and add the ChangeSet to the ChangeRecord rather // than the policy, since the policy doesn't know how to handle DirectCollectionChangeRecord. // if ordering is to be supported in the future, check how the method in CollectionMapping is implemented Object key = null; if (event.getClass().equals(ClassConstants.MapChangeEvent_Class)){ key = ((MapChangeEvent)event).getKey(); } if (event.getChangeType() == CollectionChangeEvent.ADD) { addToCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { removeFromCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } } }
/** * Raise the add change event and relationship maintainence. */ protected void raiseAddChangeEvent(Object key, Object value) { if (hasTrackedPropertyChangeListener()) { _persistence_getPropertyChangeListener().propertyChange(new MapChangeEvent(this, getTrackedAttributeName(), this, key, value, CollectionChangeEvent.ADD, true)); } // this is where relationship maintenance would go }
/** * INTERNAL: * Add or removes a new value and its change set to the collection change record based on the event passed in. This is used by * attribute change tracking. */ @Override public void updateCollectionChangeRecord(CollectionChangeEvent event, ObjectChangeSet changeSet, UnitOfWorkImpl uow) { if (event != null ) { //Letting the mapping create and add the ChangeSet to the ChangeRecord rather // than the policy, since the policy doesn't know how to handle DirectCollectionChangeRecord. // if ordering is to be supported in the future, check how the method in CollectionMapping is implemented Object key = null; if (event.getClass().equals(ClassConstants.MapChangeEvent_Class)){ key = ((MapChangeEvent)event).getKey(); } if (event.getChangeType() == CollectionChangeEvent.ADD) { addToCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else if (event.getChangeType() == CollectionChangeEvent.REMOVE) { removeFromCollectionChangeRecord(key, event.getNewValue(), changeSet, uow); } else { throw ValidationException.wrongCollectionChangeEventType(event.getChangeType()); } } }
/** * Raise the remove change event. */ protected void raiseRemoveChangeEvent(Object key, Object value) { if (hasTrackedPropertyChangeListener()) { _persistence_getPropertyChangeListener().propertyChange(new MapChangeEvent(this, getTrackedAttributeName(), this, key, value, CollectionChangeEvent.REMOVE, true)); } // this is where relationship maintenance would go }
/** * Raise the add change event and relationship maintainence. */ protected void raiseAddChangeEvent(Object key, Object value) { if (hasTrackedPropertyChangeListener()) { _persistence_getPropertyChangeListener().propertyChange(new MapChangeEvent(this, getTrackedAttributeName(), this, key, value, CollectionChangeEvent.ADD)); } // this is where relationship maintenance would go }
/** * Raise the remove change event. */ protected void raiseRemoveChangeEvent(Object key, Object value) { if (hasTrackedPropertyChangeListener()) { _persistence_getPropertyChangeListener().propertyChange(new MapChangeEvent(this, getTrackedAttributeName(), this, key, value, CollectionChangeEvent.REMOVE)); } // this is where relationship maintenance would go }
while (containerPolicy.hasNext(iterator)) { Map.Entry entry = (Map.Entry)containerPolicy.nextEntry(iterator, mergeManager.getSession()); ((ObjectChangeListener)((ChangeTracker)target)._persistence_getPropertyChangeListener()).internalPropertyChange(new MapChangeEvent(target, getAttributeName(), valueOfTarget, entry.getKey(), entry.getValue(), CollectionChangeEvent.REMOVE));// make the remove change event fire. if (fireChangeEvents) { ((ObjectChangeListener)((ChangeTracker)target)._persistence_getPropertyChangeListener()).internalPropertyChange(new MapChangeEvent(target, getAttributeName(), valueOfTarget, entry.getKey(), entry.getValue(), CollectionChangeEvent.ADD));// make the add change event fire.
while (containerPolicy.hasNext(iterator)) { Map.Entry entry = (Map.Entry)containerPolicy.nextEntry(iterator, mergeManager.getSession()); ((ObjectChangeListener)((ChangeTracker)target)._persistence_getPropertyChangeListener()).internalPropertyChange(new MapChangeEvent(target, getAttributeName(), valueOfTarget, entry.getKey(), entry.getValue(), CollectionChangeEvent.REMOVE, false));// make the remove change event fire. if (fireChangeEvents) { ((ObjectChangeListener)((ChangeTracker)target)._persistence_getPropertyChangeListener()).internalPropertyChange(new MapChangeEvent(target, getAttributeName(), valueOfTarget, entry.getKey(), entry.getValue(), CollectionChangeEvent.ADD, false));// make the add change event fire.
while (containerPolicy.hasNext(iterator)) { Map.Entry entry = (Map.Entry)containerPolicy.nextEntry(iterator, mergeManager.getSession()); ((ObjectChangeListener)((ChangeTracker)target)._persistence_getPropertyChangeListener()).internalPropertyChange(new MapChangeEvent(target, getAttributeName(), valueOfTarget, entry.getKey(), entry.getValue(), CollectionChangeEvent.REMOVE, false));// make the remove change event fire. if (fireChangeEvents) { ((ObjectChangeListener)((ChangeTracker)target)._persistence_getPropertyChangeListener()).internalPropertyChange(new MapChangeEvent(target, getAttributeName(), valueOfTarget, entry.getKey(), entry.getValue(), CollectionChangeEvent.ADD, false));// make the add change event fire.