Package ru.curs.celesta.score
Class BasicTable
java.lang.Object
ru.curs.celesta.score.NamedElement
ru.curs.celesta.score.GrainElement
ru.curs.celesta.score.DataGrainElement
ru.curs.celesta.score.BasicTable
- All Implemented Interfaces:
HasColumns,TableElement
- Direct Known Subclasses:
ReadOnlyTable,Table
Super class for
Table and ReadOnlyTable that encompasses common logic
for both table types.- Since:
- 2019-07-14
- Author:
- Pavel Perminov (packpaul@mail.ru)
-
Field Summary
Fields inherited from class ru.curs.celesta.score.NamedElement
MAX_IDENTIFIER_LENGTHFields inherited from interface ru.curs.celesta.score.TableElement
YOU_CANNOT_DROP_A_COLUMN_THAT_BELONGS_TO -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a column to the table.voidFinalizes the creation of the primary key.Returns the integer column with default value provided by a sequence (or empty Optional if such column does not exists).final Column<?> Returns a column by its name or throws an exception with a message that the column is not found.final intgetColumnIndex(String name) Column index in the list of columns.Unmodified list of table columns.Returns a set of foreign keys for the table.Returns interfaces that are implemented by the cursor (values of 'implements' property) for this table.Returns a set of indices for the table.final StringReturns PK constraint name.Returns unmodified map of primary key columns.booleanReturns true in case there are materialized views built on top of this table.booleanWhether autoupdate is on/off.
falsevalue indicates that the table was created with the option WITH NO STRUCTURE UPDATE and it won't take part in the DB autoupdate.final voidremoveColumn(Column<?> column) Removes a column from the table.voidsetAutoUpdate(boolean autoUpdate) Sets or clears the option WITH NO STRUCTURE UPDATE.voidSets primary key on the table in a form of array of columns.voidsetPkConstraintName(String pkConstraintName) Sets the name of constraint for the primary key.final StringtoString()Methods inherited from class ru.curs.celesta.score.DataGrainElement
deleteMethods inherited from class ru.curs.celesta.score.GrainElement
getGrain, getGrainPartMethods inherited from class ru.curs.celesta.score.NamedElement
equals, getCelestaDoc, getName, getQuotedName, getQuotedNameIfNeeded, hashCode, limitName, limitName, setCelestaDocMethods inherited from interface ru.curs.celesta.score.TableElement
getGrain, getName, getQuotedName, getQuotedNameIfNeeded, hasPrimeKey
-
Method Details
-
getColumns
Unmodified list of table columns.- Specified by:
getColumnsin interfaceHasColumns- Specified by:
getColumnsin interfaceTableElement- Returns:
-
getColumn
Description copied from interface:TableElementReturns a column by its name or throws an exception with a message that the column is not found.- Specified by:
getColumnin interfaceTableElement- Parameters:
colName- column name- Returns:
- Throws:
ParseException- if a column with the specified name is not found in the table
-
getPrimaryKey
Description copied from interface:TableElementReturns unmodified map of primary key columns.- Specified by:
getPrimaryKeyin interfaceTableElement- Returns:
- map of column name -> column
-
addColumn
Adds a column to the table.- Specified by:
addColumnin interfaceTableElement- Parameters:
column- new column- Throws:
ParseException- if a column with the same name is already defined
-
toString
-
setPK
Sets primary key on the table in a form of array of columns. It is used for dynamic metadata management.- Parameters:
columnNames- array of columns- Throws:
ParseException- in case when an empty array is passed in
-
removeColumn
Description copied from interface:TableElementRemoves a column from the table.- Specified by:
removeColumnin interfaceTableElement- Parameters:
column- existing column- Throws:
ParseException- if the column couldn't be removed
-
finalizePK
Finalizes the creation of the primary key.- Throws:
ParseException- if the primary key is empty.
-
getForeignKeys
Returns a set of foreign keys for the table.- Returns:
-
getIndices
Returns a set of indices for the table.- Returns:
-
getPkConstraintName
Description copied from interface:TableElementReturns PK constraint name.- Specified by:
getPkConstraintNamein interfaceTableElement- Returns:
-
setPkConstraintName
Sets the name of constraint for the primary key.- Parameters:
pkConstraintName- PK constraint name- Throws:
ParseException- incorrect name
-
isAutoUpdate
public boolean isAutoUpdate()Whether autoupdate is on/off.
falsevalue indicates that the table was created with the option WITH NO STRUCTURE UPDATE and it won't take part in the DB autoupdate. Default istrue.- Returns:
-
setAutoUpdate
public void setAutoUpdate(boolean autoUpdate) Sets or clears the option WITH NO STRUCTURE UPDATE.- Parameters:
autoUpdate-trueif the table is updated automatically,false- in the opposite case.
-
getColumnIndex
Description copied from interface:HasColumnsColumn index in the list of columns.- Specified by:
getColumnIndexin interfaceHasColumns- Parameters:
name- column name.
-
hasMaterializedViews
public boolean hasMaterializedViews()Returns true in case there are materialized views built on top of this table. -
getAutoincrementedColumn
Returns the integer column with default value provided by a sequence (or empty Optional if such column does not exists). -
getImplements
Returns interfaces that are implemented by the cursor (values of 'implements' property) for this table.- Returns:
-