public class IndexImpl extends Object implements Index
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 namefunction: is a function nameASC or + for ascending order (default)DESC or - for descending orderunique index udk := code index locid := location_id desc name index ucmt := -upper(comment)
| Constructor and Description |
|---|
IndexImpl(EntityFactoryImpl factory,
Entity entity,
SourceInfo sourceInfo)
Creates an index.
|
| Modifier and Type | Method and Description |
|---|---|
String |
createDatabaseIndexName(Entity entity)
Creates the database index name for given entity.
|
ModelException |
createModelException(String message)
Creates a model exception.
|
List<IndexAttribute> |
getAttributes()
Gets the index attributes.
|
String |
getComment()
Gets the comment.
|
Entity |
getEntity()
Gets the entity this index belongs to.
|
String |
getFilterCondition()
Gets the optional filter condition.
|
String |
getName()
Gets the name of the element.
|
ModelElement |
getParent()
Gets the parent element.
|
SourceInfo |
getSourceInfo()
Gets the information about the source where this element is defined.
|
ConfigurationLine |
getSourceLine()
Gets the source line.
|
boolean |
isLogicallyEqualTo(Index otherIndex)
Checks whether other index is logically equal to this index.
|
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. |
boolean |
isUnique()
Returns whether the index is unique.
|
void |
parse(Entity entity)
Parses a configuration line.
|
void |
setComment(String comment) |
void |
setFilterCondition(String filterCondition) |
void |
setName(String name) |
void |
setParsed(boolean parsed)
Sets the index to be parsed.
Only necessary for model converters if the properties are set explicitly to prevent parsing. |
void |
setSourceLine(ConfigurationLine sourceLine)
Sets the source line.
|
void |
setUnique(boolean unique) |
String |
sqlCreateIndex(Backend backend,
Entity entity)
Creates the index creation sql code.
|
String |
toString() |
void |
validate()
Validates the index.
|
public IndexImpl(EntityFactoryImpl factory, Entity entity, SourceInfo sourceInfo)
factory - the factory to create indexesentity - the entity this index belongs tosourceInfo - the source infopublic Entity getEntity()
Indexpublic SourceInfo getSourceInfo()
ModelElementgetSourceInfo in interface ModelElementpublic ModelElement getParent()
ModelElementgetParent in interface ModelElementpublic void parse(Entity entity) throws ModelException
entity - the entityModelException - if parsing the model failedpublic String getName()
ModelElementgetName in interface ModelElementpublic String createDatabaseIndexName(Entity entity)
IndexcreateDatabaseIndexName in interface Indexentity - the entitypublic String getComment()
IndexgetComment in interface Indexpublic boolean isUnique()
Indexpublic String getFilterCondition()
IndexgetFilterCondition in interface Indexpublic List<IndexAttribute> getAttributes()
IndexgetAttributes in interface Indexpublic void setName(String name)
public void setComment(String comment)
public void setUnique(boolean unique)
public void setFilterCondition(String filterCondition)
public void setParsed(boolean parsed)
parsed - true if don't parse anymorepublic boolean isParsed()
public void validate()
throws ModelException
Indexvalidate in interface IndexModelException - if validation failedpublic ConfigurationLine getSourceLine()
public void setSourceLine(ConfigurationLine sourceLine)
sourceLine - the linepublic ModelException createModelException(String message)
Refers to the source line if set, otherwise just the message.
message - the messagepublic String sqlCreateIndex(Backend backend, Entity entity)
IndexsqlCreateIndex in interface Indexbackend - the backend to create sql code forentity - the entity to create the index forpublic boolean isLogicallyEqualTo(Index otherIndex)
otherIndex - the other indexTentackle - distributed, domain- and model-driven