DBObjectDirectoryAdapter class

A DBObjectAdapter that stores objects in a Directory.

Simulates an Object Database adapter. Useful for development.

Doesn't enforce unique fields, as the other DBObjectAdapters (see DBObjectAdapter: "Unique fields are not enforced").

Inheritance
Available extensions

Constructors

DBObjectDirectoryAdapter(Directory directory, {bool? development, bool generateTables = false, Object? populateTables, Object? populateSource, Object? populateSourceVariables, EntityRepositoryProvider? parentRepositoryProvider, String? workingPath, bool log = false})

Properties

adapterLogger → Logger
The logger of this adapter's messages (e.g. the resolved TableSchemes).
no setter
callCloseTransactionRequired → bool
no setterinherited
cancelTransactionResultWithError → bool
no setterinherited
capability → DBAdapterCapability
The DBAdapter capability.
finalinherited
connectionInactivityLimit ↔ Duration
The maximum allowed duration of inactivity for a connection in the pool. Default: 15min
getter/setter pairinherited
connectivity → DBAdapterConnectivity
The type of connectivity.
finalinherited
cyclicDependencies → List<Initializable>
The dependencies of the current (or last) initialization attempt that were not waited for: they were (transitively) waiting for this instance (a cycle), so they may still be initializing when initialize runs or when this instance is initialized.
no setterinherited
development → bool
final
dialect → DBDialect
The DB dialect of this adapter.
no setterinherited
dialectName → String
The DB dialect name of this adapter.
no setterinherited
directory → Directory
final
encodeBytesAsDataURL → bool
If true, a bytes (Uint8List) field is stored as a DataURLBase64 string, by normalizeEntityJSON.
no setterinherited
entityRepositories → List<EntityRepository<Object>>
no setterinherited
entityRepositoriesBuildOrder → List<EntityRepository<Object>>
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
initializationStatus → InitializationStatus
Returns the current InitializationStatus.
no setterinherited
instanceID → int
finalinherited
isAsyncInitialization → bool
Returns true if this instance initialization was asynchronous.
no setterinherited
isClosed → bool
no setterinherited
isInitialized → bool
Returns true if this instance is already initialized.
no setterinherited
isInitializing → bool
Returns true if this instance is in the middle of the initialization process.
no setterinherited
isPoolEmpty → bool
no setterinherited
isPoolNotEmpty → bool
no setterinherited
lastCheckPoolElapsedTimeMs → int
no setterinherited
log → bool
finalinherited
maxConnections → int
The maximum number of connections in the pool of this adapter.
finalinherited
minConnections → int
The minimum number of connections in the pool of this adapter.
finalinherited
name → String
The name of the adapter.
finalinherited
onClose → Stream<DBAdapter<DBObjectDirectoryAdapterContext>>
On close events.
latefinalinherited
parentRepositoryProvider → EntityRepositoryProvider?
finalinherited
poolAliveElementsSize → int
no setterinherited
poolCreatedElementsCount → int
no setterinherited
poolDisposedElementsCount → int
no setterinherited
poolElements → Iterable<DBObjectDirectoryAdapterContext>
no setterinherited
poolFullWaitTimeout → Duration
no setterinherited
poolFullYieldTimeout → Duration
no setterinherited
poolSize → int
no setterinherited
poolSizeDesiredLimit → int
no setterinherited
poolYieldTimeout → Duration
no setterinherited
registeredEntityRepositories → List<EntityRepository<Object>>
no setterinherited
registeredEntityRepositoriesInformation → Map<EntityRepository<Object>, Object>
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tablesSchemes → Map<String, TableScheme>
The registered TableSchemes, by table name (see addTableSchemes).
finalinherited
throwTransactionResultWithError → bool
no setterinherited

Methods

addTableSchemes(Iterable<TableScheme> tablesSchemes) → void
Registers tablesSchemes (replacing the ones with the same name).
inherited
allRepositories({Map<Type, EntityRepository<Object>>? allRepositories, Set<EntityRepositoryProvider>? traversedProviders}) → Map<Type, EntityRepository<Object>>
inherited
applyTableOrderAndPagination(String table, Iterable<Map<String, dynamic>> entries, {int? limit, int? offset, bool? orderByID, OrderDirection? orderDirection}) → List<Map<String, dynamic>>
Orders (by the ID field of table) and paginates the selected entries: the object adapters select all the objects (no query engine), and then apply the select's order and limits here.
inherited
callCheckPool() → FutureOr<bool>
inherited
cancelTransaction(Transaction transaction, DBObjectDirectoryAdapterContext? connection, Object? error, StackTrace? stackTrace) → bool
inherited
catchFromPool({Duration? timeout}) → FutureOr<DBObjectDirectoryAdapterContext>
inherited
catchFromPopulatedPool() → FutureOr<DBObjectDirectoryAdapterContext?>
inherited
checkConnections() → FutureOr<bool>
Checks the connections of the pool. Defaults: calls removeInvalidElementsFromPool.
inherited
checkDB() → FutureOr<bool>
inherited
checkEntityFields<O>(O o, String entityName, String table, {EntityHandler<O>? entityHandler}) → void
inherited
checkInitialized({bool allowInProgress = true}) → void
Checks if this instance is initialized, initializing it if possible.
inherited
checkNotClosed() → void
inherited
checkPool() → FutureOr<bool>
Checks the pool connections and limits.
inherited
checkPoolSize(int minSize, int maxSize, int checkInvalidsIntervalMs) → FutureOr<bool>
inherited
clearPool() → FutureOr<bool>
inherited
close() → bool
inherited
closeConnection(DBObjectDirectoryAdapterContext connection) → bool
override
closePoolElement(DBObjectDirectoryAdapterContext o) → FutureOr<bool>
Defaults: calls closeConnection.
inherited
closeTransaction(Transaction transaction, DBObjectDirectoryAdapterContext? connection) → FutureOr<void>
Nothing here: the closer runs before the commit is final (it can still fail, e.g. an operation added late, and the transaction is then canceled). The transaction is closed (onTransactionContextClosed) only once committed, by resolveTransactionResult: closing it here, a cancel after it would find it already consolidated.
inherited
createAdapterException(String type, String message, {Object? parentError, StackTrace? parentStackTrace, Object? operation, Object? previousError}) → DBObjectDirectoryAdapterException
Creates the error of a failed operation of this adapter (see resolveError).
createConnection() → DBObjectDirectoryAdapterContext
Creates a connection C for this adapte
override
createPoolElement({bool force = false}) → FutureOr<DBObjectDirectoryAdapterContext?>
Defaults: calls createConnection.
inherited
createPoolElementForced() → FutureOr<DBObjectDirectoryAdapterContext>
inherited
createRepositoryAdapter<O>(String name, {String? tableName, Type? type}) → DBRepositoryAdapter<O>?
inherited
disposePoolElement(DBObjectDirectoryAdapterContext o) → FutureOr<bool>
inherited
disposeTableSchemeCache(String table, {bool fieldsTypes = false}) → TableScheme?
Disposes a TableScheme for table. Forces refresh of previous scheme. With fieldsTypes, also its fields types (getTableFieldsTypes), e.g. after a migration changed its columns.
inherited
disposeTablesSchemesCaches({bool fieldsTypes = false}) → void
Disposes all the loaded TableSchemes (see disposeTableSchemeCache), e.g. the referenced and relationship tables too, after a migration.
inherited
doCount(TransactionOperation op, String entityName, String table, {EntityMatcher? matcher, Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters, PreFinishDBOperation<int, int>? preFinish}) → FutureOr<int>
override
doDelete<R>(TransactionOperation op, String entityName, String table, EntityMatcher matcher, {Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters, PreFinishDBOperation<Iterable<Map<String, dynamic>>, R>? preFinish}) → FutureOr<R>
override
doExistIDs<I extends Object>(TransactionOperation op, String entityName, String table, List<I> ids) → FutureOr<List<I>>
override
doInitialization({Initializable? parent}) → FutureOr<InitializationResult>
Initialize this instance if is not initialized yet. Same as ensureInitialized.
inherited
doInsert<O>(TransactionOperation op, String entityName, String table, O o, Map<String, dynamic> fields, {String? idFieldName, PreFinishDBOperation? preFinish}) → FutureOr
override
doSelectAll<R>(TransactionOperation op, String entityName, String table, {int? limit, int? offset, bool? orderByID, OrderDirection? orderDirection, PreFinishDBOperation<Iterable<Map<String, dynamic>>, List<R>>? preFinish}) → FutureOr<List<R>>
Ordering and pagination:
override
doSelectByID<R>(TransactionOperation op, String entityName, String table, Object id, {PreFinishDBOperation<Map<String, dynamic>?, R?>? preFinish}) → FutureOr<R?>
override
doSelectByIDs<R>(TransactionOperation op, String entityName, String table, List<Object> ids, {int? limit, int? offset, bool? orderByID, OrderDirection? orderDirection, PreFinishDBOperation<List<Map<String, dynamic>>, List<R>>? preFinish}) → FutureOr<List<R>>
Ordering and pagination:
override
doUpdate<O>(TransactionOperation op, String entityName, String table, O o, Object id, Map<String, dynamic> fields, {String? idFieldName, PreFinishDBOperation? preFinish, bool allowAutoInsert = false}) → FutureOr
override
ensureInitialized({Initializable? parent}) → FutureOr<InitializationResult>
Ensures that this instance is initialized.
inherited
ensureInitializedAsync({Initializable? parent}) → FutureOr<InitializationResult>
Ensures that this instance is initialized. If is not initialized yet it will force an asynchronous initialization and return a Future.
inherited
executeInitialized<R>(ExecuteInitializedCallback<R> callback, {Initializable? parent}) → FutureOr<R>
Executes the callback ensuring that this instance was initialized.
inherited
executeOperation<T, R>(TransactionOperation op, FutureOr<T> f(DBObjectDirectoryAdapterContext connection), PreFinishDBOperation<T, R>? preFinish) → FutureOr<R>
Executes f in the transaction of op, and finishes op (with preFinish) after that execution, not inside it: a preFinish can issue other operations in the same transaction (e.g. selecting the sub-entities), executed after this one (inside it, they would wait for it, that waits for them).
inherited
executeTransactionOperation<R>(TransactionOperation op, FutureOr<R> f(DBObjectDirectoryAdapterContext connection)) → FutureOr<R>
Executes f with a connection of the transaction of op: from the pool if it's a single operation transaction, otherwise as an execution of the transaction (opening it if needed).
inherited
executeWithPool<R>(FutureOr<R> f(DBObjectDirectoryAdapterContext o), {Duration? timeout, bool validator(DBObjectDirectoryAdapterContext o)?, dynamic onError(Object error, StackTrace stackTrace)?}) → FutureOr<R>
inherited
filterPoolElements(FutureOr<bool> filter(DBObjectDirectoryAdapterContext o)) → FutureOr<List<DBObjectDirectoryAdapterContext>>
inherited
finishOperation<T, R>(TransactionOperation op, T res, PreFinishDBOperation<T, R>? preFinish, {TransactionErrorResolver? errorResolver}) → FutureOr<R>
Finishes the operation op with the result res of its transaction execution: applies preFinish (if any) and calls op.finish.
inherited
getConnectionURL(DBObjectDirectoryAdapterContext connection) → String
Returns the URL of the connection.
override
getEntityByID<O>(dynamic id, {Type? type, bool sync = false, EntityResolutionRules? resolutionRules}) → FutureOr<O?>
inherited
getEntityHandler<T>({String? entityName, String? tableName, Type? entityType}) → EntityHandler<T>?
inherited
getEntityID(Object entity, {String? entityName, String? tableName, Type? entityType, EntityHandler? entityHandler}) → Object?
Returns the entity ID for entityName, tableName or entityType.
inherited
getEntityRepositoresTables() → FutureOr<Map<EntityRepository<Object>, String>>
inherited
getEntityRepositoriesTables() → FutureOr<Map<EntityRepository<Object>, String>>
The table of each registered EntityRepository.
inherited
getEntityRepository<O extends Object>({O? obj, Type? type, String? name, String? tableName, Set<EntityRepositoryProvider>? traversed}) → EntityRepository<O>?
See EntityRepositoryProvider.lookupEntityRepository (the parentRepositoryProvider asked first).
inherited
getEntityRepositoryByType<O extends Object>(Type type, {Set<EntityRepositoryProvider>? traversed}) → EntityRepository<O>?
See EntityRepositoryProvider.lookupEntityRepository (the parentRepositoryProvider asked first).
inherited
getEntityRepositoryByTypeInfo<O extends Object>(TypeInfo typeInfo) → EntityRepository<O>?
inherited
getFieldType(String field, {String? entityName, String? tableName, Type? entityType}) → FutureOr<TypeInfo?>
Returns the type for the field at tableName or by entityName.
inherited
getRepositoryAdapterByName<O>(String name) → DBRepositoryAdapter<O>?
inherited
getRepositoryAdapterByTableName<O>(String tableName) → DBRepositoryAdapter<O>?
inherited
getRepositoryAdapterByType<O>(Type type) → DBRepositoryAdapter<O>?
inherited
getTableFieldsTypes(String table) → FutureOr<Map<String, Type>?>
Returns a TableScheme.fieldsTypes for table.
inherited
getTableFieldsTypesImpl(String table) → FutureOr<Map<String, Type>?>
inherited
getTableForEntityRepository(EntityRepository<Object> entityRepository) → String
Returns the table name for entityRepository.
inherited
getTableForType(TypeInfo type) → String?
Returns the table name for type.
inherited
getTableIDFieldName(String table) → String
The ID field of table: from its registered TableScheme, or id.
inherited
getTableScheme(String table, {TableRelationshipReference? relationship, Object? contextID}) → FutureOr<TableScheme?>
Returns a TableScheme for table. Calls getTableSchemeImpl handling asynchronous calls.
inherited
getTableSchemeForEntityRepository(EntityRepository<Object> entityRepository, {Object? contextID}) → FutureOr<TableScheme?>
Returns a TableScheme for entityRepository.
inherited
getTableSchemeForType(TypeInfo type) → FutureOr<TableScheme?>
Returns a TableScheme for type.
inherited
getTableSchemeIfLoaded(String table) → TableScheme?
inherited
getTableSchemeImpl(String table, TableRelationshipReference? relationship, {Object? contextID}) → TableScheme?
Implementation that returns a TableScheme for table.
inherited
information({bool extended = false, String? table}) → Map<String, dynamic>
override
initialize() → FutureOr<InitializationResult>
Initialization implementation. Do not call it directly, use doInitialization.
inherited
initializeDependencies() → List<Initializable>
Return a List of Initializable instances that need to be initialized BEFORE initialize this instance.
inherited
instantiateRepositoryAdapter<O>(String name, String? tableName, Type? type) → DBRepositoryAdapter<O>
inherited
invalidPoolElements({bool checkUsage = true}) → FutureOr<List<DBObjectDirectoryAdapterContext>>
inherited
isConnectionValid(DBObjectDirectoryAdapterContext connection, {bool checkUsage = true}) → FutureOr<bool>
Returns true if connection is valid for usage.
inherited
isPoolElementInvalid(DBObjectDirectoryAdapterContext o, {bool checkUsage = true}) → FutureOr<bool>
inherited
isPoolElementValid(DBObjectDirectoryAdapterContext o, {bool checkUsage = true}) → FutureOr<bool>
Defaults: calls isConnectionValid.
inherited
isTransactionWithSingleOperation(TransactionOperation op) → bool
inherited
normalizeEntityJSON(Map<String, dynamic> entityJson, {String? entityName, String? table, EntityRepository<Object>? entityRepository}) → Map<String, dynamic>
Normalizes an entity JSON to be stored: the references to other entities (single, EntityReference, lists and EntityReferenceList) become their IDs, and a bytes field becomes a DataURLBase64 string (if encodeBytesAsDataURL).
inherited
normalizeObjectID(Object? o) → String
Normalizes the object ID o into a safe file/object name: only word characters, . and -, no leading . (no hidden files, nor ..), and at most 220 characters (below the usual file name limits).
inherited
normalizeTableName(String table) → String
Normalizes table into a safe directory/prefix name (non-word characters replaced by _).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyKnownEntityRepositoryProvider(EntityRepositoryProvider provider) → void
inherited
notifyTableFieldTypes(String table, Map<String, Type> fieldsTypes) → Map<String, Type>
inherited
onTransactionContextCanceled(DBObjectDirectoryAdapterContext context) → void
Called when the transaction of context is canceled (after removing it from the open ones). Default: does nothing (the object adapters write immediately). DBObjectMemoryAdapter rolls back its tables.
inherited
onTransactionContextClosed(DBObjectDirectoryAdapterContext context, {required bool otherTransactionsOpen}) → void
Called when the transaction of context is closed (after removing it from the open ones). otherTransactionsOpen tells if other transactions are still open. Default: does nothing. DBObjectMemoryAdapter consolidates its tables (once all the transactions are closed).
inherited
openTransaction(Transaction transaction) → DBObjectDirectoryAdapterContext
The shared DBObjectAdapter.openTransaction, typed as this adapter's context: it opens synchronously (createConnection is synchronous), as this adapter's own openTransaction was declared before the shared implementation (a caller may rely on the concrete type).
peekFromPool() → FutureOr<DBObjectDirectoryAdapterContext?>
inherited
populateFromSource(Object? source, {String? workingPath, EntityResolutionRules? resolutionRules, Object? variables}) → FutureOr<Map<String, List<Object>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

populateImpl() → FutureOr<InitializationResult>
inherited
preparePoolElement(DBObjectDirectoryAdapterContext o) → FutureOr<DBObjectDirectoryAdapterContext?>
inherited
recyclePoolElement(DBObjectDirectoryAdapterContext o) → FutureOr<DBObjectDirectoryAdapterContext?>
inherited
registerEntityRepository<O extends Object>(EntityRepository<O> entityRepository) → void
inherited
releaseIntoPool(DBObjectDirectoryAdapterContext o) → FutureOr<bool>
inherited
removeElementsFromPool(int amount) → int
inherited
removeFromPool(DBObjectDirectoryAdapterContext o) → bool
inherited
removeInvalidElementsFromPool({bool checkUsage = true}) → FutureOr<bool>
inherited
resolveEntitiesSource(Object? source, {String? workingPath}) → FutureOr<Map<String, Iterable<Map<String, dynamic>>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveEntitiesSourceVariables(Map<String, Iterable<Map<String, dynamic>>> source, Map<String, dynamic> variables) → Map<String, Iterable<Map<String, dynamic>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveEntitySourceValueVariables(String key, Object? value, Map<String, dynamic> variables) → Object?

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveEntitySourceVariables(Map<String, dynamic> entity, Map<String, dynamic> variables) → Map<String, dynamic>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveError(Object error, StackTrace stackTrace, Object? operation, Object? previousError) → Object
Resolves an operation error into this adapter's exception (see createAdapterException).
inherited
resolveSource(Object? source, {String? workingPath}) → FutureOr<Map<String, dynamic>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveTransactionResult(dynamic result, Transaction transaction, DBObjectDirectoryAdapterContext? connection) → FutureOr
A committed transaction (not a TransactionAbortedError) is closed here (see closeTransaction); an aborted one is canceled by super.
inherited
selectIDFieldName(String table, List<String> primaryKeyCandidates) → String
Selects the ID field name from primaryKeyCandidates candidates:
inherited
storeAllFromJson(Map<String, Iterable<Map<String, dynamic>>> entries, {Transaction? transaction, EntityResolutionRules? resolutionRules, Map<String, dynamic>? variables}) → FutureOr<Map<String, List<Object>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

storeAllFromJsonEncoded(String jsonEncoded, {Transaction? transaction, EntityResolutionRules? resolutionRules, Map<String, dynamic>? variables}) → FutureOr<Map<String, List<Object>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

toString() → String
A string representation of this object.
override
validPoolElements() → FutureOr<List<DBObjectDirectoryAdapterContext>>
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

fileLimited → FileLimited
Limits the concurrent object file reads of all the DBObjectDirectoryAdapters (default: FileLimited.defaultSemaphoreLimit), so concurrent selects of large tables can't open thousands of files at once (Too many open files). Also the batch size of a select's reads.
no setter

Static Methods

boot() → void
fromConfig(Map<String, dynamic>? config, {EntityRepositoryProvider? parentRepositoryProvider, String? workingPath}) → FutureOr<DBObjectDirectoryAdapter>