Skip to main content
Hitachi Vantara Lumada and Pentaho Documentation

Target

pentaho.type.action.impl. Target

The Target class is a mixin class that builds upon EventSource to implement the ITarget interface.

It provides a generic action Execution implementation which delegates to the event observers of each of the execution phases.

The event observers have the following signature:

function(event, action) {

  // assert event instanceof pentaho.type.action.Execution;

  // assert action === event.action;
  // assert action instanceof pentaho.type.action.Base;

  // assert this === event.target;
  // assert this instanceof pentaho.type.action.ITarget;
}

The do phase event observer can return a Promise.

AMD Module

require(["pentaho/type/action/impl/Target"], function(Target) { /* code goes here */ });

Extends

Implements

Constructor

Name Description
new Target()
Abstract

This class was not designed to be constructed directly. It was designed to be used as a mixin.

Classes

Name Summary
GenericActionExecution

The GenericActionExecution class is an inner class of Target that assumes that that the execution target is a Target.

Members

Name Description
$isValid :  boolean

Determines if this value is a valid.

$key :  string

Gets the key of the value.

$type :  pentaho.type.Value.Type

Gets the type of this instance.

Methods

Name Description
_configure(config)
Protected

Configures this value with a given distinct and non-Nully configuration.

_createActionExecution(action) : pentaho.type.action.Execution
Protected

Creates an action execution for a given action.

_createGenericActionExecution(action) : pentaho.type.action.Execution
Protected

Creates a generic action execution for a given action.

_emit(event) : pentaho.lang.Event
Protected

Emits an unstructured event and returns it, unless it was canceled.

_emitActionPhaseDoEvent(actionExecution) : Promise
Protected

Emits the do phase event of an action execution.

_emitActionPhaseFinallyEvent(actionExecution)
Protected

Emits the finally phase event of an action execution.

_emitActionPhaseInitEvent(actionExecution)
Protected

Emits the init phase event of an action execution.

_emitActionPhaseWillEvent(actionExecution)
Protected

Emits the will phase event of an action execution.

_emitGeneric(source, eventArgs, type, phase, keyArgs) : boolean
Protected

Emits an event given an arbitrary payload object, its type and phase. Returns the event payload object, unless the event is canceled.

_emitGenericAllAsync(source, eventArgs, type, phase, keyArgs) : Promise.<<code>object>
Protected

Emits an event asynchronously, given an arbitrary payload object, its type and phase, and succeeding if every listener succeeds.

_emitSafe(event) : pentaho.lang.Event
Protected

Variation of the _emit method in which errors thrown by event listeners are caught and logged.

_equals(other) : boolean
Protected

Gets a value that indicates if a given distinct, non-null value of the same type represents the same entity.

_hasListeners(type, phase) : boolean
Protected

Determines if there are any registrations for a given event type and, optionally, phase.

act(action) : pentaho.type.action.Execution

Executes or starts execution of a given action in this target and returns the corresponding action execution instance.

assertValid()

Ensures that the value is valid, and throws the first validation error if it is not.

clone() : pentaho.type.Value
Abstract

Creates a shallow clone of this value.

configure(config)

Configures this value with a given configuration.

equals(other) : boolean

Determines if a given value represents the same entity.

equalsContent(other) : boolean

Gets a value that indicates if a given equal value has the same content as this one.

off(typeOrHandle, observer)

Removes one registration given its handle, or all registrations of a given event type (or types) and observer (or listener function).

on(type, observer, keyArgs) : pentaho.lang.IEventRegistrationHandle

Registers an observer (or listener function) for an event(s) of a given type(s).

toJSON() : UJsonValue

Creates a top-level JSON specification that describes this instance.

toSpec(keyArgs) : pentaho.type.spec.UInstance

Creates a specification that describes this value.

toSpecInContext(keyArgs) : any
Abstract

Creates a specification that describes this instance.

validate() : Array.<<code>pentaho.type.ValidationError>

Determines if this value is valid.

Constructor Details

new Target()
Abstract

This class was not designed to be constructed directly. It was designed to be used as a mixin.

Source: javascript/web/pentaho/type/action/impl/target.js, line 98

Members Details

$isValid:  boolean

Determines if this value is a valid.

This attribute calls validate and returns a boolean value indicating if it returned no errors.

Source: javascript/web/pentaho/type/value.js, line 168

Inherited From: pentaho.type.Value#$isValid

$key:  string

Gets the key of the value.

The key of a value must identify it among values of the same concrete type. Two values of the same concrete type and with the same key represent the same entity.

If two values have the same concrete type and their keys are equal, then it must also be the case that pentaho.type.Value#equals returns true. The opposite should be true as well. If two values of the same concrete type have distinct keys, then it must be the case that pentaho.type.Value#equals returns false.

The default implementation returns the result of calling toString().

Source: javascript/web/pentaho/type/value.js, line 89

Inherited From: pentaho.type.Value#$key

See also: pentaho.type.Value#equals

$type:  pentaho.type.Value.Type

Gets the type of this instance.

Source: javascript/web/pentaho/type/value.js, line 334

Overrides: pentaho.type.Value#$type

Methods Details

_configure(config)
Protected

Configures this value with a given distinct and non-Nully configuration.

This method can only be called when there is an ambient transaction.

The default implementation throws an error if this value's type is read-only.

Source: javascript/web/pentaho/type/value.js, line 264

Inherited From: pentaho.type.Value#_configure

Parameters:
Name Default Value Summary
config : any

The distinct, non-Nully configuration.

Throws:
Name Description
TypeError

When the value would be changed and its type is read-only.

See also: pentaho.type.Value#configure , pentaho.type.Complex#_configure , pentaho.type.List#_configure

_createActionExecution(action) : pentaho.type.action.Execution
Protected

Creates an action execution for a given action.

The default implementation delegates to [_createGenericActionExecution]{pentaho.type.action.impl.Target#_createGenericActionExecution}.

Source: javascript/web/pentaho/type/action/impl/target.js, line 170

Parameters:
Name Default Value Summary
action : pentaho.type.action.Base

The action which will be executed.

Returns:
Name Description
pentaho.type.action.Execution

The action execution.

See also: pentaho.type.action.ITarget#act

_createGenericActionExecution(action) : pentaho.type.action.Execution
Protected

Creates a generic action execution for a given action.

The implementation returns an instance of Target.GenericActionExecution.

Source: javascript/web/pentaho/type/action/impl/target.js, line 186

Parameters:
Name Default Value Summary
action : pentaho.type.action.Base

The action which will be executed.

Returns:
Name Description
pentaho.type.action.Execution

The action execution.

_emit(event) : pentaho.lang.Event
Protected

Emits an unstructured event and returns it, unless it was canceled.

When this method is called, the listeners of existing registrations are notified synchronously, by priority order and then registration order, until either the event is canceled or all of the listeners have been notified.

It is safe to register or unregister to/from an event type while it is being emitted. However, changes are only taken into account in subsequent emissions.

If a listener function throws an error, the event processing is interrupted. No more registrations are processed and the error is passed to the caller.

Source: javascript/web/pentaho/lang/EventSource.js, line 262

Inherited From: pentaho.lang.EventSource#_emit

Parameters:
Name Default Value Summary
event : pentaho.lang.Event

The event object.

Returns:
Name Description
pentaho.lang.Event | null

The given event object or null, when canceled.

See also: pentaho.lang.EventSource#_emitSafe , pentaho.lang.EventSource#_emitGeneric

_emitActionPhaseDoEvent(actionExecution) : Promise
Protected

Emits the do phase event of an action execution.

The default implementation delegates to _emitGenericAllAsync, when the action is asynchronous. Delegates to _emitGeneric, otherwise.

Source: javascript/web/pentaho/type/action/impl/target.js, line 244

Parameters:
Name Default Value Summary
actionExecution : pentaho.type.action.Execution

The action execution.

Returns:
Name Description
Promise | null

A promise to the completion of the asynchronous do listener, of an asynchronous action, or null.

_emitActionPhaseFinallyEvent(actionExecution)
Protected

Emits the finally phase event of an action execution.

The default implementation delegates to _emitGeneric.

Source: javascript/web/pentaho/type/action/impl/target.js, line 268

Parameters:
Name Default Value Summary
actionExecution : pentaho.type.action.Execution

The action execution.

_emitActionPhaseInitEvent(actionExecution)
Protected

Emits the init phase event of an action execution.

The default implementation delegates to _emitGeneric.

Source: javascript/web/pentaho/type/action/impl/target.js, line 202

Parameters:
Name Default Value Summary
actionExecution : pentaho.type.action.Execution

The action execution.

_emitActionPhaseWillEvent(actionExecution)
Protected

Emits the will phase event of an action execution.

The default implementation delegates to _emitGeneric.

Source: javascript/web/pentaho/type/action/impl/target.js, line 220

Parameters:
Name Default Value Summary
actionExecution : pentaho.type.action.Execution

The action execution.

_emitGeneric(source, eventArgs, type, phase, keyArgs) : boolean
Protected

Emits an event given an arbitrary payload object, its type and phase. Returns the event payload object, unless the event is canceled.

Source: javascript/web/pentaho/lang/EventSource.js, line 318

Inherited From: pentaho.lang.EventSource#_emitGeneric

Parameters:
Name Default Value Summary
source : object

The this value of listener functions.

eventArgs : Array

The arguments of listener functions.

type : nonEmptyString

The type of the event.

phase : nonEmptyString
Optional

The phase of the event. For unstructured events don't specify this argument (or specify a Nully value).

keyArgs : Object
Optional

The keyword arguments' object.

Parameters:
Name Default Value Summary
isCanceled : function
Optional

A predicate that indicates if the given event args are in a canceled state. Its this value is the value of source.

errorHandler : function
Optional

When specified with a null value, no error handling is performed and errors thrown by listeners are thrown back to this method's caller. When unspecified or specified as undefined, defaults to a function that simply logs the listener errors, and lets execution continue to the following listeners. The function arguments are: the error, the eventArgs, the event type and the event phase. Its this value is the value of source.

interceptor : function
Optional
null

A function which is called for each event listener function, with the arguments listener, source, eventArgs and the index of the listener.

Returns:
Name Description
boolean

false when the event is canceled; true, otherwise.

_emitGenericAllAsync(source, eventArgs, type, phase, keyArgs) : Promise.<<code>object>
Protected

Emits an event asynchronously, given an arbitrary payload object, its type and phase, and succeeding if every listener succeeds.

Listeners are called in parallel.

Returns a promise that is fulfilled or rejected with the event payload object. If any listener throws or rejects, the returned promise is rejected as well.

Source: javascript/web/pentaho/lang/EventSource.js, line 440

Inherited From: pentaho.lang.EventSource#_emitGenericAllAsync

Parameters:
Name Default Value Summary
source : object

The this value of listener functions.

eventArgs : Array

The arguments of listener functions.

type : nonEmptyString

The type of the event.

phase : nonEmptyString
Optional

The phase of the event. For unstructured events don't specify this argument (or specify a Nully value).

keyArgs : Object
Optional

The keyword arguments' object.

Parameters:
Name Default Value Summary
isCanceled : function
Optional

A predicate that indicates if the given event args are in a canceled state. Its this value is the value of source.

getCancellationReason : function
Optional

A function that given the event args returns its a cancellation reason, usually an Error. Its this value is the value of source.

errorHandler : function
Optional

When specified with a null value, no error handling is performed. Errors thrown by, or promises rejected by, any listeners cause the whole event to be rejected.

When unspecified or specified as undefined, defaults to a function that simply logs any listener errors, yet always succeeding.

The function arguments are: the error, the event, the event type and the event phase.

Returns:
Name Description
Promise.<<code>object>

A promise. When fulfilled, it is with the value undefined. When rejected due to a thrown error, the rejection reason is that error. When explicitly rejected by the error handler, the given rejection reason is preserved. When rejected due to a cancellation, the rejection reason is the cancellation reason, if any.

_emitSafe(event) : pentaho.lang.Event
Protected

Variation of the _emit method in which errors thrown by event listeners are caught and logged.

If an event listener throws an error, the following event listeners are still processed.

Source: javascript/web/pentaho/lang/EventSource.js, line 284

Inherited From: pentaho.lang.EventSource#_emitSafe

Parameters:
Name Default Value Summary
event : pentaho.lang.Event

The event object.

Returns:
Name Description
pentaho.lang.Event | null

The given event object or null, when canceled.

See also: pentaho.lang.EventSource#_emit , pentaho.lang.EventSource#_emitGeneric

_equals(other) : boolean
Protected

Gets a value that indicates if a given distinct, non-null value of the same type represents the same entity.

The default implementation considers two values equal if they have the equal keys.

Source: javascript/web/pentaho/type/value.js, line 135

Inherited From: pentaho.type.Value#_equals

Parameters:
Name Default Value Summary
other : pentaho.type.Value

A distinct value to test for equality.

Returns:
Name Description
boolean

true if the given value is equal to this one; false, otherwise.

See also: pentaho.type.Value#equals , pentaho.type.Value#$key

_hasListeners(type, phase) : boolean
Protected

Determines if there are any registrations for a given event type and, optionally, phase.

This method can be used to avoid creating expensive event objects for an event type and, optionally, phase, that don't have registrations.

Source: javascript/web/pentaho/lang/EventSource.js, line 214

Inherited From: pentaho.lang.EventSource#_hasListeners

Parameters:
Name Default Value Summary
type : nonEmptyString

The type of the event.

phase : nonEmptyString
Optional

The phase of a structured event. For unstructured events don't specify this argument. For structured events, if this argument is not specified, the result will be true if there are any listeners, for any of the phases.

Returns:
Name Description
boolean

true if the event has any listeners for the given event type and phase; false, otherwise.

Examples

if(this._hasListeners("click")) {

 var event = new Event("click", this, true);

 if(this._emit(event)) {
 // ...
 }
}
if(this._hasListeners("select")) {

 var event = new Event("select");

 if(this._emitGeneric(this, [event], "select", "will")) {

 // Select ...

 this._emitGeneric(this, [event], "select", "finally");
 }
}
Implements:
act(action) : pentaho.type.action.Execution

Executes or starts execution of a given action in this target and returns the corresponding action execution instance.

This method can be given synchronous or asynchronous actions. To wait for the result of an asynchronous action, obtain the promise property of the returned action execution instance.

Source: doc-js/pentaho/type/action/ITarget.jsdoc, line 37

Parameters:
Name Default Value Summary
action : pentaho.type.action.Base | pentaho.type.action.spec.IBase

The action or action specification to execute.

Returns:
Name Description
pentaho.type.action.Execution

The resulting action execution.

assertValid()

Ensures that the value is valid, and throws the first validation error if it is not.

This method calls the validate method.

Source: javascript/web/pentaho/type/value.js, line 202

Inherited From: pentaho.type.Value#assertValid

Throws:
Name Description
pentaho.type.ValidationError

When the value is not valid, the first error returned by the validate method.

clone() : pentaho.type.Value
Abstract

Creates a shallow clone of this value.

Source: javascript/web/pentaho/type/value.js, line 93

Inherited From: pentaho.type.Value#clone

Returns:
Name Description
pentaho.type.Value

The value clone.

Implements:
configure(config)

Configures this value with a given configuration.

This method ensures a transaction exists and then delegates to _configure.

For more information on the semantics of configuration, see Complex#_configure and List#_configure.

Source: javascript/web/pentaho/type/value.js, line 232

Inherited From: pentaho.type.Value#configure

Parameters:
Name Default Value Summary
config : any

The value configuration.

Throws:
Name Description
TypeError

When the value would be changed and its type is read-only.

See also: pentaho.type.Element#configureOrCreate , pentaho.type.Complex#_configure , pentaho.type.List#_configure

equals(other) : boolean

Determines if a given value represents the same entity.

This method checks if the given value is identical to this one. Otherwise, if not Nully and has the same constructor, execution is delegated to this value's _equals method.

Source: javascript/web/pentaho/type/value.js, line 116

Inherited From: pentaho.type.Value#equals

Parameters:
Name Default Value Summary
other : pentaho.type.Value

A value to test for equality.

Returns:
Name Description
boolean

true if the given value is equal to this one; or, false, otherwise.

See also: pentaho.type.Value#_equals

equalsContent(other) : boolean

Gets a value that indicates if a given equal value has the same content as this one.

This method must only be called if the equals method returns true.

The default implementation returns false.

Source: javascript/web/pentaho/type/value.js, line 152

Inherited From: pentaho.type.Value#equalsContent

Parameters:
Name Default Value Summary
other : pentaho.type.Value

An equal value to test for content-equality.

Returns:
Name Description
boolean

true if the given value is equal in content to this one; false, otherwise.

See also: pentaho.type.Value#equals

Implements:
off(typeOrHandle, observer)

Removes one registration given its handle, or all registrations of a given event type (or types) and observer (or listener function).

To remove an event registration, it is sufficient to call the dispose method of the registration handle returned by on, upon registration. Alternatively, as a convenience syntax, the registration handle can be passed as the single argument to this method.

It is safe to unregister from an event type while it is being emitted. However, any registrations removed during the current emission will still execute.

Specifying an event registration handle that has already been disposed of has no effect. Specifying an event type and observer (or listener function) that have no registrations has no effect.

Source: doc-js/pentaho/lang/IEventSource.jsdoc, line 131

Inherited From: pentaho.lang.EventSource#off

Parameters:
Name Default Value Summary
typeOrHandle : nonEmptyString | Array.<<code>nonEmptyString> | pentaho.lang.IEventRegistrationHandle

The type or types of events, or an event registration handle to dispose of. When a string, it can be a comma-separated list of event types.

observer : pentaho.lang.IEventObserver | pentaho.lang.EventListener | pentaho.lang.EventListenerAsync

The event observer (or listener function). Required when typeOrHandle is not an event registration handle; ignored, otherwise.

See also: pentaho.lang.IEventSource#on

Implements:
on(type, observer, keyArgs) : pentaho.lang.IEventRegistrationHandle

Registers an observer (or listener function) for an event(s) of a given type(s).

Optionally, a listening priority may be specified to adjust the order by which an observer is notified, relative to other listeners.

Note that if an observer is registered more than once to the same event type, a new registration is created each time and its listeners will be called once per registration.

It is safe to register for an event type while it is being emitted. However, new registrations are only taken into account in subsequent emissions.

When type represents multiple event types, the returned event registration handle is a composite registration for all of the event types.

This method is compatible with the dojo/on API.

Source: doc-js/pentaho/lang/IEventSource.jsdoc, line 90

Inherited From: pentaho.lang.EventSource#on

Parameters:
Name Default Value Summary
type : nonEmptyString | Array.<<code>nonEmptyString>

The type or types of events. When a string, it can be a comma-separated list of event types.

observer : pentaho.lang.IEventObserver | pentaho.lang.EventListener | pentaho.lang.EventListenerAsync

The event observer (or listener function).

keyArgs : object
Optional

Keyword arguments.

Parameters:
Name Default Value Summary
priority : number
Optional
0

The listening priority. Higher priority observers are notified of an event before any lower priority observers. The priority can be set to -Infinity or Infinity. In case two observers are assigned the same priority, the registration order determines which is notified first.

Returns:
Name Description
pentaho.lang.IEventRegistrationHandle

An event registration handle that can be used for later removal.

See also: pentaho.lang.IEventSource#off

toJSON() : UJsonValue

Creates a top-level JSON specification that describes this instance.

Attributes which do not have a JSON-compatible specification are omitted. Specifically, for inline types, attributes with a function value are not supported.

This method simply calls pentaho.type.Instance#toSpec with argument keyArgs.isJson as true and exists for seamless integration with JavaScript's JSON.stringify method.

Source: javascript/web/pentaho/type/instance.js, line 210

Inherited From: pentaho.type.Instance#toJSON

Returns:
Name Description
UJsonValue

A JSON-compatible specification.

See also: pentaho.type.Instance#toSpec

Implements:
toSpec(keyArgs) : pentaho.type.spec.UInstance

Creates a specification that describes this value.

If an ambient specification context, currently exists, it is used to manage the serialization process. Otherwise, one is created and set as current. Then, the actual work is delegated to pentaho.type.Instance#toSpecInContext.

Source: javascript/web/pentaho/type/value.js, line 272

Inherited From: pentaho.type.Value#toSpec

Parameters:
Name Default Value Summary
keyArgs : Object
Optional

The keyword arguments object. Passed to every value and type serialized within this scope.

Please see the documentation of value subclasses for information on additional, supported keyword arguments.

Parameters:
Name Default Value Summary
isJson : boolean
Optional
false

Generates a JSON-compatible specification. Attributes which do not have a JSON-compatible specification are omitted.

declaredType : pentaho.type.Type
Optional

The base type of this value's storage location. If the value does not have this exact type, its inline type property must be included in the specification. Otherwise, it can be omitted. When unspecified, the inline type property is only included if forceType is true.

forceType : boolean
Optional
false

Forces inclusion of the inline type property, _, in the specification.

omitFormatted : boolean
Optional
false

Omits the formatted value on Simple values' specifications.

preferPropertyArray : boolean
Optional
false

Indicates that, if possible, array form is used for Complex values' specifications.

The array form of a complex value cannot be used when its type must be inlined.

includeDefaults : boolean
Optional
false

When true, all of the properties of Complex values are serialized. When false, the default, only properties whose value is different from their default value are serialized.

Only applies to complex values that are serialized in object form. In array form, all of the properties of complex values are serialized independently of their value.

omitProps : Object
Optional

An object whose own property names with a truthy value are the names of the properties of the current complex type to omit from the serialization.

Only applies when a complex is output in object form. In array form, all properties are output whatever their value.

This argument only applies to complex values and is not passed through to the values of their properties.

Returns:
Name Description
pentaho.type.spec.UInstance

A specification of this value.

toSpecInContext(keyArgs) : any
Abstract

Creates a specification that describes this instance.

Source: javascript/web/pentaho/type/instance.js, line 190

Inherited From: pentaho.type.Instance#toSpecInContext

Parameters:
Name Default Value Summary
keyArgs : Object
Optional

The keyword arguments' object. Passed to every instance and type serialized within this scope.

Please see the documentation of subclasses for information on additional, supported keyword arguments.

Returns:
Name Description
any

A specification of this instance.

See also: pentaho.type.Instance#toSpec

validate() : Array.<<code>pentaho.type.ValidationError>

Determines if this value is valid.

The default implementation does nothing and considers the instance valid. Override to implement a type's specific validation logic.

You can use the error utilities in pentaho.type.Util to help in the implementation.

Source: javascript/web/pentaho/type/value.js, line 187

Inherited From: pentaho.type.Value#validate

Returns:
Name Description
Array.<<code>pentaho.type.ValidationError>

A non-empty array of errors or null.

See also: pentaho.type.Value#$isValid