Package wt.container.batch
Interface TransactionContainer
public interface TransactionContainer
TransactionContainers are used to link together a group of BatchContainers
which are being used in a single update transaction. TransactionContainers
keep a time ordered record of BatchContainer changes by recording each
BatchContainer change as an Asssertion.
Example client code:
// Create the overall transaction container
TransactionContainer txnCntr = BatchContainerFactory.instantiateTransactionContainer();
// Create a main container.
BatchContainer mainContainer = BatchContainerFactory.instantiateGeneralContainer( txnCntr, "main" );
// Create a new A object.
RoleAType roleA = RoleAType.newRoleAType();
// Capture the add assertion.
mainContainer.add( roleA );
// Create a role B container.
RoleBatchContainer roleBContainer = BatchContainerFactory.instantiateRoleBatchContainer( txnCntr, "name", "assocName", "roleB", roleA );
// If roleA object already existed then pre-populate the container.
QueryResult qr = ???.navigate();
roleBContainer.populate( qr );
// Create a role B object.
RoleBType roleB = RoleBType.newRoleBType();
// Assert the existence of the new roleB object.
mainContainer.add( roleB );
// Capture in container.
roleBContainer.add( roleB );
// Make the assertions permanent.
if ( txnCntr.setTransactionResults( ??????.manager.submitTransaction( txnCntr ) ) )
{
// Loop through for bad assertions.
Enumeration enum = txnCntr.getAssertions();
while ( enum.hasMoreElements() ) {
Assertion nextAssertion = (Assertion) enum.nextElement();
if ( assertion.getException() != null )
// do something...
} // whild
} // if
Supported API: true
Extendable: false
Example client code:
// Create the overall transaction container
TransactionContainer txnCntr = BatchContainerFactory.instantiateTransactionContainer();
// Create a main container.
BatchContainer mainContainer = BatchContainerFactory.instantiateGeneralContainer( txnCntr, "main" );
// Create a new A object.
RoleAType roleA = RoleAType.newRoleAType();
// Capture the add assertion.
mainContainer.add( roleA );
// Create a role B container.
RoleBatchContainer roleBContainer = BatchContainerFactory.instantiateRoleBatchContainer( txnCntr, "name", "assocName", "roleB", roleA );
// If roleA object already existed then pre-populate the container.
QueryResult qr = ???.navigate();
roleBContainer.populate( qr );
// Create a role B object.
RoleBType roleB = RoleBType.newRoleBType();
// Assert the existence of the new roleB object.
mainContainer.add( roleB );
// Capture in container.
roleBContainer.add( roleB );
// Make the assertions permanent.
if ( txnCntr.setTransactionResults( ??????.manager.submitTransaction( txnCntr ) ) )
{
// Loop through for bad assertions.
Enumeration enum = txnCntr.getAssertions();
while ( enum.hasMoreElements() ) {
Assertion nextAssertion = (Assertion) enum.nextElement();
if ( assertion.getException() != null )
// do something...
} // whild
} // if
Supported API: true
Extendable: false
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddBatchContainer(String name, BatchContainer batchContainer) Operation addBatchContainer is used to associate a BatchContainer with the transaction.booleanclearAll()Operation clearAll clears each associated BatchContainer and the list of Assertions.Operation getAssertions returns the Assertions for the transaction.Return the set of assertion targets.getBatchContainer(String name) Operation getBatchContainer returns the BatchContainer for the specified name.Operation getBatchContainerNames returns the BatchContainer name keys.Operation getBatchContainers returns all batch containers associated with the transaction.booleansetTransactionResults(TransactionResult[] results) Operation setTransactionResults is used to record the results of submitting the assertions to a server.
-
Method Details
-
addBatchContainer
Operation addBatchContainer is used to associate a BatchContainer with the transaction. To distinquish one BatchContainer from another the association is qualified by a name key. False is returned if no change to the TransactionContainer occurred, i.e. the BatchContainer was already contained.
Supported API: true- Parameters:
name-batchContainer-- Returns:
- boolean
-
getBatchContainers
Enumeration getBatchContainers()Operation getBatchContainers returns all batch containers associated with the transaction.
Supported API: true- Returns:
- Enumeration
-
getBatchContainerNames
Enumeration getBatchContainerNames()Operation getBatchContainerNames returns the BatchContainer name keys.
Supported API: true- Returns:
- Enumeration
-
getBatchContainer
Operation getBatchContainer returns the BatchContainer for the specified name.
Supported API: true- Parameters:
name-- Returns:
- BatchContainer
-
getAssertions
Enumeration getAssertions()Operation getAssertions returns the Assertions for the transaction. The enumeration is in time ordered sequence.
Supported API: true- Returns:
- Enumeration
-
setTransactionResults
Operation setTransactionResults is used to record the results of submitting the assertions to a server. If any exceptions are detected the server returnes an array of TransactionResult obejcts which indicate which Assertion failed and the associated WTException. This operation loops over the results array and attaches the exceptions to the appropriate assertion.
Supported API: true- Parameters:
results-- Returns:
- boolean
-
clearAll
boolean clearAll()Operation clearAll clears each associated BatchContainer and the list of Assertions.
Supported API: true- Returns:
- boolean
-
getAssertionTargets
Enumeration getAssertionTargets()Return the set of assertion targets. Targets of multiple assertions will not be replicated.
Supported API: true- Returns:
- Enumeration
-