- All Known Implementing Classes:
ModelImpl
public interface Model
Model singleton.
- Author:
- harald
-
Method Summary
Modifier and TypeMethodDescriptionvoidClears the model.Gets all cached entities.getByClassId(int classId) Gets the entity by its class id.getByEntityName(String entityName) Gets the entity by its name.getByFilePath(String filePath) Gets the entity by the mapfile path.getByTableName(String tableName) Gets the entity by its table name.Gets the entity factory singleton.Gets all foreign keys.static ModelThe singleton.booleanReturns whether schema names are mapped.loadByFilePath(String filePath, ModelDefaults defaults, EntityAliases aliases) Loads an entity for a given mapfile name.
Entities are cached so they are loaded and parsed only once.voidloadModel(String modelDir, ModelDefaults defaults, EntityAliases aliases) Loads the whole model from the model directory if not yet done.voidRefreshes the model.
Checks for changes and reloads if necessary.voidsetSchemaNameMapped(boolean mapSchemas) Sets whether schema names should be mapped to the leading part of tablenames.
-
Method Details
-
getInstance
The singleton.- Returns:
- the singleton
-
getEntityFactory
EntityFactory getEntityFactory()Gets the entity factory singleton.- Returns:
- the entity model factory
-
loadModel
void loadModel(String modelDir, ModelDefaults defaults, EntityAliases aliases) throws ModelException Loads the whole model from the model directory if not yet done.- Parameters:
modelDir- the directory containing the model filesdefaults- optional model defaults, null if nonealiases- optional entity aliases, null if none- Throws:
ModelException- if the model is inconsistent
-
clearModel
void clearModel()Clears the model. -
setSchemaNameMapped
void setSchemaNameMapped(boolean mapSchemas) Sets whether schema names should be mapped to the leading part of tablenames.- Parameters:
mapSchemas- true if map
-
isSchemaNameMapped
boolean isSchemaNameMapped()Returns whether schema names are mapped.- Returns:
- true if mapped
-
refreshModel
Refreshes the model.
Checks for changes and reloads if necessary.- Throws:
ModelException- if the model is inconsistent
-
getAllEntitites
Gets all cached entities.- Returns:
- all entities loaded so far
- Throws:
ModelException- if the model is inconsistent
-
getByFilePath
Gets the entity by the mapfile path.- Parameters:
filePath- the pathname of the mapfile- Returns:
- the entity, null if no such entity
- Throws:
ModelException- if the model is inconsistent
-
getByTableName
Gets the entity by its table name.- Parameters:
tableName- the table name (optional leading schema will be ignored)- Returns:
- the entity, null if no such entity
- Throws:
ModelException- if the model is inconsistent
-
getByEntityName
Gets the entity by its name.- Parameters:
entityName- the name- Returns:
- the entity, null if no such entity
- Throws:
ModelException- if the model is inconsistent
-
getByClassId
Gets the entity by its class id.- Parameters:
classId- the class id- Returns:
- the entity, null if no such entity
- Throws:
ModelException- if the model is inconsistent
-
loadByFilePath
Entity loadByFilePath(String filePath, ModelDefaults defaults, EntityAliases aliases) throws ModelException Loads an entity for a given mapfile name.
Entities are cached so they are loaded and parsed only once.- Parameters:
filePath- the path of the mapfiledefaults- optional model defaults, null if nonealiases- optional entity aliases, null if none- Returns:
- the entity
- Throws:
ModelException- if no such mapfile or parsing error
-
getForeignKeys
Gets all foreign keys.- Returns:
- the foreign keys
- Throws:
ModelException- if model is inconsistent
-