- java.lang.Object
-
- org.tentackle.model.impl.IndexImpl
-
- All Implemented Interfaces:
Index,ModelElement
public class IndexImpl extends Object implements Index
Index descriptor.An index line is of the form:
[unique] index <name> := part1[ part2 ...]
wherepartis:[+|-]<column> | <function>(<column>) [asc|desc]
where:name: is the index name (the table-name will be prepended, separated by an underscore)column: is either the database column-name of the entity attribute namefunction: is a function nameASCor+for ascending order (default)DESCor-for descending order
unique index udk := code index locid := location_id desc name index ucmt := -upper(comment)
- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description IndexImpl(EntityFactoryImpl factory, Entity entity, SourceInfo sourceInfo)Creates an index.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcreateDatabaseIndexName(Entity entity)Creates the database index name for given entity.ModelExceptioncreateModelException(String message)Creates a model exception.List<IndexAttribute>getAttributes()Gets the index attributes.StringgetComment()Gets the comment.EntitygetEntity()Gets the entity this index belongs to.StringgetFilterCondition()Gets the optional filter condition.StringgetName()Gets the name of the element.intgetOrdinal()Gets the ordinal along the inheritance path.ModelElementgetParent()Gets the parent element.SourceInfogetSourceInfo()Gets the information about the source where this element is defined.ConfigurationLinegetSourceLine()Gets the source line.booleanisLogicallyEqualTo(Index otherIndex)Checks whether other index is logically equal to this index.booleanisParsed()Returns whether index is already parsed.
Indexes are parsed delayed because some attributes may be added later when the whole model is known.booleanisUnique()Returns whether the index is unique.voidparse(Entity entity)Parses a configuration line.voidsetComment(String comment)voidsetFilterCondition(String filterCondition)voidsetName(String name)voidsetOrdinal(int ordinal)voidsetParsed(boolean parsed)Sets the index to be parsed.
Only necessary for model converters if the properties are set explicitly to prevent parsing.voidsetSourceLine(ConfigurationLine sourceLine)Sets the source line.voidsetUnique(boolean unique)StringsqlCreateIndex(Backend backend, Entity entity)Creates the index creation sql code.StringtoString()voidvalidate()Validates the index.
-
-
-
Constructor Detail
-
IndexImpl
public IndexImpl(EntityFactoryImpl factory, Entity entity, SourceInfo sourceInfo)
Creates an index.- Parameters:
factory- the factory to create indexesentity- the entity this index belongs tosourceInfo- the source info
-
-
Method Detail
-
getEntity
public Entity getEntity()
Description copied from interface:IndexGets the entity this index belongs to.
-
getSourceInfo
public SourceInfo getSourceInfo()
Description copied from interface:ModelElementGets the information about the source where this element is defined.- Specified by:
getSourceInfoin interfaceModelElement- Returns:
- the source info
-
getParent
public ModelElement getParent()
Description copied from interface:ModelElementGets the parent element.- Specified by:
getParentin interfaceModelElement- Returns:
- the parent, null if none
-
getOrdinal
public int getOrdinal()
Description copied from interface:ModelElementGets the ordinal along the inheritance path.- Specified by:
getOrdinalin interfaceModelElement- Returns:
- the ordinal, starting at 0
-
setOrdinal
public void setOrdinal(int ordinal)
-
parse
public void parse(Entity entity) throws ModelException
Parses a configuration line.- Parameters:
entity- the entity- Throws:
ModelException- if parsing the model failed
-
getName
public String getName()
Description copied from interface:ModelElementGets the name of the element.- Specified by:
getNamein interfaceModelElement- Returns:
- the name
-
createDatabaseIndexName
public String createDatabaseIndexName(Entity entity)
Description copied from interface:IndexCreates the database index name for given entity.- Specified by:
createDatabaseIndexNamein interfaceIndex- Parameters:
entity- the entity- Returns:
- the effective sql name
-
getComment
public String getComment()
Description copied from interface:IndexGets the comment.- Specified by:
getCommentin interfaceIndex- Returns:
- the comment
-
isUnique
public boolean isUnique()
Description copied from interface:IndexReturns whether the index is unique.
-
getFilterCondition
public String getFilterCondition()
Description copied from interface:IndexGets the optional filter condition.- Specified by:
getFilterConditionin interfaceIndex- Returns:
- the condition, null if none
-
getAttributes
public List<IndexAttribute> getAttributes()
Description copied from interface:IndexGets the index attributes.- Specified by:
getAttributesin interfaceIndex- Returns:
- the attributes
-
setName
public void setName(String name)
-
setComment
public void setComment(String comment)
-
setUnique
public void setUnique(boolean unique)
-
setFilterCondition
public void setFilterCondition(String filterCondition)
-
setParsed
public void setParsed(boolean parsed)
Sets the index to be parsed.
Only necessary for model converters if the properties are set explicitly to prevent parsing.- Parameters:
parsed- true if don't parse anymore
-
isParsed
public boolean isParsed()
Returns whether index is already parsed.
Indexes are parsed delayed because some attributes may be added later when the whole model is known.- Returns:
- true if parsed
-
validate
public void validate() throws ModelExceptionDescription copied from interface:IndexValidates the index.- Specified by:
validatein interfaceIndex- Throws:
ModelException- if validation failed
-
getSourceLine
public ConfigurationLine getSourceLine()
Gets the source line.- Returns:
- the line
-
setSourceLine
public void setSourceLine(ConfigurationLine sourceLine)
Sets the source line.- Parameters:
sourceLine- the line
-
createModelException
public ModelException createModelException(String message)
Creates a model exception.Refers to the source line if set, otherwise just the message.
- Parameters:
message- the message- Returns:
- the exception
-
sqlCreateIndex
public String sqlCreateIndex(Backend backend, Entity entity)
Description copied from interface:IndexCreates the index creation sql code.- Specified by:
sqlCreateIndexin interfaceIndex- Parameters:
backend- the backend to create sql code forentity- the entity to create the index for- Returns:
- the SQL code
-
isLogicallyEqualTo
public boolean isLogicallyEqualTo(Index otherIndex)
Checks whether other index is logically equal to this index.- Parameters:
otherIndex- the other index- Returns:
- true if equal
-
-