Execution
pentaho.action Execution
The action.Execution
class represents a certain model of action execution.
This class manages the execution of an action and enforces the multiple phases by which all actions, generically, go through, which are: "init", "will", "do", and "finally".
Synchronous or Asynchronous
The associated action can be synchronous or asynchronous, as determined by the type property, pentaho.action.Base.isSync
. The execution of a synchronous action is completed synchronously. while that of an asynchronous action only completes asynchronously, due to its asynchronous "do" phase.
The execute
method handles the execution of both types of actions. When the associated action is asynchronous
, or it is not know if it is synchronous or asynchronous, after calling execute
, obtain the value of the promise
property and wait for its resolution.
Execution model
The following is a detailed description of the action execution model:
-
When an action execution is constructed, it is in the
unstarted
state.The action's
label
anddescription
properties, and any other property which defines what it ultimately does, can still be freely modified.In this state, the execution cannot be settled by marking it
done
orrejected
. -
When the
execute
method is called, the execution enters the init phase:- the state is set to
init
; - the
_onPhaseInit
method is called.
The action's
label
anddescription
properties, and any other property which defines what it ultimately does, can be freely modified at this stage.The execution can be settled by marking it
rejected
in which case it transits to the finally phase.Otherwise, if the associated action is not
valid
, the execution is automatically rejected with the first reported validation error.Otherwise, the execution automatically transits to the will phase.
- the state is set to
-
In the will phase, what the associated action will do is already determined and cannot change anymore:
- the state is set to
will
; - the associated action is frozen, using
Object.freeze
, and should not be modified anymore (e.g. by modifying nested objects); trying to modify direct properties of the action will throw aTypeError
; - the
_onPhaseWill
method is called.
From this point on, an execution can be canceled based on what exactly the associated action will do.
The execution can be settled by marking it
rejected
, in which case it transits to the finally phase.Otherwise, the execution automatically transits to the do phase.
- the state is set to
-
In the do phase, the execution, proper, is carried out:
- the state is set to
do
; - the
_onPhaseDo
method is called. - if after calling
_onPhaseDo
, the execution is not yet done or rejected, the_doDefault
method is called, allowing the action execution class to clearly handle a default behaviour.
The execution can be settled by marking it
rejected
or, alternatively,done
.In either case, the execution transits to the finally phase.
- the state is set to
-
In the beginning of the finally phase, the execution is considered
settled
, with or without success.If this phase was entered due to a rejection, the execution is in one of the states
canceled
orfailed
, depending on the type of rejection reason,isRejected
istrue
, and anerror
may be available.Otherwise, the execution was successful and it is in the
did
state. PropertyisDone
now returnstrue
and aresult
may be available.The
_onPhaseFinally
method is called.The
finished
state
bit is set to on. PropertyisFinished
now returnstrue
.
AMD Module
require(["pentaho/action/Execution"], function(Execution) { /* code goes here */ });
Extends
Constructor
Name | Description |
---|---|
new Execution() Abstract | Creates an action execution instance for a given action and target. |
Members
Name | Description |
---|---|
__isInside : | Indicates if currently calling any of the methods: |
base : Protected | If a method has been overridden, then the base method provides access to the overridden method. |
Methods
Name | Description |
---|---|
extend(source, keyArgs) : object | Extend an object with the properties of another. |
Constructor Details
new Execution() Abstract |
---|
Creates an action execution instance for a given action and target. Source: javascript/web/pentaho/action/Execution.js, line 182 |
Members Details
__isInside: |
---|
Indicates if currently calling any of the methods: Source: javascript/web/pentaho/action/Execution.js, line 202 Default Value: false See also: pentaho.action.Execution#__callInside |
base: Protected |
---|
If a method has been overridden, then the base method provides access to the overridden method. Can also be called from within a constructor function. Source: javascript/web/pentaho/lang/Base.js, line 299 Inherited From: pentaho.lang.Base#base |
Methods Details
extend(source, keyArgs) : object | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Extend an object with the properties of another. Methods that are overridden are accessible through This object is extended, but its class doesn't change. Source: javascript/web/pentaho/lang/Base.js, line 1040 Inherited From: pentaho.lang.Base#extend
|