Project Wonder 5.0.0.8654

er.extensions.eof
Class ERXCustomObject

java.lang.Object
  extended by com.webobjects.eocontrol.EOCustomObject
      extended by er.extensions.eof.ERXCustomObject
All Implemented Interfaces:
_EOPrivateMemento, EODeferredFaulting, EOEnterpriseObject, EOFaulting, EOKeyValueCoding, EOKeyValueCoding._BestBindingCreation._ForwardingBindingCheck, EOKeyValueCoding._KeyBindingCreation, EOKeyValueCodingAdditions, EORelationshipManipulation, EOValidation, NSKeyValueCoding, NSKeyValueCoding._KeyBindingCreation, NSKeyValueCoding._ReflectionKeyBindingCreation.Callback, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, NSValidation, ERXEnterpriseObject, ERXGeneratesPrimaryKeyInterface, ERXGuardedObjectInterface, Serializable

public class ERXCustomObject
extends EOCustomObject
implements ERXGuardedObjectInterface, ERXGeneratesPrimaryKeyInterface, ERXEnterpriseObject

This class contains a bunch of extensions to the regular EOCustomObject class. Of notable interest it contains built in support for generating primary keys via the ERXGeneratesPrimaryKeyInterface, support for an augmented transaction methods like willUpdate and didDelete and a bunch of handy utility methods like committedSnapshotValueForKey . At the moment it is required that those wishing to take advantage of templatized and localized validation exceptions need to subclass this class. Hopefully in the future we can get rid of this requirement. Also, this class supports auto-updating of inverse relationships. You can simply call eo.setFoo(other), eo.takeValueForKey(other), eo.addObjectToBothSidesOfRelationshipWithKey(other, "foo") or eo.addToFoos(other) and the inverse relationship will get updated for you automagically, so that you don't need to call other.addToBars(eo) or other.setBar(eo). Doing so doesn't hurt, though. Giving a null value of removing the object from a to-many will result in the inverse relationship getting cleared.
This feature should greatly help readability and reduce the number errors you make when you forget to update an inverse relationship. To turn this feature on, you must set the system default er.extensions.ERXEnterpriseObject.updateInverseRelationships=true.

See Also:
Serialized Form

Nested Class Summary
static class ERXCustomObject.ERXCustomObjectClazz<T extends EOEnterpriseObject>
          Clazz object implementation for ERXCustomObject.
 
Nested classes/interfaces inherited from class com.webobjects.eocontrol.EOCustomObject
EOCustomObject._BooleanFieldBinding, EOCustomObject._FieldBinding, EOCustomObject._LazyFieldBinding, EOCustomObject._NumberFieldBinding
 
Nested classes/interfaces inherited from interface er.extensions.eof.ERXEnterpriseObject
ERXEnterpriseObject.Observer, ERXEnterpriseObject.Processor
 
Nested classes/interfaces inherited from interface com.webobjects.eocontrol.EOKeyValueCodingAdditions
EOKeyValueCodingAdditions.DefaultImplementation, EOKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding._BooleanFieldBinding, NSKeyValueCoding._BooleanMethodBinding, NSKeyValueCoding._FieldBinding, NSKeyValueCoding._ForwardingBinding, NSKeyValueCoding._KeyBinding, NSKeyValueCoding._MethodBinding, NSKeyValueCoding._NumberFieldBinding, NSKeyValueCoding._NumberMethodBinding, NSKeyValueCoding._ReflectionKeyBindingCreation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null<T>, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor
 
Nested classes/interfaces inherited from interface com.webobjects.eocontrol.EOKeyValueCoding
EOKeyValueCoding._BestBindingCreation, EOKeyValueCoding._KeyBindingCreation, EOKeyValueCoding._StoredForwardingBinding
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding._BooleanFieldBinding, NSKeyValueCoding._BooleanMethodBinding, NSKeyValueCoding._FieldBinding, NSKeyValueCoding._ForwardingBinding, NSKeyValueCoding._KeyBinding, NSKeyValueCoding._MethodBinding, NSKeyValueCoding._NumberFieldBinding, NSKeyValueCoding._NumberMethodBinding, NSKeyValueCoding._ReflectionKeyBindingCreation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null<T>, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation
NSValidation._MethodBinding, NSValidation._ValidationBinding, NSValidation.ValidationException
 
Nested classes/interfaces inherited from interface com.webobjects.eocontrol._EOPrivateMemento
_EOPrivateMemento.DefaultImplementation
 
Field Summary
protected  String _primaryKey
           
 String insertionStackTrace
           
protected  boolean wasInitialized
           
 
Fields inherited from class com.webobjects.eocontrol.EOCustomObject
__readOnly, _CLASS
 
Fields inherited from interface er.extensions.eof.ERXEnterpriseObject
applyRestrictingQualifierOnInsert, DidDeleteProcessor, DidInsertProcessor, DidRevertProcessor, DidUpdateProcessor, FlushCachesProcessor, insertionTrackingLog, KEY_MARKER, log, logMod, tranLogDidDelete, tranLogDidInsert, tranLogDidRevert, tranLogDidUpdate, tranLogMightDelete, tranLogWillDelete, tranLogWillInsert, tranLogWillRevert, tranLogWillUpdate, validation, validationException, WillDeleteProcessor, WillInsertProcessor, WillRevertProcessor, WillUpdateProcessor
 
Fields inherited from interface com.webobjects.eocontrol.EOEnterpriseObject
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Constructor Summary
ERXCustomObject()
           
 
Method Summary
 boolean _setUpdateInverseRelationships(boolean newValue)
          Toggles whether or not inverse relationships should be updates.
 void addObjectsToBothSidesOfRelationshipWithKey(NSArray objects, String key)
          Adds a collection of objects to a given relationship by calling addObjectToBothSidesOfRelationshipWithKey for all objects in the collection.
 void addObjectToBothSidesOfRelationshipWithKey(EORelationshipManipulation eo, String key)
          Adds a check to make sure that both the object being added and this object are in the same editing context.
 void awakeFromClientUpdate(EOEditingContext editingContext)
          Checks the editing context delegate before calling super's implementation.
 void awakeFromFetch(EOEditingContext editingContext)
          Checks the editing context delegate before calling super's implementation.
 void awakeFromInsertion(EOEditingContext editingContext)
          Checks the editing context delegate before calling super's implementation.
 void batchCheckConsistency()
          This method is very similar to the checkConsistency method except that this method is only called from an outside process, usually a batch process, to verify that the data this object holds is consistent.
 boolean canDelete()
          Implementation of ERXGuardedObjectInterface.
 boolean canUpdate()
          Implementation of ERXGuardedObjectInterface.
 NSDictionary changesFromCommittedSnapshot()
          Computes the current set of changes that this object has from the currently committed snapshot.
 void checkConsistency()
          Debugging method that will be called on an object before it is saved to the database if the property key: ERDebuggingEnabled is enabled.
 Object committedSnapshotValueForKey(String key)
          Determines what the value of the given key is in the committed snapshot
 void delete()
          Implementation of ERXGuardedObjectInterface.
 String description()
          Cover method to return toString.
 void didDelete(EOEditingContext ec)
          Called on the object after is has been deleted.
 void didInsert()
          Called on the object after is has successfully been inserted into the database.
 void didRevert(EOEditingContext ec)
          Called on the object after it has been reverted.
 void didUpdate()
          Called on the object after is has successfully been updated in the database.
 String encryptedPrimaryKey()
          Takes the primary key of the object and encrypts it with the blowfish cipher using ERXCrypto.
protected  void excludeObjectFromPropertyWithKey(Object o, String key)
          Overridden to support two-way relationship setting.
 void flushCaches()
          This is called when an object has had changes merged into it by the editing context.
 Object foreignKeyForRelationshipWithKey(String rel)
          Returns the foreign key for a given relationship.
 Logger getClassLog()
          This methods checks if we already have created an Logger for this class If not, one will be created, stored and returned on next request.
protected  void includeObjectIntoPropertyWithKey(Object o, String key)
          Overridden to support two-way relationship setting.
protected  void init(EOEditingContext ec)
          used for initialization stuff instead of awakeFromInsertion.
 boolean isDeletedEO()
          Determines if this object is a deleted object by checking to see if it is included in the deletedObjects array of the editing context or - if it's editing context is null - it already has a global id.
 boolean isNewEO()
          Deprecated. use ERXGenericRecord#isNewObject
 boolean isNewObject()
          Determines if this object is a new object and hasn't been saved to the database yet.
 EOEnterpriseObject localInstanceIn(EOEditingContext ec)
          Returns this EO in the supplied editing context.
 EOEnterpriseObject localInstanceOf(EOEnterpriseObject eo)
          Returns an EO in the same editing context as the caller.
 NSArray localInstancesOf(NSArray eos)
          Returns an array of EOs in the same editing context as the caller.
 void mightDelete()
          Called as part of the augmented transaction process.
 boolean parentObjectStoreIsObjectStoreCoordinator()
          Simple method that will return if the parent object store of this object's editing context is an instance of EOObjectStoreCoordinator.
 String primaryKey()
          Primary key of the object as a String.
 NSArray primaryKeyAttributeNames()
          Returns the names of all primary key attributes.
 NSDictionary primaryKeyDictionary(boolean inTransaction)
          Implementation of the interface ERXGeneratesPrimaryKeyInterface.
 String primaryKeyInTransaction()
          Calling this method will return the primary key of the given enterprise object or if one has not been assigned to it yet, then it will have the adaptor channel generate one for it, cache it and then use that primary key when it is saved to the database.
 Object rawPrimaryKey()
          Gives the raw primary key of the object.
 Object rawPrimaryKeyInTransaction()
          Calling this method will return the primary key of the given enterprise object or if one has not been assigned to it yet, then it will have the adaptor channel generate one for it, cache it and then use that primary key when it is saved to the database.
 ERXEnterpriseObject refetchObjectFromDBinEditingContext(EOEditingContext ec)
          Method that will make sure to fetch an eo from the Database and place it in the editingContext provided as an argument
 void removeObjectsFromBothSidesOfRelationshipWithKey(NSArray objects, String key)
          Removes a collection of objects to a given relationship by calling removeObjectFromBothSidesOfRelationshipWithKey for all objects in the collection.
 void removeObjectsFromPropertyWithKey(NSArray objects, String key)
          Removes a collection of objects to a given relationship by calling removeObjectFromPropertyWithKey for all objects in the collection.
 ERXEnterpriseObject self()
          self is usefull for directtoweb purposes
static boolean shouldTrimSpaces()
           
 void takeStoredValueForKey(Object value, String key)
           
 void takeValueForKey(Object value, String key)
           
 String toLongString()
          Returns the super classes implementation of toString which prints out the current key-value pairs for all of the attributes and relationships for the current object.
 String toString()
          Overrides the EOGenericRecord's implementation to provide a slightly less verbose output.
 void trimSpaces()
          This method will trim the leading and trailing white space from any attributes that are mapped to a String object.
static boolean usesDeferredFaultCreation()
           
 void validateForDelete()
          Calls up validateForUpdate() on the class description if it supports it.
 void validateForInsert()
          Calls up validateForInsert() on the class description if it supports it.
 void validateForSave()
          This method performs a few checks before invoking super's implementation.
 void validateForUpdate()
          Calls up validateForUpdate() on the class description if it supports it.
 Object validateValueForKey(Object value, String key)
          Overrides the default validation mechanisms to provide a few checks before invoking super's implementation, which incidently just invokes validateValueForKey on the object's class description.
 void willDelete()
          Called as part of the augmented transaction process.
 void willInsert()
          Called as part of the augmented transaction process.
 void willRevert()
          Called on the object before it will be reverted.
 void willUpdate()
          Called as part of the augmented transaction process.
 
Methods inherited from class com.webobjects.eocontrol.EOCustomObject
__classDescription, __clearPendingChanges, __editingContext, __globalID, __hasAuxillaryObservers, __hasPendingChanges, __hasPendingUpdate, __isInitialized, __isPendingDeletion, __isPendingInsertion, __isShared, __lastSnapshot, __originalSnapshot, __retainCount, __setAuxillaryObservers, __setClassDescription, __setEditingContext, __setGlobalID, __setInitialized, __setLastSnapshot, __setOriginalSnapshot, __setPendingDeletion, __setPendingInsertion, __setPendingUpdate, __setRetainCount, __setShared, _createKeyGetBindingForKey, _createKeySetBindingForKey, _createStoredKeyGetBindingForKey, _createStoredKeySetBindingForKey, _fieldKeyBinding, _forwardingBindingNeededForClass, _keyGetBindingForKey, _keySetBindingForKey, _methodKeyGetBinding, _methodKeySetBinding, _otherStorageBinding, _storedKeyGetBindingForKey, _storedKeySetBindingForKey, addObjectToPropertyWithKey, allPropertyKeys, attributeKeys, canAccessFieldsDirectly, changesFromSnapshot, classDescription, classDescriptionForDestinationKey, clearFault, clearProperties, deleteRuleForRelationshipKey, editingContext, entityName, eoDescription, eoShallowDescription, equals, faultHandler, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hashCode, inverseForRelationshipKey, invokeRemoteMethod, isFault, isReadOnly, isToManyKey, opaqueState, ownsDestinationObjectsForRelationshipKey, prepareValuesForClient, propagateDeleteWithEditingContext, readResolve, reapplyChangesFromDictionary, removeObjectFromBothSidesOfRelationshipWithKey, removeObjectFromPropertyWithKey, shouldUseStoredAccessors, snapshot, storedValueForKey, takeValueForKeyPath, takeValuesFromDictionary, takeValuesFromDictionaryWithMapping, toManyRelationshipKeys, toOneRelationshipKeys, turnIntoFault, unableToSetNullForKey, updateFromSnapshot, userPresentableDescription, validateClientUpdate, validateTakeValueForKeyPath, valueForKey, valueForKeyPath, valuesForKeys, valuesForKeysWithMapping, willChange, willRead, willReadRelationship
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.webobjects.eocontrol.EOEnterpriseObject
allPropertyKeys, attributeKeys, changesFromSnapshot, classDescription, classDescriptionForDestinationKey, clearProperties, deleteRuleForRelationshipKey, editingContext, entityName, eoDescription, eoShallowDescription, inverseForRelationshipKey, invokeRemoteMethod, isReadOnly, isToManyKey, opaqueState, ownsDestinationObjectsForRelationshipKey, prepareValuesForClient, propagateDeleteWithEditingContext, reapplyChangesFromDictionary, snapshot, toManyRelationshipKeys, toOneRelationshipKeys, updateFromSnapshot, userPresentableDescription, willChange
 
Methods inherited from interface com.webobjects.eocontrol.EOKeyValueCodingAdditions
takeValuesFromDictionary, takeValuesFromDictionaryWithMapping, valuesForKeys, valuesForKeysWithMapping
 
Methods inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
takeValueForKeyPath, valueForKeyPath
 
Methods inherited from interface com.webobjects.foundation.NSKeyValueCoding
valueForKey
 
Methods inherited from interface com.webobjects.eocontrol.EOKeyValueCoding
storedValueForKey
 
Methods inherited from interface com.webobjects.foundation.NSKeyValueCoding
valueForKey
 
Methods inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
handleQueryWithUnboundKey, handleTakeValueForUnboundKey, unableToSetNullForKey
 
Methods inherited from interface com.webobjects.eocontrol.EORelationshipManipulation
addObjectToPropertyWithKey, removeObjectFromBothSidesOfRelationshipWithKey, removeObjectFromPropertyWithKey
 
Methods inherited from interface com.webobjects.eocontrol.EOValidation
validateClientUpdate
 
Methods inherited from interface com.webobjects.foundation.NSValidation
validateTakeValueForKeyPath
 
Methods inherited from interface com.webobjects.eocontrol.EODeferredFaulting
willReadRelationship
 
Methods inherited from interface com.webobjects.eocontrol.EOFaulting
clearFault, faultHandler, isFault, turnIntoFault, willRead
 

Field Detail

insertionStackTrace

public String insertionStackTrace

wasInitialized

protected boolean wasInitialized

_primaryKey

protected String _primaryKey
Constructor Detail

ERXCustomObject

public ERXCustomObject()
Method Detail

shouldTrimSpaces

public static boolean shouldTrimSpaces()

_setUpdateInverseRelationships

public boolean _setUpdateInverseRelationships(boolean newValue)
Description copied from interface: ERXEnterpriseObject
Toggles whether or not inverse relationships should be updates. This is called by ERXGenericRecord.InverseRelationshipUpdater to prevent infinite loops and should not be called by anything else unless you know exactly what you are doing.

Specified by:
_setUpdateInverseRelationships in interface ERXEnterpriseObject
Parameters:
newValue - whether or not inverse relationships should be updated
Returns:
the previous setting of the updateInverseRelationships setting

getClassLog

public Logger getClassLog()
Description copied from interface: ERXEnterpriseObject
This methods checks if we already have created an Logger for this class If not, one will be created, stored and returned on next request. This method eliminates individual static variables for Logger's in all subclasses. We use an NSDictionary here because static fields are class specific and thus something like lazy initialization would not work in this case.

Specified by:
getClassLog in interface ERXEnterpriseObject
Returns:
an Logger for this objects class

self

public ERXEnterpriseObject self()
Description copied from interface: ERXEnterpriseObject
self is usefull for directtoweb purposes

Specified by:
self in interface ERXEnterpriseObject

canDelete

public boolean canDelete()
Implementation of ERXGuardedObjectInterface. This is checked before the object is deleted in the willDelete method which is in turn called by ERXEditingContextDelegate. The default implementation returns true.

Specified by:
canDelete in interface ERXGuardedObjectInterface
Returns:
true

canUpdate

public boolean canUpdate()
Implementation of ERXGuardedObjectInterface. This is checked before the object is deleted in the willUpdate method which is in turn called by ERXEditingContextDelegate. The default implementation returns true.

Specified by:
canUpdate in interface ERXGuardedObjectInterface
Returns:
true

delete

public void delete()
Implementation of ERXGuardedObjectInterface. This is used to work around a bug in EOF that doesn't refresh the relationship in the parent editingContext for the object.

Specified by:
delete in interface ERXGuardedObjectInterface

mightDelete

public void mightDelete()
Description copied from interface: ERXEnterpriseObject
Called as part of the augmented transaction process. This method is called when deleteObject() is called on the editing context. The benefit over willDelete() is that in this method, the relationships are still intact. Mostly, at least, as it's also called when the deletes cascade.

Specified by:
mightDelete in interface ERXEnterpriseObject

willDelete

public void willDelete()
                throws NSValidation.ValidationException
Description copied from interface: ERXEnterpriseObject
Called as part of the augmented transaction process. This method is called after saveChanges is called on the editing context, but before the object is actually deleted from the database. This method is also called before validateForDelete is called on this object. This method is called by the editing context delegate ERXDefaultEditingContextDelegate.

Specified by:
willDelete in interface ERXEnterpriseObject
Throws:
NSValidation.ValidationException - to stop the object from being deleted.

willInsert

public void willInsert()
Description copied from interface: ERXEnterpriseObject
Called as part of the augmented transaction process. This method is called after saveChanges is called on the editing context, but before the object is actually inserted into the database. This method is also called before validateForInsert is called on this object. This method is called by the editing context delegate ERXDefaultEditingContextDelegate.

Specified by:
willInsert in interface ERXEnterpriseObject

willUpdate

public void willUpdate()
Description copied from interface: ERXEnterpriseObject
Called as part of the augmented transaction process. This method is called after saveChanges is called on the editing context, but before the object is actually updated in the database. This method is also called before validateForSave is called on this object. This method is called by the editing context delegate ERXDefaultEditingContextDelegate.

Specified by:
willUpdate in interface ERXEnterpriseObject

flushCaches

public void flushCaches()
Description copied from interface: ERXEnterpriseObject
This is called when an object has had changes merged into it by the editing context. This is called by ERXDefaultEditingContextDelegate after it merges changes. Any caches that an object keeps based on any of it's values it should flush. The default implementation of this method does nothing.

Specified by:
flushCaches