Class EntityImpl

java.lang.Object
org.tentackle.model.impl.EntityImpl
All Implemented Interfaces:
Comparable<EntityImpl>, Entity, ModelElement

public class EntityImpl extends Object implements Entity, Comparable<EntityImpl>
The entity model implementation.
Author:
harald
  • Constructor Details

    • EntityImpl

      public EntityImpl(EntityFactoryImpl factory, SourceInfo sourceInfo)
      Creates an entity.
      Parameters:
      factory - the factory to create entity options
      sourceInfo - the source information
  • Method Details

    • getSourceInfo

      public SourceInfo getSourceInfo()
      Description copied from interface: ModelElement
      Gets the information about the source where this element is defined.
      Specified by:
      getSourceInfo in interface ModelElement
      Returns:
      the source info
    • getParent

      public ModelElement getParent()
      Description copied from interface: ModelElement
      Gets the parent element.
      Specified by:
      getParent in interface ModelElement
      Returns:
      the parent, null if none
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(EntityImpl o)
      Specified by:
      compareTo in interface Comparable<EntityImpl>
    • parseConfiguration

      public boolean parseConfiguration(ConfigurationLine line) throws ModelException
      Parses a configuration line.
      Parameters:
      line - the configuration line
      Returns:
      true if known configuration processed
      Throws:
      ModelException - if parsing failed
    • getName

      public String getName()
      Description copied from interface: ModelElement
      Gets the name of the element.
      Specified by:
      getName in interface ModelElement
      Returns:
      the name
    • setName

      public void setName(String name)
      Sets the entity's name.
      Parameters:
      name - the name
    • getOrdinal

      public int getOrdinal()
      Description copied from interface: ModelElement
      Gets the ordinal along the inheritance path.
      Specified by:
      getOrdinal in interface ModelElement
      Returns:
      the ordinal, starting at 0
    • setOrdinal

      public void setOrdinal(int ordinal)
    • getClassId

      public int getClassId()
      Description copied from interface: Entity
      Gets the unique id of this entity.
      A sort of class-ID that is used to map from a small number to a class or classname.
      Specified by:
      getClassId in interface Entity
      Returns:
      the entity class id
    • setClassId

      public void setClassId(int classId)
      Sets the entity id.
      Parameters:
      classId - the id
    • getTableName

      public String getTableName()
      Description copied from interface: Entity
      Gets the database table name.
      An optional schema may be prepended separated by a dot.

      Important: similar to the entity name, the table name must be unique among the whole model and all schemas. This restriction avoids unnecessary confusion and reduces the potential for errors in SQL statements.

      Specified by:
      getTableName in interface Entity
      Returns:
      the tablename (always in lowercase), null if entity doesn't map to its own table
    • getSchemaName

      public String getSchemaName()
      Description copied from interface: Entity
      Gets the schema name.
      Specified by:
      getSchemaName in interface Entity
      Returns:
      the schema (always in lowercase), null if default
    • getTableNameWithoutSchema

      public String getTableNameWithoutSchema()
      Description copied from interface: Entity
      Gets the tablename without the leading schema.

      Important: similar to the entity name, the table name must be unique among the whole model and all schemas. This restriction avoids unnecessary confusion and reduces the potential for errors in SQL statements.

      Specified by:
      getTableNameWithoutSchema in interface Entity
      Returns:
      the tablename relative to its schema (always in lowercase), null if entity doesn't map to its own table
    • getTableAlias

      public String getTableAlias()
      Description copied from interface: Entity
      Gets the table alias for joined selects.
      The alias is unique among all tables. If the model does not provide an alias, a unique alias will be generated.
      Specified by:
      getTableAlias in interface Entity
      Returns:
      the table alias
    • getDefinedTableAlias

      public String getDefinedTableAlias()
      Description copied from interface: Entity
      Gets the table alias originally configured in the model.
      Specified by:
      getDefinedTableAlias in interface Entity
      Returns:
      the fixed alias, null if automatic
    • setTableName

      public void setTableName(String tableName)
      Sets the tablename.
      Parameters:
      tableName - the tablename
    • setTableAlias

      public void setTableAlias(String tableAlias)
      Sets the table alias.
      Parameters:
      tableAlias - the alias
    • setDefinedTableAlias

      public void setDefinedTableAlias(String definedTableAlias)
      Sets the table alias defined by the model specification.
      Parameters:
      definedTableAlias - the original alias, null if automatic
    • getIntegrity

      public Integrity getIntegrity()
      Description copied from interface: Entity
      Gets the referential integrity mode.
      Specified by:
      getIntegrity in interface Entity
      Returns:
      the integrity mode
    • getInheritanceType

      public InheritanceType getInheritanceType()
      Description copied from interface: Entity
      Gets the inheritance type.
      Specified by:
      getInheritanceType in interface Entity
      Returns:
      the inheritance type
    • getHierarchyInheritanceType

      public InheritanceType getHierarchyInheritanceType()
      Description copied from interface: Entity
      Gets the inheritance type of the hierarchy.
      For leafs, which have InheritanceType.NONE, the type of the super entity is returned.
      Specified by:
      getHierarchyInheritanceType in interface Entity
      Returns:
      the effective inheritance type
    • getSuperEntityName

      public String getSuperEntityName()
      Description copied from interface: Entity
      Gets the name of the super class entity.
      Specified by:
      getSuperEntityName in interface Entity
      Returns:
      the super class name, null if not inherited
    • getSuperEntity

      public Entity getSuperEntity()
      Description copied from interface: Entity
      Gets the super class entity if inherited.
      Specified by:
      getSuperEntity in interface Entity
      Returns:
      the super entity, null if not inherited
    • getSuperEntities

      public List<Entity> getSuperEntities()
      Description copied from interface: Entity
      Gets all super entities.
      Specified by:
      getSuperEntities in interface Entity
      Returns:
      the path along up to the top super entity.
    • getTopSuperEntity

      public Entity getTopSuperEntity()
      Description copied from interface: Entity
      Gets the top most entity of the inheritance tree.
      Returns this entity if there is no inheritance.
      Specified by:
      getTopSuperEntity in interface Entity
      Returns:
      the root of the inheritance hierarchy
    • getInheritanceChain

      public List<Entity> getInheritanceChain(Entity childEntity) throws ModelException
      Description copied from interface: Entity
      Gets the inheritance chain from this entity down to given sub entity.
      Specified by:
      getInheritanceChain in interface Entity
      Parameters:
      childEntity - the sub entity
      Returns:
      the chain starting with this entity end ending with the sub entity
      Throws:
      ModelException - if subEntity does not inherit this entity
    • getSubEntities

      public List<Entity> getSubEntities()
      Description copied from interface: Entity
      Gets the direct sub entities.
      Specified by:
      getSubEntities in interface Entity
      Returns:
      the sub entities, empty list if no sub entities
    • getAllSubEntities

      public List<Entity> getAllSubEntities()
      Description copied from interface: Entity
      Gets all sub entities.
      Specified by:
      getAllSubEntities in interface Entity
      Returns:
      the sub entities, empty list if no sub entities
    • getLeafEntities

      public List<Entity> getLeafEntities()
      Description copied from interface: Entity
      Gets the list of non-abstract leaf sub entities.
      If this entity is already non-abstract the list consists of this entity.
      Specified by:
      getLeafEntities in interface Entity
      Returns:
      the leafs
    • collectLeafEntities

      protected void collectLeafEntities(List<Entity> leafs, Entity entity)
      Recursively collects the leaf children.
      Parameters:
      leafs - the list if leafs
      entity - the current entity to analyze
    • collectSubEntities

      protected void collectSubEntities(List<Entity> subEntities, Entity entity)
      Recursively collects all sub entities.
      Parameters:
      subEntities - the list of collected sub entities
      entity - the current entity to analyze
    • getAssociatedEntities

      public Set<Entity> getAssociatedEntities()
      Description copied from interface: Entity
      Gets a set of all entities that are associated to this entity.
      The kind of association can be a relation, a foreign relation or some hierarchy dependency or a combination of.
      Specified by:
      getAssociatedEntities in interface Entity
      Returns:
      the set of entities including me
    • collectAssociatedEntities

      protected void collectAssociatedEntities(Set<Entity> associates, Entity entity, Set<Entity> processedEntities)
      Recursively collects the associated entities for a given entity.
      Parameters:
      associates - the set of associated entities so far
      entity - the current entity to analyze
      processedEntities - the already processed entities (to avoid loops)
    • setIntegrity

      public void setIntegrity(Integrity integrity)
      Sets the integrity.
      Parameters:
      integrity - the integrity
    • setInheritanceType

      public void setInheritanceType(InheritanceType inheritanceType)
      Sets the inheritance type.
      Parameters:
      inheritanceType - the inheritance type
    • setSuperEntityName

      public void setSuperEntityName(String superEntityName)
      Sets the name of the super entity.
      Parameters:
      superEntityName - the super entity
    • setSuperEntity

      public void setSuperEntity(Entity superEntity)
      Sets the super entity.
      Parameters:
      superEntity - the super entity
    • setContextIdAttribute

      public void setContextIdAttribute(Attribute contextIdAttribute)
      Sets the context id attribute.
      Parameters:
      contextIdAttribute - the attribute providing the context ID
    • setSorting

      public void setSorting(List<AttributeSorting> sorting)
      Sets the default sorting.
      Parameters:
      sorting - the sorting, null if none
    • getOptions

      public EntityOptionsImpl getOptions()
      Description copied from interface: Entity
      Gets the options.
      Specified by:
      getOptions in interface Entity
      Returns:
      the options
    • getAttributes

      public List<Attribute> getAttributes()
      Description copied from interface: Entity
      Gets the attributes.
      Specified by:
      getAttributes in interface Entity
      Returns:
      the attributes
    • isRootEntityAccordingToModel

      public boolean isRootEntityAccordingToModel()
      Returns whether this entity is a root-entity according to model.
      Specified by:
      isRootEntityAccordingToModel in interface Entity
      Returns:
      true if root entity
    • setRootEntityAccordingToModel

      public void setRootEntityAccordingToModel(boolean modelRoot)
      Sets whether this entity is a root-entity according to model.
      Parameters:
      modelRoot - true if root entity
    • isProvidingRootClassIdAccordingToModel

      public boolean isProvidingRootClassIdAccordingToModel()
      Returns whether this entity should provide a root class id according to model.
      Specified by:
      isProvidingRootClassIdAccordingToModel in interface Entity
      Returns:
      true if should provide a root class id
    • setProvidingRootClassIdAccordingToModel

      public void setProvidingRootClassIdAccordingToModel(boolean modelRootClassId)
      Sets whether this entity should provide a root class id according to model.
      Parameters:
      modelRootClassId - true if should provide a root class id
    • isProvidingRootIdAccordingToModel

      public boolean isProvidingRootIdAccordingToModel()
      Returns whether this entity should provide a root id according to model.
      Specified by:
      isProvidingRootIdAccordingToModel in interface Entity
      Returns:
      true if the entity should provide a root id
    • setProvidingRootIdAccordingToModel

      public void setProvidingRootIdAccordingToModel(boolean modelRootId)
      Sets whether this entity should provide a root id according to model.
      Parameters:
      modelRootId - true if the entity should provide a root id
    • getInheritedAttributes

      public List<Attribute> getInheritedAttributes() throws ModelException
      Description copied from interface: Entity
      Gets the inherited attributes.
      Specified by:
      getInheritedAttributes in interface Entity
      Returns:
      the attributes
      Throws:
      ModelException
    • getEmbeddedAttributes

      public List<Attribute> getEmbeddedAttributes() throws ModelException
      Description copied from interface: Entity
      Gets the attributes of embedded entities.
      Specified by:
      getEmbeddedAttributes in interface Entity
      Returns:
      the embedded attributes
      Throws:
      ModelException
    • getEmbeddedRelations

      public List<Relation> getEmbeddedRelations(Entity embeddingEntity) throws ModelException
      Description copied from interface: Entity
      Gets the relations of all embedded entities.
      Due to the restriction of embedded entities, these relations are all non-composite object relations.
      Specified by:
      getEmbeddedRelations in interface Entity
      Parameters:
      embeddingEntity - the effectively embedding entity
      Returns:
      the list of embedded relations
      Throws:
      ModelException - if failed
    • getSubEntityAttributes

      public List<Attribute> getSubEntityAttributes()
      Description copied from interface: Entity
      Gets the attributes from the sub entities.
      Specified by:
      getSubEntityAttributes in interface Entity
      Returns:
      the attributes
    • getAttributesIncludingInherited

      public List<Attribute> getAttributesIncludingInherited() throws ModelException
      Description copied from interface: Entity
      Gets the attributes including the inherited ones.
      Specified by:
      getAttributesIncludingInherited in interface Entity
      Returns:
      the attributes
      Throws:
      ModelException
    • getAttributesIncludingSubEntities

      public List<Attribute> getAttributesIncludingSubEntities()
      Description copied from interface: Entity
      Gets the attributes including the ones from the sub entities.
      Specified by:
      getAttributesIncludingSubEntities in interface Entity
      Returns:
      the attributes
    • getAllAttributes

      public List<Attribute> getAllAttributes() throws ModelException
      Description copied from interface: Entity
      Gets all attributes including inherited and from sub entities.
      Specified by:
      getAllAttributes in interface Entity
      Returns:
      the attributes
      Throws:
      ModelException
    • getTableAttributes

      public List<Attribute> getTableAttributes() throws ModelException
      Description copied from interface: Entity
      Gets the attributes of the table mapped by this entity.
      Specified by:
      getTableAttributes in interface Entity
      Returns:
      the attributes, empty if entity does not map to a table or does not provide attributes
      Throws:
      ModelException
    • getMappedAttributes

      public List<Attribute> getMappedAttributes() throws ModelException
      Description copied from interface: Entity
      Gets the attributes mapped by the persistence layer for this entity.
      Specified by:
      getMappedAttributes in interface Entity
      Returns:
      the attributes
      Throws:
      ModelException
    • moveIdSerialToEnd

      protected List<Attribute> moveIdSerialToEnd(List<Attribute> attributes)
      Moved id and serial to the end of a new created attribute list.
      Parameters:
      attributes - the attribute list
      Returns:
      the new filtered attribute list
    • removeIdSerial

      protected List<Attribute> removeIdSerial(List<Attribute> attributes)
      Removes id and serial from the list of attributes.
      Parameters:
      attributes - the attribute list
      Returns:
      the new filtered attribute list
    • appendIdSerial

      protected List<Attribute> appendIdSerial(Entity entity, List<Attribute> attributes)
      Appends id and serial from another entity.
      Parameters:
      entity - the entity defining id and serial
      attributes - the attribute list
      Returns:
      the new filtered attribute list
    • getInheritedIndexes

      public List<Index> getInheritedIndexes()
      Description copied from interface: Entity
      Gets inherited indexes.
      Specified by:
      getInheritedIndexes in interface Entity
      Returns:
      the indexes
    • getIndexesIncludingInherited

      public List<Index> getIndexesIncludingInherited()
      Description copied from interface: Entity
      Gets all including inherited indexes.
      Specified by:
      getIndexesIncludingInherited in interface Entity
      Returns:
      the indexes
    • getSubEntityIndexes

      public List<Index> getSubEntityIndexes()
      Description copied from interface: Entity
      Gets indexes from sub entities.
      Specified by:
      getSubEntityIndexes in interface Entity
      Returns:
      the indexes
    • getIndexesIncludingSubEntities

      public List<Index> getIndexesIncludingSubEntities()
      Description copied from interface: Entity
      Gets all including indexes from sub entities.
      Specified by:
      getIndexesIncludingSubEntities in interface Entity
      Returns:
      the indexes
    • getAllIndexes

      public List<Index> getAllIndexes()
      Description copied from interface: Entity
      Gets all including inherited and indexes from sub entities.
      Specified by:
      getAllIndexes in interface Entity
      Returns:
      the indexes
    • getTableIndexes

      public List<Index> getTableIndexes()
      Description copied from interface: Entity
      Gets the indexes of the table mapped by this entity.
      Specified by:
      getTableIndexes in interface Entity
      Returns:
      the indexes, empty if entity does not map to a table or provides no indexes
    • getInheritedRelations

      public List<Relation> getInheritedRelations() throws ModelException
      Description copied from interface: Entity
      Gets the inherited relations.
      Specified by:
      getInheritedRelations in interface Entity
      Returns:
      the relations
      Throws:
      ModelException
    • getSubEntityRelations

      public List<Relation> getSubEntityRelations()
      Description copied from interface: Entity
      Gets the relations from the sub entities.
      Specified by:
      getSubEntityRelations in interface Entity
      Returns:
      the relations
    • getRelationsIncludingInherited

      public List<Relation> getRelationsIncludingInherited() throws ModelException
      Description copied from interface: Entity
      Gets all including inherited relations.
      Specified by:
      getRelationsIncludingInherited in interface Entity
      Returns:
      the relations
      Throws:
      ModelException
    • getRelationsIncludingSubEntities

      public List<Relation> getRelationsIncludingSubEntities()
      Description copied from interface: Entity
      Gets all relations including the ones from the sub entities.
      Specified by:
      getRelationsIncludingSubEntities in interface Entity
      Returns:
      the relations
    • getAllRelations

      public List<Relation> getAllRelations() throws ModelException
      Description copied from interface: Entity
      Gets all relations including the inherited and the ones from the sub entities.
      Specified by:
      getAllRelations in interface Entity
      Returns:
      the relations
      Throws:
      ModelException
    • getTableRelations

      public List<Relation> getTableRelations() throws ModelException
      Description copied from interface: Entity
      Gets the relations of the table mapped by this entity.
      Will also contain the relations from embedded entities.
      Specified by:
      getTableRelations in interface Entity
      Returns:
      the relations, empty if entity does not map to a table or provides no relations
      Throws:
      ModelException
    • getCompositePaths

      public Set<List<Relation>> getCompositePaths()
      Description copied from interface: Entity
      Gets the paths of composite relations to this entity.
      Notice that this includes paths to sub-entities as well.
      Specified by:
      getCompositePaths in interface Entity
      Returns:
      the paths, empty list if this is not a component of any other entity
    • getAllCompositePaths

      public Set<List<Relation>> getAllCompositePaths()
      Description copied from interface: Entity
      Gets the paths of composite relations to this entity.
      Notice that this includes paths to sub-entities and super-entities as well.
      Specified by:
      getAllCompositePaths in interface Entity
      Returns:
      the paths, empty list if this is not a component of any other entity
    • getEmbeddingPaths

      public Set<List<Relation>> getEmbeddingPaths()
      Description copied from interface: Entity
      Gets the paths of embedding relations to this entity.
      Specified by:
      getEmbeddingPaths in interface Entity
      Returns:
      the paths, empty list if this is not an embedded entity
    • getEmbeddingEntities

      public Set<Entity> getEmbeddingEntities()
      Description copied from interface: Entity
      Gets the embedding entities for this embedded entity.
      Specified by:
      getEmbeddingEntities in interface Entity
      Returns:
      the embedding entities, empty if this is not an embedded entity
    • getComponents

      public Set<Entity> getComponents()
      Description copied from interface: Entity
      Gets the direct components of this entity.
      Specified by:
      getComponents in interface Entity
      Returns:
      the components
    • getComponentsIncludingInherited

      public Set<Entity> getComponentsIncludingInherited() throws ModelException
      Description copied from interface: Entity
      Gets the direct and inherited components of this entity.
      Specified by:
      getComponentsIncludingInherited in interface Entity
      Returns:
      the components
      Throws:
      ModelException
    • getAllComponents

      public Set<Entity> getAllComponents() throws ModelException
      Description copied from interface: Entity
      Gets all direct and indirect components of this entity.
      Specified by:
      getAllComponents in interface Entity
      Returns:
      the components
      Throws:
      ModelException
    • isDeeplyReferenced

      public boolean isDeeplyReferenced()
      Description copied from interface: Entity
      Returns whether this entity or one of its components is deeply referenced.
      Specified by:
      isDeeplyReferenced in interface Entity
      Returns:
      true if deeply referenced, false if not
    • setDeeplyReferenced

      public void setDeeplyReferenced(boolean deeplyReferenced)
    • getDeepReferences

      public List<Relation> getDeepReferences()
      Description copied from interface: Entity
      Gets the deep references to this entity.
      Specified by:
      getDeepReferences in interface Entity
      Returns:
      the deep references, empty if no deep references
    • getDeepReferencesToComponents

      public List<Relation> getDeepReferencesToComponents()
      Description copied from interface: Entity
      Gets the deep references to components of this root entity.
      Will contain all deep references to all components, not only the direct children.
      Specified by:
      getDeepReferencesToComponents in interface Entity
      Returns:
      the deep references, empty if this is not a root entity or there are no deep references
    • getDeeplyReferencedComponents

      public List<Relation> getDeeplyReferencedComponents()
      Description copied from interface: Entity
      Gets the deeply referenced components.
      Will contain the relations to components where Entity.isDeeplyReferenced() is true.
      Specified by:
      getDeeplyReferencedComponents in interface Entity
      Returns:
      the composite relations deeply referenced
    • getAttributeByJavaName

      public Attribute getAttributeByJavaName(String javaName, boolean all)
      Description copied from interface: Entity
      Gets an attribute by its java name.
      Specified by:
      getAttributeByJavaName in interface Entity
      Parameters:
      javaName - the java name
      all - true if include inherited attributes
      Returns:
      the attribute, null if no such attribute
    • getAttributeByColumnName

      public Attribute getAttributeByColumnName(String columnName, boolean all)
      Description copied from interface: Entity
      Gets an attribute by its database column name.

      Notice that upper/lowercase doesn't matter.

      Specified by:
      getAttributeByColumnName in interface Entity
      Parameters:
      columnName - the database column name
      all - true if include inherited attributes
      Returns:
      the attribute, null if no such attribute
    • getContextIdAttribute

      public Attribute getContextIdAttribute()
      Description copied from interface: Entity
      Gets the attribute that holds the context id.
      Specified by:
      getContextIdAttribute in interface Entity
      Returns:
      the context attribute, null if none
    • getUniqueDomainKey

      public List<Attribute> getUniqueDomainKey() throws ModelException
      Description copied from interface: Entity
      Gets the attributes describing the unique domain key.
      Specified by:
      getUniqueDomainKey in interface Entity
      Returns:
      the udk attributes, empty if no udk
      Throws:
      ModelException
    • getUniqueDomainKeyImpl

      protected void getUniqueDomainKeyImpl(List<Attribute> uniqueDomainKeys, Entity entity) throws ModelException
      Adds the unique domain keys recursively for given entity to the list.
      Parameters:
      uniqueDomainKeys - the unique domain key attributes
      entity - the entity to inspect
      Throws:
      ModelException
    • getSorting

      public List<AttributeSorting> getSorting()
      Description copied from interface: Entity
      Gets the default sorting for this entity.
      Specified by:
      getSorting in interface Entity
      Returns:
      the sorting, null if unsorted by default
    • getIndexes

      public List<Index> getIndexes()
      Description copied from interface: Entity
      Gets the indexes.
      Specified by:
      getIndexes in interface Entity
      Returns:
      the indexes
    • getIndex

      public Index getIndex(String name, boolean all)
      Description copied from interface: Entity
      Gets an index by its name.
      Specified by:
      getIndex in interface Entity
      Parameters:
      name - the index name
      all - true if include inherited indexes
      Returns:
      the index, null if no such index
    • getRelations

      public List<Relation> getRelations()
      Description copied from interface: Entity
      Gets the relations.
      Specified by:
      getRelations in interface Entity
      Returns:
      the relations
    • getReferencingRelations

      public List<Relation> getReferencingRelations()
      Description copied from interface: Entity
      Gets the relations from other entities directly referencing this entity.
      Specified by:
      getReferencingRelations in interface Entity
      Returns:
      the relations
    • getInheritedReferencingRelations

      public List<Relation> getInheritedReferencingRelations()
      Description copied from interface: Entity
      Gets the relations from other entities referencing any super-entity.
      Specified by:
      getInheritedReferencingRelations in interface Entity
      Returns:
      the relations
    • getReferencingRelationsIncludingInherited

      public List<Relation> getReferencingRelationsIncludingInherited()
      Description copied from interface: Entity
      Gets the relations from other entities referencing this entity or any super-entity.
      Specified by:
      getReferencingRelationsIncludingInherited in interface Entity
      Returns:
      the relations
    • getSubEntityReferencingRelations

      public List<Relation> getSubEntityReferencingRelations()
      Description copied from interface: Entity
      Gets the relations from other entities referencing any sub-entity.
      Specified by:
      getSubEntityReferencingRelations in interface Entity
      Returns:
      the relations
    • getReferencingRelationsIncludingSubEntities

      public List<Relation> getReferencingRelationsIncludingSubEntities()
      Description copied from interface: Entity
      Gets the relations from other entities referencing this entity or any sub-entity.
      Specified by:
      getReferencingRelationsIncludingSubEntities in interface Entity
      Returns:
      the relations
    • getAllReferencingRelations

      public List<Relation> getAllReferencingRelations()
      Description copied from interface: Entity
      Gets the relations from other entities referencing this entity or any sub-entity or super entity.
      Specified by:
      getAllReferencingRelations in interface Entity
      Returns:
      the relations
    • getRelation

      public Relation getRelation(String name, boolean all)
      Description copied from interface: Entity
      Gets a relation by its name.
      Specified by:
      getRelation in interface Entity
      Parameters:
      name - the relation's name
      all - true if include inherited relations
      Returns:
      the relation, null if no such relation
    • getRelations

      public List<Relation> getRelations(Entity entity, boolean all)
      Description copied from interface: Entity
      Gets all relations for a given entity type.
      Specified by:
      getRelations in interface Entity
      Parameters:
      entity - the entity
      all - true if include inherited relations
      Returns:
      the relations, empty if no such relation
    • validate

      public void validate() throws ModelException
      Validates the entity without relation dependent settings.
      Throws:
      ModelException - if validation failed
    • validateRelated

      public void validateRelated() throws ModelException
      Validates the relation dependent settings.
      Assumes ModelImpl.updateRelations() applied successfully.
      Throws:
      ModelException - if validation failed
    • sqlCreateTable

      public String sqlCreateTable(Backend backend) throws ModelException
      Description copied from interface: Entity
      Creates the table creation sql code.
      Specified by:
      sqlCreateTable in interface Entity
      Parameters:
      backend - the backend to create sql code for
      Returns:
      the SQL code
      Throws:
      ModelException - if model inconsistent
    • isComposite

      public boolean isComposite()
      Description copied from interface: Entity
      Returns whether entity has composite relations.
      Specified by:
      isComposite in interface Entity
      Returns:
      true if composite entity
    • isEffectivelyComposite

      public boolean isEffectivelyComposite()
      Description copied from interface: Entity
      Returns whether entity has composite non-embedded relations.
      Specified by:
      isEffectivelyComposite in interface Entity
      Returns:
      true if not only embedded composite relations
    • isAbstract

      public boolean isAbstract()
      Description copied from interface: Entity
      Returns whether class may be instantiated.
      Specified by:
      isAbstract in interface Entity
      Returns:
      true if class is abstract
    • isEmbedded

      public boolean isEmbedded()
      Description copied from interface: Entity
      Returns whether this is an embedded entity.
      Such entities are embedded via embedding relations. Embedded entities are mapped to their embedding entity, which is always a regular non-embedded entity. Embedded entities can embed other embedded entities, but cannot have regular components. However, embedded entities can have non-composite object relations (1:1).
      Specified by:
      isEmbedded in interface Entity
      Returns:
      true if embedded
      See Also:
    • isTracked

      public boolean isTracked()
      Description copied from interface: Entity
      Returns whether entity is tracked.
      Specified by:
      isTracked in interface Entity
      Returns:
      true if tracked
    • isDeletionCascaded

      public Boolean isDeletionCascaded()
      Description copied from interface: Entity
      Returns the cascade-flag if it is the same for all composite relations.
      If there are no composite relations at all, false is returned.
      Specified by:
      isDeletionCascaded in interface Entity
      Returns:
      the cascade flag, null if mixed composite relations
    • isRootOfInheritanceHierarchy

      public boolean isRootOfInheritanceHierarchy()
      Description copied from interface: Entity
      Returns whether entity is the root of an inheritance hierarchy.
      Specified by:
      isRootOfInheritanceHierarchy in interface Entity
      Returns:
      true if root
    • getRootAttributes

      public Set<Attribute> getRootAttributes()
      Description copied from interface: Entity
      Returns the attributes that corresponds to the root id.
      Specified by:
      getRootAttributes in interface Entity
      Returns:
      the attributes, empty list if root id is provided separately or no root id at all
    • getRootAttribute

      public Attribute getRootAttribute()
      Description copied from interface: Entity
      Returns the single root attribute if there is exactly one.
      Specified by:
      getRootAttribute in interface Entity
      Returns:
      the attribute, null if none or more than one
    • getRootEntities

      public Set<Entity> getRootEntities()
      Description copied from interface: Entity
      Returns the root entities.
      Returns all roots, even abstract ones.
      Specified by:
      getRootEntities in interface Entity
      Returns:
      the root entities, empty list if rootclassid is provided separately or no rootclassid at all
    • getRootEntity

      public Entity getRootEntity()
      Description copied from interface: Entity
      Returns the single root entity, if there is exactly one, and it is not abstract.
      Specified by:
      getRootEntity in interface Entity
      Returns:
      the root entity, null if none or abstract or more than one
    • isRootEntity

      public boolean isRootEntity()
      Description copied from interface: Entity
      Returns whether this is a root entity.
      Inspects the super entities as well.
      Specified by:
      isRootEntity in interface Entity
      Returns:
      true if root entity
    • getTableProvidingEntity

      public Entity getTableProvidingEntity()
      Description copied from interface: Entity
      Gets the entity that provides the database table.
      Specified by:
      getTableProvidingEntity in interface Entity
      Returns:
      the table providing entity, null if entity is abstract and does not correspond to a single table
    • toString

      public String toString()
      Overrides:
      toString in class Object