Using Logic Transactions

This chapter explains how to use logic transactions to safely structure a configuration session.

This chapter covers the following topics:

Using Logic Transactions

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).

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.