/** * ADVANCED: * This method is used to add an object to a collection once the changeSet is applied. * The referenceKey parameter should only be used for direct Maps. */ public void simpleAddToCollectionChangeRecord(Object referenceKey, Object changeSetToAdd, ObjectChangeSet changeSet, AbstractSession session) { if (this.getContainerPolicy().hasOrder()) { this.simpleAddToCollectionChangeRecordWithOrder(referenceKey, changeSetToAdd, changeSet, session); } else { this.simpleAddToCollectionChangeRecordWithoutOrder(referenceKey, changeSetToAdd, changeSet, session); } }
/** * ADVANCED: * This method is used to remove an object from a collection once the changeSet is applied. * The referenceKey parameter should only be used for direct Maps. */ public void simpleRemoveFromCollectionChangeRecord(Object referenceKey, Object changeSetToRemove, ObjectChangeSet changeSet, AbstractSession session) { if (this.getContainerPolicy().hasOrder()) { this.simpleRemoveFromCollectionChangeRecordWithOrder(referenceKey, changeSetToRemove, changeSet, session); } else { this.simpleRemoveFromCollectionChangeRecordWithoutOrder(referenceKey, changeSetToRemove, changeSet, session); } }
/** * INTERNAL: * Merge changes from the source to the target object. */ public void mergeChangesIntoObject(Object target, ChangeRecord changeRecord, Object source, MergeManager mergeManager, AbstractSession targetSession) { if (this.getContainerPolicy().hasOrder()) { this.mergeChangesIntoObjectWithOrder(target, changeRecord, source, mergeManager, targetSession); } else { this.mergeChangesIntoObjectWithoutOrder(target, changeRecord, source, mergeManager, targetSession); } }
/** * ADVANCED: * This method is used to add an object to a collection once the changeSet is applied. * The referenceKey parameter should only be used for direct Maps. */ public void simpleAddToCollectionChangeRecord(Object referenceKey, Object changeSetToAdd, ObjectChangeSet changeSet, AbstractSession session) { if (this.getContainerPolicy().hasOrder()) { this.simpleAddToCollectionChangeRecordWithOrder(referenceKey, changeSetToAdd, changeSet, session); } else { this.simpleAddToCollectionChangeRecordWithoutOrder(referenceKey, changeSetToAdd, changeSet, session); } }
/** * ADVANCED: * This method is used to remove an object from a collection once the changeSet is applied. * The referenceKey parameter should only be used for direct Maps. */ public void simpleRemoveFromCollectionChangeRecord(Object referenceKey, Object changeSetToRemove, ObjectChangeSet changeSet, AbstractSession session) { if (this.getContainerPolicy().hasOrder()) { this.simpleRemoveFromCollectionChangeRecordWithOrder(referenceKey, changeSetToRemove, changeSet, session); } else { this.simpleRemoveFromCollectionChangeRecordWithoutOrder(referenceKey, changeSetToRemove, changeSet, session); } }
/** * Merge changes from the source to the target object. * Simply replace the entire target collection. */ private void mergeChangesIntoObjectWithOrder(Object target, ChangeRecord changeRecord, Object source, MergeManager mergeManager) { ContainerPolicy cp = this.getContainerPolicy(); AbstractSession session = mergeManager.getSession(); Vector changes = ((EISOrderedCollectionChangeRecord)changeRecord).getNewCollection(); Object targetCollection = cp.containerInstance(changes.size()); for (Enumeration stream = changes.elements(); stream.hasMoreElements();) { Object targetElement = this.buildAddedElementFromChangeSet(stream.nextElement(), mergeManager); cp.addInto(targetElement, targetCollection, session); } // reset the attribute to allow for set method to re-morph changes if the collection is not being stored directly this.setRealAttributeValueInObject(target, targetCollection); }
/** * ADVANCED: * This method is used to remove an object from a collection once the changeSet is applied. * The referenceKey parameter should only be used for direct Maps. */ public void simpleRemoveFromCollectionChangeRecord(Object referenceKey, Object changeSetToRemove, ObjectChangeSet changeSet, AbstractSession session) { if (this.getContainerPolicy().hasOrder()) { this.simpleRemoveFromCollectionChangeRecordWithOrder(referenceKey, changeSetToRemove, changeSet, session); } else { this.simpleRemoveFromCollectionChangeRecordWithoutOrder(referenceKey, changeSetToRemove, changeSet, session); } }
/** * INTERNAL: * Merge changes from the source to the target object. */ public void mergeChangesIntoObject(Object target, ChangeRecord changeRecord, Object source, MergeManager mergeManager) { if (this.getContainerPolicy().hasOrder()) { this.mergeChangesIntoObjectWithOrder(target, changeRecord, source, mergeManager); } else { this.mergeChangesIntoObjectWithoutOrder(target, changeRecord, source, mergeManager); } }
/** * INTERNAL: * Merge changes from the source to the target object. */ public void mergeChangesIntoObject(Object target, ChangeRecord changeRecord, Object source, MergeManager mergeManager, AbstractSession targetSession) { if (this.getContainerPolicy().hasOrder()) { this.mergeChangesIntoObjectWithOrder(target, changeRecord, source, mergeManager, targetSession); } else { this.mergeChangesIntoObjectWithoutOrder(target, changeRecord, source, mergeManager, targetSession); } }
/** * ADVANCED: * This method is used to add an object to a collection once the changeSet is applied. * The referenceKey parameter should only be used for direct Maps. */ public void simpleAddToCollectionChangeRecord(Object referenceKey, Object changeSetToAdd, ObjectChangeSet changeSet, AbstractSession session) { if (this.getContainerPolicy().hasOrder()) { this.simpleAddToCollectionChangeRecordWithOrder(referenceKey, changeSetToAdd, changeSet, session); } else { this.simpleAddToCollectionChangeRecordWithoutOrder(referenceKey, changeSetToAdd, changeSet, session); } }
/** * Merge changes from the source to the target object. * Simply replace the entire target collection. */ private void mergeChangesIntoObjectWithOrder(Object target, ChangeRecord changeRecord, Object source, MergeManager mergeManager, AbstractSession targetSession) { ContainerPolicy cp = this.getContainerPolicy(); AbstractSession session = mergeManager.getSession(); List changes = ((EISOrderedCollectionChangeRecord)changeRecord).getNewCollection(); Object targetCollection = cp.containerInstance(changes.size()); for (Object changed : changes) { Object targetElement = buildAddedElementFromChangeSet(changed, mergeManager, targetSession); cp.addInto(targetElement, targetCollection, session); } // reset the attribute to allow for set method to re-morph changes if the collection is not being stored directly this.setRealAttributeValueInObject(target, targetCollection); }
/** * Merge changes from the source to the target object. * Simply replace the entire target collection. */ private void mergeChangesIntoObjectWithOrder(Object target, ChangeRecord changeRecord, Object source, MergeManager mergeManager, AbstractSession targetSession) { ContainerPolicy cp = this.getContainerPolicy(); AbstractSession session = mergeManager.getSession(); List changes = ((EISOrderedCollectionChangeRecord)changeRecord).getNewCollection(); Object targetCollection = cp.containerInstance(changes.size()); for (Object changed : changes) { Object targetElement = buildAddedElementFromChangeSet(changed, mergeManager, targetSession); cp.addInto(targetElement, targetCollection, session); } // reset the attribute to allow for set method to re-morph changes if the collection is not being stored directly this.setRealAttributeValueInObject(target, targetCollection); }
/** * Compare the attributes. Return true if they are alike. * The order of the elements is significant. */ private boolean compareAttributeValuesWithOrder(Object collection1, Object collection2, AbstractSession session) { ContainerPolicy cp = this.getContainerPolicy(); Object iter1 = cp.iteratorFor(collection1); Object iter2 = cp.iteratorFor(collection2); while (cp.hasNext(iter1)) { if (!this.compareElements(cp.next(iter1, session), cp.next(iter2, session), session)) { return false; } } return true; }
/** * Compare the attributes. Return true if they are alike. * The order of the elements is significant. */ private boolean compareAttributeValuesWithOrder(Object collection1, Object collection2, AbstractSession session) { ContainerPolicy cp = this.getContainerPolicy(); Object iter1 = cp.iteratorFor(collection1); Object iter2 = cp.iteratorFor(collection2); while (cp.hasNext(iter1)) { if (!this.compareElements(cp.next(iter1, session), cp.next(iter2, session), session)) { return false; } } return true; }
/** * Compare the attributes. Return true if they are alike. * The order of the elements is significant. */ private boolean compareAttributeValuesWithOrder(Object collection1, Object collection2, AbstractSession session) { ContainerPolicy cp = this.getContainerPolicy(); Object iter1 = cp.iteratorFor(collection1); Object iter2 = cp.iteratorFor(collection2); while (cp.hasNext(iter1)) { if (!this.compareElements(cp.next(iter1, session), cp.next(iter2, session), session)) { return false; } } return true; }
/** * Compare the attributes. Return true if they are alike. * Assume the passed-in attributes are non-null. */ private boolean compareAttributeValues(Object collection1, Object collection2, AbstractSession session) { ContainerPolicy cp = this.getContainerPolicy(); if (cp.sizeFor(collection1) != cp.sizeFor(collection2)) { return false; } // if they are both empty, go no further... if (cp.sizeFor(collection1) == 0) { return true; } if (cp.hasOrder()) { return this.compareAttributeValuesWithOrder(collection1, collection2, session); } else { return this.compareAttributeValuesWithoutOrder(collection1, collection2, session); } }
/** * INTERNAL: * Build and return the change record that results * from comparing the two collection attributes. */ public ChangeRecord compareForChange(Object clone, Object backup, ObjectChangeSet owner, AbstractSession session) { ContainerPolicy cp = this.getContainerPolicy(); Object cloneCollection = this.getRealCollectionAttributeValueFromObject(clone, session); Object backupCollection = null; if (owner.isNew()) { backupCollection = cp.containerInstance(1); } else { backupCollection = this.getRealCollectionAttributeValueFromObject(backup, session); } if (cp.hasOrder()) { return this.compareAttributeValuesForChangeWithOrder(cloneCollection, backupCollection, owner, session); } else { return this.compareAttributeValuesForChangeWithoutOrder(cloneCollection, backupCollection, owner, session); } }
/** * INTERNAL: * Merge changes from the source to the target object. * Simply replace the entire target collection. */ public void mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager) { ContainerPolicy cp = this.getContainerPolicy(); AbstractSession session = mergeManager.getSession(); Object sourceCollection = this.getRealCollectionAttributeValueFromObject(source, session); Object targetCollection = cp.containerInstance(cp.sizeFor(sourceCollection)); for (Object iter = cp.iteratorFor(sourceCollection); cp.hasNext(iter);) { Object targetElement = this.buildElementFromElement(cp.next(iter, session), mergeManager); cp.addInto(targetElement, targetCollection, session); } // reset the attribute to allow for set method to re-morph changes if the collection is not being stored directly this.setRealAttributeValueInObject(target, targetCollection); }
/** * INTERNAL: * Merge changes from the source to the target object. * Simply replace the entire target collection. */ public void mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager, AbstractSession targetSession) { ContainerPolicy cp = this.getContainerPolicy(); AbstractSession session = mergeManager.getSession(); Object sourceCollection = this.getRealCollectionAttributeValueFromObject(source, session); Object targetCollection = cp.containerInstance(cp.sizeFor(sourceCollection)); for (Object iter = cp.iteratorFor(sourceCollection); cp.hasNext(iter);) { Object targetElement = this.buildElementFromElement(cp.next(iter, session), mergeManager, targetSession); cp.addInto(targetElement, targetCollection, session); } // reset the attribute to allow for set method to re-morph changes if the collection is not being stored directly setRealAttributeValueInObject(target, targetCollection); }
/** * INTERNAL: * Merge changes from the source to the target object. * Simply replace the entire target collection. */ public void mergeIntoObject(Object target, boolean isTargetUnInitialized, Object source, MergeManager mergeManager, AbstractSession targetSession) { ContainerPolicy cp = this.getContainerPolicy(); AbstractSession session = mergeManager.getSession(); Object sourceCollection = this.getRealCollectionAttributeValueFromObject(source, session); Object targetCollection = cp.containerInstance(cp.sizeFor(sourceCollection)); for (Object iter = cp.iteratorFor(sourceCollection); cp.hasNext(iter);) { Object targetElement = this.buildElementFromElement(cp.next(iter, session), mergeManager, targetSession); cp.addInto(targetElement, targetCollection, session); } // reset the attribute to allow for set method to re-morph changes if the collection is not being stored directly setRealAttributeValueInObject(target, targetCollection); }