Deveel.Data.TableSourceComposite.Rollback C# (CSharp) Method

Rollback() private method

private Rollback ( Transaction transaction, IList touchedTables, TransactionRegistry journal ) : void
transaction Deveel.Data.Transactions.Transaction
touchedTables IList
journal Deveel.Data.Transactions.TransactionRegistry
return void
        internal void Rollback(Transaction transaction, IList<IMutableTable> touchedTables, TransactionRegistry journal)
        {
            // Go through the journal.  Any rows added should be marked as deleted
            // in the respective master table.

            // Get individual journals for updates made to tables in this
            // transaction.
            // The list MasterTableJournal
            var journalList = new List<TableEventRegistry>();
            for (int i = 0; i < touchedTables.Count; ++i) {
                var tableJournal = touchedTables[i].EventRegistry;
                if (tableJournal.EventCount > 0) // Check the journal has entries.
                    journalList.Add(tableJournal);
            }

            var changedTables = journalList.ToArray();

            lock (commitLock) {
                try {
                    // For each change to each table,
                    foreach (var changeJournal in changedTables) {
                        // The table the changes were made to.
                        int tableId = changeJournal.TableId;
                        // Get the master table with this table id.
                        var master = GetTableSource(tableId);
                        // Commit the rollback on the table.
                        master.RollbackTransactionChange(changeJournal);
                    }
                } finally {
                    // Notify the conglomerate that this transaction has closed.
                    CloseTransaction(transaction);
                }
            }
        }