|
Project Wonder 2.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eocontrol.EOCustomObject com.webobjects.eocontrol.EOGenericRecord er.extensions.ERXGenericRecord
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.
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.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 java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final ERXLogger tranLogDidInsert
public static final ERXLogger tranLogDidDelete
public static final ERXLogger tranLogDidUpdate
public static final ERXLogger tranLogWillInsert
public static final ERXLogger tranLogWillDelete
public static final ERXLogger tranLogWillUpdate
public static final ERXLogger validation
public static final ERXLogger validationException
public static final ERXLogger insertionTrackingLog
public static final ERXLogger log
public static NSMutableDictionary classLogs
public static final Object lock
public static final String KEY_MARKER
public String insertionStackTrace
Constructor Detail |
public ERXGenericRecord()
Method Detail |
public static boolean shouldTrimSpaces()
public ERXLogger getClassLog()
ERXLogger
for this objects classpublic ERXGenericRecord self()
public boolean canDelete()
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
.
canDelete
in interface ERXGuardedObjectInterface
public boolean canUpdate()
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
.
canUpdate
in interface ERXGuardedObjectInterface
public void delete()
ERXGuardedObjectInterface
.
This is used to work around a bug in EOF that doesn't refresh the relationship in the parent
editingContext for the object.
delete
in interface ERXGuardedObjectInterface
public void willDelete() throws NSValidation.ValidationException
validateForDelete
is called on this
object. This method is called by the editing context
delegate ERXDefaultEditingContextDelegate
.
NSValidation.ValidationException
- to stop the object
from being deleted.public void willInsert()
validateForInsert
is called on this
object. This method is called by the editing context
delegate ERXDefaultEditingContextDelegate
.
public void willUpdate()
validateForSave
is called on this
object. This method is called by the editing context
delegate ERXDefaultEditingContextDelegate
.
public void flushCaches()
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.
public void didDelete(EOEditingContext ec)
ec
is a child context when doing something here that
can't be undone.
ec
- editing context that used to be associated
with the object.public void didUpdate()
public void didInsert()
public void addObjectsToBothSidesOfRelationshipWithKey(NSArray objects, String key)
addObjectToBothSidesOfRelationshipWithKey
for all
objects in the collection.
objects
- objects to add to both sides of the given relationshipkey
- relationship keypublic void removeObjectsFromBothSidesOfRelationshipWithKey(NSArray objects, String key)
removeObjectFromBothSidesOfRelationshipWithKey
for all
objects in the collection.
objects
- objects to be removed from both sides of the given relationshipkey
- relationship keypublic void removeObjectsFromPropertyWithKey(NSArray objects, String key)
removeObjectFromPropertyWithKey
for all
objects in the collection.
objects
- objects to be removed from both sides of the given relationshipkey
- relationship keypublic boolean _checkEditingContextDelegate(EOEditingContext editingContext)
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.
editingContext
- to check for the correct delegate.
public void awakeFromClientUpdate(EOEditingContext editingContext)
_checkEditingContextDelegate
for an explanation
as to what this check does.
awakeFromClientUpdate
in interface EOEnterpriseObject
editingContext
- to be checked to make sure it has the
correct type of delegate set.public void awakeFromInsertion(EOEditingContext editingContext)
_checkEditingContextDelegate
for an explanation
as to what this check does.
awakeFromInsertion
in interface EOEnterpriseObject
editingContext
- to be checked to make sure it has the
correct type of delegate set.public void awakeFromFetch(EOEditingContext editingContext)
_checkEditingContextDelegate
for an explanation
as to what this check does.
awakeFromFetch
in interface EOEnterpriseObject
editingContext
- to be checked to make sure it has the
correct type of delegate set.public void addObjectToBothSidesOfRelationshipWithKey(EORelationshipManipulation eo, String key)
addObjectToBothSidesOfRelationshipWithKey
in interface EORelationshipManipulation
eo
- enterprise object to be added to the relationshipkey
- relationship to add the object to.public String primaryKey()
public Object rawPrimaryKeyInTransaction()
rawPrimaryKey
.
public String primaryKeyInTransaction()
primaryKey
.
public Object rawPrimaryKey()
public String encryptedPrimaryKey()
ERXCrypto
.
public Object foreignKeyForRelationshipWithKey(String rel)
rel
- relationship key
public NSArray primaryKeyAttributeNames()
public NSDictionary primaryKeyDictionary(boolean inTransaction)
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'.
primaryKeyDictionary
in interface ERXGeneratesPrimaryKeyInterface
inTransaction
- boolean flag to tell the object if it is currently in the
middle of a transaction.
public Object committedSnapshotValueForKey(String key)
key
- to be checked in committed snapshot
public EOEnterpriseObject localInstanceOf(EOEnterpriseObject eo)
public NSArray localInstancesOf(NSArray eos)
public NSDictionary changesFromCommittedSnapshot()
public boolean parentObjectStoreIsObjectStoreCoordinator()
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.
public ERXGenericRecord refetchObjectFromDBinEditingContext(EOEditingContext ec)
public String toString()
toLongString
. To restore the original
verbose logging in your subclasses override this method and
return toLongString.
public String description()
toString
.
public String toLongString()
toString
.public void trimSpaces()
public boolean isDeletedEO()
public boolean isNewEO()
ERXGenericRecord#isNewObject
public boolean isNewObject()
public static void didSave(NSNotification n)
didInsert
,
didUpdate
and didDelete
on the objects
respectively.
n
- notifcation posted after an editing context has
successfully saved changes to the database.public Object validateValueForKey(Object value, String key) throws NSValidation.ValidationException
ERXEntityClassDescription
or subclass.
It is that class that provides the hooks to convert model
throw validation exceptions into ERXValidationException
objects.
validateValueForKey
in interface NSValidation
value
- to be validated for a given attribute or relationshipkey
- corresponding to an attribute or relationship
NSValidation.ValidationException
- if the value fails validationpublic void validateForSave() throws NSValidation.ValidationException
checkConsistency
will be called on this object.
validateForSave
in interface EOValidation
NSValidation.ValidationException
- if the object does not
pass validation for saving to the database.public void validateForInsert() throws NSValidation.ValidationException
validateForInsert
in interface EOValidation
NSValidation.ValidationException
- if the object does not
pass validation for saving to the database.public void validateForUpdate() throws NSValidation.ValidationException
validateForUpdate
in interface EOValidation
NSValidation.ValidationException
- if the object does not
pass validation for saving to the database.public void validateForDelete() throws NSValidation.ValidationException
validateForDelete
in interface EOValidation
NSValidation.ValidationException
- if the object does not
pass validation for saving to the database.public void checkConsistency() throws NSValidation.ValidationException
NSValidation.ValidationException
- if the object is not consistentpublic void batchCheckConsistency() throws NSValidation.ValidationException
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.
NSValidation.ValidationException
- if the object fails consisntency
|
Last updated: Do, Dez 9, 2004 12:46 PM CET | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |