java.lang.Object
org.tentackle.model.impl.IndexImpl
- All Implemented Interfaces:
Index,ModelElement
Index descriptor.
An index line is of the form:
[unique] index <name> := part1[ part2 ...]where
part is:
[+|-]<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 name. Columns of embedded entities are defined by prepending the corresponding dotted path to the column. For multi-column types the column consists of the attribute's column name, followed by a hash, followed by the column name within the datatype.function: 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) index xpos := position#x
- Author:
- harald
-
Constructor Summary
ConstructorsConstructorDescriptionIndexImpl(EntityFactoryImpl factory, Entity entity, SourceInfo sourceInfo) Creates an index. -
Method Summary
Modifier and TypeMethodDescriptioncreateDatabaseIndexName(Entity entity) Creates the database index name for given entity.createModelException(String message) Creates a model exception.Gets the index attributes.Gets the comment.Gets the entity this index belongs to.Gets the optional filter condition.getName()Gets the name of the element.intGets the ordinal along the inheritance path.Gets the parent element.Gets the information about the source where this element is defined.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.voidParses a configuration line.voidsetComment(String comment) voidsetFilterCondition(String filterCondition) voidvoidsetOrdinal(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) sqlCreateIndex(Backend backend, Entity entity) Creates the index creation sql code.toString()voidvalidate()Validates the index.
-
Constructor Details
-
IndexImpl
Creates an index.- Parameters:
factory- the factory to create indexesentity- the entity this index belongs tosourceInfo- the source info
-
-
Method Details
-
getEntity
Description copied from interface:IndexGets the entity this index belongs to. -
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
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
Parses a configuration line.- Parameters:
entity- the entity- Throws:
ModelException- if parsing the model failed
-
getName
Description copied from interface:ModelElementGets the name of the element.- Specified by:
getNamein interfaceModelElement- Returns:
- the name
-
createDatabaseIndexName
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
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
Description copied from interface:IndexGets the optional filter condition.- Specified by:
getFilterConditionin interfaceIndex- Returns:
- the condition, null if none
-
getAttributes
Description copied from interface:IndexGets the index attributes.- Specified by:
getAttributesin interfaceIndex- Returns:
- the attributes
-
setName
-
setComment
-
setUnique
public void setUnique(boolean unique) -
setFilterCondition
-
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 already parsed
-
toString
-
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
Description copied from interface:IndexValidates the index.- Specified by:
validatein interfaceIndex- Throws:
ModelException- if validation failed
-
getSourceLine
Gets the source line.- Returns:
- the line
-
setSourceLine
Sets the source line.- Parameters:
sourceLine- the line
-
createModelException
Creates a model exception.Refers to the source line if set, otherwise just the message.
- Parameters:
message- the message- Returns:
- the exception
-
sqlCreateIndex
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
Checks whether other index is logically equal to this index.- Parameters:
otherIndex- the other index- Returns:
- true if equal
-