This chapter explains how to use logic transactions to safely structure a configuration session.
This chapter covers the following topics:
In order to help you maintain consistency in interactions with the Oracle Configurator logic engine, you must use configuration-level logic transactions. A logic transaction comprises all the logical assertions that constitute a user interaction. At the end of a transaction, you can obtain a list of all validation failures, by calling Configuration.getValidationFailures(). See Validating Configurations.
The Configuration object, oracle.apps.cz.cio.Configuration, provides a set of methods for starting, ending, and rolling back configuration-level logic transactions. Note that logic transactions are not database transactions.
Inside a transaction, the normal course of action is to set the logical states and numeric values of runtime nodes (as described in Getting and Setting Logic States and Getting and Setting Numeric Values).
Use Configuration.beginConfigTransaction() to create a new transaction, returning a ConfigTransaction object. After performing the desired series of operations (for instance, setting states and values), you must end, commit, or roll back the transaction by passing the ConfigTransaction object to one of the mutually exclusive methods that finish the transaction:
endConfigTransaction
commitConfigTransaction
rollbackConfigTransaction
Configuration.commitConfigTransaction() commits the given transaction or series of nested transactions, propagates the effect of user selections throughout the configuration, and triggers validation checking (see Validating Configurations).
Configuration.endConfigTransaction() ends the transaction that was started with beginConfigTransaction(), without committing it (thus skipping validation checking).
Configuration.rollbackConfigTransaction() rolls back the unfinished transaction, undoing the operations performed inside it.
You can nest intermediate transactions with beginConfigTransaction() and endConfigTransaction, delaying validation checking until you call commitConfigTransaction(). You should not perform any actions (such as setting states or counts, or selecting Options) before opening a nested transaction. If there are actions performed in an uncommitted parent transaction, these may produce erroneous results for Configuration.getUnsatisfiedItems(). You must end or commit inner transactions before ending or committing the outer ones that contain them. When rolling back unfinished transactions, with rollbackConfigTransaction(), you can roll back outer transactions, which automatically rolls back the inner transactions.
Transactions should also be used when you employ nonoverridable requests. See Nonoverridable Requests.
There are situations in which you must take care to commit a transaction at the appropriate time. The fragmentary code in Using a Logic Transaction with a Deletion illustrates the need for wrapping a common operation inside a transaction to insure that the operation’s effects are reflected in other parts of the program. Setting Nonoverridable Requests also illustrates the use of transactions.
Using a Logic Transaction with a Deletion
... Component comp; ComponentSet compSet; ConfigTransaction tr; Configuration config; IOption opt; // ---------------------------------------------------------- // This sequence produces unintended results: ...
... // Select a child of compSet.
... opt.select()
... // User wants to see the list of all selected nodes: collec = config.getSelectedItems(); // The returned collection includes children of the deleted component, // because no transaction was commited. // ---------------------------------------------------------- // This sequence produces the intended results: ... // Add a component: comp = compSet.add(); ...
// User selects a child of compSet (interactively).
... // Delete the component, inside a transaction: tr = config.beginConfigTransaction(); compSet.delete(component); config.commitConfigTransaction(tr); ... // User wants to see the list of all selected nodes: collec = config.getSelectedItems(); // The returned collection does NOT include children of the deleted component, // because the deletion transaction was commited.