Project Wonder 5.0

er.extensions.eof
Class ERXModelGroup

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

public class ERXModelGroup
extends com.webobjects.eoaccess.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 and 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.

Properties
EOPrototypesFileGLOBALEOPrototypesFileGLOBAL
           
JNDI.global.authenticationMethodJNDI.global.authenticationMethod
           
JNDI.global.passwordJNDI.global.password
           
JNDI.global.pluginJNDI.global.plugin
           
JNDI.global.serverUrlJNDI.global.serverUrl
           
JNDI.global.usernameJNDI.global.username
           
dbConfigNameGLOBALdbConfigNameGLOBAL
           
[MODEL_NAME].DBConfigName[MODEL_NAME].DBConfigName
           
dbConnectAdaptorGLOBALdbConnectAdaptorGLOBAL
           
[MODEL_NAME].adaptor[MODEL_NAME].adaptor
           
dbConnectDatabaseGLOBALdbConnectDatabaseGLOBAL
           
[MODEL_NAME].DBDatabase[MODEL_NAME].DBDatabase
           
dbConnectDriverGLOBALdbConnectDriverGLOBAL
           
[MODEL_NAME].DBDriver[MODEL_NAME].DBDriver
           
dbConnectHostNameGLOBALdbConnectHostNameGLOBAL
           
[MODEL_NAME].DBHostName[MODEL_NAME].DBHostName
           
dbConnectJDBCInfoGLOBALdbConnectJDBCInfoGLOBAL
           
[MODEL_NAME].DBJDBCInfo[MODEL_NAME].DBJDBCInfo
           
dbConnectPasswordGLOBALdbConnectPasswordGLOBAL
           
[MODEL_NAME].DBPassword[MODEL_NAME].DBPassword
           
[MODEL_NAME].password[MODEL_NAME].password
           
dbConnectPluginGLOBALdbConnectPluginGLOBAL
           
[MODEL_NAME].DBPlugin[MODEL_NAME].DBPlugin
           
[MODEL_NAME].plugin[MODEL_NAME].plugin
           
dbConnectServerGLOBALdbConnectServerGLOBAL
           
[MODEL_NAME].DBServer[MODEL_NAME].DBServer
           
dbConnectURLGLOBALdbConnectURLGLOBAL
           
[MODEL_NAME].URL[MODEL_NAME].URL
           
[MODEL_NAME].serverUrl[MODEL_NAME].serverUrl
           
dbConnectUserGLOBALdbConnectUserGLOBAL
           
[MODEL_NAME].DBUser[MODEL_NAME].DBUser
           
[MODEL_NAME].username[MODEL_NAME].username
           
dbConnectionRecycleGLOBALdbConnectionRecycleGLOBAL
           
dbDebugLevelGLOBALdbDebugLevelGLOBAL
           
dbEOPrototypesEntityGLOBALdbEOPrototypesEntityGLOBAL
           
dbLogPathGLOBALdbLogPathGLOBAL
           
dbMaxCheckoutGLOBALdbMaxCheckoutGLOBAL
           
dbMaxConnectionsGLOBALdbMaxConnectionsGLOBAL
           
dbMinConnectionsGLOBALdbMinConnectionsGLOBAL
           
dbRemoveJdbc2InfoGLOBALdbRemoveJdbc2InfoGLOBAL
           
er.extensions.ERXModelGroup.[ENTITY_NAME].[ATTRIBUTE_NAME].columnNameer.extensions.ERXModelGroup.[ENTITY_NAME].[ATTRIBUTE_NAME].columnName
           
er.extensions.ERXModelGroup.[ENTITY_NAME].[ATTRIBUTE_NAME].ignoreTypeMismatcher.extensions.ERXModelGroup.[ENTITY_NAME].[ATTRIBUTE_NAME].ignoreTypeMismatch
           
er.extensions.ERXModelGroup.[ENTITY_NAME].externalNameer.extensions.ERXModelGroup.[ENTITY_NAME].externalName
           
er.extensions.ERXModelGroup.flattenPrototypeser.extensions.ERXModelGroup.flattenPrototypes
           
er.extensions.ERXModelGroup.ignoreTypeMismatcher.extensions.ERXModelGroup.ignoreTypeMismatch
           
er.extensions.ERXModelGroup.modelClassNameer.extensions.ERXModelGroup.modelClassName
           
er.extensions.ERXModelGroup.modelLoadOrder NSArray.EmptyArray
           
er.extensions.ERXModelGroup.patchModelsOnLoader.extensions.ERXModelGroup.patchModelsOnLoad
           
er.extensions.ERXModelGroup.patchedModelClassNameer.extensions.ERXModelGroup.patchedModelClassName
           
er.extensions.ERXModelGroup.prototypeModelNameer.extensions.ERXModelGroup.prototypeModelName
           
er.extensions.ERXModelGroup.prototypeModelNameser.extensions.ERXModelGroup.prototypeModelNames
           
er.extensions.ERXModelGroup.raiseOnUnmatchingConnectionDictionaries, true
           
er.extensions.ERXModelGroup.sqlDumpDirectoryer.extensions.ERXModelGroup.sqlDumpDirectory
           
[MODEL_NAME].DBConnectionRecycle[MODEL_NAME].DBConnectionRecycle
           
[MODEL_NAME].DBDebugLevel[MODEL_NAME].DBDebugLevel
           
[MODEL_NAME].DBLogPath[MODEL_NAME].DBLogPath
           
[MODEL_NAME].DBMaxCheckout[MODEL_NAME].DBMaxCheckout
           
[MODEL_NAME].DBMaxConnections[MODEL_NAME].DBMaxConnections
           
[MODEL_NAME].DBMinConnections[MODEL_NAME].DBMinConnections
           
[MODEL_NAME].EOPrototypesEntity[MODEL_NAME].EOPrototypesEntity
           
[MODEL_NAME].EOPrototypesFile[MODEL_NAME].EOPrototypesFile
           
[MODEL_NAME].authenticationMethod[MODEL_NAME].authenticationMethod
           
[MODEL_NAME].removeJdbc2Info[MODEL_NAME].removeJdbc2Info
           

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
com.webobjects.eoaccess.EOModelGroup.ClassDelegate, com.webobjects.eoaccess.EOModelGroup.Delegate
 
Field Summary
protected  com.webobjects.foundation.NSArray<java.lang.String> _modelLoadOrder
          er.extensions.ERXModelGroup.modelLoadOrder defines the load order of the models.
protected  com.webobjects.foundation.NSArray<java.lang.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 java.lang.String LANGUAGES_KEY
          Key for languages, can be either in properties or in the model object's user info.
static org.apache.log4j.Logger log
          logging support
static java.lang.String ModelGroupAddedNotification
          Notification 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(java.lang.String key)
           
static boolean _isKeyEnumOverriden(com.webobjects.eoaccess.EOAttribute att, int key)
           
static java.lang.Object _keyForEnum(int key)
           
static com.webobjects.foundation.NSArray _prototypeKeys()
           
 void addModel(com.webobjects.eoaccess.EOModel eomodel)
          This implementation will load models that have entity name conflicts, removing the offending entity.
 com.webobjects.eoaccess.EOModel addModelWithPathURL(java.net.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 com.webobjects.foundation.NSDictionary databaseConfigForModel(com.webobjects.eoaccess.EOModel model)
           
 int entityCode(com.webobjects.eoaccess.EOEntity entity)
          Looks up the userInfo for the Entity with the specified entityName and returns it if the code could be found.
 int entityCode(java.lang.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(com.webobjects.eoaccess.EOModel model)
           
protected  void fixJDBCDictionary(com.webobjects.eoaccess.EOModel model)
           
protected  void fixJNDIDictionary(com.webobjects.eoaccess.EOModel model)
          Similar to fixJDBCDictionary, but for JNDI EOModels.
protected  void fixOpenBaseDictionary(com.webobjects.eoaccess.EOModel model)
           
protected  void fixOracleDictionary(com.webobjects.eoaccess.EOModel model)
           
static boolean isPrototypeEntity(com.webobjects.eoaccess.EOEntity entity)
          Returns whether or not the given entity is a prototype.
static boolean isPrototypeEntityName(java.lang.String entityName)
          Returns whether or not the given entity name is a prototype entity
 boolean isPrototypeModel(com.webobjects.eoaccess.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(com.webobjects.foundation.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(com.webobjects.eoaccess.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 java.lang.String prototypeEntityNameForModel(com.webobjects.eoaccess.EOModel model)
           
 void resetConnectionDictionaryInModel(com.webobjects.eoaccess.EOModel model)
          Resets the connection dictionary to the specified values that are in the defaults.
static java.lang.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 final org.apache.log4j.Logger log
logging support


LANGUAGES_KEY

public static final java.lang.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 final 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 final boolean flattenPrototypes
er.extensions.ERXModelGroup.flattenPrototypes defines if the prototypes should get flattened. Default is true.

Note: the default of true may be incompatible with ERXModel#isUseExtendedPrototypesEnabled.


_prototypeModelNames

protected com.webobjects.foundation.NSArray<java.lang.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 com.webobjects.foundation.NSArray<java.lang.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 java.lang.String ModelGroupAddedNotification
Notification 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(com.webobjects.eoaccess.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 com.webobjects.eoaccess.EOModelGroup
Parameters:
eomodel - model to be added

sqlDumpDirectory

public static java.lang.String sqlDumpDirectory()

addModelWithPathURL

public com.webobjects.eoaccess.EOModel addModelWithPathURL(java.net.URL url)
Overridden to use our model class in the runtime.

Overrides:
addModelWithPathURL in class com.webobjects.eoaccess.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(java.lang.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(com.webobjects.eoaccess.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(com.webobjects.eoaccess.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(java.lang.String entityName)
Returns whether or not the given entity name is a prototype entity


modelAddedHandler

public void modelAddedHandler(com.webobjects.foundation.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(com.webobjects.eoaccess.EOModel model)

fixFlatDictionary

protected void fixFlatDictionary(com.webobjects.eoaccess.EOModel model)

fixOpenBaseDictionary

protected void fixOpenBaseDictionary(com.webobjects.eoaccess.EOModel model)

fixJNDIDictionary

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

Parameters:
model - the JNDI EOModel to fix
Properties
[modelName].serverUrl the per-model server URL to set
           
[modelName].user the per-model username to set
           
[modelName].password the per-model password to set
           
[modelName].authenticationModel the per-model authenticationMethod to set
           
JNDI.global.serverUrl the global JNDI serverUrl to use by default
           
JNDI.global.username the global JNDI username to use by default
           
JNDI.global.password the global JNDI password to use by default
           
JNDI.global.authenticationMethod the global JNDI authenticationMethod to use by default
           

fixJDBCDictionary

protected void fixJDBCDictionary(com.webobjects.eoaccess.EOModel model)

isPrototypeModel

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


resetConnectionDictionaryInModel

public void resetConnectionDictionaryInModel(com.webobjects.eoaccess.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 java.lang.String prototypeEntityNameForModel(com.webobjects.eoaccess.EOModel model)

databaseConfigForModel

protected static com.webobjects.foundation.NSDictionary databaseConfigForModel(com.webobjects.eoaccess.EOModel model)

preloadERXConstantClassesForModel

protected void preloadERXConstantClassesForModel(com.webobjects.eoaccess.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:
java.lang.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.

Properties
er.extensions.ERXModelGroup.[entityName].externalName change the table name for the given entityName
           
er.extensions.ERXModelGroup.[entityName].[attributeName].columnName change the column name for the given attribute
           

_prototypeKeys

public static com.webobjects.foundation.NSArray _prototypeKeys()

_keyForEnum

public static java.lang.Object _keyForEnum(int key)

_enumForKey

public static int _enumForKey(java.lang.String key)

_isKeyEnumOverriden

public static boolean _isKeyEnumOverriden(com.webobjects.eoaccess.EOAttribute att,
                                          int key)

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.