public String toString() { return this.getClass().getName() + "(" + getAttribute() + ")"; }
/** * ADVANCED: * This method will return a collection of the fieldnames of attributes changed in an object * */ public Vector getChangedAttributeNames() { Vector names = new Vector(); Enumeration attributes = getChanges().elements(); while (attributes.hasMoreElements()) { names.addElement(((ChangeRecord)attributes.nextElement()).getAttribute()); } return names; }
/** * ADVANCED: * This method will return true if the specified attributue has been changed * * @param String the name of the attribute to search for */ public boolean hasChangeFor(String attributeName) { Enumeration attributes = getChanges().elements(); while (attributes.hasMoreElements()) { if (((ChangeRecord)attributes.nextElement()).getAttribute().equals(attributeName)) { return true; } } return false; }
/** * @param changeRecord prototype.changeset.ChangeRecord */ public void addChange(ChangeRecord changeRecord) { if (changeRecord == null) { return; } ChangeRecord existingChangeRecord = (ChangeRecord)getAttributesToChanges().get(changeRecord.getAttribute()); // change tracking may add a change to an existing attribute fix that here. if ( existingChangeRecord != null){ getChanges().remove(existingChangeRecord); } getChanges().addElement(changeRecord); getAttributesToChanges().put(changeRecord.getAttribute(), changeRecord); updateUOWChangeSet(); }
/** * INTERNAL: * Merge changes between the objects, this merge algorthim is dependent on the merge manager. */ public void mergeChangesIntoObject(Object target, ObjectChangeSet changeSet, Object source, MergeManager mergeManager) { for (Enumeration changes = changeSet.getChanges().elements(); changes.hasMoreElements();) { ChangeRecord record = (ChangeRecord)changes.nextElement(); //cr 4236, use ObjectBuilder getMappingForAttributeName not the Descriptor one because the // ObjectBuilder method is much more efficient. DatabaseMapping mapping = getMappingForAttributeName(record.getAttribute()); mapping.mergeChangesIntoObject(target, record, source, mergeManager); } // PERF: Avoid events if no listeners. if (getDescriptor().getEventManager().hasAnyEventListeners()) { oracle.toplink.essentials.descriptors.DescriptorEvent event = new oracle.toplink.essentials.descriptors.DescriptorEvent(target); event.setSession(mergeManager.getSession()); event.setOriginalObject(source); event.setChangeSet(changeSet); event.setEventCode(DescriptorEventManager.PostMergeEvent); getDescriptor().getEventManager().executeEvent(event); } }
throw ValidationException.primaryKeyUpdateDisallowed(changeRecord.getOwner().getClassName(), changeRecord.getAttribute());
ChangeRecord thisRecord = (ChangeRecord) this.getChangesForAttributeNamed(record.getAttribute()); if (thisRecord == null) { record.updateReferences(mergeToChangeSet, mergeFromChangeSet);
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. * Validation preventing primary key updates is implemented here. */ public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session) { if (isReadOnly()) { return; } if (isPrimaryKeyMapping() && !changeRecord.getOwner().isNew()) { throw ValidationException.primaryKeyUpdateDisallowed(changeRecord.getOwner().getClassName(), changeRecord.getAttribute()); } Object attributeValue = ((DirectToFieldChangeRecord)changeRecord).getNewValue(); Object fieldValue = getFieldValue(attributeValue, session); row.add(getField(), fieldValue); }