[history/serdha] Reorganizing packaes
This commit is contained in:
parent
c02dc87ad2
commit
332c2d75f2
@ -1,347 +0,0 @@
|
|||||||
package ru.landgrafhomyak.serdha.api.v0.ddl.module
|
|
||||||
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.ddl.table.Table
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.dml.CopyQuery
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.dml.CreateCopyQueryScope
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.dml.CreateInsertQueryScope
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.dml.DeleteQuery
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.dml.InsertQuery
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.dml.SelectQuery
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.dml.UpdateQuery
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.runtime.SynchronizedDatabase
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.runtime.Transaction
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scope methods for creating new [module template][ModuleTemplate].
|
|
||||||
*
|
|
||||||
* @see ModuleTemplate.CreateModuleTemplatesScope.createTemplate
|
|
||||||
* @see ModuleTemplate.ModuleCreator.createSchema
|
|
||||||
*/
|
|
||||||
public interface CreateModuleScope {
|
|
||||||
/**
|
|
||||||
* Functional interface for creating table.
|
|
||||||
*
|
|
||||||
* Can be implemented like a companion object that just calls [TableUserExtension]'s constructor with the same or similar signature.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type for containing table-related descriptors.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createTable
|
|
||||||
* @see CreateModuleScope.createSessionScopeTemporaryTable
|
|
||||||
* @see CreateModuleScope.createTransactionScopeTemporaryTable
|
|
||||||
* @see UpgradeModuleScope.TableUpgrade
|
|
||||||
*/
|
|
||||||
public interface TableCreator<TableUserExtension : Any> {
|
|
||||||
/**
|
|
||||||
* Scope method that uses [creator] to initialize table schema.
|
|
||||||
*
|
|
||||||
* @param creator Object with descriptor providers and factories.
|
|
||||||
* @return User's object with descriptors for future access.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createTable
|
|
||||||
* @see CreateModuleScope.createSessionScopeTemporaryTable
|
|
||||||
* @see CreateModuleScope.createTransactionScopeTemporaryTable
|
|
||||||
* @see UpgradeModuleScope.TableUpgrade
|
|
||||||
*/
|
|
||||||
public fun createTable(creator: ru.landgrafhomyak.serdha.api.v0.ddl.table.CreateTableScope<TableUserExtension>): TableUserExtension
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates table in [specified namespace][namespace] with [specified name][name] and stores it in the database.
|
|
||||||
* If table was created by previous synchronizations, asserts that table at the specified path in the database is same as table provided by [initializer].
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] this table must be [kept][UpgradeModuleScope.upgradeTable] (or [renamed][CreateModuleScope.renameTable]) or [deleted][CreateModuleScope.deleteTable].
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type for containing table-related descriptors.
|
|
||||||
* @param namespace Way to group tables if there is a lot.
|
|
||||||
* @param name Name of table for debugging.
|
|
||||||
* @param initializer Table-related descriptors initializer.
|
|
||||||
* @return Table descriptor.
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any> createTable(namespace: Namespace, name: String, initializer: TableCreator<TableUserExtension>): Table<TableUserExtension, Nothing>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a temporary table that exits only until connection to the database not [closed][SynchronizedDatabase._close].
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type for containing table-related descriptors.
|
|
||||||
* @param namespace Way to group tables if there is a lot.
|
|
||||||
* @param name Name of table for debugging.
|
|
||||||
* @param initializer Table-related descriptors initializer.
|
|
||||||
* @return Table descriptor.
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any> createSessionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableCreator<TableUserExtension>): Table<TableUserExtension, Nothing>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a temporary table that exits only inside [transaction][Transaction] and auto-deleted (or cleared, depends on driver implementation) when it [finished][Transaction._assertTransactionFinishedAndReleaseResources].
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type for containing table-related descriptors.
|
|
||||||
* @param namespace Way to group tables if there is a lot.
|
|
||||||
* @param name Name of table for debugging.
|
|
||||||
* @param initializer Table-related descriptors initializer.
|
|
||||||
* @return Table descriptor.
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any> createTransactionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableCreator<TableUserExtension>): Table<TableUserExtension, Nothing>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Functional interface for creating 'SELECT' query.
|
|
||||||
*
|
|
||||||
* Can be implemented like a companion object that just calls [QueryUserWrapper]'s constructor with the same or similar signature.
|
|
||||||
*
|
|
||||||
* @param QueryUserWrapper User's type with descriptors related to query.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createSelectQuery
|
|
||||||
*/
|
|
||||||
public interface SelectQueryCreator<QueryUserWrapper : Any> {
|
|
||||||
/**
|
|
||||||
* Scope method that uses [creator] to create a query.
|
|
||||||
*
|
|
||||||
* @param creator Object with descriptor providers and factories.
|
|
||||||
* @return User's object with query-related descriptors for future access.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createSelectQuery
|
|
||||||
*/
|
|
||||||
public fun createSelect(creator: ru.landgrafhomyak.serdha.api.v0.dml.CreateSelectQueryScope<QueryUserWrapper>): QueryUserWrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'SELECT' query.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param QueryUserWrapper User's type for containing query-related descriptors.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createTemporarySelectQuery
|
|
||||||
*/
|
|
||||||
public fun <QueryUserWrapper : Any> createSelectQuery(initializer: SelectQueryCreator<QueryUserWrapper>): SelectQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'SELECT' query accessible only while the module is [creating][ModuleTemplate.ModuleCreator] or [updating][ModuleTemplate.ModuleUpgrade].
|
|
||||||
* Using this function instead of [CreateModuleScope.createSelectQuery] may help the driver to optimize caches and runtime indexes.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param QueryUserWrapper User's type for containing query-related descriptors.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createSelectQuery
|
|
||||||
*/
|
|
||||||
public fun <QueryUserWrapper : Any> createTemporarySelectQuery(initializer: SelectQueryCreator<QueryUserWrapper>): SelectQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Functional interface for creating 'INSERT ... VALUES' query.
|
|
||||||
*
|
|
||||||
* Can be implemented like a companion object that just calls [QueryUserWrapper]'s constructor with the same or similar signature.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table to which values will be inserted.
|
|
||||||
* @param QueryUserWrapper User's type with descriptors related to query.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createInsertQuery
|
|
||||||
*/
|
|
||||||
public interface InsertQueryCreator<TableUserExtension : Any, QueryUserWrapper : Any> {
|
|
||||||
/**
|
|
||||||
* Scope method that uses [creator] to create a query.
|
|
||||||
*
|
|
||||||
* @param table Descriptor of table to which values will be inserted.
|
|
||||||
* @param creator Object with descriptor providers and factories.
|
|
||||||
* @return User's object with query-related descriptors for future access.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createInsertQuery
|
|
||||||
*/
|
|
||||||
public fun createInsert(table: Table<TableUserExtension, *>, creator: CreateInsertQueryScope<TableUserExtension, QueryUserWrapper>): QueryUserWrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'INSERT ... VALUES' query.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table to which values will be inserted.
|
|
||||||
* @param QueryUserWrapper User's type for containing query-related descriptors.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createTemporaryInsertQuery
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any, QueryUserWrapper : Any> createInsertQuery(table: Table<TableUserExtension, *>, initializer: InsertQueryCreator<TableUserExtension, QueryUserWrapper>): InsertQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'INSERT ... VALUES' query accessible only while the module is [creating][ModuleTemplate.ModuleCreator] or [updating][ModuleTemplate.ModuleUpgrade].
|
|
||||||
* Using this function instead of [CreateModuleScope.createInsertQuery] may help the driver to optimize caches and runtime indexes.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table to which values will be inserted.
|
|
||||||
* @param QueryUserWrapper User's type for containing query-related descriptors.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createInsertQuery
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any, QueryUserWrapper : Any> createTemporaryInsertQuery(table: Table<TableUserExtension, *>, initializer: InsertQueryCreator<TableUserExtension, QueryUserWrapper>): InsertQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Functional interface for creating 'INSERT ... FROM' query.
|
|
||||||
*
|
|
||||||
* Can be implemented like a companion object that just calls [QueryUserWrapper]'s constructor with the same or similar signature.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table to which values will be inserted.
|
|
||||||
* @param QueryUserWrapper User's type with descriptors related to query.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createCopyQuery
|
|
||||||
*/
|
|
||||||
public interface CopyQueryCreator<TableUserExtension : Any, QueryUserWrapper : Any> {
|
|
||||||
/**
|
|
||||||
* Scope method that uses [creator] to create a query.
|
|
||||||
*
|
|
||||||
* @param table Descriptor of table to which values will be inserted.
|
|
||||||
* @param creator Object with descriptor providers and factories.
|
|
||||||
* @return User's object with query-related descriptors for future access.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createCopyQuery
|
|
||||||
*/
|
|
||||||
public fun createCopy(table: Table<TableUserExtension, *>, creator: CreateCopyQueryScope<TableUserExtension, QueryUserWrapper>): QueryUserWrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'INSERT ... FROM' query.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table to which values will be inserted.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createTemporaryCopyQuery
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any, QueryUserWrapper : Any> createCopyQuery(table: Table<TableUserExtension, *>, initializer: CopyQueryCreator<TableUserExtension, QueryUserWrapper>): CopyQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'INSERT ... FROM' query accessible only while the module is [creating][ModuleTemplate.ModuleCreator] or [updating][ModuleTemplate.ModuleUpgrade].
|
|
||||||
* Using this function instead of [CreateModuleScope.createCopyQuery] may help the driver to optimize caches and runtime indexes.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table to which values will be inserted.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createCopyQuery
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any, QueryUserWrapper : Any> createTemporaryCopyQuery(table: Table<TableUserExtension, *>, initializer: CopyQueryCreator<TableUserExtension, QueryUserWrapper>): CopyQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Functional interface for creating 'UPDATE' query.
|
|
||||||
*
|
|
||||||
* Can be implemented like a companion object that just calls [QueryUserWrapper]'s constructor with the same or similar signature.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table, whose rows will be updated.
|
|
||||||
* @param QueryUserWrapper User's type with descriptors related to query.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createUpdateQuery
|
|
||||||
*/
|
|
||||||
public interface UpdateQueryCreator<TableUserExtension : Any, QueryUserWrapper : Any> {
|
|
||||||
/**
|
|
||||||
* Scope method that uses [creator] to create a query.
|
|
||||||
*
|
|
||||||
* @param table Descriptor of table which rows will be updated.
|
|
||||||
* @param creator Object with descriptor providers and factories.
|
|
||||||
* @return User's object with query-related descriptors for future access.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createUpdateQuery
|
|
||||||
*/
|
|
||||||
public fun createUpdate(table: Table<TableUserExtension, *>, creator: ru.landgrafhomyak.serdha.api.v0.dml.CreateUpdateQueryScope<TableUserExtension, QueryUserWrapper>): QueryUserWrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'UPDATE' query.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table to which values will be inserted.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createTemporaryUpdateQuery
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any, QueryUserWrapper : Any> createUpdateQuery(table: Table<TableUserExtension, *>, initializer: UpdateQueryCreator<TableUserExtension, QueryUserWrapper>): UpdateQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'UPDATE' query accessible only while the module is [creating][ModuleTemplate.ModuleCreator] or [updating][ModuleTemplate.ModuleUpgrade].
|
|
||||||
* Using this function instead of [CreateModuleScope.createUpdateQuery] may help the driver to optimize caches and runtime indexes.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table to which values will be inserted.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createUpdateQuery
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any, QueryUserWrapper : Any> createTemporaryUpdateQuery(table: Table<TableUserExtension, *>, initializer: UpdateQueryCreator<TableUserExtension, QueryUserWrapper>): UpdateQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Functional interface for creating 'DELETE' query.
|
|
||||||
*
|
|
||||||
* Can be implemented like a companion object that just calls [QueryUserWrapper]'s constructor with the same or similar signature.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table from which data will be deleted.
|
|
||||||
* @param QueryUserWrapper User's type with descriptors related to query.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createDeleteQuery
|
|
||||||
*/
|
|
||||||
public interface DeleteQueryCreator<TableUserExtension : Any, QueryUserWrapper : Any> {
|
|
||||||
/**
|
|
||||||
* Scope method that uses [creator] to create a query.
|
|
||||||
*
|
|
||||||
* @param table Descriptor of table from which data will be deleted.
|
|
||||||
* @param creator Object with descriptor providers and factories.
|
|
||||||
* @return User's object with query-related descriptors for future access.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createDeleteQuery
|
|
||||||
*/
|
|
||||||
public fun createDelete(table: Table<TableUserExtension, *>, creator: ru.landgrafhomyak.serdha.api.v0.dml.CreateDeleteQueryScope<TableUserExtension, QueryUserWrapper>): QueryUserWrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'DELETE' query.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table from which data will be deleted.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createTemporaryDeleteQuery
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any, QueryUserWrapper : Any> createDeleteQuery(table: Table<TableUserExtension, *>, initializer: DeleteQueryCreator<TableUserExtension, QueryUserWrapper>): DeleteQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates 'DELETE' query accessible only while the module is [creating][ModuleTemplate.ModuleCreator] or [updating][ModuleTemplate.ModuleUpgrade].
|
|
||||||
* Using this function instead of [CreateModuleScope.createDeleteQuery] may help the driver to optimize caches and runtime indexes.
|
|
||||||
*
|
|
||||||
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type with descriptors related to table from which data will be deleted.
|
|
||||||
* @param initializer Query-related descriptors initializer.
|
|
||||||
* @return Query descriptor.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createDeleteQuery
|
|
||||||
*/
|
|
||||||
public fun <TableUserExtension : Any, QueryUserWrapper : Any> createTemporaryDeleteQuery(table: Table<TableUserExtension, *>, initializer: DeleteQueryCreator<TableUserExtension, QueryUserWrapper>): DeleteQuery<QueryUserWrapper>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replaces [specified namespace][rootNs] with schema provided by [template].
|
|
||||||
* [This namespace][rootNs] will be root namespace for module and shouldn't contain any other definitions.
|
|
||||||
*
|
|
||||||
* @param rootNs Namespace where the new module will be located.
|
|
||||||
* @param template Schema template.
|
|
||||||
* @return Module descriptor.
|
|
||||||
*/
|
|
||||||
public fun <ModuleUserExtension : Any> substituteModule(rootNs: Namespace, template: ModuleTemplate<ModuleUserExtension>): Module<ModuleUserExtension>
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package ru.landgrafhomyak.serdha.api.v0.ddl.table
|
|
||||||
|
|
||||||
public interface Index<OwnerTableUserWrapper : Any> {
|
|
||||||
public val name: String
|
|
||||||
public val table: Table<OwnerTableUserWrapper, *>
|
|
||||||
public val columns: List<Column<*, *, OwnerTableUserWrapper>>
|
|
||||||
}
|
|
@ -1,13 +1,10 @@
|
|||||||
package ru.landgrafhomyak.serdha.api.v0.ddl.table
|
package ru.landgrafhomyak.db.serdha0.api.misc
|
||||||
|
|
||||||
import kotlin.jvm.JvmName
|
import kotlin.jvm.JvmName
|
||||||
import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType
|
import ru.landgrafhomyak.db.serdha0.api.table.Table
|
||||||
import ru.landgrafhomyak.serdha.api.v0.dml.SelectedTable
|
|
||||||
|
|
||||||
public interface Column<RT, DT : DatabaseType<RT>, TableUserExtension : Any> {
|
public interface Column<RT, DT : DatabaseType<RT>, TableUserExtension : Any> {
|
||||||
public val name: String
|
public val name: String
|
||||||
|
|
||||||
public val type: DT
|
public val type: DT
|
||||||
|
|
||||||
public val table: Table<TableUserExtension, *>
|
public val table: Table<TableUserExtension, *>
|
||||||
}
|
}
|
@ -0,0 +1,102 @@
|
|||||||
|
package ru.landgrafhomyak.db.serdha0.api.module
|
||||||
|
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.table.Table
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.queries.QueryCreator
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.runtime.SynchronizedDatabase
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.table.CreateTableScope
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope methods for creating new [module template][ModuleTemplate].
|
||||||
|
*
|
||||||
|
* @see ModuleTemplate.CreateModuleTemplatesScope.createTemplate
|
||||||
|
* @see ModuleTemplate.ModuleCreator.createSchema
|
||||||
|
*/
|
||||||
|
public interface CreateModuleScope {
|
||||||
|
/**
|
||||||
|
* Functional interface for creating table.
|
||||||
|
*
|
||||||
|
* Can be implemented like a companion object that just calls [TableUserExtension]'s constructor with the same or similar signature.
|
||||||
|
*
|
||||||
|
* @param TableUserExtension User's type for containing table-related descriptors.
|
||||||
|
*
|
||||||
|
* @see CreateModuleScope.createTable
|
||||||
|
* @see CreateModuleScope.createSessionScopeTemporaryTable
|
||||||
|
* @see CreateModuleScope.createTransactionScopeTemporaryTable
|
||||||
|
* @see UpgradeModuleScope.TableUpgrade
|
||||||
|
*/
|
||||||
|
public interface TableCreator<TableUserExtension : Any> {
|
||||||
|
/**
|
||||||
|
* Scope method that uses [creator] to initialize table schema.
|
||||||
|
*
|
||||||
|
* @param creator Object with descriptor providers and factories.
|
||||||
|
* @return User's object with descriptors for future access.
|
||||||
|
*
|
||||||
|
* @see CreateModuleScope.createTable
|
||||||
|
* @see CreateModuleScope.createSessionScopeTemporaryTable
|
||||||
|
* @see CreateModuleScope.createTransactionScopeTemporaryTable
|
||||||
|
* @see UpgradeModuleScope.TableUpgrade
|
||||||
|
*/
|
||||||
|
public fun createTable(creator: CreateTableScope<TableUserExtension>): TableUserExtension
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates table in [specified namespace][namespace] with [specified name][name] and stores it in the database.
|
||||||
|
* If table was created by previous synchronizations, asserts that table at the specified path in the database is same as table provided by [initializer].
|
||||||
|
*
|
||||||
|
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] this table must be [kept][UpgradeModuleScope.upgradeTable] (or [renamed][UpgradeModuleScope.renameTable]) or [deleted][UpgradeModuleScope.deleteTable].
|
||||||
|
*
|
||||||
|
* @param TableUserExtension User's type for containing table-related descriptors.
|
||||||
|
* @param namespace Way to group tables if there is a lot.
|
||||||
|
* @param name Name of table for debugging.
|
||||||
|
* @param initializer Table-related descriptors initializer.
|
||||||
|
* @return Table descriptor.
|
||||||
|
*/
|
||||||
|
public fun <TableUserExtension : Any> createTable(namespace: Namespace, name: String, initializer: TableCreator<TableUserExtension>): Table<TableUserExtension, Nothing>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a temporary table that exits only until connection to the database not [closed][SynchronizedDatabase._close].
|
||||||
|
*
|
||||||
|
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
||||||
|
*
|
||||||
|
* @param TableUserExtension User's type for containing table-related descriptors.
|
||||||
|
* @param namespace Way to group tables if there is a lot.
|
||||||
|
* @param name Name of table for debugging.
|
||||||
|
* @param initializer Table-related descriptors initializer.
|
||||||
|
* @return Table descriptor.
|
||||||
|
*/
|
||||||
|
public fun <TableUserExtension : Any> createSessionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableCreator<TableUserExtension>): Table<TableUserExtension, Nothing>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a temporary table that exits only inside [transaction][Transaction] and auto-deleted (or cleared, depends on driver implementation) when it [finished][Transaction._assertTransactionFinishedAndReleaseResources].
|
||||||
|
*
|
||||||
|
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
||||||
|
*
|
||||||
|
* @param TableUserExtension User's type for containing table-related descriptors.
|
||||||
|
* @param namespace Way to group tables if there is a lot.
|
||||||
|
* @param name Name of table for debugging.
|
||||||
|
* @param initializer Table-related descriptors initializer.
|
||||||
|
* @return Table descriptor.
|
||||||
|
*/
|
||||||
|
public fun <TableUserExtension : Any> createTransactionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableCreator<TableUserExtension>): Table<TableUserExtension, Nothing>
|
||||||
|
|
||||||
|
public val queries: QueryCreator.Scope
|
||||||
|
|
||||||
|
public val temporarySubqueries: QueryCreator.Scope
|
||||||
|
|
||||||
|
public val moduleConfiguringTemporaryQueries: QueryCreator.Scope
|
||||||
|
|
||||||
|
public fun <qUE : Any> createQuery(creator: QueryCreator<qUE>): qUE
|
||||||
|
|
||||||
|
public fun <qUE : Any> createModuleConfiguringTemporaryQuery(creator: QueryCreator<qUE>): qUE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces [specified namespace][rootNs] with schema provided by [template].
|
||||||
|
* [This namespace][rootNs] will be root namespace for module and shouldn't contain any other definitions.
|
||||||
|
*
|
||||||
|
* @param rootNs Namespace where the new module will be located.
|
||||||
|
* @param template Schema template.
|
||||||
|
* @return Module descriptor.
|
||||||
|
*/
|
||||||
|
public fun <ModuleUserExtension : Any> substituteModule(rootNs: Namespace, template: ModuleTemplate<ModuleUserExtension>): Module<ModuleUserExtension>
|
||||||
|
}
|
@ -1,8 +1,10 @@
|
|||||||
package ru.landgrafhomyak.serdha.api.v0.ddl.module
|
package ru.landgrafhomyak.db.serdha0.api.module
|
||||||
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.runtime.SynchronizedDatabase
|
import kotlin.jvm.JvmName
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.runtime.SynchronizedDatabase
|
||||||
|
|
||||||
public interface Module<ModuleUserExtension : Any> {
|
public interface Module<ModuleUserExtension : Any> {
|
||||||
|
|
||||||
public val userExtension: ModuleUserExtension
|
public val userExtension: ModuleUserExtension
|
||||||
|
|
||||||
public val versionKey: String
|
public val versionKey: String
|
@ -1,6 +1,6 @@
|
|||||||
package ru.landgrafhomyak.serdha.api.v0.ddl.module
|
package ru.landgrafhomyak.db.serdha0.api.module
|
||||||
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.runtime.Transaction
|
import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction
|
||||||
|
|
||||||
public interface ModuleTemplate<@Suppress("unused") ModuleUserExtension : Any> {
|
public interface ModuleTemplate<@Suppress("unused") ModuleUserExtension : Any> {
|
||||||
public interface Provider<UserExtension : Any> {
|
public interface Provider<UserExtension : Any> {
|
@ -1,4 +1,4 @@
|
|||||||
package ru.landgrafhomyak.serdha.api.v0.ddl.module
|
package ru.landgrafhomyak.db.serdha0.api.module
|
||||||
|
|
||||||
public interface Namespace {
|
public interface Namespace {
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
@ -1,22 +1,18 @@
|
|||||||
package ru.landgrafhomyak.serdha.api.v0.ddl.table
|
package ru.landgrafhomyak.db.serdha0.api.table
|
||||||
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.Expression
|
import ru.landgrafhomyak.db.serdha0.api.misc.Column
|
||||||
import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseType
|
import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType
|
||||||
import ru.landgrafhomyak.serdha.api.v0.ddl.types.DatabaseTypesProvider
|
|
||||||
import ru.landgrafhomyak.serdha.api.v0.ddl.types.RowId
|
|
||||||
|
|
||||||
public interface CreateTableScope<TableUserExtension : Any> {
|
public interface CreateTableScope<TableUserExtension : Any> {
|
||||||
public val expressionBuilder: Expression.Builder<TableUserExtension>
|
public val types: DatabaseType.Provider
|
||||||
|
|
||||||
public val types: DatabaseTypesProvider
|
|
||||||
|
|
||||||
public fun <RT, DT : DatabaseType<RT>> column(name: String, type: DT): Column<RT, DT, TableUserExtension>
|
public fun <RT, DT : DatabaseType<RT>> column(name: String, type: DT): Column<RT, DT, TableUserExtension>
|
||||||
|
|
||||||
public fun index(name: String, vararg columns: Column<*, *, TableUserExtension>): Index<TableUserExtension>
|
public fun index(name: String, vararg columns: Column<*, *, TableUserExtension>): Index<TableUserExtension>
|
||||||
|
|
||||||
public fun uniqueIndex(name: String, distinctNulls: Boolean, vararg columns: Column<*, *, TableUserExtension>): UniqueIndex<TableUserExtension>
|
public fun uniqueIndex(name: String, distinctNulls: Boolean, vararg columns: Column<*, *, TableUserExtension>): UniqueIndex<TableUserExtension>
|
||||||
public fun checkConstraint(name: String, constraint: Expression<Boolean, DatabaseType.BOOLEAN, TableUserExtension>): CheckConstraint<TableUserExtension>
|
public fun <ConstraintUserExtension : Any> checkConstraint(name: String, creator: CheckConstraint.Creator<ConstraintUserExtension, TableUserExtension>, recheckExistingRows: Boolean = false): CheckConstraint<TableUserExtension>
|
||||||
public fun <RT : Any, DT : DatabaseType<RT>> defaultValue(c: Column<RT, DT, TableUserExtension>, expr: Expression<RT, DT, TableUserExtension>): DefaultConstraint<RT, DT, TableUserExtension>
|
public fun <ConstraintUserExtension : Any, RT : Any, DT : DatabaseType<RT>> defaultValue(c: Column<RT, DT, TableUserExtension>, creator: DefaultConstraint.Creator<ConstraintUserExtension, RT, DT, TableUserExtension>): DefaultConstraint<TableUserExtension>
|
||||||
|
|
||||||
@Suppress("PropertyName")
|
@Suppress("PropertyName")
|
||||||
public val rowId_column: Column<RowId<TableUserExtension>, DatabaseType<RowId<TableUserExtension>>, TableUserExtension>
|
public val rowId_column: Column<RowId<TableUserExtension>, DatabaseType<RowId<TableUserExtension>>, TableUserExtension>
|
@ -0,0 +1,10 @@
|
|||||||
|
package ru.landgrafhomyak.db.serdha0.api.table
|
||||||
|
|
||||||
|
import kotlin.jvm.JvmName
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.misc.Column
|
||||||
|
|
||||||
|
public interface Index<OwnerTableUserExtension : Any> {
|
||||||
|
public val name: String
|
||||||
|
public val table: Table<OwnerTableUserExtension, *>
|
||||||
|
public val columns: List<Column<*, *, OwnerTableUserExtension>>
|
||||||
|
}
|
@ -1,6 +1,9 @@
|
|||||||
package ru.landgrafhomyak.serdha.api.v0.ddl.table
|
package ru.landgrafhomyak.db.serdha0.api.table
|
||||||
|
|
||||||
public interface Table<UserExtension : Any, PreviousUserExtension : Any> {
|
import ru.landgrafhomyak.db.serdha0.api.misc._Selectable
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.module.Module
|
||||||
|
|
||||||
|
public interface Table<UserExtension : Any, PreviousUserExtension : Any> : _Selectable<UserExtension> {
|
||||||
public val userExtension: UserExtension
|
public val userExtension: UserExtension
|
||||||
public val name: String
|
public val name: String
|
||||||
public val module: Module<*>
|
public val module: Module<*>
|
||||||
@ -12,5 +15,6 @@ public interface Table<UserExtension : Any, PreviousUserExtension : Any> {
|
|||||||
|
|
||||||
public val temporaryType: TemporaryType?
|
public val temporaryType: TemporaryType?
|
||||||
|
|
||||||
|
// todo make nullable for temp tables
|
||||||
public val namespacesFromModuleRoot: List<String>
|
public val namespacesFromModuleRoot: List<String>
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ru.landgrafhomyak.serdha.api.v0.ddl.table
|
package ru.landgrafhomyak.db.serdha0.api.table
|
||||||
|
|
||||||
public interface UniqueIndex<OwnerTableUserExtension : Any> : Index<OwnerTableUserExtension> {
|
public interface UniqueIndex<OwnerTableUserExtension : Any> : Index<OwnerTableUserExtension> {
|
||||||
public val areNullsDistinct: Boolean
|
public val areNullsDistinct: Boolean
|
Loading…
Reference in New Issue
Block a user