ERXEntityClassDescription.Factory Class Reference

Collaboration diagram for ERXEntityClassDescription.Factory:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void checkForeignKeys (EOEntity eoentity)
void classDescriptionNeededForClass (NSNotification n)
void classDescriptionNeededForEntityName (NSNotification n)
 Factory ()
final void modelGroupWasAdded (NSNotification n)
final void modelWasAdded (NSNotification n)
void reset ()

Protected Member Functions

void handleMandatoryRelationshipError (EOEntity eoentity, EORelationship relationship, EOAttribute attribute)
void handleOptionalRelationshipError (EOEntity eoentity, EORelationship relationship, EOAttribute attribute)
boolean isFixingRelationshipsEnabled ()
boolean isRapidTurnaroundEnabled ()
ERXEntityClassDescription newClassDescriptionForEntity (EOEntity entity)
void prepareEntityForRegistration (EOEntity eoentity)
void processModelGroup (EOModelGroup group)
void registerDescriptionForClass (Class class1)
void registerDescriptionForEntitiesInModel (EOModel model)
void registerDescriptionForEntity (EOEntity entity)

Private Member Functions

void _setClassDescriptionOnEntity (EOEntity entity, ERXEntityClassDescription cd)

Private Attributes

NSMutableDictionary _classDescriptionForEntity = new NSMutableDictionary()
NSMutableDictionary _entitiesForClass = new NSMutableDictionary()
NSMutableArray _registeredModelNames = new NSMutableArray()


Detailed Description

This factory inner class is registered as the observer for three notifications: modelWasAdded, classDescriptionNeededForEntity and classDescriptionNeededForClass. If you wish to provide your own subclass of ERXEntityClassDescription then you need to create a subclass of Factory and set that class name in the system properties under the key: er.extensions.ERXClassDescription.factoryClass In your Factory subclass override the method: newClassDescriptionForEntity to provide your own ERXEntityClassDescription subclass.

Constructor & Destructor Documentation

Factory (  ) 

Public constructor


Member Function Documentation

void _setClassDescriptionOnEntity ( EOEntity  entity,
ERXEntityClassDescription  cd 
) [private]

This is a hack to work around RadarBug:2867501. EOEntity is hardwired to return an EOEntityClassdescription for the method classDescriptionForNewInstances, this causes a serious problem when using custom class descriptions with D2W which makes use of this method. What this hack does is use the magic of key-value coding to push our custom class description onto a given entity. In order to do this we needed to add the custom KVCProtectedAccessor to the package com.webobjects.eoaccess.

Parameters:
entity to have the custom class description set on
cd class description to set on the entity

void checkForeignKeys ( EOEntity  eoentity  ) 

Checks for foreign keys that are NOT NULL, but whose relationship is marked as non-mandatory and vice-versa. This error is not checked by EOModeler, so we do it here.

Parameters:
eoentity to be check

void classDescriptionNeededForClass ( NSNotification  n  ) 

Method called by the NSNotificationCenter when a class description is needed for a given Class. Usually this method isn't needed seeing as we preempt the on demand loading of class descriptions by loading all of them when the EOModel is loaded. This method just calls the method registerDescriptionForClass

Parameters:
n notification that has the Class object that needs a class description.

void classDescriptionNeededForEntityName ( NSNotification  n  ) 

Method called by the NSNotificationCenter when a class description is needed for a given entity. Usually this method isn't needed seeing as we preempt the on demand loading of class descriptions by loading all of them when the EOModel is loaded. This method just calls the method registerDescriptionForEntity

Parameters:
n notification that has the name of the entity that needs the class description.

void handleMandatoryRelationshipError ( EOEntity  eoentity,
EORelationship  relationship,
EOAttribute  attribute 
) [protected]

Handles errors when a mandatory relationship has a source attribute that is set to not allow null values. Subclasses can override this to do more specific handling.

void handleOptionalRelationshipError ( EOEntity  eoentity,
EORelationship  relationship,
EOAttribute  attribute 
) [protected]

Handles errors when an optional relationship has a source attribute that is set to allow null values. Subclasses can override this to do more specific handling.

boolean isFixingRelationshipsEnabled (  )  [protected]

boolean isRapidTurnaroundEnabled (  )  [protected]

final void modelGroupWasAdded ( NSNotification  n  ) 

Method called when a model group did load.

final void modelWasAdded ( NSNotification  n  ) 

Method called by the NSNotificationCenter when an EOModel is loaded. This method just calls the method registerDescriptionForEntitiesInModel

Parameters:
n notification that has the EOModel that was loaded.

ERXEntityClassDescription newClassDescriptionForEntity ( EOEntity  entity  )  [protected]

Factory method that is used to create a new class description for a given entity. Sub classes that wish to provide a sub class of ERXEntityClassDescription should override this method to create that custom description. By default this method returns a new ERXEntityClassDescription.

Parameters:
entity to create the class description for
Returns:
new class description for the given entity

void prepareEntityForRegistration ( EOEntity  eoentity  )  [protected]

Allows for entities to be altered before they have a custom class description registered. Sub classes can override this method to provide any extra alterings before the description is registered. However be sure to call super as this method does convert the class name from EOGenericRecord to ERXGenericRecord, which unfortunately is required for custom validation to work at the moment.

Parameters:
eoentity to be prepared for registration

void processModelGroup ( EOModelGroup  group  )  [protected]

Called when a model group finished loading. Checks foreign keys by default. Override to to more...

Parameters:
group 

void registerDescriptionForClass ( Class  class1  )  [protected]

This method is called when a class description is needed for a particular class. Here we use the previous cache that we constructed of class to entity map when the models were loaded. In this way we can register all of the custom class descriptions for a given class if need be.

Parameters:
class1 class object to have a custom class description registered for.

void registerDescriptionForEntitiesInModel ( EOModel  model  )  [protected]

This method registers custom class descriptions for all of the entities in a given model. This method is called when a model is loaded. The reason for this method is to preempt the usual class description loading mechanism which has a race condition involved for the order in which the notifications are recieved.

Parameters:
model that contains all of the entities to be registerd

void registerDescriptionForEntity ( EOEntity  entity  )  [protected]

Registers a custom class description for the given entity using the method newClassDescriptionForEntity which can be overridden by subclasses to provide a different class description subclass.

Parameters:
entity to register the class description for

void reset (  ) 


Member Data Documentation

holds a mapping of entity to class descriptions

holds a mapping of class to entities

holds a reference to all of the registered model names


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

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