Skip to main content
Pentaho Documentation

TransactionScope

pentaho.type.changes.TransactionScope

The TransactionScope class manages a transaction.

Extends

Constructor

Name Description
new TransactionScope(context, transaction)

Creates a TransactionScope.

Members

Name Description
canCommit : boolean

Gets a value that indicates if this scope can commit the ambient transaction.

context : pentaho.type.Context

Gets the associated context.

isCurrent : boolean

Gets a value that indicates if this scope is the current scope of its context.

isInside : boolean

Gets a value that indicates if this scope has not been exited.

isRoot : boolean

Indicates if this scope is the ambient transaction's root/outermost scope.

transaction : pentaho.type.changes.Transaction

Gets the associated transaction, if any, or null.

Methods

Name Description
_assertInsideAndCurrent()
 
Protected

Throws an error if the scope has been exited from or is not the current scope.

accept() : pentaho.type.changes.AbstractTransactionScope

Accepts the scope.

acceptWill() : pentaho.lang.ActionResult

Previews the result of committing the transaction by performing its will phase.

dispose()

Exits the scope, without any warnings in case it is not inside or is not the current scope.

exit(keyArgs) : pentaho.type.changes.AbstractTransactionScope

Exits the scope.

reject(reason)

Rejects the associated transaction, exits the scope and throws an error containing the provided rejected reason.

using(fun, ctx) : any

Calls a given function within the scope and safely rejects the scope in the case where an error occurs and exits the scope otherwise.

Constructor Details

new TransactionScope(context, transaction)

Creates a TransactionScope.

Source: javascript/web/pentaho/type/changes/TransactionScope.js, line 24

Parameters:
Name Default Value Summary
context : pentaho.type.Context

The associated context.

transaction : pentaho.type.changes.Transaction

The associated transaction.

Members Details

canCommit: boolean

Gets a value that indicates if this scope can commit the ambient transaction.

A scope can commit its transaction if:

  1. it is the root and current scope of the context
  2. the transaction is in the proposed state.

Source: javascript/web/pentaho/type/changes/TransactionScope.js, line 51

context: pentaho.type.Context

Gets the associated context.

Source: javascript/web/pentaho/type/changes/AbstractTransactionScope.js, line 51

Inherited From: pentaho.type.changes.AbstractTransactionScope#context

isCurrent: boolean

Gets a value that indicates if this scope is the current scope of its context.

A context's current scope is its innermost scope.

Source: javascript/web/pentaho/type/changes/AbstractTransactionScope.js, line 148

Inherited From: pentaho.type.changes.AbstractTransactionScope#isCurrent

isInside: boolean

Gets a value that indicates if this scope has not been exited.

Source: javascript/web/pentaho/type/changes/AbstractTransactionScope.js, line 136

Inherited From: pentaho.type.changes.AbstractTransactionScope#isInside

isRoot: boolean

Indicates if this scope is the ambient transaction's root/outermost scope.

Source: javascript/web/pentaho/type/changes/AbstractTransactionScope.js, line 71

transaction: pentaho.type.changes.Transaction

Gets the associated transaction, if any, or null.

Source: javascript/web/pentaho/type/changes/AbstractTransactionScope.js, line 61

Inherited From: pentaho.type.changes.AbstractTransactionScope#transaction

Methods Details

_assertInsideAndCurrent()
 
Protected

Throws an error if the scope has been exited from or is not the current scope.

Source: javascript/web/pentaho/type/changes/AbstractTransactionScope.js, line 103

Inherited From: pentaho.type.changes.AbstractTransactionScope#_assertInsideAndCurrent

Throws:
Name Description
pentaho.lang.OperationInvalidError

When the scope has been exited from or it is not the current scope of its context.

accept() : pentaho.type.changes.AbstractTransactionScope

Accepts the scope.

When the scope can commit its transaction, as determined by canCommit, accepting the scope attempts to commit its transaction and exits from the scope. If committing the transaction fails, the rejection error is thrown.

Otherwise, if the scope cannot commit its transaction, accepting the scope simply exits from it.

Source: javascript/web/pentaho/type/changes/TransactionScope.js, line 95

Returns:
Name Description
pentaho.type.changes.AbstractTransactionScope

This scope.

Throws:
Name Description
pentaho.lang.OperationInvalidError

When the transaction scope has already been exited.

pentaho.lang.OperationInvalidError

When the transaction scope is not the current scope.

Error

When attempting to commit the transaction fails.

acceptWill() : pentaho.lang.ActionResult

Previews the result of committing the transaction by performing its will phase.

Call this method to determine if an operation would be valid when there's no a priori intention of committing it, in case it is valid. If the previewing returns a fulfilled result, the transaction can still be committed later, if desired.

In any case, no more changes can be performed in this transaction, after acceptWill has been called; the transaction becomes read-only.

Source: javascript/web/pentaho/type/changes/TransactionScope.js, line 73

Returns:
Name Description
pentaho.lang.ActionResult

The commit result, if the transaction was committed; null, otherwise.

Throws:
Name Description
pentaho.lang.OperationInvalidError

When the transaction scope has already been exited from.

pentaho.lang.OperationInvalidError

When the transaction scope is not the current scope. Can only accept the current scope of the transaction.

dispose()

Exits the scope, without any warnings in case it is not inside or is not the current scope.

This method is equivalent to calling exit with keyArgs.sloppy with value true.

Source: javascript/web/pentaho/type/changes/AbstractTransactionScope.js, line 238

Inherited From: pentaho.type.changes.AbstractTransactionScope#dispose

exit(keyArgs) : pentaho.type.changes.AbstractTransactionScope

Exits the scope.

After this operation, the scope cannot be operated on anymore. However, properties like context and transaction remain available for reading.

If this method is called and the the scope has already been exited from, or is not the current scope, a warning is logged, unless keyArgs.sloppy is true.

Source: javascript/web/pentaho/type/changes/AbstractTransactionScope.js, line 194

Inherited From: pentaho.type.changes.AbstractTransactionScope#exit

Parameters:
Name Default Value Summary
keyArgs : Object
 
Optional

The keyword arguments.

Parameters:
Name Default Value Summary
sloppy : boolean
 
Optional

Indicates that no warning should be logged if this method is called when the scope has already been exited from or is not the current scope.

Returns:
Name Description
pentaho.type.changes.AbstractTransactionScope

This scope.

reject(reason)

Rejects the associated transaction, exits the scope and throws an error containing the provided rejected reason.

Source: javascript/web/pentaho/type/changes/TransactionScope.js, line 118

Parameters:
Name Default Value Summary
reason : string | Error | pentaho.lang.UserError
 
Optional
"canceled"

The reason for rejecting the transaction.

Throws:
Name Description
pentaho.lang.OperationInvalidError

When not sloppy and the transaction scope has already been exited from.

pentaho.lang.OperationInvalidError

When not sloppy and the transaction scope is not the current scope.

Error

The rejection error.

using(fun, ctx) : any

Calls a given function within the scope and safely rejects the scope in the case where an error occurs and exits the scope otherwise.

If the transaction has been rejected somehow, its rejection error is thrown back to the caller.

In any case, the scope will have been exited from when this method returns.

Source: javascript/web/pentaho/type/changes/TransactionScope.js, line 144

Overrides: pentaho.type.changes.AbstractTransactionScope#using

Parameters:
Name Default Value Summary
fun : function

The function to call within the scope. The function is called with the this context specified in argument ctx. The return value of fun is returned back from this method.

ctx : Object
 
Optional

The this context in which to call fun. When unspecified, the function will have a null this.

Returns:
Name Description
any

The value returned by fun.

Throws:
Name Description
Error

When the transaction is rejected, the rejection error.