Project Wonder 2.0

er.extensions
Class ERXGenericRecord

java.lang.Object
  extended bycom.webobjects.eocontrol.EOCustomObject
      extended bycom.webobjects.eocontrol.EOGenericRecord
          extended byer.extensions.ERXGenericRecord
All Implemented Interfaces:
_EOPrivateMemento, EODeferredFaulting, EOEnterpriseObject, EOFaulting, EOKeyValueCoding, EOKeyValueCoding._BestBindingCreation._ForwardingBindingCheck, EOKeyValueCoding._KeyBindingCreation, EOKeyValueCodingAdditions, EORelationshipManipulation, EOValidation, ERXGeneratesPrimaryKeyInterface, ERXGuardedObjectInterface, NSKeyValueCoding, NSKeyValueCoding._KeyBindingCreation, NSKeyValueCoding._ReflectionKeyBindingCreation.Callback, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, NSValidation, Serializable
Direct Known Subclasses:
_ERCLogEntry, _ERCMailState, _ERCMessageAttachment, _ERCPreference, _ERCStatic, ERCStampedEnterpriseObject

public class ERXGenericRecord
extends EOGenericRecord
implements ERXGuardedObjectInterface, ERXGeneratesPrimaryKeyInterface

This class contains a bunch of extensions to the regular EOGenericRecord 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.

See Also:
Serialized Form

Nested Class Summary
static class ERXGenericRecord.ERXGenericRecordClazz
          Clazz object implementation for ERXGenericRecord.
 
Nested classes inherited from class com.webobjects.eocontrol.EOGenericRecord
EOGenericRecord._DictionaryBinding, EOGenericRecord._LazyDictionaryBinding
 
Nested classes inherited from class com.webobjects.eocontrol.EOCustomObject
EOCustomObject._BooleanFieldBinding, EOCustomObject._FieldBinding, EOCustomObject._LazyFieldBinding, EOCustomObject._NumberFieldBinding
 
Nested classes inherited from class com.webobjects.eocontrol.EOKeyValueCodingAdditions
EOKeyValueCodingAdditions.DefaultImplementation, EOKeyValueCodingAdditions.Utility
 
Nested classes inherited from class com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding._BooleanMethodBinding, NSKeyValueCoding._ForwardingBinding, NSKeyValueCoding._KeyBinding, NSKeyValueCoding._KeyBindingCreation, NSKeyValueCoding._MethodBinding, NSKeyValueCoding._NumberMethodBinding, NSKeyValueCoding._ReflectionKeyBindingCreation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor
 
Nested classes inherited from class com.webobjects.eocontrol.EOKeyValueCoding
EOKeyValueCoding._BestBindingCreation, EOKeyValueCoding._KeyBindingCreation, EOKeyValueCoding._StoredForwardingBinding
 
Nested classes inherited from class com.webobjects.foundation.NSValidation
NSValidation._MethodBinding, NSValidation._ValidationBinding, NSValidation.DefaultImplementation, NSValidation.Utility, NSValidation.ValidationException
 
Nested classes inherited from class com.webobjects.eocontrol._EOPrivateMemento
_EOPrivateMemento.DefaultImplementation
 
Field Summary
static NSMutableDictionary classLogs
          holds all subclass related ERXLogger's
 String insertionStackTrace
           
static ERXLogger insertionTrackingLog
          logging support for insertion tracking
static String KEY_MARKER
           
static Object lock
           
static ERXLogger log
          general logging support
static ERXLogger tranLogDidDelete
          logging support.
static ERXLogger tranLogDidInsert
          logging support.
static ERXLogger tranLogDidUpdate
          logging support.
static ERXLogger tranLogWillDelete
          logging support.
static ERXLogger tranLogWillInsert
          logging support.
static ERXLogger tranLogWillUpdate
          logging support.
static ERXLogger validation
          logging support for validation information
static ERXLogger validationException
          logging support for validation exceptions
 
Fields inherited from class com.webobjects.eocontrol.EOGenericRecord
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Constructor Summary
ERXGenericRecord()
           
 
Method Summary
 boolean _checkEditingContextDelegate(EOEditingContext editingContext)
          By default, and this should change in the future, all editing contexts that are created and use ERXGenericRecords or subclasses need to have a delegate set of instance ERXEditingContextDelegate.
 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 similiar 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.
static void didSave(NSNotification n)
          Called by an observer after an editing context has successfully saved changes to a database.
 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.
 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.
 ERXLogger getClassLog()
          This methods checks if we already have created an ERXLogger for this class If not, one will be created, stored and returned on next request.
 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.
 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 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.
 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()
           
 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 asigned 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.
 ERXGenericRecord 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.
 ERXGenericRecord self()
          self is usefull for directtoweb purposes
static boolean shouldTrimSpaces()
           
 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.
 void validateForDelete()
          This method uses Validity if the property key er.extensions.ERXGenericRecord.useValidity is set to true
 void validateForInsert()
          This method uses Validity if the property key er.extensions.ERXGenericRecord.useValidity is set to true
 void validateForSave()
          This method performs a few checks before invoking super's implementation.
 void validateForUpdate()
          This method uses Validity if the property key er.extensions.ERXGenericRecord.useValidity is set to true
 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 willUpdate()
          Called as part of the augmented transaction process.
 
Methods inherited from class com.webobjects.eocontrol.EOGenericRecord
__setClassDescription, _keyGetBindingForKey, _keySetBindingForKey, _otherStorageBinding, _storedKeyGetBindingForKey, _storedKeySetBindingForKey, classDescription, usesDeferredFaultCreation
 
Methods inherited from class com.webobjects.eocontrol.EOCustomObject
__classDescription, __clearPendingChanges, __editingContext, __globalID, __hasAuxillaryObservers, __hasPendingChanges, __hasPendingUpdate, __isInitialized, __isPendingDeletion, __isPendingInsertion, __isShared, __lastSnapshot, __originalSnapshot, __retainCount, __setAuxillaryObservers, __setEditingContext, __setGlobalID, __setInitialized, __setLastSnapshot, __setOriginalSnapshot, __setPendingDeletion, __setPendingInsertion, __setPendingUpdate, __setRetainCount, __setShared, _createKeyGetBindingForKey, _createKeySetBindingForKey, _createStoredKeyGetBindingForKey, _createStoredKeySetBindingForKey, _fieldKeyBinding, _forwardingBindingNeededForClass, _methodKeyGetBinding, _methodKeySetBinding, addObjectToPropertyWithKey, allPropertyKeys, attributeKeys, canAccessFieldsDirectly, changesFromSnapshot, classDescriptionForDestinationKey, clearFault, clearProperties, deleteRuleForRelationshipKey, editingContext, entityName, eoDescription, eoShallowDescription, equals, excludeObjectFromPropertyWithKey, faultHandler, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hashCode, includeObjectIntoPropertyWithKey, inverseForRelationshipKey, invokeRemoteMethod, isFault, isToManyKey, opaqueState, ownsDestinationObjectsForRelationshipKey, prepareValuesForClient, propagateDeleteWithEditingContext, readResolve, reapplyChangesFromDictionary, removeObjectFromBothSidesOfRelationshipWithKey, removeObjectFromPropertyWithKey, shouldUseStoredAccessors, snapshot, storedValueForKey, takeStoredValueForKey, takeValueForKey, 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
 

Field Detail

tranLogDidInsert

public static final ERXLogger tranLogDidInsert
logging support. Called after an object is successfully inserted


tranLogDidDelete

public static final ERXLogger tranLogDidDelete
logging support. Called after an object is successfully deleted


tranLogDidUpdate

public static final ERXLogger tranLogDidUpdate
logging support. Called after an object is successfully updated


tranLogWillInsert

public static final ERXLogger tranLogWillInsert
logging support. Called before an object is inserted


tranLogWillDelete

public static final ERXLogger tranLogWillDelete
logging support. Called before an object is deleted


tranLogWillUpdate

public static final ERXLogger tranLogWillUpdate
logging support. Called before an object is updated


validation

public static final ERXLogger validation
logging support for validation information


validationException

public static final ERXLogger validationException
logging support for validation exceptions


insertionTrackingLog

public static final ERXLogger insertionTrackingLog
logging support for insertion tracking


log

public static final ERXLogger log
general logging support


classLogs

public static NSMutableDictionary classLogs
holds all subclass related ERXLogger's


lock

public static final Object lock

KEY_MARKER

public static final String KEY_MARKER
See Also:
Constant Field Values

insertionStackTrace

public String insertionStackTrace
Constructor Detail

ERXGenericRecord

public ERXGenericRecord()
Method Detail

shouldTrimSpaces

public static boolean shouldTrimSpaces()

getClassLog

public ERXLogger getClassLog()
This methods checks if we already have created an ERXLogger for this class If not, one will be created, stored and returned on next request. This method eliminates individual static variables for ERXLogger'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.

Returns:
an ERXLogger for this objects class

self

public ERXGenericRecord self()
self is usefull for directtoweb purposes


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

willDelete

public void willDelete()
                throws NSValidation.ValidationException
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.

Throws:
NSValidation.ValidationException - to stop the object from being deleted.

willInsert

public void willInsert()
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.


willUpdate

public void willUpdate()
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.


flushCaches

public void flushCaches()
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.


didDelete

public void didDelete(EOEditingContext ec)
Called on the object after is has been deleted. The editing context is passed to the object since by this point the editingContext of the object is null. You should check if the ec is a child context when doing something here that can't be undone.

Parameters:
ec - editing context that used to be associated with the object.

didUpdate

public void didUpdate()
Called on the object after is has successfully been updated in the database.


didInsert

public void didInsert()
Called on the object after is has successfully been inserted into the database.


addObjectsToBothSidesOfRelationshipWithKey

public void addObjectsToBothSidesOfRelationshipWithKey(NSArray objects,
                                                       String key)
Adds a collection of objects to a given relationship by calling addObjectToBothSidesOfRelationshipWithKey for all objects in the collection.

Parameters:
objects - objects to add to both sides of the given relationship
key - relationship key

removeObjectsFromBothSidesOfRelationshipWithKey

public void removeObjectsFromBothSidesOfRelationshipWithKey(NSArray objects,
                                                            String key)
Removes a collection of objects to a given relationship by calling removeObjectFromBothSidesOfRelationshipWithKey for all objects in the collection.

Parameters:
objects - objects to be removed from both sides of the given relationship
key - relationship key

removeObjectsFromPropertyWithKey

public void removeObjectsFromPropertyWithKey(NSArray objects,
                                             String key)
Removes a collection of objects to a given relationship by calling removeObjectFromPropertyWithKey for all objects in the collection.

Parameters:
objects - objects to be removed from both sides of the given relationship
key - relationship key

_checkEditingContextDelegate

public boolean _checkEditingContextDelegate(EOEditingContext editingContext)
By default, and this should change in the future, all editing contexts that are created and use ERXGenericRecords or subclasses need to have a delegate set of instance ERXEditingContextDelegate. These delegates provide the augmentation to the regular transaction mechanism, all of the will* methods plus the flushCaching method. To change the default behaviour set the property: er.extensions.ERXRaiseOnMissingEditingContextDelegate to false in your WebObjects.properties file. This method is called when an object is fetched, updated or inserted.

Parameters:
editingContext - to check for the correct delegate.
Returns:
if the editing context has the correct delegate set.

awakeFromClientUpdate

public void awakeFromClientUpdate(EOEditingContext editingContext)
Checks the editing context delegate before calling super's implementation. See the method _checkEditingContextDelegate for an explanation as to what this check does.

Specified by:
awakeFromClientUpdate in interface EOEnterpriseObject
Parameters:
editingContext - to be checked to make sure it has the correct type of delegate set.

awakeFromInsertion

public void awakeFromInsertion(EOEditingContext editingContext)
Checks the editing context delegate before calling super's implementation. See the method _checkEditingContextDelegate for an explanation as to what this check does.

Specified by:
awakeFromInsertion in interface EOEnterpriseObject
Parameters:
editingContext - to be checked to make sure it has the correct type of delegate set.

awakeFromFetch

public void awakeFromFetch(EOEditingContext editingContext)
Checks the editing context delegate before calling super's implementation. See the method _checkEditingContextDelegate for an explanation as to what this check does.

Specified by:
awakeFromFetch in interface EOEnterpriseObject
Parameters:
editingContext - to be checked to make sure it has the correct type of delegate set.

addObjectToBothSidesOfRelationshipWithKey

public 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. If not then a runtime exception is thrown instead of getting the somewhat cryptic NSInternalInconsistency excpetion that is thrown when you attempt to save changes to the database.

Specified by:
addObjectToBothSidesOfRelationshipWithKey in interface EORelationshipManipulation
Parameters:
eo - enterprise object to be added to the relationship
key - relationship to add the object to.

primaryKey

public String primaryKey()
Primary key of the object as a String.

Returns:
primary key for the given object as a String

rawPrimaryKeyInTransaction

public Object rawPrimaryKeyInTransaction()
Calling this method will return the primary key of the given enterprise object or if one has not been asigned 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. If you just want the primary key of the object or null if it doesn't have one yet, use the method rawPrimaryKey.

Returns:
the primary key of this object.

primaryKeyInTransaction

public 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. This method returns the string representation of the primary key. If you just want the primary key of the object or null if it doesn't have one yet, use the method primaryKey.

Returns:
string representation of the primary key of this object.

rawPrimaryKey

public Object rawPrimaryKey()
Gives the raw primary key of the object. This could be anything from an NSData to a BigDecimal.

Returns:
the raw primary key of this object.

encryptedPrimaryKey

public String encryptedPrimaryKey()
Takes the primary key of the object and encrypts it with the blowfish cipher using ERXCrypto.

Returns:
blowfish encrypted primary key

foreignKeyForRelationshipWithKey

public Object foreignKeyForRelationshipWithKey(String rel)
Returns the foreign key for a given relationship.

Parameters:
rel - relationship key
Returns:
foreign key for a given relationship.

primaryKeyAttributeNames

public NSArray primaryKeyAttributeNames()

primaryKeyDictionary

public NSDictionary primaryKeyDictionary(boolean inTransaction)
Implementation of the interface ERXGeneratesPrimaryKeyInterface. This implementation operates in the following fashion. If it is called passing in 'false' and it has not yet been saved to the database, meaning this object does not yet have a primary key assigned, then it will have the adaptor channel generate a primary key for it. Then when the object is saved to the database it will use the previously generated primary key instead of having the adaptor channel generate another primary key. If 'true' is passed in then this method will either return the previously generated primaryKey dictionary or null if it does not have one. Typically you should only call this method with the 'false' parameter seeing as unless you are doing something really funky you won't be dealing with this object when it is in the middle of a transaction. The delegate ERXDatabaseContextDelegate is the only class that should be calling this method and passing in 'true'.

Specified by:
primaryKeyDictionary in interface ERXGeneratesPrimaryKeyInterface
Parameters:
inTransaction - boolean flag to tell the object if it is currently in the middle of a transaction.
Returns:
primary key dictionary for the current object, if the object does not have a primary key assigned yet and is not in the middle of a transaction then a new primary key dictionary is created, cached and returned.

committedSnapshotValueForKey

public Object committedSnapshotValueForKey(String key)
Determines what the value of the given key is in the committed snapshot

Parameters:
key - to be checked in committed snapshot
Returns:
the committed snapshot value for the given key

localInstanceOf

public EOEnterpriseObject localInstanceOf(EOEnterpriseObject eo)
Returns an EO in the same editing context as the caller.

Returns:
an EO in the same editing context as the caller.

localInstancesOf

public NSArray localInstancesOf(NSArray eos)
Returns an array of EOs in the same editing context as the caller.

Returns:
array of EOs in the same editing context as the caller.

changesFromCommittedSnapshot

public NSDictionary changesFromCommittedSnapshot()
Computes the current set of changes that this object has from the currently committed snapshot.

Returns:
a dictionary holding the changed values from the currently committed snapshot.

parentObjectStoreIsObjectStoreCoordinator

public boolean parentObjectStoreIsObjectStoreCoordinator()
Simple method that will return if the parent object store of this object's editing context is an instance of EOObjectStoreCoordinator. The reason this is important is because if this condition evaluates to true then when changes are saved in this editing context they will be propagated to the database.

Returns:
if the parent object store of this object's editing context is an EOObjectStoreCoordinator.

refetchObjectFromDBinEditingContext

public ERXGenericRecord 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

Returns:
a fresh instance of an EO fetched from the DB and placed in the editing context argument

toString

public String toString()
Overrides the EOGenericRecord's implementation to provide a slightly less verbose output. A typical output for an object mapped to the class com.foo.User with a primary key of 50 would look like: EOGenericRecord's implementation is preserved in the method toLongString. To restore the original verbose logging in your subclasses override this method and return toLongString.

Returns:
much less verbose description of an enterprise object.

description

public String description()
Cover method to return toString.

Returns:
the results of calling toString.

toLongString

public 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. Very verbose.

Returns:
super's implementation of toString.

trimSpaces

public void trimSpaces()
This method will trim the leading and trailing white space from any attributes that are mapped to a String object. This method is called before the object is saved to the database. Override this method to do nothing if you wish to preserve your leading and trailing white space.


isDeletedEO

public 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.

Note: An object that has just been created will also not have an editing context and by this method would test positive for being a deleted object.

Returns:
if the object is a deleted object

isNewEO

public boolean isNewEO()
Deprecated. use ERXGenericRecord#isNewObject


isNewObject

public boolean isNewObject()
Determines if this object is a new object and hasn't been saved to the database yet. This method just calls the method ERExtensions.isNewObject passing in this object as the current parameter. Note that an object that has been successfully deleted will also look as if it is a new object because it will have a null editingcontext.

Returns:
if the object is a new enterprise object.

didSave

public static void didSave(NSNotification n)
Called by an observer after an editing context has successfully saved changes to a database. This method enumerates through all of the objects that were inserted, updated and deleted calling didInsert, didUpdate and didDelete on the objects respectively.

Parameters:
n - notifcation posted after an editing context has successfully saved changes to the database.

validateValueForKey

public Object validateValueForKey(Object value,
                                  String key)
                           throws NSValidation.ValidationException
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. The class description for this object should be an ERXEntityClassDescription or subclass. It is that class that provides the hooks to convert model throw validation exceptions into ERXValidationException objects.

Specified by:
validateValueForKey in interface NSValidation
Parameters:
value - to be validated for a given attribute or relationship
key - corresponding to an attribute or relationship
Returns:
the validated value
Throws:
NSValidation.ValidationException - if the value fails validation

validateForSave

public void validateForSave()
                     throws NSValidation.ValidationException
This method performs a few checks before invoking super's implementation. If the property key: ERDebuggingEnabled is set to true then the method checkConsistency will be called on this object.

Specified by:
validateForSave in interface EOValidation
Throws:
NSValidation.ValidationException - if the object does not pass validation for saving to the database.

validateForInsert

public void validateForInsert()
                       throws NSValidation.ValidationException
This method uses Validity if the property key er.extensions.ERXGenericRecord.useValidity is set to true

Specified by:
validateForInsert in interface EOValidation
Throws:
NSValidation.ValidationException - if the object does not pass validation for saving to the database.

validateForUpdate

public void validateForUpdate()
                       throws NSValidation.ValidationException
This method uses Validity if the property key er.extensions.ERXGenericRecord.useValidity is set to true

Specified by:
validateForUpdate in interface EOValidation
Throws:
NSValidation.ValidationException - if the object does not pass validation for saving to the database.

validateForDelete

public void validateForDelete()
                       throws NSValidation.ValidationException
This method uses Validity if the property key er.extensions.ERXGenericRecord.useValidity is set to true

Specified by:
validateForDelete in interface EOValidation
Throws:
NSValidation.ValidationException - if the object does not pass validation for saving to the database.

checkConsistency

public void checkConsistency()
                      throws NSValidation.ValidationException
Debugging method that will be called on an object before it is saved to the database if the property key: ERDebuggingEnabled is enabled. This allows for adding in a bunch of expensive validation checks that should only be enabled in developement and testing environments.

Throws:
NSValidation.ValidationException - if the object is not consistent

batchCheckConsistency

public void batchCheckConsistency()
                           throws NSValidation.ValidationException
This method is very similiar 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. JUnit tests are great for testing that all of the methods of a single object function correctly, batch checking of consistency is a good way of checking that all of the data in a given database is consistent. Hopefully in the future we will add a batch check consistency application to demonstrate the use of this method.

Throws:
NSValidation.ValidationException - if the object fails consisntency

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.