public class EntityImpl extends Object implements Entity, Comparable<EntityImpl>
| Constructor and Description |
|---|
EntityImpl(EntityFactoryImpl factory,
SourceInfo sourceInfo)
Creates an entity.
|
| Modifier and Type | Method and Description |
|---|---|
protected List<Attribute> |
appendIdSerial(Entity entity,
List<Attribute> attributes)
Appends id and serial from another entity.
|
protected void |
collectAssociatedEntities(Set<Entity> associates,
Entity entity,
Set<Entity> processedEntities)
Recursively collects the associated entities for a given entity.
|
protected void |
collectLeafEntities(List<Entity> leafs,
Entity entity)
Recursivly collects the leaf childs.
|
protected void |
collectSubEntities(List<Entity> subEntities,
Entity entity)
Recursivly collects all sub entities.
|
int |
compareTo(EntityImpl o) |
boolean |
equals(Object obj) |
List<Attribute> |
getAllAttributes()
Gets all attributes including inherited and from sub entities.
|
Set<Entity> |
getAllComponents()
Gets all direct and indirect components of this entity.
|
List<Index> |
getAllIndexes()
Gets all including inherited and indexes from sub entities.
|
List<Relation> |
getAllReferencingRelations()
Gets the relations from other entities referencing this entity or any sub-entity or super entity.
|
List<Relation> |
getAllRelations()
Gets all relations including the inherited and the ones from the sub entities.
|
List<Entity> |
getAllSubEntities()
Gets all sub entities.
|
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. |
Attribute |
getAttributeByColumnName(String columnName,
boolean all)
Gets an attribute by its database column name.
|
Attribute |
getAttributeByJavaName(String javaName,
boolean all)
Gets an attribute by its java name.
|
List<Attribute> |
getAttributes()
Gets the attributes.
|
List<Attribute> |
getAttributesIncludingInherited()
Gets the attributes including the inherited ones.
|
List<Attribute> |
getAttributesIncludingSubEntities()
Gets the attributes including the ones from the sub entities.
|
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. |
Set<Entity> |
getComponents()
Gets the direct components of this entity.
|
Set<Entity> |
getComponentsIncludingInherited()
Gets the direct and inherited components of this entity.
|
Set<List<Relation>> |
getCompositePaths()
Gets the paths of composite relations to this entity.
Notice that this inludes paths to sub-entities as well. |
Attribute |
getContextIdAttribute()
Gets the attribute that holds the context id.
|
List<Relation> |
getDeeplyReferencedComponents()
Gets the deeply referenced components.
Will contain the relations to components where Entity.isDeeplyReferenced() is true. |
List<Relation> |
getDeepReferences()
Gets the deep references to this entity.
|
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. |
InheritanceType |
getHierarchyInheritanceType()
Gets the inheritance type of the hierarchy.
For leafs, which have InheritanceType.NONE, the type of the super entity is returned. |
Index |
getIndex(String name,
boolean all)
Gets an index by its name.
|
List<Index> |
getIndexes()
Gets the indexes.
|
List<Index> |
getIndexesIncludingInherited()
Gets all including inherited indexes.
|
List<Index> |
getIndexesIncludingSubEntities()
Gets all including indexes from sub entities.
|
List<Entity> |
getInheritanceChain(Entity childEntity)
Gets the inheritance chain from this entity down to given sub entity.
|
int |
getInheritanceLevel()
Gets the inheritance level if this is a sub entity.
|
InheritanceType |
getInheritanceType()
Gets the inheritance type.
|
List<Attribute> |
getInheritedAttributes()
Gets the inherited attributes.
|
List<Index> |
getInheritedIndexes()
Gets inherited indexes.
|
List<Relation> |
getInheritedReferencingRelations()
Gets the relations from other entities referencing any super-entity.
|
List<Relation> |
getInheritedRelations()
Gets the inherited relations.
|
Integrity |
getIntegrity()
Gets the referential integrity mode.
|
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. |
List<Attribute> |
getMappedAttributes()
Gets the attributes mapped by the persistence layer for this entity.
|
String |
getName()
Gets the name of the entity.
|
EntityOptionsImpl |
getOptions()
Gets the options.
|
List<Relation> |
getReferencingRelations()
Gets the relations from other entities directly referencing this entity.
|
List<Relation> |
getReferencingRelationsIncludingInherited()
Gets the relations from other entities referencing this entity or any super-entity.
|
List<Relation> |
getReferencingRelationsIncludingSubEntities()
Gets the relations from other entities referencing this entity or any sub-entity.
|
Relation |
getRelation(String name,
boolean all)
Gets a relation by its name.
|
List<Relation> |
getRelations()
Gets the relations.
|
List<Relation> |
getRelationsIncludingInherited()
Gets all including inherited relations.
|
List<Relation> |
getRelationsIncludingSubEntities()
Gets all relations including the ones from the sub entities.
|
Attribute |
getRootAttribute()
Returns the single root attribute if there is exactly one.
|
Set<Attribute> |
getRootAttributes()
Returns the attributes that corresponds to the root id.
|
Set<Entity> |
getRootEntities()
Returns the root entities.
Returns all roots, even abstract ones. |
Entity |
getRootEntity()
Returns the single root entity if there is exactly one and it is not abstract.
|
String |
getSchemaName()
Gets the schema name.
|
List<AttributeSorting> |
getSorting()
Gets the default sorting for this entity.
|
List<Entity> |
getSubEntities()
Gets the direct sub entities.
|
List<Attribute> |
getSubEntityAttributes()
Gets the attributes from the sub entities.
|
List<Index> |
getSubEntityIndexes()
Gets indexes from sub entities.
|
List<Relation> |
getSubEntityReferencingRelations()
Gets the relations from other entities referencing any sub-entity.
|
List<Relation> |
getSubEntityRelations()
Gets the relations from the sub entities.
|
List<Entity> |
getSuperEntities()
Gets all super entities.
|
Entity |
getSuperEntity()
Gets the super class entity if inherited.
|
String |
getSuperEntityName()
Gets the name of the super class entity.
|
String |
getTableAlias()
Gets the table alias for joined selects.
The alias is unique among all tables. |
List<Attribute> |
getTableAttributes()
Gets the attributes of the table mapped by this entity.
|
List<Index> |
getTableIndexes()
Gets the indexes of the table mapped by this entity.
|
String |
getTableName()
Gets the database table name.
An optional schema may be prepended separated by a dot. |
String |
getTableNameWithoutSchema()
Gets the tablename without the leading schema.
|
Entity |
getTableProvidingEntity()
Gets the entity that provides the database table.
|
List<Relation> |
getTableRelations()
Gets the relations of the table mapped by this entity.
|
Entity |
getTopSuperEntity()
Gets the top most entity of the inheritance tree.
Returns this entity if there is no inheritance. |
List<Attribute> |
getUniqueDomainKey()
Gets the attributes describing the unique domain key.
|
protected void |
getUniqueDomainKeyImpl(List<Attribute> uniqueDomainKeys,
Entity entity)
Adds the unique domain keys recursively for given entity to the list.
|
int |
hashCode() |
boolean |
isAbstract()
Returns whether class may be instantiated.
|
boolean |
isComposite()
Returns whether entity has composite relations.
|
boolean |
isDeeplyReferenced()
Returns whether this entity or one of its components is deeply referenced.
|
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. |
boolean |
isProvidingRootClassIdAccordingToModel()
Returns whether this entity should provide a root class id according to model.
|
boolean |
isProvidingRootIdAccordingToModel()
Returns whether this entity should provide a root id according to model.
|
boolean |
isRootEntityAccordingToModel()
Returns whether this entity is a root-entity according to model.
|
boolean |
isRootOfInheritanceHierarchy()
Returns whether entity is the root of an inheritance hierarchy.
|
boolean |
isTracked()
Returns whether entity is tracked.
|
protected List<Attribute> |
moveIdSerialToEnd(List<Attribute> attributes)
Moved id and serial to the end of a new created attribute list.
|
boolean |
parseConfiguration(ConfigurationLine line)
Parses a configuration line.
|
protected List<Attribute> |
removeIdSerial(List<Attribute> attributes)
Removes id and serial from the list of attributes.
|
void |
setClassId(int classId)
Sets the entity id.
|
void |
setContextIdAttribute(Attribute contextIdAttribute)
Sets the context id attribute.
|
void |
setDeeplyReferenced(boolean deeplyReferenced) |
void |
setInheritanceLevel(int inheritanceLevel)
Sets the inheritance level.
|
void |
setInheritanceType(InheritanceType inheritanceType)
Sets the inheritance type.
|
void |
setIntegrity(Integrity integrity)
Sets the integrity.
|
void |
setName(String name)
Sets the entity's name.
|
void |
setProvidingRootClassIdAccordingToModel(boolean modelRootClassId)
Sets whether this entity should provide a root class id according to model.
|
void |
setProvidingRootIdAccordingToModel(boolean modelRootId)
Sets whether this entity should provide a root id according to model.
|
void |
setRootEntityAccordingToModel(boolean modelRoot)
Sets whether this entity is a root-entity according to model.
|
void |
setSorting(List<AttributeSorting> sorting)
Sets the default sorting.
|
void |
setSuperEntity(Entity superEntity)
Sets the super entity.
|
void |
setSuperEntityName(String superEntityName)
Sets the name of the super entity.
|
void |
setTableAlias(String tableAlias)
Sets the table alias.
|
void |
setTableName(String tableName)
Sets the tablename.
|
String |
sqlCreateTable(Backend backend)
Creates the table creation sql code.
|
String |
toString() |
void |
validate()
Validates the entity without relation dependent settings.
|
void |
validateRelated()
Validates the relation dependent settings.
Assumes ModelImpl.updateRelations(org.tentackle.model.ModelDefaults) applied successfully. |
public EntityImpl(EntityFactoryImpl factory, SourceInfo sourceInfo)
factory - the factory to create entity optionssourceInfo - the source informationpublic int compareTo(EntityImpl o)
compareTo in interface Comparable<EntityImpl>public boolean parseConfiguration(ConfigurationLine line) throws ModelException
line - the configuation lineModelException - if parsing failedpublic String getName()
Entitypublic void setName(String name)
name - the namepublic int getClassId()
EntitygetClassId in interface Entitypublic void setClassId(int classId)
classId - the idpublic String getTableName()
EntitygetTableName in interface Entitypublic String getSchemaName()
EntitygetSchemaName in interface Entitypublic String getTableNameWithoutSchema()
EntitygetTableNameWithoutSchema in interface Entitypublic String getTableAlias()
EntitygetTableAlias in interface Entitypublic void setTableName(String tableName)
tableName - the tablenamepublic void setTableAlias(String tableAlias)
tableAlias - the aliaspublic Integrity getIntegrity()
EntitygetIntegrity in interface Entitypublic InheritanceType getInheritanceType()
EntitygetInheritanceType in interface Entitypublic InheritanceType getHierarchyInheritanceType()
EntityInheritanceType.NONE, the type of the super entity is returned.getHierarchyInheritanceType in interface Entitypublic String getSuperEntityName()
EntitygetSuperEntityName in interface Entitypublic Entity getSuperEntity()
EntitygetSuperEntity in interface Entitypublic List<Entity> getSuperEntities()
EntitygetSuperEntities in interface Entitypublic Entity getTopSuperEntity()
EntitygetTopSuperEntity in interface Entitypublic List<Entity> getInheritanceChain(Entity childEntity) throws ModelException
EntitygetInheritanceChain in interface EntitychildEntity - the sub entityModelException - if subEntity does not inherit this entitypublic int getInheritanceLevel()
EntitygetInheritanceLevel in interface Entitypublic List<Entity> getSubEntities()
EntitygetSubEntities in interface Entitypublic List<Entity> getAllSubEntities()
EntitygetAllSubEntities in interface Entitypublic List<Entity> getLeafEntities()
EntitygetLeafEntities in interface Entityprotected void collectLeafEntities(List<Entity> leafs, Entity entity)
leafs - the list if leafsentity - the current entity to analyzeprotected void collectSubEntities(List<Entity> subEntities, Entity entity)
subEntities - the list of collected sub entitiesentity - the current entity to analyzepublic Set<Entity> getAssociatedEntities()
EntitygetAssociatedEntities in interface Entityprotected void collectAssociatedEntities(Set<Entity> associates, Entity entity, Set<Entity> processedEntities)
associates - the set of associated entities so farentity - the current entity to analyzeprocessedEntities - the already processed entities (to avoid loops)public void setIntegrity(Integrity integrity)
integrity - the integritypublic void setInheritanceType(InheritanceType inheritanceType)
inheritanceType - the inheritance typepublic void setInheritanceLevel(int inheritanceLevel)
inheritanceLevel - the inheritance levelpublic void setSuperEntityName(String superEntityName)
superEntityName - the super entitypublic void setSuperEntity(Entity superEntity)
superEntity - the super entitypublic void setContextIdAttribute(Attribute contextIdAttribute)
contextIdAttribute - the attribute providing the context IDpublic void setSorting(List<AttributeSorting> sorting)
sorting - the sorting, null if nonepublic EntityOptionsImpl getOptions()
EntitygetOptions in interface Entitypublic List<Attribute> getAttributes()
EntitygetAttributes in interface Entitypublic boolean isRootEntityAccordingToModel()
isRootEntityAccordingToModel in interface Entitypublic void setRootEntityAccordingToModel(boolean modelRoot)
modelRoot - true if root entitypublic boolean isProvidingRootClassIdAccordingToModel()
isProvidingRootClassIdAccordingToModel in interface Entitypublic void setProvidingRootClassIdAccordingToModel(boolean modelRootClassId)
modelRootClassId - true if should provide a root class idpublic boolean isProvidingRootIdAccordingToModel()
isProvidingRootIdAccordingToModel in interface Entitypublic void setProvidingRootIdAccordingToModel(boolean modelRootId)
modelRootId - true if should provide a root idpublic List<Attribute> getInheritedAttributes()
EntitygetInheritedAttributes in interface Entitypublic List<Attribute> getSubEntityAttributes()
EntitygetSubEntityAttributes in interface Entitypublic List<Attribute> getAttributesIncludingInherited()
EntitygetAttributesIncludingInherited in interface Entitypublic List<Attribute> getAttributesIncludingSubEntities()
EntitygetAttributesIncludingSubEntities in interface Entitypublic List<Attribute> getAllAttributes()
EntitygetAllAttributes in interface Entitypublic List<Attribute> getTableAttributes()
EntitygetTableAttributes in interface Entitypublic List<Attribute> getMappedAttributes()
EntitygetMappedAttributes in interface Entityprotected List<Attribute> moveIdSerialToEnd(List<Attribute> attributes)
attributes - the attribute listprotected List<Attribute> removeIdSerial(List<Attribute> attributes)
attributes - the attribute listprotected List<Attribute> appendIdSerial(Entity entity, List<Attribute> attributes)
entity - the entity defining id and serialattributes - the attribute listpublic List<Index> getInheritedIndexes()
EntitygetInheritedIndexes in interface Entitypublic List<Index> getIndexesIncludingInherited()
EntitygetIndexesIncludingInherited in interface Entitypublic List<Index> getSubEntityIndexes()
EntitygetSubEntityIndexes in interface Entitypublic List<Index> getIndexesIncludingSubEntities()
EntitygetIndexesIncludingSubEntities in interface Entitypublic List<Index> getAllIndexes()
EntitygetAllIndexes in interface Entitypublic List<Index> getTableIndexes()
EntitygetTableIndexes in interface Entitypublic List<Relation> getInheritedRelations()
EntitygetInheritedRelations in interface Entitypublic List<Relation> getSubEntityRelations()
EntitygetSubEntityRelations in interface Entitypublic List<Relation> getRelationsIncludingInherited()
EntitygetRelationsIncludingInherited in interface Entitypublic List<Relation> getRelationsIncludingSubEntities()
EntitygetRelationsIncludingSubEntities in interface Entitypublic List<Relation> getAllRelations()
EntitygetAllRelations in interface Entitypublic List<Relation> getTableRelations()
EntitygetTableRelations in interface Entitypublic Set<List<Relation>> getCompositePaths()
EntitygetCompositePaths in interface Entitypublic Set<Entity> getComponents()
EntitygetComponents in interface Entitypublic Set<Entity> getComponentsIncludingInherited()
EntitygetComponentsIncludingInherited in interface Entitypublic Set<Entity> getAllComponents()
EntitygetAllComponents in interface Entitypublic boolean isDeeplyReferenced()
EntityisDeeplyReferenced in interface Entitypublic void setDeeplyReferenced(boolean deeplyReferenced)
public List<Relation> getDeepReferences()
EntitygetDeepReferences in interface Entitypublic List<Relation> getDeepReferencesToComponents()
EntitygetDeepReferencesToComponents in interface Entitypublic List<Relation> getDeeplyReferencedComponents()
EntityEntity.isDeeplyReferenced() is true.getDeeplyReferencedComponents in interface Entitypublic Attribute getAttributeByJavaName(String javaName, boolean all)
EntitygetAttributeByJavaName in interface EntityjavaName - the java nameall - true if include inherited attributespublic Attribute getAttributeByColumnName(String columnName, boolean all)
EntityNotice that upper/lowercase doesnt matter.
getAttributeByColumnName in interface EntitycolumnName - the database column nameall - true if include inherited attributespublic Attribute getContextIdAttribute()
EntitygetContextIdAttribute in interface Entitypublic List<Attribute> getUniqueDomainKey()
EntitygetUniqueDomainKey in interface Entityprotected void getUniqueDomainKeyImpl(List<Attribute> uniqueDomainKeys, Entity entity)
uniqueDomainKeys - the unique domain key attributesentity - the entity to inspectpublic List<AttributeSorting> getSorting()
EntitygetSorting in interface Entitypublic List<Index> getIndexes()
EntitygetIndexes in interface Entitypublic Index getIndex(String name, boolean all)
Entitypublic List<Relation> getRelations()
EntitygetRelations in interface Entitypublic List<Relation> getReferencingRelations()
EntitygetReferencingRelations in interface Entitypublic List<Relation> getInheritedReferencingRelations()
EntitygetInheritedReferencingRelations in interface Entitypublic List<Relation> getReferencingRelationsIncludingInherited()
EntitygetReferencingRelationsIncludingInherited in interface Entitypublic List<Relation> getSubEntityReferencingRelations()
EntitygetSubEntityReferencingRelations in interface Entitypublic List<Relation> getReferencingRelationsIncludingSubEntities()
EntitygetReferencingRelationsIncludingSubEntities in interface Entitypublic List<Relation> getAllReferencingRelations()
EntitygetAllReferencingRelations in interface Entitypublic Relation getRelation(String name, boolean all)
EntitygetRelation in interface Entityname - the relation's nameall - true if include inherited relationspublic void validate()
throws ModelException
ModelException - if validation failedpublic void validateRelated()
throws ModelException
ModelImpl.updateRelations(org.tentackle.model.ModelDefaults) applied successfully.ModelException - if validation failedpublic String sqlCreateTable(Backend backend) throws ModelException
EntitysqlCreateTable in interface Entitybackend - the backend to create sql code forModelException - if model inconsistentpublic boolean isComposite()
EntityisComposite in interface Entitypublic boolean isAbstract()
EntityisAbstract in interface Entitypublic boolean isTracked()
Entitypublic Boolean isDeletionCascaded()
EntityisDeletionCascaded in interface Entitypublic boolean isRootOfInheritanceHierarchy()
EntityisRootOfInheritanceHierarchy in interface Entitypublic Set<Attribute> getRootAttributes()
EntitygetRootAttributes in interface Entitypublic Attribute getRootAttribute()
EntitygetRootAttribute in interface Entitypublic Set<Entity> getRootEntities()
EntitygetRootEntities in interface Entitypublic Entity getRootEntity()
EntitygetRootEntity in interface Entitypublic Entity getTableProvidingEntity()
EntitygetTableProvidingEntity in interface EntityCopyright © 2016 Krake Softwaretechnik. All rights reserved.