Interface Model

All Known Implementing Classes:
ModelImpl

public interface Model
Model singleton.
Author:
harald
  • Field Details

    • MODEL_INDEX_LIST

      static final String MODEL_INDEX_LIST
      Name of the index file holding the model names within a jar or classpath.
      Resides in META-INF.
      See Also:
  • Method Details

    • getInstance

      static Model getInstance()
      The singleton.
      Returns:
      the singleton
    • getEntityFactory

      EntityFactory getEntityFactory()
      Gets the entity factory singleton.
      Returns:
      the entity model factory
    • setModelDefaults

      void setModelDefaults(ModelDefaults modelDefaults)
      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

      void setEntityAliases(EntityAliases entityAliases)
      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 files
      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
      See Also:
    • loadFromURL

      EntityInfo loadFromURL(URL url, boolean updateRelations) throws ModelException
      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 file
      updateRelations - 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

      Collection<EntityInfo> loadFromJar(File file, boolean updateRelations) throws ModelException
      Loads the model from a jar file.
      Reads the model files listed in META-INF/MODEL-INDEX.LIST.
      Parameters:
      file - the jar file
      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
    • loadFromResources

      Collection<EntityInfo> loadFromResources(boolean updateRelations) throws ModelException
      Loads from resources.
      Locates all META-INF/MODEL-INDEX.LIST resources 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

      void updateRelations() throws ModelException
      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

      void refreshModel() throws ModelException
      Refreshes the model.
      Checks for changes and reloads if necessary.
      Throws:
      ModelException - if the model is inconsistent
    • getAllEntities

      Collection<Entity> getAllEntities() throws ModelException
      Gets all cached entities.
      Returns:
      all entities loaded so far
      Throws:
      ModelException - if the model is inconsistent
    • getByURL

      Entity getByURL(URL url) throws ModelException
      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

      Entity getByTableName(String tableName) throws ModelException
      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

      Entity getByEntityName(String entityName) throws ModelException
      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

      Entity getByClassId(int classId) throws ModelException
      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

      EntityInfo getEntityInfo(Entity entity) throws ModelException
      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

      Collection<ForeignKey> getForeignKeys() throws ModelException
      Gets all foreign keys.
      Returns:
      the foreign keys
      Throws:
      ModelException - if model is inconsistent