@Service(value=Model.class) public class ModelImpl extends Object implements Model
| Constructor and Description |
|---|
ModelImpl()
Creates a model.
|
| Modifier and Type | Method and Description |
|---|---|
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 Reader |
createFileReader(String fileName)
Creates a reader for given filename.
|
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(ModelDefaults defaults,
String fileName)
Loads an entity for a given mapfile name.
Entities are cached so they are loaded and parsed only once. |
protected Entity |
loadByFileName(ModelDefaults defaults,
String fileName,
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)
Loads the whole model from the model directory if not yet done.
|
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 void |
updateCompositePath(List<Relation> compositePath,
Entity entity)
Updates the composite path.
|
protected void |
updateRelations(ModelDefaults defaults)
Updates the inheritance links and relations of all entities in the model.
|
protected void |
updateRelations(ModelDefaults defaults,
ModelEntity loadedModelEntity)
Updates all relations.
|
protected String |
validateComponents(Entity entity,
Integrity integrity,
StringBuilder exMsg,
Set<Entity> exEntities)
Verifies that the integrity is the same within a given composite hierarchy.
|
protected String |
validateInheritanceHierarchy(Entity entity,
InheritanceType inheritanceType,
TrackType trackType,
Integrity integrity,
StringBuilder exMsg,
Set<Entity> exEntities)
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) throws ModelException
ModelloadModel in interface ModelmodelDir - the directory containing the model filesdefaults - model defaults, 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(ModelDefaults defaults, String fileName) throws ModelException
ModelloadByFileName in interface Modeldefaults - the model defaultsfileName - the name of the mapfileModelException - if no such mapfile or parsing errorprotected Entity loadByFileName(ModelDefaults defaults, String fileName, boolean updateRelations) throws ModelException
defaults - the model defaultsfileName - the name of the mapfileupdateRelations - true if update the related entites in the modelModelException - if no such mapfile or parsing errorprotected void updateRelations(ModelDefaults defaults) throws ModelException
defaults - the model defaultsModelException - if relations or inheritance misconfiguredprotected void updateRelations(ModelDefaults defaults, ModelEntity loadedModelEntity) throws ModelException
defaults - the model defaultsloadedModelEntity - 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 Reader createFileReader(String fileName) throws ModelException
fileName - the filenameModelException - if creating the reader failed (because file not found)protected String validateInheritanceHierarchy(Entity entity, InheritanceType inheritanceType, TrackType trackType, Integrity integrity, StringBuilder exMsg, Set<Entity> exEntities)
entity - the entity to checkinheritanceType - the inheritance typetrackType - the tracking typeintegrity - the integrity typeexMsg - execption message bufferexEntities - the entities related to the exception messageprotected String validateComponents(Entity entity, Integrity integrity, StringBuilder exMsg, Set<Entity> exEntities)
entity - the entity to checkintegrity - the integrity typeexMsg - execption message bufferexEntities - the entities related to the exception messageCopyright © 2016 Krake Softwaretechnik. All rights reserved.