ERXGenericRecord Class Reference

Inherits com::webobjects::eocontrol::EOGenericRecord, er::extensions::eof::ERXGuardedObjectInterface, er::extensions::eof::ERXGeneratesPrimaryKeyInterface, er::extensions::eof::ERXEnterpriseObject, er::extensions::eof::ERXDatabaseContextDelegate::AutoBatchFaultingEnterpriseObject, and er::extensions::eof::ERXNonNullObjectInterface.

Inherited by _Company, _Employee, _ERAttachment, _ERAttachmentData, _Bug, _Comment, _Component, _Difficulty, _Framework, _People, _Priority, _Release, _RequirementSubType, _RequirementType, _TestItem, _TestItemState, _ERCHelpText, _ERCLogEntry, _ERCMailMessage, _ERCMessageAttachment, _ERCPreference, _ERCStatic, _ERCAuditBlob, _ERCAuditTrail, _ERCAuditTrailEntry, ERCStampedEnterpriseObject, _Company, _Employee, _Paycheck, _Role, ERXPartialGenericRecord, _ERIAttribute, _ERIAttributeGroup, _ERIAttributeType, _ERIValidationRule, _Asset, _AssetGroup, _Tag, _ERIDirectory, _ERIFile, _ERIFileContent, _Animal, _Company, _Person, _ServerForum, _ServerPost, _ServerTopic, _ServerUser, _ERTag, _Company, _Employee, Record, _Forum, _Post, _Topic, _User, _Movie, _MovieRole, _PlotSummary, _Review, _Talent, _TalentPhoto, _Voting, Studio, and _Studio.

Collaboration diagram for ERXGenericRecord:

Collaboration graph
[legend]

List of all members.

Classes

class  ERXGenericRecordClazz< T extends EOEnterpriseObject >
class  InverseRelationshipUpdater
class  LocalizedBinding
class  TouchingBinding

Public Member Functions

NSKeyValueCoding._KeyBinding _otherStorageBinding (String key)
void _setPrimaryKeyDictionary (NSDictionary< String, Object > pkDict)
boolean _setUpdateInverseRelationships (boolean newValue)
void _setValueForPrimaryKey (Object value, String pkAttributeName)
void addObjectsToBothSidesOfRelationshipWithKey (NSArray objects, String key)
void addObjectToBothSidesOfRelationshipWithKey (EORelationshipManipulation eo, String key)
void awakeFromClientUpdate (EOEditingContext editingContext)
void awakeFromFetch (EOEditingContext editingContext)
void awakeFromInsertion (EOEditingContext editingContext)
void batchCheckConsistency () throws NSValidation.ValidationException
String batchFaultingRelationshipName ()
EOGlobalID batchFaultingSourceGlobalID ()
long batchFaultingTimeStamp ()
boolean canDelete ()
boolean canUpdate ()
NSDictionary changesFromCommittedSnapshot ()
void checkConsistency () throws NSValidation.ValidationException
void clearProperties ()
NSDictionary committedSnapshot ()
Object committedSnapshotValueForKey (String key)
void delete ()
String description ()
void didCopyFromChildInEditingContext (ERXGenericRecord originalEO, EOEditingContext childEditingContext)
void didDelete (EOEditingContext ec)
void didInsert ()
void didRevert (EOEditingContext ec)
void didUpdate ()
String encryptedPrimaryKey ()
EOEntity entity ()
 ERXGenericRecord ()
 ERXGenericRecord (EOClassDescription classDescription)
void excludeObjectFromPropertyWithKey (Object o, String key)
void flushCaches ()
Object foreignKeyForRelationshipWithKey (String rel)
Logger getClassLog ()
boolean hasKeyChangedFromCommittedSnapshot (String key)
boolean hasKeyChangedFromCommittedSnapshotFromValue (String key, Object oldValue)
boolean hasKeyChangedFromCommittedSnapshotFromValueToNewValue (String key, Object oldValue, Object newValue)
boolean hasKeyChangedFromCommittedSnapshotToValue (String key, Object newValue)
void includeObjectIntoPropertyWithKey (Object o, String key)
boolean isDeletedEO ()
boolean isNewEO ()
boolean isNewObject ()
final Boolean isNonNull ()
boolean isUpdatedObject ()
boolean isValidatedWhenNested ()
NSArray< StringlocalesForKey (String key)
EOEnterpriseObject localInstanceIn (EOEditingContext ec)
EOEnterpriseObject localInstanceOf (EOEnterpriseObject eo)
NSArray localInstancesOf (NSArray eos)
void mightDelete ()
boolean parentObjectStoreIsObjectStoreCoordinator ()
EOKeyGlobalID permanentGlobalID ()
EOKeyGlobalID permanentGlobalID (boolean generateIfMissing)
String primaryKey ()
NSArray< StringprimaryKeyAttributeNames ()
NSDictionary< String, Object > primaryKeyDictionary (boolean inTransaction)
String primaryKeyInTransaction ()
Object rawPrimaryKey ()
Object rawPrimaryKeyInTransaction ()
ERXEnterpriseObject refetchObjectFromDB ()
ERXEnterpriseObject refetchObjectFromDBinEditingContext (EOEditingContext ec)
void removeObjectsFromBothSidesOfRelationshipWithKey (NSArray objects, String key)
void removeObjectsFromPropertyWithKey (NSArray objects, String key)
ERXEnterpriseObject self ()
void setBatchFaultingTimestamp (long timestamp)
void setValidatedWhenNested (boolean validatedWhenNested)
void takeStoredValueForKey (Object value, String key)
void takeValueForKey (Object value, String key)
final< T > void takeValueForKey (Object value, ERXKey< T > key)
String toLongString ()
String toString ()
void touchFromBatchFaultingSource (AutoBatchFaultingEnterpriseObject toucher, String key)
void trimSpaces ()
void updateFromSnapshot (NSDictionary snapshot)
void validateForInsert () throws NSValidation.ValidationException
void validateForSave () throws NSValidation.ValidationException
void validateForUpdate () throws NSValidation.ValidationException
Object validateValueForKey (Object value, String key) throws NSValidation.ValidationException
final< T > T valueForKey (ERXKey< T > key)
void willDelete () throws NSValidation.ValidationException
void willInsert ()
Object willReadRelationship (Object aObject)
void willRevert ()
void willUpdate ()

Static Public Member Functions

static void checkMatchingEditingContexts (EOEnterpriseObject source, String relationshipName, EOEnterpriseObject destination)
static boolean localizationShouldFallbackToDefaultLanguage ()
static boolean shouldTrimSpaces ()

Public Attributes

EOGlobalID _touchSource

Protected Member Functions

boolean _updateInverseRelationships ()
Object _validateValueForKey (Object value, String key) throws NSValidation.ValidationException
boolean applyRestrictingQualifierOnInsert ()
void init (EOEditingContext ec)

Protected Attributes

String _primaryKey = null
String insertionStackTrace = null

Private Member Functions

boolean _checkEditingContextDelegate (EOEditingContext editingContext)
String localizedKey (String key)

Private Attributes

long _fetchTime
EOKeyGlobalID _permanentGlobalID
NSDictionary _primaryKeyDictionary
String _touchKey
boolean _updateInverseRelationships = ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships
boolean _validatedWhenNested = true

Static Private Attributes

static final
NSMutableDictionary< Class,
Logger > 
classLogs = new NSMutableDictionary<Class, Logger>()


Detailed Description

This class contains a bunch of extensions to the regular EOGenericRecord class. Of notable interest is: 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.
If you *do* call addToBars(), you need to use includeObjectIntoPropertyWithKey() in this method.
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.

Constructor & Destructor Documentation

ERXGenericRecord ( EOClassDescription  classDescription  ) 


Member Function Documentation

boolean _checkEditingContextDelegate ( EOEditingContext  editingContext  )  [private]

By default, and this should change in the future, all editing contexts that are created and use ERXEnterpriseObjects 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.

NSKeyValueCoding._KeyBinding _otherStorageBinding ( String  key  ) 

void _setPrimaryKeyDictionary ( NSDictionary< String, Object >  pkDict  ) 

Sets the primary key dictionary for this EO (key = attribute name, value = pk value). This should only be called on uncommitted objects.

Parameters:
pkDict the new primary key dictionary

boolean _setUpdateInverseRelationships ( boolean  newValue  )  [virtual]

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.

Parameters:
newValue whether or not inverse relationships should be updated
Returns:
the previous setting of the updateInverseRelationships setting

Implements ERXEnterpriseObject.

void _setValueForPrimaryKey ( Object  value,
String  pkAttributeName 
)

Sets the value for the primary key attribute with the given name. This should only be called on uncommitted objects.

Parameters:
value the pk value
pkAttributeName the pk attribute name

boolean _updateInverseRelationships (  )  [protected]

Object _validateValueForKey ( Object  value,
String  key 
) throws NSValidation.ValidationException [protected]

Reimplemented in ERXPartialGenericRecord.

void addObjectsToBothSidesOfRelationshipWithKey ( NSArray  objects,
String  key 
) [virtual]

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

Implements ERXEnterpriseObject.

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.

Parameters:
eo enterprise object to be added to the relationship
key relationship to add the object to.

boolean applyRestrictingQualifierOnInsert (  )  [protected]

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.

Parameters:
editingContext to be checked to make sure it has the correct type of delegate set.

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.

Parameters:
editingContext to be checked to make sure it has the correct type of delegate set.

Reimplemented in ERXPartialGenericRecord.

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.

Parameters:
editingContext to be checked to make sure it has the correct type of delegate set.

Reimplemented in ERDatabaseAttachment, ERFileAttachment, ERS3Attachment, MovieRole, Studio, and ERXPartialGenericRecord.

void batchCheckConsistency (  )  throws NSValidation.ValidationException [virtual]

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

Exceptions:
NSValidation.ValidationException if the object fails consistency

Implements ERXEnterpriseObject.

String batchFaultingRelationshipName (  ) 

The key that touched us

Returns:
relationship name

Implements ERXDatabaseContextDelegate.AutoBatchFaultingEnterpriseObject.

EOGlobalID batchFaultingSourceGlobalID (  ) 

The source EO that touched us

Returns:
gid of the source

Implements ERXDatabaseContextDelegate.AutoBatchFaultingEnterpriseObject.

long batchFaultingTimeStamp (  ) 

The fetch time for this object

Returns:
fetch time

Implements ERXDatabaseContextDelegate.AutoBatchFaultingEnterpriseObject.

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.

Returns:
true

Implements ERXGuardedObjectInterface.

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.

Returns:
true

Implements ERXGuardedObjectInterface.

NSDictionary changesFromCommittedSnapshot (  )  [virtual]

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.

Implements ERXEnterpriseObject.

void checkConsistency (  )  throws NSValidation.ValidationException [virtual]

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 development and testing environments.

Exceptions:
NSValidation.ValidationException if the object is not consistent

Implements ERXEnterpriseObject.

static void checkMatchingEditingContexts ( EOEnterpriseObject  source,
String  relationshipName,
EOEnterpriseObject  destination 
) [static]

Checks that the editing contexts in source and destination matches and throws an exception if they do not.

Parameters:
source the source object
relationshipName the name of the relationship that is being updated
destination the destination object
Exceptions:
RuntimeException if the editing contexts do not match

void clearProperties (  ) 

NSDictionary committedSnapshot (  ) 

This method exists because EOEditingContext.committedSnapshotForObject() gives unexpected results for newly inserted objects if EOEditingContext.processRecentChanges() has been called. This method always returns a dictionary whose values are all NSKeyValueCoding.NullValue in the case of a newly inserted object.

Returns:
the committed snapshot

Object committedSnapshotValueForKey ( String  key  )  [virtual]

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

Implements ERXEnterpriseObject.

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.

Implements ERXGuardedObjectInterface.

Reimplemented in ERXPartialGenericRecord.

String description (  )  [virtual]

Cover method to return toString.

Returns:
the results of calling toString.

Implements ERXEnterpriseObject.

Reimplemented in _Forum.

void didCopyFromChildInEditingContext ( ERXGenericRecord  originalEO,
EOEditingContext  childEditingContext 
)

Called when this EO is saved from a child editing context into a parent editing context.

Parameters:
originalEO the original EO in the child editing context
childEditingContext the child editing context

void didDelete ( EOEditingContext  ec  )  [virtual]

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.

Implements ERXEnterpriseObject.

Reimplemented in ERAttachment, ERXPartialGenericRecord, and ERIFile.

void didInsert (  )  [virtual]

Called on the object after is has successfully been inserted into the database.

Implements ERXEnterpriseObject.

Reimplemented in ERAttachment, ERS3Attachment, ERXPartialGenericRecord, and ERIFile.

void didRevert ( EOEditingContext  ec  )  [virtual]

Called on the object after it has been reverted. The editing context is passed to the object because if the object was in the insertedObjects list before the revert, the object has had its editingContext nulled.

Default implementation calls flushCaches.

Parameters:
ec editing context that is either currently associated with the object if the object was marked as changed or deleted before the revert, otherwise the editing context that was associated with the object before the revert.

Implements ERXEnterpriseObject.

Reimplemented in ERXPartialGenericRecord.

void didUpdate (  )  [virtual]

Called on the object after is has successfully been updated in the database.

Implements ERXEnterpriseObject.

Reimplemented in Bug, ERXPartialGenericRecord, and ERIFile.

String encryptedPrimaryKey (  )  [virtual]

Takes the primary key of the object and encrypts it with the blowfish cipher using ERXCrypto.

Returns:
blowfish encrypted primary key

Implements ERXEnterpriseObject.

EOEntity entity (  ) 

Returns the entity for the current object. Defers to ERXEOAccessUtilities.entityNamed() for the actual work.

Returns:
EOEntity for the current object

void excludeObjectFromPropertyWithKey ( Object  o,
String  key 
)

Overridden to support two-way relationship setting.

void flushCaches (  )  [virtual]

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.

Implements ERXEnterpriseObject.

Object foreignKeyForRelationshipWithKey ( String  rel  )  [virtual]

Returns the foreign key for a given relationship.

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

Implements ERXEnterpriseObject.

Logger getClassLog (  )  [virtual]

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.

Returns:
an Logger for this objects class

Implements ERXEnterpriseObject.

boolean hasKeyChangedFromCommittedSnapshot ( String  key  ) 

Returns whether or not the given key has changed when compared to the committed snapshot.

Parameters:
key The key that you wish to check has changed from the committed snapshot
Returns:
true if it has changed

boolean hasKeyChangedFromCommittedSnapshotFromValue ( String  key,
Object  oldValue 
)

Returns whether or not the given key has changed from the given committed value.

Parameters:
key The key that you wish to check has changed from the committed snapshot
oldValue The value you wish to see if the key has changed from EG. Has 'status' changed from STATUS.PENDING_STATUS
Returns:
true if the specified key value has changed from the specified value

boolean hasKeyChangedFromCommittedSnapshotFromValueToNewValue ( String  key,
Object  oldValue,
Object  newValue 
)

Returns whether or not the given key has changed from the given previous value to the new value since the committed value.

Parameters:
key The key that you wish to check has changed from the committed snapshot
oldValue The value you wish to see if the key has changed from
newValue The value you wish to see if the key has changed to EG. Has 'status' changed from STATUS.PENDING_STATUS to STATUS.CONFIRMED_STATUS
Returns:
true if the specified key value has changed from the specified value

boolean hasKeyChangedFromCommittedSnapshotToValue ( String  key,
Object  newValue 
)

Returns whether or not the given key has changed to the new value since the committed value.

Parameters:
key The key that you wish to check has changed from the committed snapshot
newValue The value you wish to see if the key has changed to EG. Has 'status' changed to STATUS.CANCELLED_STATUS
Returns:
true if the specified key value has changed to the specified value

void includeObjectIntoPropertyWithKey ( Object  o,
String  key 
)

Overridden to support two-way relationship setting.

void init ( EOEditingContext  ec  )  [protected]

used for initialization stuff instead of awakeFromInsertion. awakeFromInsertions is buggy because if an EO is deleted and then its EOEditingContext is reverted using 'revert' for example then EOF will -insert- this EO again in its EOEditingContext which in turn calls awakeFromInsertion again.

Parameters:
ec the EOEditingContext in which this new EO is inserted

Reimplemented in Asset, AssetGroup, Tag, Bug, Comment, Difficulty, Framework, People, Priority, Release, Requirement, RequirementSubType, RequirementType, TestItem, TestItemState, ERCAuditBlob, ERCAuditTrail, ERCAuditTrailEntry, ERCHelpText, ERCLogEntry, ERCMailMessage, ERCMailMessageArchive, ERCMessageAttachment, ERCPreference, ERCStampedEnterpriseObject, ERIAttribute, ERIAttributeGroup, ERIAttributeType, ERIValidationRule, ERIDirectory, ERIFile, and ERIFileContent.

boolean isDeletedEO (  )  [virtual]

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.

Returns:
if the object is a deleted object

Implements ERXEnterpriseObject.

boolean isNewEO (  ) 

boolean isNewObject (  )  [virtual]

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 editing context.

Returns:
if the object is a new enterprise object.

Implements ERXEnterpriseObject.

final Boolean isNonNull (  ) 

boolean isUpdatedObject (  ) 

Returns true if this EO has been modified in this editing context. In EOF terms, this means that the EO's snapshot in this EC is not .equals the original database snapshot for the EO.

Returns:
true if this EO's snapshot does not match the original snapshot

boolean isValidatedWhenNested (  ) 

Returns whether or not this object is validated when it is committed in a nested editing context.

Returns:
whether or not this object is validated when it is committed in a nested editing context.

NSArray<String> localesForKey ( String  key  ) 

Returns all available ERXLanguages for the given key

Parameters:
key 
Returns:
NSArray of language/locale keys

EOEnterpriseObject localInstanceIn ( EOEditingContext  ec  )  [virtual]

EOEnterpriseObject localInstanceOf ( EOEnterpriseObject  eo  )  [virtual]

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

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

Implements ERXEnterpriseObject.

NSArray localInstancesOf ( NSArray  eos  )  [virtual]

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.

Implements ERXEnterpriseObject.

static boolean localizationShouldFallbackToDefaultLanguage (  )  [static]

String localizedKey ( String  key  )  [private]

void mightDelete (  )  [virtual]

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.

Implements ERXEnterpriseObject.

Reimplemented in ERXPartialGenericRecord.

boolean parentObjectStoreIsObjectStoreCoordinator (  )  [virtual]

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.

Implements ERXEnterpriseObject.

EOKeyGlobalID permanentGlobalID (  ) 

Calls permanentGlobalID(boolean) passing true for generateIfMissing.

See also:
permanentGlobalID(boolean)

EOKeyGlobalID permanentGlobalID ( boolean  generateIfMissing  ) 

This method allows you to compute what the permanent EOGlobalID will be for an object before it has been saved to the database. It functions by calling into primaryKeyDictionary() to allocate the primary key if necessary. Then we build an EOKeyGlobalID from it. If the object already has a permanent global ID, we use that.

If you pass false for generateIfMissing and this object has a temporary global ID, null will be returned.

String primaryKey (  )  [virtual]

Primary key of the object as a String.

Returns:
primary key for the given object as a String

Implements ERXEnterpriseObject.

NSArray<String> primaryKeyAttributeNames (  )  [virtual]

Returns the names of all primary key attributes.

Implements ERXEnterpriseObject.

NSDictionary<String, Object> 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'.

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.

Implements ERXGeneratesPrimaryKeyInterface.

String primaryKeyInTransaction (  )  [virtual]

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.

Implements ERXEnterpriseObject.

Object rawPrimaryKey (  )  [virtual]

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.

Implements ERXEnterpriseObject.

Object rawPrimaryKeyInTransaction (  )  [virtual]

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

Implements ERXEnterpriseObject.

ERXEnterpriseObject refetchObjectFromDB (  ) 

Calls the method refetchObjectFromDBinEditingContext(EOEditingContext ec) and passes the object's Editing Context as Editing Context parameter.

Returns:
the newly fetched object from the DB.

ERXEnterpriseObject refetchObjectFromDBinEditingContext ( EOEditingContext  ec  )  [virtual]

Method that will make sure to fetch an eo from the Database and place it in the editingContext provided as an argument

Parameters:
ec the editing context in which the result will be placed
Returns:
fresh instance of an EO fetched from the DB and placed in the editing context argument

Implements ERXEnterpriseObject.

void removeObjectsFromBothSidesOfRelationshipWithKey ( NSArray  objects,
String  key 
) [virtual]

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

Implements ERXEnterpriseObject.

void removeObjectsFromPropertyWithKey ( NSArray  objects,
String  key 
) [virtual]

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

Implements ERXEnterpriseObject.

ERXEnterpriseObject self (  )  [virtual]

self is usefull for directtoweb purposes

Implements ERXEnterpriseObject.

void setBatchFaultingTimestamp ( long  timestamp  ) 

Touches this EO from a fetch. Note that this is the last fetch, not when the object has been initialized.

Parameters:
timestamp 

Implements ERXDatabaseContextDelegate.AutoBatchFaultingEnterpriseObject.

void setValidatedWhenNested ( boolean  validatedWhenNested  ) 

If false, when this object is committed into a nested editingContext and it exists in the parent editing context, validation will be skipped. This supports nested UI workflows where you want to create a new to-one relationship for an object that isn't fully configured by localInstancing it into a nested editing context. In that scenario, the localInstance'd EO would attempt to validate when the nested editing context is committed, throwing a validation exception that should be deferred to the parent editing context. This defaults to true, which maintains the current behavior.

Parameters:
validatedWhenNested 

static boolean shouldTrimSpaces (  )  [static]

void takeStoredValueForKey ( Object  value,
String  key 
)

void takeValueForKey ( Object  value,
String  key 
)

Overridden to support two-way relationship setting.

final<T> void takeValueForKey ( Object  value,
ERXKey< T >  key 
)

Type-safe KVC setter (final for now)

Parameters:
<T> 
value 
key 

String toLongString (  )  [virtual]

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.

Implements ERXEnterpriseObject.

Reimplemented in ERCMailMessage.

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: <com.foo.User pk:"50"> 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.

Reimplemented in Record, ERCMailMessage, and ERCStatic.

void touchFromBatchFaultingSource ( AutoBatchFaultingEnterpriseObject  toucher,
String  key 
)

Touches this EO with the given source and the given key. Stores GID and timestamp.

Parameters:
toucher 
key 

Implements ERXDatabaseContextDelegate.AutoBatchFaultingEnterpriseObject.

void trimSpaces (  )  [virtual]

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.

Implements ERXEnterpriseObject.

void updateFromSnapshot ( NSDictionary  snapshot  ) 

This method explicitly turns off inverse relationship updating, because it's only called during undo and revert inside of EOF. If you are calling this method, it's presumed that you understand the consequences of your actions :)

void validateForInsert (  )  throws NSValidation.ValidationException

Calls up validateForInsert() on the class description if it supports it.

Exceptions:
NSValidation.ValidationException if the object does not pass validation for saving to the database.

Reimplemented in Bug, and ERXPartialGenericRecord.

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.

Exceptions:
NSValidation.ValidationException if the object does not pass validation for saving to the database.

Reimplemented in ERCMailMessage, and ERXPartialGenericRecord.

void validateForUpdate (  )  throws NSValidation.ValidationException

Calls up validateForUpdate() on the class description if it supports it.

Exceptions:
NSValidation.ValidationException if the object does not pass validation for saving to the database.

Reimplemented in Bug, and ERXPartialGenericRecord.

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.

Parameters:
value to be validated for a given attribute or relationship
key corresponding to an attribute or relationship
Exceptions:
NSValidation.ValidationException if the value fails validation
Returns:
the validated value

final<T> T valueForKey ( ERXKey< T >  key  ) 

Type-safe KVC getter (final for now)

Parameters:
<T> 
key 

void willDelete (  )  throws NSValidation.ValidationException [virtual]

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.

Exceptions:
NSValidation.ValidationException to stop the object from being deleted.

Implements ERXEnterpriseObject.

Reimplemented in ERCStampedEnterpriseObject, ERTag, and ERXPartialGenericRecord.

void willInsert (  )  [virtual]

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.

Implements ERXEnterpriseObject.

Reimplemented in ERCStampedEnterpriseObject, and ERXPartialGenericRecord.

Object willReadRelationship ( Object  aObject  ) 

void willRevert (  )  [virtual]

Called on the object before it will be reverted.

Default implementation does nothing other than log.

Implements ERXEnterpriseObject.

Reimplemented in ERXPartialGenericRecord.

void willUpdate (  )  [virtual]

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.

Implements ERXEnterpriseObject.

Reimplemented in ERCStampedEnterpriseObject, and ERXPartialGenericRecord.


Member Data Documentation

long _fetchTime [private]

Last fetch time

EOKeyGlobalID _permanentGlobalID [private]

String _primaryKey = null [protected]

NSDictionary _primaryKeyDictionary [private]

caches the primary key dictionary for the given object

String _touchKey [private]

Which key touched us

EOGlobalID _touchSource

Which GID touched us

boolean _validatedWhenNested = true [private]

final NSMutableDictionary<Class, Logger> classLogs = new NSMutableDictionary<Class, Logger>() [static, private]

holds all subclass related Logger's


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:10 2012 for Project Wonder by  doxygen 1.5.8