- java.lang.Object
-
- org.tentackle.model.impl.IndexImpl
-
- All Implemented Interfaces:
Index,ModelElement
public class IndexImpl extends java.lang.Object implements Index
Index descriptor.- 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 java.lang.StringcreateDatabaseIndexName(Entity entity)Creates the database index name for given entity.ModelExceptioncreateModelException(java.lang.String message)Creates a model exception.java.util.List<IndexAttribute>getAttributes()Gets the index attributes.java.lang.StringgetComment()Gets the comment.EntitygetEntity()Gets the entity this index belongs to.java.lang.StringgetFilterCondition()Gets the optional filter condition.java.lang.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.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(java.lang.String comment)voidsetFilterCondition(java.lang.String filterCondition)voidsetName(java.lang.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)java.lang.StringsqlCreateIndex(org.tentackle.sql.Backend backend, Entity entity)Creates the index creation sql code.java.lang.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 java.lang.String getName()
Description copied from interface:ModelElementGets the name of the element.- Specified by:
getNamein interfaceModelElement- Returns:
- the name
-
createDatabaseIndexName
public java.lang.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 java.lang.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 java.lang.String getFilterCondition()
Description copied from interface:IndexGets the optional filter condition.- Specified by:
getFilterConditionin interfaceIndex- Returns:
- the condition, null if none
-
getAttributes
public java.util.List<IndexAttribute> getAttributes()
Description copied from interface:IndexGets the index attributes.- Specified by:
getAttributesin interfaceIndex- Returns:
- the attributes
-
setName
public void setName(java.lang.String name)
-
setComment
public void setComment(java.lang.String comment)
-
setUnique
public void setUnique(boolean unique)
-
setFilterCondition
public void setFilterCondition(java.lang.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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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(java.lang.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 java.lang.String sqlCreateIndex(org.tentackle.sql.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
-
-