@Service(value=Model.class) public class ModelImpl extends Object implements Model
| Constructor and Description |
|---|
ModelImpl()
Creates a model.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addModelEntity(ModelEntity modelEntity)
Adds an entity to the model.
|
void |
clearModel()
Clears the model.
|
protected EntityFactory |
createEntityFactory()
Creates the entity factory for this model.
The method is invoked once from within the Model constructor. |
protected ModelDirectory |
createModelDirectory(String modelDir,
ModelDefaults defaults,
EntityAliases aliases)
Creates a model directory object.
|
protected ModelEntity |
createModelEntity(Entity entity,
String fileName)
Creates a model entity wrapper.
|
protected Reader |
createReader(String name)
Creates a reader for given name.
|
Collection<Entity> |
getAllEntitites()
Gets all cached entities.
|
Entity |
getByClassId(int classId)
Gets the entity by its id.
|
Entity |
getByEntityName(String entityName)
Gets the entity by its name.
|
Entity |
getByFileName(String fileName)
Gets the entity by the mapfile name.
|
EntityFactory |
getEntityFactory()
Gets the entity factory singleton.
|
Collection<ForeignKey> |
getForeignKeys()
Gets all foreign keys.
|
boolean |
isSchemaNameMapped()
Returns whether schema names are mapped.
|
Entity |
loadByFileName(String fileName,
ModelDefaults defaults,
EntityAliases aliases)
Loads an entity for a given mapfile name.
Entities are cached so they are loaded and parsed only once. |
protected Entity |
loadByFileName(String fileName,
ModelDefaults defaults,
EntityAliases aliases,
boolean updateRelations)
Loads an entity for a given mapfile name.
Entities are cached so they are loaded and parsed only once. |
void |
loadModel(String modelDir,
ModelDefaults defaults,
EntityAliases aliases)
Loads the whole model from the model directory if not yet done.
|
protected Entity |
parseEntity(ModelDefaults defaults,
String fileName)
Parses the given file and returns the created entity.
|
void |
refreshModel()
Refreshes the model.
Checks for changes and reloads if necessary. |
void |
setSchemaNameMapped(boolean mapSchemas)
Sets whether schema names should be mapped to the leading part of tablenames.
|
protected String |
translateAlias(EntityAliases aliases,
String name)
Translates an entity name if it is an alias.
|
protected void |
updateCompositePath(List<Relation> compositePath,
Entity entity)
Updates the composite path.
|
protected void |
updateRelations(ModelDefaults defaults,
EntityAliases aliases)
Updates the inheritance links and relations of all entities in the model.
|
protected void |
updateRelations(ModelDefaults defaults,
EntityAliases aliases,
ModelEntity loadedModelEntity)
Updates all relations.
|
protected void |
validateComponents(Entity entity,
Integrity integrity,
Set<ModelError> errors)
Verifies that the integrity is the same within a given composite hierarchy.
|
protected void |
validateInheritanceHierarchy(Entity entity,
InheritanceType inheritanceType,
TrackType trackType,
Integrity integrity,
Set<ModelError> errors)
Verifies that the inheritance, integrity and track type is the same within a given interitance hierarchy.
Notice that concrete classes (the leafs of the hierarchy) must have InheritanceType.NONE defined! |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInstancepublic void setSchemaNameMapped(boolean mapSchemas)
ModelsetSchemaNameMapped in interface ModelmapSchemas - true if mappublic boolean isSchemaNameMapped()
ModelisSchemaNameMapped in interface Modelpublic EntityFactory getEntityFactory()
ModelgetEntityFactory in interface Modelpublic void loadModel(String modelDir, ModelDefaults defaults, EntityAliases aliases) throws ModelException
ModelloadModel in interface ModelmodelDir - the directory containing the model filesdefaults - optional model defaults, null if nonealiases - optional entity aliases, null if noneModelException - if the model is inconsistentpublic void clearModel()
ModelclearModel in interface Modelpublic void refreshModel()
throws ModelException
ModelrefreshModel in interface ModelModelException - if the model is inconsistentpublic Collection<Entity> getAllEntitites() throws ModelException
ModelgetAllEntitites in interface ModelModelException - if the model is inconsistentpublic Entity getByFileName(String fileName) throws ModelException
ModelgetByFileName in interface ModelfileName - the name of the mapfileModelException - if the model is inconsistentpublic Entity getByEntityName(String entityName) throws ModelException
ModelgetByEntityName in interface ModelentityName - the nameModelException - if the model is inconsistentpublic Entity getByClassId(int classId) throws ModelException
ModelgetByClassId in interface ModelclassId - the class idModelException - if the model is inconsistentpublic Entity loadByFileName(String fileName, ModelDefaults defaults, EntityAliases aliases) throws ModelException
ModelloadByFileName in interface ModelfileName - the name of the mapfiledefaults - optional model defaults, null if nonealiases - optional entity aliases, null if noneModelException - if no such mapfile or parsing errorprotected Entity loadByFileName(String fileName, ModelDefaults defaults, EntityAliases aliases, boolean updateRelations) throws ModelException
fileName - the name of the mapfiledefaults - optional model defaults, null if nonealiases - optional entity aliases, null if noneupdateRelations - true if update the related entites in the modelModelException - if no such mapfile or parsing errorprotected Entity parseEntity(ModelDefaults defaults, String fileName) throws ModelException
defaults - the model defaults, null if nonefileName - the name of the file holding the modelModelException - if parsing failedprotected void addModelEntity(ModelEntity modelEntity) throws ModelException
modelEntity - the model entityModelException - if duplicate entities detectedprotected void updateRelations(ModelDefaults defaults, EntityAliases aliases) throws ModelException
defaults - the optional model defaultsaliases - the optional entity aliasesModelException - if relations or inheritance misconfiguredprotected void updateRelations(ModelDefaults defaults, EntityAliases aliases, ModelEntity loadedModelEntity) throws ModelException
defaults - the optional model defaultsaliases - the optional entity aliasesloadedModelEntity - the entity that caused the update, null if noneModelException - if relations or inheritance misconfiguredprotected void updateCompositePath(List<Relation> compositePath, Entity entity)
compositePath - the path that leads to given entity so farentity - the entitypublic Collection<ForeignKey> getForeignKeys() throws ModelException
ModelgetForeignKeys in interface ModelModelException - if model is inconsistentprotected EntityFactory createEntityFactory()
protected ModelDirectory createModelDirectory(String modelDir, ModelDefaults defaults, EntityAliases aliases) throws ModelException
modelDir - the directory namedefaults - optional model defaults, null if nonealiases - optional entity aliases, null if noneModelException - if directory does not exist or is not a directoryprotected ModelEntity createModelEntity(Entity entity, String fileName) throws ModelException
entity - the entityfileName - the model file nameModelException - if creation failedprotected Reader createReader(String name) throws ModelException
name - the file- or resource nameModelException - if creating the reader failed (because file not found)protected void validateInheritanceHierarchy(Entity entity, InheritanceType inheritanceType, TrackType trackType, Integrity integrity, Set<ModelError> errors)
entity - the entity to checkinheritanceType - the inheritance typetrackType - the tracking typeintegrity - the integrity typeerrors - the collected model errorsprotected void validateComponents(Entity entity, Integrity integrity, Set<ModelError> errors)
entity - the entity to checkintegrity - the integrity typeerrors - the collected model errorsprotected String translateAlias(EntityAliases aliases, String name)
aliases - the entity aliasesname - the original nameTentackle - a domain driven enterprise framework