- All Known Implementing Classes:
ModelImpl
public interface Model
Model singleton.
- Author:
- harald
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of the index file holding the model names within a jar or classpath.
Resides inMETA-INF. -
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.getByTableName(String tableName) Gets the entity by its table name.Gets the entity by the model file path.Gets the entity aliases.Gets the entity factory singleton.getEntityInfo(Entity entity) Gets the model information for the given entity.Gets all foreign keys.static ModelThe singleton.Gets the model defaults.booleanReturns whether schema names are mapped.loadFromDirectory(String modelDir, boolean updateRelations) Loads the whole model from the model directory if not yet done.loadFromJar(File file, boolean updateRelations) Loads the model from a jar file.
Reads the model files listed inMETA-INF/MODEL-INDEX.LIST.loadFromResources(boolean updateRelations) Loads from resources.
Locates allMETA-INF/MODEL-INDEX.LISTresources and loads the model files.loadFromURL(URL url, boolean updateRelations) Loads an entity from a given URL.
Entities are cached, so they are loaded and parsed only once.voidRefreshes the model.
Checks for changes and reloads if necessary.voidsetEntityAliases(EntityAliases entityAliases) Sets the entity aliases for relations between entities.voidsetModelDefaults(ModelDefaults modelDefaults) Sets the model defaults to apply when loading the model sources.voidsetSchemaNameMapped(boolean mapSchemas) Sets whether schema names should be mapped to the leading part of table names.voidUpdates the relations if not yet done during load.
-
Field Details
-
MODEL_INDEX_LIST
Name of the index file holding the model names within a jar or classpath.
Resides inMETA-INF.- See Also:
-
-
Method Details
-
getInstance
The singleton.- Returns:
- the singleton
-
getEntityFactory
EntityFactory getEntityFactory()Gets the entity factory singleton.- Returns:
- the entity model factory
-
setModelDefaults
Sets the model defaults to apply when loading the model sources.- Parameters:
modelDefaults- the model defaults, null if none
-
getModelDefaults
ModelDefaults getModelDefaults()Gets the model defaults.- Returns:
- the model defaults, null if none
-
setEntityAliases
Sets the entity aliases for relations between entities.- Parameters:
entityAliases- the aliases, null if none
-
getEntityAliases
EntityAliases getEntityAliases()Gets the entity aliases.- Returns:
- the aliases, null if none
-
loadFromDirectory
Collection<EntityInfo> loadFromDirectory(String modelDir, boolean updateRelations) throws ModelException Loads the whole model from the model directory if not yet done.- Parameters:
modelDir- the name of the directory containing the model filesupdateRelations- true if update the relations, false if model is still incomplete- Returns:
- the entity infos of the loaded model files
- Throws:
ModelException- if the model is inconsistent- See Also:
-
loadFromURL
Loads an entity from a given URL.
Entities are cached, so they are loaded and parsed only once.- Parameters:
url- the URL of the model fileupdateRelations- true if update the relations, false if model is still incomplete- Returns:
- the entity info
- Throws:
ModelException- if the model is inconsistent- See Also:
-
loadFromJar
Loads the model from a jar file.
Reads the model files listed inMETA-INF/MODEL-INDEX.LIST.- Parameters:
file- the jar fileupdateRelations- true if update the relations, false if model is still incomplete- Returns:
- the entity infos of the loaded model files
- Throws:
ModelException- if the model is inconsistent
-
loadFromResources
Loads from resources.
Locates allMETA-INF/MODEL-INDEX.LISTresources and loads the model files.- Parameters:
updateRelations- true if update the relations, false if model is still incomplete- Returns:
- the entity infos of the loaded model files
- Throws:
ModelException- if the model is inconsistent
-
updateRelations
Updates the relations if not yet done during load.- Throws:
ModelException- if model is inconsistent- See Also:
-
clearModel
void clearModel()Clears the model. -
setSchemaNameMapped
void setSchemaNameMapped(boolean mapSchemas) Sets whether schema names should be mapped to the leading part of table names.- 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
-
getAllEntities
Gets all cached entities.- Returns:
- all entities loaded so far
- Throws:
ModelException- if the model is inconsistent
-
getByURL
Gets the entity by the model file path.- Parameters:
url- the URL of the model file- 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
-
getEntityInfo
Gets the model information for the given entity.- Parameters:
entity- the entity- Returns:
- the model info, never null
- Throws:
ModelException- if the model is inconsistent or no such entity
-
getForeignKeys
Gets all foreign keys.- Returns:
- the foreign keys
- Throws:
ModelException- if model is inconsistent
-