|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eoaccess.EOModel
public class EOModel
An EOModel represents a mapping between a database schema and a set of classes based on the entity-relationship model for an application. The model contains a number of EOEntity objects representing the tables (entities) of the database schema. Each EOEntity object has a number of EOAttribute and EORelationship objects representing the properties (columns or fields) of the table (entity) in the database schema.
An EOModel maintains a mapping between each of its EOEntity objects and a corresponding Enterprise Object class for use with the database level of the Enterprise Objects Framework. You can determine the EOEntity for a particular Enterprise Object with the entityForObject
method.
An EOModel is specific to a particular database server, and can store information needed to connect to that server as well as the name of an adaptor framework to load so that the Enterprise Objects Framework can communicate with the database.
Models can be organized into model groups and may have relationships that reference other models in the same model group. The other models may map to different databases and types of servers.
EOModel files are usually built using the EOModeler application, but it is possible to build an EOModel file programmatically if needed. The EOAdaptorChannel class declares methods for reading basic schema information from a relational database. You can use this information to build up an EOModel programmatically, and then enhance that model by defining extra relationships, flattening attributes, and so on.
EOModel files are typically stored in a project or a framework. To load an EOModel, provide a model file's path to the constructor. Note that loading an EOModel doesn't have the effect of loading all of its entities. EOModel files can be quite large, so to reduce start-up time, entity definitions
are only loaded as needed. This incremental model loading is possible because an EOModel actually consists of one index file and two files for each entity. Models have an .eomodeld
file wrapper ( which is actually a directory), and the individual entity files within the model are
in ASCII format. The index file has the name index.eomodeld
, and it contains the connection dictionary, the adaptor name, and a list of all of the entities in the model. This is the file that is loaded when you create a new model from a path.
The two entity files consist of a property list (.plist
) file that describes the entity and a fetch specification (.fspec
) file that describes any named fetch specifications for that entity.
index.eomodeld
file, which is used to access the model's entities.
When an entity is loaded, EOModel posts an EntityLoadedNotification
.
EOModel.entityForObject(EOEnterpriseObject object)
Nested Class Summary | |
---|---|
protected static class |
EOModel.EOModelFileNameFilter
Used to filter out all the EOModel managed file and copy teh rest of the file over to the new model. |
Field Summary | |
---|---|
static String |
EntityLoadedNotification
The notification posted after an EOEntity is loaded into memory. |
Constructor Summary | |
---|---|
|
EOModel()
Creates and returns a new EOModel. |
protected |
EOModel(NSDictionary propertyList,
String path)
|
protected |
EOModel(NSDictionary propertyList,
URL url)
|
|
EOModel(String path)
Deprecated. use EOModel(URL url) instead. |
|
EOModel(URL url)
Creates a new EOModel object by reading the contents of the model archive at url . |
Method Summary | |
---|---|
String |
adaptorName()
Returns the name of the adaptor for the receiver. |
void |
addEntity(EOEntity entity)
Adds entity to the receiver. |
void |
addStoredProcedure(EOStoredProcedure storedProcedure)
Adds storedProcedure to the receiver. |
NSArray |
availablePrototypeAttributeNames()
Returns a list of names of all available prototypes. |
void |
beautifyNames()
Makes all of the receiver's named components conform to a standard convention. |
NSDictionary |
connectionDictionary()
Returns a dictionary containing information used to connect to the database server. |
void |
dispose()
Conformance to NSDisposable. |
void |
encodeTableOfContentsIntoPropertyList(NSMutableDictionary result)
Encodes the receiver into result . |
NSArray |
entities()
Returns an array containing the receiver's entities. |
NSArray |
entitiesWithSharedObjects()
Returns an array of entities that have objects to load into a shared editing context. |
EOEntity |
entityForObject(EOEnterpriseObject object)
Returns the entity associated with object , whether object is an instance of an Enterprise Object class, an instance of EOGenericRecord, or a fault. |
EOEntity |
entityNamed(String name)
Returns the entity named name , or null if no such entity exists in this model. |
NSArray |
entityNames()
Returns an array containing the names of the receiver's entities. |
static String |
entityPrototypeNameForAdaptor(EOAdaptor adaptor)
|
static String |
entityPrototypePlugInNameForAdaptor(EOAdaptor adaptor)
|
NSArray |
externalModelsReferenced()
Returns an array containing those models that are referenced by the receiver. |
void |
loadAllModelObjects()
Loads any of the receiver's entities, stored procedures, attributes, and relationships that have not yet been loaded. |
EOModelGroup |
modelGroup()
Returns the model group to which the receiver belongs. |
String |
name()
Returns the receiver's name. |
String |
path()
Deprecated. use pathURL instead. |
URL |
pathURL()
Returns the URL to the EOModel file used to create the receiver, or null if the model wasn't initialized from an URL. |
EOAttribute |
prototypeAttributeNamed(String name)
Returns the prototype attribute identified by name . |
NSArray |
referencesToProperty(Object property)
Returns an array of all properties in the receiver that reference property , whether derived attributes, relationships that reference property , and so on. |
void |
removeEntity(EOEntity entity)
Removes entity from the receiver without performing any referential integrity checking. |
void |
removeEntityAndReferences(EOEntity entity)
Removes entity from the receiver along with any attributes or relationships in other entities that reference entity . |
void |
removeStoredProcedure(EOStoredProcedure storedProcedure)
Removes storedProcedure from the receiver without checking whether any entity uses it. |
void |
setAdaptorName(String adaptorName)
Sets the name of the receiver's adaptor to adaptorName . |
void |
setConnectionDictionary(NSDictionary connectionDictionary)
Sets the dictionary containing information used to connect to the database to connectionDictionary . |
void |
setModelGroup(EOModelGroup group)
Sets the model group to which the receiver should belong. |
void |
setName(String newName)
Sets the name of the receiver to newNname . |
void |
setUserInfo(NSDictionary dictionary)
Sets the receiver's userInfo dictionary to dictionary . |
EOStoredProcedure |
storedProcedureNamed(String name)
Returns the stored procedure named name , or null if the receiver doesn't contain a stored procedure with the given name. |
NSArray |
storedProcedureNames()
Returns an array containing the names of all of the receiver's stored procedures sorted in alphabetical order. |
NSArray |
storedProcedures()
Returns an array containing all of the receiver's stored procedures or an empty array if the receiver has no stored procedures. |
String |
toString()
Returns a string representation of the receiver. |
NSDictionary |
userInfo()
Returns a dictionary of user data. |
void |
writeToFile(String path)
Writes out the model archive representation of the receiver in the location specified by path . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String EntityLoadedNotification
Constructor Detail |
---|
public EOModel()
@Deprecated public EOModel(String path)
path
. Sets the EOModel's name and path from the context of the model archive. Throws an IllegalArgumentException if path
is null
or if unable to read the file
at path
. Throws a runtime exception if unable for any other reason to initialize the model from the specified file path; the error text indicates the nature of the exception.
path
- The path to a model archive.
IllegalArgumentException
- if path
is null
or if unable to read the file.EOModel.EOModel(URL url)
,
EOModel.name()
,
EOModel.path()
,
(NSMutableDictionary propertyList)
public EOModel(URL url)
url
. Sets the EOModel's name and path from the context of the model archive. Throws an IllegalArgumentException if url
is null
or if unable to read content from
url
. Throws a runtime exception if unable for any other reason to initialize the model from the specified java.net.URL; the error text indicates the nature of the exception.
url
- The java.net.URL to a model archive.
IllegalArgumentException
- if url
is null
or if unable to read the content.EOModel.EOModel(URL url)
,
EOModel.name()
,
EOModel.pathURL()
,
(NSMutableDictionary propertyList)
protected EOModel(NSDictionary propertyList, String path)
protected EOModel(NSDictionary propertyList, URL url)
Method Detail |
---|
public void dispose()
dispose
in interface NSDisposable
public String toString()
toString
in class Object
public String name()
EOModel.path()
,
EOModel.EOModel(String path)
,
EOModel.EOModel(NSDictionary tableOfContents, String path)
@Deprecated public String path()
null
.EOModel.pathURL()
public URL pathURL()
null
if the model wasn't initialized from an URL.
null
.EOModel.name()
,
EOModel.EOModel(String path)
,
EOModel.EOModel(NSDictionary tableOfContents, String path)
public NSArray entityNames()
EOModel.entities()
,
EOModel.entityNamed(String name)
public EOEntity entityNamed(String name)
name
, or null
if no such entity exists in this model. Posts an EntityLoadedNotification
when the entity is loaded. Throws a runtime exception if an error occurs during loading; the error text indicates the nature of the
exception.
name
- The name of an entity.
name
, or null
.EOModel.EntityLoadedNotification
,
EOModel.entityNames()
,
EOModel.entities()
public NSArray entities()
EOModel.entityNames()
public EOEntity entityForObject(EOEnterpriseObject object)
object
, whether object
is an instance of an Enterprise Object class, an instance of EOGenericRecord, or a fault. Returns null
if object
has no associated entity.
object
- An object.
object
, or null
.public String adaptorName()
adaptorWithName
to construct an adaptor.
EOAdaptor.adaptorWithName(String name)
public NSDictionary connectionDictionary()
EOAdaptor
public NSDictionary userInfo()
EOModel.setUserInfo(NSDictionary dictionary)
public NSArray entitiesWithSharedObjects()
EOEditingContext
public EOModelGroup modelGroup()
EOModel.setModelGroup(EOModelGroup group)
,
EOModelGroup
public NSArray storedProcedureNames()
EOModel.storedProcedures()
,
EOModel.storedProcedureNamed(String name)
,
EOStoredProcedure
public EOStoredProcedure storedProcedureNamed(String name)
name
, or null
if the receiver doesn't contain a stored procedure with the given name. Throws a runtime exception if an error occurs during processing; the error text indicates the nature of the exception. Throws an
IllegalArgumentException if the model's index file (table of contents) contains name
but the associated stored procedure is not found in the model's .eomodeld
directory.
name
- The name of a stored procedure.
name
, or null
.
IllegalArgumentException
- if the model file is corrupted.EOModel.storedProcedureNames()
,
EOModel.storedProcedures()
,
EOStoredProcedure
public NSArray storedProcedures()
EOModel.storedProcedureNames()
,
EOModel.storedProcedureNamed(String name)
,
EOStoredProcedure
public static String entityPrototypeNameForAdaptor(EOAdaptor adaptor)
public static String entityPrototypePlugInNameForAdaptor(EOAdaptor adaptor)
public EOAttribute prototypeAttributeNamed(String name)
name
. Looks first in the receiver, then in the model group to which the receiver belongs, and finally in the adaptor associated with the receiver.
name
- An attribute name.
name
.EOModel.availablePrototypeAttributeNames()
public NSArray availablePrototypeAttributeNames()
EOModel.prototypeAttributeNamed(String attributeName)
public void writeToFile(String path)
path
. If the directory specified by path
already exists, a backup copy is first created from the existing archive with a tilde (~) character appended to the archive name to
distinguish it. As a side-effect, this method resets the current path for the receiver to path
.
Throws a runtime exception if unable to write the archive; the error text indicates the nature of the exception.
path
- The filesystem location at which to write the model archive.EOModel.path()
public void encodeTableOfContentsIntoPropertyList(NSMutableDictionary result)
result
. This method is used to create an ASCII representation of an EOModel in property list format.
result
- The dictionary into which to encode the receiver.EOModel.EOModel()
,
EOModel.EOModel(String path)
,
EOModel.EOModel(NSDictionary tableOfContents, String path)
public void setName(String newName)
newNname
.
newName
- A new name for the receiver.public void setAdaptorName(String adaptorName)
adaptorName
.
adaptorName
- The name of the receiver's adaptor.public void setConnectionDictionary(NSDictionary connectionDictionary)
connectionDictionary
.
connectionDictionary
- The information used to connect to the database.EOAdaptor
,
EOAdaptor.adaptorWithModel(EOModel model)
public void setUserInfo(NSDictionary dictionary)
dictionary
. User information is arbitrary auxiliary data which the application can use for whatever it needs. dictionary
can only contain property list data types, which are String, NSDictionary, NSArray, and NSData.
dictionary
- A dictionary of auxiliary data for the application to use as it needs.public void addEntity(EOEntity entity)
entity
to the receiver. Throws an exception if: entity
is null.entity
's EOModel is not the receiver.entity
.
entity
- An EOEntity object to add to the receiver.
IllegalArgumentException
- if entity
is null
, has a different EOModel, or has the same name as another entity registered with the receiver.EOModel.entities()
,
EOModel.removeEntity(EOEntity name)
,
EOModel.removeEntityAndReferences(EOEntity entity)
public void removeEntity(EOEntity entity)
entity
from the receiver without performing any referential integrity checking.
entity
- An EOEntity object to remove from the receiver.EOModel.addEntity(EOEntity anEntity)
,
EOModel.removeEntityAndReferences(EOEntity entity)
public void removeEntityAndReferences(EOEntity entity)
entity
from the receiver along with any attributes or relationships in other entities that reference entity
.
entity
- An EOEntity object to remove from the receiver.EOModel.addEntity(EOEntity anEntity)
,
EOModel.removeEntity(EOEntity entity)
public void addStoredProcedure(EOStoredProcedure storedProcedure)
storedProcedure
to the receiver. Throws an exception if:storedProcedure
is null.storedProcedure
's EOModel is not the receiver.storedProcedure
does not have a valid name.storedProcedure
.
storedProcedure
- An EOStoredProcedure object to add to the receiver.
IllegalArgumentException
- if storedProcedure
is null
, has a different EOModel, has an invalid name, or has the same name as another stored procedure registered with the receiver.EOModel.removeStoredProcedure(EOStoredProcedure storedProcedure)
,
EOModel.storedProcedures()
,
EOModel.storedProcedureNamed(String name)
public void removeStoredProcedure(EOStoredProcedure storedProcedure)
storedProcedure
from the receiver without checking whether any entity uses it.
storedProcedure
- The stored procedure to remove from the receiver.EOModel.addStoredProcedure(EOStoredProcedure storedProcedure)
,
EOModel.storedProcedures()
public void setModelGroup(EOModelGroup group)
group
- The model group to which the receiver should belong.EOModel.modelGroup()
public void loadAllModelObjects()
EOModel.entities()
,
EOModel.storedProcedures()
,
EOEntity.attributes()
,
EOEntity.relationships()
public NSArray referencesToProperty(Object property)
property
, whether derived attributes, relationships that reference property
, and so on. Returns null
if property
isn't referenced by any of the properties in the
model.
property
- The name of a property.
property
.EOModel.externalModelsReferenced()
public NSArray externalModelsReferenced()
EOModel.referencesToProperty(Object aProperty)
public void beautifyNames()
EOEntity.nameForExternalName(String name, String separatorString , boolean initialCaps)
,
EOModel.name()
,
EOEntity.beautifyName()
,
EOAttribute.beautifyName()
,
EORelationship.beautifyName()
,
EOStoredProcedure.beautifyName()
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |