Extends:
next.util.NextObject
A Model maintains a mapping between each of its Entity objects and a corresponding enterprise object class for use with the database level of the Enterprise Objects Framework. You can determine the Entity for a particular enterprise object with the entityForObject
method.
A Model is specific to a particular database server, and stores information needed to connect to that server. This includes the name of an adaptor framework to load so that the Enterprise Objects Framework can communicate with the database. Models are stored in the file system in a manner similar to adaptor framework; see "Loading a Model File" below for more information.
Models can have relationships that reference other models in the same model group. The other models may map to different databases and types of servers.
Models are organized into model groups; see the ModelGroup class specification for more information.
To load a Model, provide a model file's path to the constructor. Note that loading a Model doesn't have the effect of loading all of its entities. Model 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 a Model actually consists of one index file and a separate file 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. It is this file that gets loaded when you create a new model from a path. When an entity is loaded, Model posts an EntityLoadedNotification.
Some of the Model methods contain the string "TableOfContents". A Model's "table of contents" corresponds to its index.eomodeld
file, which is used to access the model's entities. index.eomodeld
is just the ASCII representation of a model's table of contents.
next.eo.Model
()
public next.eo.Model
(java.lang.String path)
public next.eo.Model
(next.util.ImmutableHashtable tableOfContents, java.lang.String path)
Creates a new Model object. If path is provided, the new Model is created by reading the contents of the file identified by path as a model archive. Sets the Model's name and path from the context of the model archive. Throws an exception if for any reason it cannot initialize the model from the file specified by path.
If tableOfContents is provided, the new Model is created from tableOfContents, which is the property list representation of a Model). Sets the Model's name and path using path.
See also:
name
, path
, encodeTableOfContentsIntoPropertyList
adaptorName
()
Returns the name of the adaptor for the receiver. This name can be used with Adaptor's adaptorWithName
static method to create an adaptor.
addEntity
(next.eo.Entity anEntity)
Adds anEntity to the receiver. Throws an exception if an error occurs (for example, if anEntity doesn't exist, if the entity belongs to another model, or if an entity of the same name is already in the receiver).
See also:
entities
, removeEntity
, removeEntityAndReferences
, model
(Entity)
addStoredProcedure
(next.eo.StoredProcedure storedProcedure)
Adds storedProcedure to the receiver. Throws an exception if an error occurs (for example, if a stored procedure of the same name is already in the receiver).
See also:
removeStoredProcedure
, storedProcedures
, storedProcedureNamed
beautifyNames
()
Makes all of the receiver's named components conform to a standard convention.
See also:
nameForExternalName
(Entity), beautifyName
(Entity, Attribute, Relationship,
StoredProcedure)
connectionDictionary
()
Returns a dictionary containing information used to connect to the database server. The connection dictionary is the place to specify default login information for applications using the model. See the Attribute class specification for more information.
encodeTableOfContentsIntoPropertyList
(next.util.MutableHashtable propertyList)
Encodes the receiver into propertyList. This method is used to get an ASCII representation of a Model in property list format.
See also: "Constructors"
entities
()
Returns an array containing the receiver's entities. Note that this method loads every entity, and thus defeats the benefits of incremental model loading.
See also:
entityNames
entityForObject
(java.lang.Object anEO)
Returns the entity associated with anEO, whether anEO is an instance of an enterprise object class, an instance of GenericRecord, or a fault object (see the next.eo.Fault class specification for information on faults). Returns null
if anEO has no associated entity.
entityNamed
(java.lang.String name)
Returns the entity named name, or null
if no such entity exists. Posts an EntityLoadedNotification when the entity is loaded.
See also:
entityNames
, entities
entityNames
()
Returns an array containing the names of the Model's entities.
See also:
entities
, entityNamed
externalModelsReferenced
()
Returns an array containing those models that are referenced by this model.
See also:
referencesToProperty
loadAllModelObjects
()
Loads any of the receiver's entities, stored procedures, attributes, and relationships that have not yet been loaded.
See also:
attributes
(Entity), entities
, relationships
(Entity), storedProcedures
modelGroup
()
Returns the model group of which the receiver is a part.
See also:
setModelGroup
name
()
Returns the receiver's name.
See also:
path
, "Constructors"
path
()
Returns the name of the Model file used to create the receiver, or null
if the model wasn't initialized from a file.
See also:
name
, "Constructors"
referencesToProperty
(java.lang.Object aProperty)
Returns an array of all properties in the receiver that reference aProperty, whether derived attributes, relationships that reference aProperty, and so on. Returns null
if aProperty isn't referenced by any of the properties in the model.
See also:
externalModelsReferenced
removeEntity
(next.eo.Entity entity)
Removes entity without performing any referential integrity checking.
See also:
addEntity
, removeEntityAndReferences
removeEntityAndReferences
(next.eo.Entity entity)
Removes entity and any attributes or relationships in other entities that reference entity.
See also:
removeEntity
, addEntity
removeStoredProcedure
(next.eo.StoredProcedure aStoredProcedure)
Removes aStoredProcedure without checking to see if an entity uses it.
See also:
addStoredProcedure
, storedProcedures
setAdaptorName
(java.lang.String adaptorName)
Sets the name of the receiver's adaptor to adaptorName.
See also:
availableAdaptorNames
(Adaptor)
setConnectionDictionary
(next.util.ImmutableHashtable connectionDictionary)
Sets the dictionary containing information used to connect to the database to connectionDictionary. See the Adaptor class specification for more information on working with connection dictionaries.
See also:
adaptorWithModel
(Adaptor)
setModelGroup
(next.eo.ModelGroup aModelGroup)
Sets the model group of which the receiver should be a part.
modelGroup
setName
(java.lang.String name)
Sets the name of the receiver to name.
setUserInfo
(next.util.ImmutableHashtable dictionary)
Sets the dictionary of auxiliary data, which your application can use for whatever it needs. dictionary can only contain property list data types-that is, dictionaries (next.util.ImmutableHashtables, next.util.MutableHashtables), strings (java.lang.String), arrays (next.util.ImmutableVector, next.util.MutableVector), and data objects (next.util.ImmutableBytes, next.util.MutableBytes).
storedProcedureNamed
(java.lang.String name)
Returns the stored procedure named name, or null
if the model doesn't contain a stored procedure with the given name.
See also:
storedProcedureNames
, storedProcedures
storedProcedureNames
()
Returns an array containing the names of all of the model's stored procedures.
See also:
storedProcedureNamed
, storedProcedures
storedProcedures
()
Returns an array containing all of the model's stored procedures. Note that this method loads each of the model's stored procedures, thus defeating the benefits of incremental model loading.
See also:
storedProcedureNames
, storedProcedureNamed
userInfo
()
Returns a dictionary of user data. You can use this to store any auxiliary information it needs.
See also:
setUserInfo
writeToFile
(java.lang.String path)
Saves the receiver in the directory specified by path. If the file specified by path already exists, a backup copy is first created (using path with a "~" character appended). As a side-effect, this method resets the current path.
writeToFile
throws an exception on any error which prevents the file from being written.
See also:
path
Notification Object | The entity that was loaded. |
Userinfo | None |