-
- All Superinterfaces:
ModelElement
- All Known Implementing Classes:
EntityImpl
public interface Entity extends ModelElement
The entity.This is the top-level model element.
- Author:
- harald
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<Attribute>getAllAttributes()Gets all attributes including inherited and from sub entities.java.util.Set<Entity>getAllComponents()Gets all direct and indirect components of this entity.java.util.Set<java.util.List<Relation>>getAllCompositePaths()Gets the paths of composite relations to this entity.
Notice that this inludes paths to sub-entities and super-entities as well.java.util.List<Index>getAllIndexes()Gets all including inherited and indexes from sub entities.java.util.List<Relation>getAllReferencingRelations()Gets the relations from other entities referencing this entity or any sub-entity or super entity.java.util.List<Relation>getAllRelations()Gets all relations including the inherited and the ones from the sub entities.java.util.List<Entity>getAllSubEntities()Gets all sub entities.java.util.Set<Entity>getAssociatedEntities()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.AttributegetAttributeByColumnName(java.lang.String columnName, boolean all)Gets an attribute by its database column name.AttributegetAttributeByJavaName(java.lang.String javaName, boolean all)Gets an attribute by its java name.java.util.List<Attribute>getAttributes()Gets the attributes.java.util.List<Attribute>getAttributesIncludingInherited()Gets the attributes including the inherited ones.java.util.List<Attribute>getAttributesIncludingSubEntities()Gets the attributes including the ones from the sub entities.intgetClassId()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.java.util.Set<Entity>getComponents()Gets the direct components of this entity.java.util.Set<Entity>getComponentsIncludingInherited()Gets the direct and inherited components of this entity.java.util.Set<java.util.List<Relation>>getCompositePaths()Gets the paths of composite relations to this entity.
Notice that this inludes paths to sub-entities as well.AttributegetContextIdAttribute()Gets the attribute that holds the context id.java.util.List<Relation>getDeeplyReferencedComponents()Gets the deeply referenced components.
Will contain the relations to components whereisDeeplyReferenced()is true.java.util.List<Relation>getDeepReferences()Gets the deep references to this entity.java.util.List<Relation>getDeepReferencesToComponents()Gets the deep references to components of this root entity.
Will contain all deep references to all components, not only the direct childs.java.lang.StringgetDefinedTableAlias()Gets the table alias originally configured in the model.InheritanceTypegetHierarchyInheritanceType()Gets the inheritance type of the hierarchy.
For leafs, which haveInheritanceType.NONE, the type of the super entity is returned.IndexgetIndex(java.lang.String name, boolean all)Gets an index by its name.java.util.List<Index>getIndexes()Gets the indexes.java.util.List<Index>getIndexesIncludingInherited()Gets all including inherited indexes.java.util.List<Index>getIndexesIncludingSubEntities()Gets all including indexes from sub entities.java.util.List<Entity>getInheritanceChain(Entity subEntity)Gets the inheritance chain from this entity down to given sub entity.InheritanceTypegetInheritanceType()Gets the inheritance type.java.util.List<Attribute>getInheritedAttributes()Gets the inherited attributes.java.util.List<Index>getInheritedIndexes()Gets inherited indexes.java.util.List<Relation>getInheritedReferencingRelations()Gets the relations from other entities referencing any super-entity.java.util.List<Relation>getInheritedRelations()Gets the inherited relations.IntegritygetIntegrity()Gets the referential integrity mode.java.util.List<Entity>getLeafEntities()Gets the list of non-abstract leaf sub entities.
If this entity is already non-abstract the list consists of this entity.java.util.List<Attribute>getMappedAttributes()Gets the attributes mapped by the persistence layer for this entity.EntityOptionsgetOptions()Gets the options.java.util.List<Relation>getReferencingRelations()Gets the relations from other entities directly referencing this entity.java.util.List<Relation>getReferencingRelationsIncludingInherited()Gets the relations from other entities referencing this entity or any super-entity.java.util.List<Relation>getReferencingRelationsIncludingSubEntities()Gets the relations from other entities referencing this entity or any sub-entity.RelationgetRelation(java.lang.String name, boolean all)Gets a relation by its name.java.util.List<Relation>getRelations()Gets the relations.java.util.List<Relation>getRelations(Entity entity, boolean all)Gets all relations for a given entity type.java.util.List<Relation>getRelationsIncludingInherited()Gets all including inherited relations.java.util.List<Relation>getRelationsIncludingSubEntities()Gets all relations including the ones from the sub entities.AttributegetRootAttribute()Returns the single root attribute if there is exactly one.java.util.Set<Attribute>getRootAttributes()Returns the attributes that corresponds to the root id.java.util.Set<Entity>getRootEntities()Returns the root entities.
Returns all roots, even abstract ones.EntitygetRootEntity()Returns the single root entity if there is exactly one and it is not abstract.java.lang.StringgetSchemaName()Gets the schema name.java.util.List<AttributeSorting>getSorting()Gets the default sorting for this entity.java.util.List<Entity>getSubEntities()Gets the direct sub entities.java.util.List<Attribute>getSubEntityAttributes()Gets the attributes from the sub entities.java.util.List<Index>getSubEntityIndexes()Gets indexes from sub entities.java.util.List<Relation>getSubEntityReferencingRelations()Gets the relations from other entities referencing any sub-entity.java.util.List<Relation>getSubEntityRelations()Gets the relations from the sub entities.java.util.List<Entity>getSuperEntities()Gets all super entities.EntitygetSuperEntity()Gets the super class entity if inherited.java.lang.StringgetSuperEntityName()Gets the name of the super class entity.java.lang.StringgetTableAlias()Gets the table alias for joined selects.
The alias is unique among all tables.java.util.List<Attribute>getTableAttributes()Gets the attributes of the table mapped by this entity.java.util.List<Index>getTableIndexes()Gets the indexes of the table mapped by this entity.java.lang.StringgetTableName()Gets the database table name.
An optional schema may be prepended separated by a dot.java.lang.StringgetTableNameWithoutSchema()Gets the tablename without the leading schema.EntitygetTableProvidingEntity()Gets the entity that provides the database table.java.util.List<Relation>getTableRelations()Gets the relations of the table mapped by this entity.EntitygetTopSuperEntity()Gets the top most entity of the inheritance tree.
Returns this entity if there is no inheritance.java.util.List<Attribute>getUniqueDomainKey()Gets the attributes describing the unique domain key.booleanisAbstract()Returns whether class may be instantiated.booleanisComposite()Returns whether entity has composite relations.booleanisDeeplyReferenced()Returns whether this entity or one of its components is deeply referenced.java.lang.BooleanisDeletionCascaded()Returns the cascade-flag if it is the same for all composite relations.
If there are no composite relations at all, false is returned.booleanisProvidingRootClassIdAccordingToModel()Returns whether this entity should provide a root class id according to model.booleanisProvidingRootIdAccordingToModel()Returns whether this entity should provide a root id according to model.booleanisRootEntity()Returns whether this is a root entity.
Inspects the super entities as well.booleanisRootEntityAccordingToModel()Returns whether this entity is a root-entity according to model.booleanisRootOfInheritanceHierarchy()Returns whether entity is the root of an inheritance hierarchy.booleanisTracked()Returns whether entity is tracked.java.lang.StringsqlCreateTable(org.tentackle.sql.Backend backend)Creates the table creation sql code.-
Methods inherited from interface org.tentackle.model.ModelElement
getName, getOrdinal, getParent, getSourceInfo
-
-
-
-
Method Detail
-
getClassId
int getClassId()
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.- Returns:
- the entity class id
-
getTableName
java.lang.String getTableName()
Gets the database table name.
An optional schema may be prepended separated by a dot.- Returns:
- the tablename (always in lowercase)
-
getSchemaName
java.lang.String getSchemaName()
Gets the schema name.- Returns:
- the schema (always in lowercase), null if default
-
getTableNameWithoutSchema
java.lang.String getTableNameWithoutSchema()
Gets the tablename without the leading schema.- Returns:
- the tablename relative to its schema (always in lowercase)
-
getTableAlias
java.lang.String getTableAlias()
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.- Returns:
- the table alias
-
getDefinedTableAlias
java.lang.String getDefinedTableAlias()
Gets the table alias originally configured in the model.- Returns:
- the fixed alias, null if automatic
-
getIntegrity
Integrity getIntegrity()
Gets the referential integrity mode.- Returns:
- the integrity mode
-
getOptions
EntityOptions getOptions()
Gets the options.- Returns:
- the options
-
getAttributes
java.util.List<Attribute> getAttributes()
Gets the attributes.- Returns:
- the attributes
-
getInheritedAttributes
java.util.List<Attribute> getInheritedAttributes()
Gets the inherited attributes.- Returns:
- the attributes
-
getSubEntityAttributes
java.util.List<Attribute> getSubEntityAttributes()
Gets the attributes from the sub entities.- Returns:
- the attributes
-
getAttributesIncludingInherited
java.util.List<Attribute> getAttributesIncludingInherited()
Gets the attributes including the inherited ones.- Returns:
- the attributes
-
getAttributesIncludingSubEntities
java.util.List<Attribute> getAttributesIncludingSubEntities()
Gets the attributes including the ones from the sub entities.- Returns:
- the attributes
-
getAllAttributes
java.util.List<Attribute> getAllAttributes()
Gets all attributes including inherited and from sub entities.- Returns:
- the attributes
-
getTableAttributes
java.util.List<Attribute> getTableAttributes()
Gets the attributes of the table mapped by this entity.- Returns:
- the attributes, empty if entity does not map to a table or does not provide attributes
-
getMappedAttributes
java.util.List<Attribute> getMappedAttributes()
Gets the attributes mapped by the persistence layer for this entity.- Returns:
- the attributes
-
getAttributeByJavaName
Attribute getAttributeByJavaName(java.lang.String javaName, boolean all)
Gets an attribute by its java name.- Parameters:
javaName- the java nameall- true if include inherited attributes- Returns:
- the attribute, null if no such attribute
-
getAttributeByColumnName
Attribute getAttributeByColumnName(java.lang.String columnName, boolean all)
Gets an attribute by its database column name.Notice that upper/lowercase doesnt matter.
- Parameters:
columnName- the database column nameall- true if include inherited attributes- Returns:
- the attribute, null if no such attribute
-
getContextIdAttribute
Attribute getContextIdAttribute()
Gets the attribute that holds the context id.- Returns:
- the context attribute, null if none
-
getUniqueDomainKey
java.util.List<Attribute> getUniqueDomainKey()
Gets the attributes describing the unique domain key.- Returns:
- the udk attributes, empty if no udk
-
getSorting
java.util.List<AttributeSorting> getSorting()
Gets the default sorting for this entity.- Returns:
- the sorting, null if unsorted by default
-
getRelations
java.util.List<Relation> getRelations()
Gets the relations.- Returns:
- the relations
-
getInheritedRelations
java.util.List<Relation> getInheritedRelations()
Gets the inherited relations.- Returns:
- the relations
-
getSubEntityRelations
java.util.List<Relation> getSubEntityRelations()
Gets the relations from the sub entities.- Returns:
- the relations
-
getRelationsIncludingInherited
java.util.List<Relation> getRelationsIncludingInherited()
Gets all including inherited relations.- Returns:
- the relations
-
getRelationsIncludingSubEntities
java.util.List<Relation> getRelationsIncludingSubEntities()
Gets all relations including the ones from the sub entities.- Returns:
- the relations
-
getAllRelations
java.util.List<Relation> getAllRelations()
Gets all relations including the inherited and the ones from the sub entities.- Returns:
- the relations
-
getTableRelations
java.util.List<Relation> getTableRelations()
Gets the relations of the table mapped by this entity.- Returns:
- the relations, empty if entity does not map to a table or provides no relations
-
getRelation
Relation getRelation(java.lang.String name, boolean all)
Gets a relation by its name.- Parameters:
name- the relation's nameall- true if include inherited relations- Returns:
- the relation, null if no such relation
-
getRelations
java.util.List<Relation> getRelations(Entity entity, boolean all)
Gets all relations for a given entity type.- Parameters:
entity- the entityall- true if include inherited relations- Returns:
- the relations, empty if no such relation
-
getReferencingRelations
java.util.List<Relation> getReferencingRelations()
Gets the relations from other entities directly referencing this entity.- Returns:
- the relations
-
getInheritedReferencingRelations
java.util.List<Relation> getInheritedReferencingRelations()
Gets the relations from other entities referencing any super-entity.- Returns:
- the relations
-
getSubEntityReferencingRelations
java.util.List<Relation> getSubEntityReferencingRelations()
Gets the relations from other entities referencing any sub-entity.- Returns:
- the relations
-
getReferencingRelationsIncludingInherited
java.util.List<Relation> getReferencingRelationsIncludingInherited()
Gets the relations from other entities referencing this entity or any super-entity.- Returns:
- the relations
-
getReferencingRelationsIncludingSubEntities
java.util.List<Relation> getReferencingRelationsIncludingSubEntities()
Gets the relations from other entities referencing this entity or any sub-entity.- Returns:
- the relations
-
getAllReferencingRelations
java.util.List<Relation> getAllReferencingRelations()
Gets the relations from other entities referencing this entity or any sub-entity or super entity.- Returns:
- the relations
-
getIndexes
java.util.List<Index> getIndexes()
Gets the indexes.- Returns:
- the indexes
-
getInheritedIndexes
java.util.List<Index> getInheritedIndexes()
Gets inherited indexes.- Returns:
- the indexes
-
getSubEntityIndexes
java.util.List<Index> getSubEntityIndexes()
Gets indexes from sub entities.- Returns:
- the indexes
-
getIndexesIncludingInherited
java.util.List<Index> getIndexesIncludingInherited()
Gets all including inherited indexes.- Returns:
- the indexes
-
getIndexesIncludingSubEntities
java.util.List<Index> getIndexesIncludingSubEntities()
Gets all including indexes from sub entities.- Returns:
- the indexes
-
getAllIndexes
java.util.List<Index> getAllIndexes()
Gets all including inherited and indexes from sub entities.- Returns:
- the indexes
-
getTableIndexes
java.util.List<Index> getTableIndexes()
Gets the indexes of the table mapped by this entity.- Returns:
- the indexes, empty if entity does not map to a table or provides no indexes
-
getIndex
Index getIndex(java.lang.String name, boolean all)
Gets an index by its name.- Parameters:
name- the index nameall- true if include inherited indexes- Returns:
- the index, null if no such index
-
sqlCreateTable
java.lang.String sqlCreateTable(org.tentackle.sql.Backend backend) throws ModelExceptionCreates the table creation sql code.- Parameters:
backend- the backend to create sql code for- Returns:
- the SQL code
- Throws:
ModelException- if model inconsistent
-
isComposite
boolean isComposite()
Returns whether entity has composite relations.- Returns:
- true if composite entity
-
isAbstract
boolean isAbstract()
Returns whether class may be instantiated.- Returns:
- true if class is abstract
-
isTracked
boolean isTracked()
Returns whether entity is tracked.- Returns:
- true if tracked
-
isDeletionCascaded
java.lang.Boolean isDeletionCascaded()
Returns the cascade-flag if it is the same for all composite relations.
If there are no composite relations at all, false is returned.- Returns:
- the cascade flag, null if mixed composite relations
-
getRootAttributes
java.util.Set<Attribute> getRootAttributes()
Returns the attributes that corresponds to the root id.- Returns:
- the attributes, empty list if root id is provided separately or no root id at all
-
getRootAttribute
Attribute getRootAttribute()
Returns the single root attribute if there is exactly one.- Returns:
- the attribute, null if none or more than one
-
getRootEntities
java.util.Set<Entity> getRootEntities()
Returns the root entities.
Returns all roots, even abstract ones.- Returns:
- the root entities, empty list if rootclassid is provided separately or no rootclassid at all
-
getRootEntity
Entity getRootEntity()
Returns the single root entity if there is exactly one and it is not abstract.- Returns:
- the root entity, null if none or abstract or more than one
-
isRootEntity
boolean isRootEntity()
Returns whether this is a root entity.
Inspects the super entities as well.- Returns:
- true if root entity
-
isRootOfInheritanceHierarchy
boolean isRootOfInheritanceHierarchy()
Returns whether entity is the root of an inheritance hierarchy.- Returns:
- true if root
-
getTableProvidingEntity
Entity getTableProvidingEntity()
Gets the entity that provides the database table.- Returns:
- the table providing entity, null if entity is abstract and does not correspond to a single table
-
getInheritanceType
InheritanceType getInheritanceType()
Gets the inheritance type.- Returns:
- the inheritance type
-
getHierarchyInheritanceType
InheritanceType getHierarchyInheritanceType()
Gets the inheritance type of the hierarchy.
For leafs, which haveInheritanceType.NONE, the type of the super entity is returned.- Returns:
- the effective inheritance type
-
getSuperEntityName
java.lang.String getSuperEntityName()
Gets the name of the super class entity.- Returns:
- the super class name, null if not inherited
-
getSuperEntity
Entity getSuperEntity()
Gets the super class entity if inherited.- Returns:
- the super entity, null if not inherited
-
getSuperEntities
java.util.List<Entity> getSuperEntities()
Gets all super entities.- Returns:
- the path along up to the top super entity.
-
getTopSuperEntity
Entity getTopSuperEntity()
Gets the top most entity of the inheritance tree.
Returns this entity if there is no inheritance.- Returns:
- the root of the inheritance hierarchy
-
getInheritanceChain
java.util.List<Entity> getInheritanceChain(Entity subEntity) throws ModelException
Gets the inheritance chain from this entity down to given sub entity.- Parameters:
subEntity- 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
java.util.List<Entity> getSubEntities()
Gets the direct sub entities.- Returns:
- the sub entities, empty list if no sub entities
-
getAllSubEntities
java.util.List<Entity> getAllSubEntities()
Gets all sub entities.- Returns:
- the sub entities, empty list if no sub entities
-
getLeafEntities
java.util.List<Entity> getLeafEntities()
Gets the list of non-abstract leaf sub entities.
If this entity is already non-abstract the list consists of this entity.- Returns:
- the leafs
-
getAssociatedEntities
java.util.Set<Entity> getAssociatedEntities()
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.- Returns:
- the set of entities including me
-
getCompositePaths
java.util.Set<java.util.List<Relation>> getCompositePaths()
Gets the paths of composite relations to this entity.
Notice that this inludes paths to sub-entities as well.- Returns:
- the paths, empty list if this is not a component of any other entity
-
getAllCompositePaths
java.util.Set<java.util.List<Relation>> getAllCompositePaths()
Gets the paths of composite relations to this entity.
Notice that this inludes paths to sub-entities and super-entities as well.- Returns:
- the paths, empty list if this is not a component of any other entity
-
getComponents
java.util.Set<Entity> getComponents()
Gets the direct components of this entity.- Returns:
- the components
-
getComponentsIncludingInherited
java.util.Set<Entity> getComponentsIncludingInherited()
Gets the direct and inherited components of this entity.- Returns:
- the components
-
getAllComponents
java.util.Set<Entity> getAllComponents()
Gets all direct and indirect components of this entity.- Returns:
- the components
-
isProvidingRootClassIdAccordingToModel
boolean isProvidingRootClassIdAccordingToModel()
Returns whether this entity should provide a root class id according to model.- Returns:
- true if should provide a root class id
-
isProvidingRootIdAccordingToModel
boolean isProvidingRootIdAccordingToModel()
Returns whether this entity should provide a root id according to model.- Returns:
- true if should provide a root id
-
isRootEntityAccordingToModel
boolean isRootEntityAccordingToModel()
Returns whether this entity is a root-entity according to model.- Returns:
- true if root entity
-
getDeepReferences
java.util.List<Relation> getDeepReferences()
Gets the deep references to this entity.- Returns:
- the deep references, empty if no deep references
-
isDeeplyReferenced
boolean isDeeplyReferenced()
Returns whether this entity or one of its components is deeply referenced.- Returns:
- true if deeply referenced, false if not
-
getDeepReferencesToComponents
java.util.List<Relation> getDeepReferencesToComponents()
Gets the deep references to components of this root entity.
Will contain all deep references to all components, not only the direct childs.- Returns:
- the deep references, empty if this is not a root entity or there are no deep references
-
getDeeplyReferencedComponents
java.util.List<Relation> getDeeplyReferencedComponents()
Gets the deeply referenced components.
Will contain the relations to components whereisDeeplyReferenced()is true.- Returns:
- the composite relations deeply referenced
-
-