Project Wonder 5.0.0.8795

er.extensions.eof
Class ERXModelGroup

java.lang.Object
  extended by com.webobjects.eoaccess.EOModelGroup
      extended by er.extensions.eof.ERXModelGroup

public class ERXModelGroup
extends EOModelGroup

Enhanced model group that supports connection dict switching, definable and predictable model orderings and stackable prototypes. It also fixes some errors when loading prototypes and EOModeler backup files (Foo.emodeld~). The class is the meant to be the default model group abd works in conjunction with ERXExtensions to set itself up on load.
You must use EOModelGroup.defaultGroup() and not EOModelGroup.globalModelGroup() because only the former will result in this class getting created.


Nested Class Summary
static class ERXModelGroup.LocalizedAttributeProcessor
          Processes ERXLanguages attributes.
static class ERXModelGroup.Model
          Extends models by model-specific prototypes.
 
Nested classes/interfaces inherited from class com.webobjects.eoaccess.EOModelGroup
EOModelGroup.ClassDelegate, EOModelGroup.Delegate
 
Field Summary
protected  NSArray<String> _modelLoadOrder
          er.extensions.ERXModelGroup.modelLoadOrder defines the load order of the models.
protected  NSArray<String> _prototypeModelNames
          er.extensions.ERXModelGroup.prototypeModelNames defines the names of the models that are prototypes.
protected static boolean flattenPrototypes
          er.extensions.ERXModelGroup.flattenPrototypes defines if the prototypes should get flattened.
static String LANGUAGES_KEY
          Key for languages, can be either in properties or in the model object's user info.
static Logger log
          logging support
static String ModelGroupAddedNotification
          Nofitication that is sent when the model group was created form the bundle loading.
protected static boolean patchModelsOnLoad
          er.extensions.ERXModelGroup.patchModelsOnLoad is a boolean that defines is the created should be a ERXModelGroup.Model not a EOModel.
 
Fields inherited from class com.webobjects.eoaccess.EOModelGroup
_delegate, _delegateRespondsTo_classForObjectWithGlobalID, _delegateRespondsTo_failedToLookupClassNamed, _delegateRespondsTo_relationshipFailedToLookupDestinationWithName, _delegateRespondsTo_relationshipForRow, _delegateRespondsTo_subEntityForEntity, _modelsByName, _subEntitiesCache, ModelAddedNotification, ModelInvalidatedNotification
 
Constructor Summary
ERXModelGroup()
          Default public constructor
 
Method Summary
static int _enumForKey(String key)
           
static boolean _isKeyEnumOverriden(EOAttribute att, int key)
           
static Object _keyForEnum(int key)
           
static NSArray _prototypeKeys()
           
 void addModel(EOModel eomodel)
          This implementation will load models that have entity name conflicts, removing the offending entity.
 EOModel addModelWithPathURL(URL url)
          Overridden to use our model class in the runtime.
 void checkForMismatchedJoinTypes()
          Looks for foreign key attributes that have a different type from the destination attribute.
 void checkInheritanceRelationships()
          Corrects a strange EOF inheritance issue where if a model gets loaded and an entity that has children located in a different model that hasn't been loaded yet will not be setup correctly.
protected static NSDictionary databaseConfigForModel(EOModel model)
           
 int entityCode(EOEntity entity)
          Looks up the userInfo for the Entity with the specified entityName and returns it if the code could be found.
 int entityCode(String ename)
          Looks up the userInfo for the Entity with the specified entityName and returns it if the code could be found.
protected  void fixFlatDictionary(EOModel model)
           
protected  void fixJDBCDictionary(EOModel model)
           
protected  void fixJNDIDictionary(EOModel model)
          Similar to fixJDBCDictionary, but for JNDI EOModels.
protected  void fixOpenBaseDictionary(EOModel model)
           
protected  void fixOracleDictionary(EOModel model)
           
static boolean isPrototypeEntity(EOEntity entity)
          Returns whether or not the given entity is a prototype.
static boolean isPrototypeEntityName(String entityName)
          Returns whether or not the given entity name is a prototype entity
 boolean isPrototypeModel(EOModel model)
          Returns whether the given model is listed as a prototype model in the properties.
 void loadModelsFromLoadedBundles()
          The only reason this method is needed is so our model group subclass is used.
 void modelAddedHandler(NSNotification n)
          Called when a model is loaded.
protected  void modifyModelsFromProperties()
          Modifies various settings of the entities and attributes in this model group based on System properties.
static boolean patchModelsOnLoad()
           
protected  void preloadERXConstantClassesForModel(EOModel model)
          The classes referenced in the ERXConstantClassName field of an attribute's userInfo needs to be class-loaded before the attribute is used.
static String prototypeEntityNameForModel(EOModel model)
           
 void resetConnectionDictionaryInModel(EOModel model)
          Resets the connection dictionary to the specified values that are in the defaults.
static String sqlDumpDirectory()
           
 
Methods inherited from class com.webobjects.eoaccess.EOModelGroup
_addSubEntitiesCache, _childrenForEntityNamed, _registerChildForParent, addModelWithPath, classDelegate, defaultGroup, delegate, entitiesWithSharedObjects, entityForObject, entityNamed, fetchSpecificationNamed, globalModelGroup, loadAllModelObjects, modelGroupForObjectStoreCoordinator, modelNamed, modelNames, models, modelWithPath, modelWithPathURL, removeModel, setClassDelegate, setDefaultGroup, setDelegate, setModelGroupForObjectStoreCoordinator, storedProcedureNamed, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

public static Logger log
logging support


LANGUAGES_KEY

public static final String LANGUAGES_KEY
Key for languages, can be either in properties or in the model object's user info.

See Also:
Constant Field Values

patchModelsOnLoad

protected static boolean patchModelsOnLoad
er.extensions.ERXModelGroup.patchModelsOnLoad is a boolean that defines is the created should be a ERXModelGroup.Model not a EOModel. Default is false.


flattenPrototypes

protected static boolean flattenPrototypes
er.extensions.ERXModelGroup.flattenPrototypes defines if the prototypes should get flattened. Default is true.


_prototypeModelNames

protected NSArray<String> _prototypeModelNames
er.extensions.ERXModelGroup.prototypeModelNames defines the names of the models that are prototypes. They get put in front of the model load order. The default is erprototypes


_modelLoadOrder

protected NSArray<String> _modelLoadOrder
er.extensions.ERXModelGroup.modelLoadOrder defines the load order of the models. When you use this property the bundle loading will be disregarded. There is no default value.


ModelGroupAddedNotification

public static final String ModelGroupAddedNotification
Nofitication that is sent when the model group was created form the bundle loading.

See Also:
Constant Field Values
Constructor Detail

ERXModelGroup

public ERXModelGroup()
Default public constructor

Method Detail

loadModelsFromLoadedBundles

public void loadModelsFromLoadedBundles()
The only reason this method is needed is so our model group subclass is used. Other than that it does the exact same thing as EOModelGroup's implementation.


addModel

public void addModel(EOModel eomodel)
This implementation will load models that have entity name conflicts, removing the offending entity. The reason this is needed is because multiple models might have JDBC prototype entities which would cause problems for the model group.

Overrides:
addModel in class EOModelGroup
Parameters:
eomodel - model to be added

sqlDumpDirectory

public static String sqlDumpDirectory()

addModelWithPathURL

public EOModel addModelWithPathURL(URL url)
Overridden to use our model class in the runtime.

Overrides:
addModelWithPathURL in class EOModelGroup

checkForMismatchedJoinTypes

public void checkForMismatchedJoinTypes()
Looks for foreign key attributes that have a different type from the destination attribute. The classic example of this is a long foreign key pointing to an integer primary key, which has a terrible consequence that is nearly impossible to track down.


checkInheritanceRelationships

public void checkInheritanceRelationships()
Corrects a strange EOF inheritance issue where if a model gets loaded and an entity that has children located in a different model that hasn't been loaded yet will not be setup correctly. Specifically when those child entities are loaded they will not have their parentEntity relationship set correctly.


entityCode

public int entityCode(String ename)
Looks up the userInfo for the Entity with the specified entityName and returns it if the code could be found.

Parameters:
ename - the name from the Entity for which we want to the get entityCode
Returns:
either the userInfo.entityCode or 0 if no entry could be found

entityCode

public int entityCode(EOEntity entity)
Looks up the userInfo for the Entity with the specified entityName and returns it if the code could be found.

Parameters:
entity - the Entity for which we want to the get entityCode
Returns:
either the userInfo.entityCode or 0 if no entry could be found

patchModelsOnLoad

public static boolean patchModelsOnLoad()

isPrototypeEntity

public static boolean isPrototypeEntity(EOEntity entity)
Returns whether or not the given entity is a prototype.

Parameters:
entity - the entity to check
Returns:
whether or not the entity is a prototype

isPrototypeEntityName

public static boolean isPrototypeEntityName(String entityName)
Returns whether or not the given entity name is a prototype entity


modelAddedHandler

public void modelAddedHandler(NSNotification n)
Called when a model is loaded. This will reset the connection dictionary and insert the correct EOPrototypes if those are used

Parameters:
n - notification posted when a model is loaded. The object is the model.

fixOracleDictionary

protected void fixOracleDictionary(EOModel model)

fixFlatDictionary

protected void fixFlatDictionary(EOModel model)

fixOpenBaseDictionary

protected void fixOpenBaseDictionary(EOModel model)

fixJNDIDictionary

protected void fixJNDIDictionary(EOModel model)
Similar to fixJDBCDictionary, but for JNDI EOModels.

Parameters:
model - the JNDI EOModel to fix

fixJDBCDictionary

protected void fixJDBCDictionary(EOModel model)

isPrototypeModel

public boolean isPrototypeModel(EOModel model)
Returns whether the given model is listed as a prototype model in the properties.

Parameters:
model -

resetConnectionDictionaryInModel

public void resetConnectionDictionaryInModel(EOModel model)
Resets the connection dictionary to the specified values that are in the defaults. This method will look for defaults in the form:

                <MODELNAME>.DBServer
                <MODELNAME>.DBUser
                <MODELNAME>.DBPassword
                <MODELNAME>.URL (for JDBC)        
 
if the serverName and username both exists, we overwrite the connection dict (password is optional). Otherwise we fall back to what's in the model. Likewise default values can be specified of the form:

   dbConnectUserGLOBAL
   dbConnectPasswordGLOBAL
   dbConnectURLGLOBAL
 

Parameters:
model - to be reset

prototypeEntityNameForModel

public static String prototypeEntityNameForModel(EOModel model)

databaseConfigForModel

protected static NSDictionary databaseConfigForModel(EOModel model)

preloadERXConstantClassesForModel

protected void preloadERXConstantClassesForModel(EOModel model)
The classes referenced in the ERXConstantClassName field of an attribute's userInfo needs to be class-loaded before the attribute is used. This method enumerates all the attributes of all the entities in a model looking for those class names, and class loads them. Because the constant class name could be an inner class, it tries the raw value first, then replaces the last dot of the class name with a dollar sign and tries again.

Parameters:
model - the model to load constants for
Throws:
IllegalArgumentException - if the ERXConstantClassName cannot be resolved.

modifyModelsFromProperties

protected void modifyModelsFromProperties()
Modifies various settings of the entities and attributes in this model group based on System properties.


_prototypeKeys

public static NSArray _prototypeKeys()

_keyForEnum

public static Object _keyForEnum(int key)

_enumForKey

public static int _enumForKey(String key)

_isKeyEnumOverriden

public static boolean _isKeyEnumOverriden(EOAttribute att,
                                          int key)

Last updated: Fri, Jan 9, 2009 • 04:35 AM EST

Copyright © 2002 – 2007 Project Wonder.