Context
pentaho.type. Context
A class that holds configured types.
When a component, like a visualization, is being assembled, it should not necessarily be unaware of the environment where it is going to be used. A context object gathers information that has a global scope, such as the current locale or the current theme, which is likely to have an impact on how a visualization is presented to the user. For instance, the color palette used in a categorical bar chart might be related to the current theme. As such, besides holding contextual, environmental information, a context object should contain the necessary logic to facilitate the configuration of component types using that information. The Pentaho Type API embraces this concept by defining types as type factories that take a context object as their argument.
The instance constructors of types must be obtained from a context object, using one of the provided methods: get
, getAsync
, getAll
, or getAllAsync
so that these are configured before being used. This applies whether an instance constructor is used for creating an instance or to derive a subtype.
A type context holds environmental information in the form of an environment of the JavaScript Pentaho Platform
, which contains relevant information such as: application
, user
, theme
and locale
. Their values determine (or "select") the type configuration rules that apply and are used to configure the constructors provided by the context.
Note that anonymous types cannot be directly configured, as type configuration rules are targeted at specific, identified types.
For information on how to configure the Context
class, see pentaho.type.spec.IContext
.
AMD Module
require(["pentaho/type/Context"], function(Context) { /* code goes here */ });
See also: pentaho.type.spec.IContext
Constructor
Name | Description |
---|---|
new Context(env, config) | Creates a |
Members
Name | Description |
---|---|
environment : | Gets the associated platform environment. |
instances : | Gets the associated instances' container. |
isConfiguring : | Gets a value that indicates that the context is currently loading and, in particular, configuring a type. |
transaction : | Gets the ambient transaction, if any, or |
Methods
Name | Description |
---|---|
createAsync(envSpec) : Promise.<<code>!pentaho.type.Context > Static | Creates a new context with a given environment and returns a promise for it. |
enterChange() : pentaho.type.changes.TransactionScope | Enters a scope of change. |
enterCommitted() : pentaho.type.changes.CommittedScope | Enters a read-committed scope. |
get(typeRef, keyArgs) : Class.<<code>pentaho.type.Instance > | Gets the configured instance constructor of a type. |
getAll(baseTypeId, keyArgs) : Array.<<code>Class.<<code>pentaho.type.Value >> | Gets the configured instance constructors of all of the loaded types that are subtypes of a given base type. |
getAllAsync(baseTypeId, keyArgs) : Promise.<<code>Array.<<code>Class.<<code>pentaho.type.Instance >>> | Gets a promise for the configured instance constructors of all of the types that are subtypes of a given base type. |
getAsync(typeRef, keyArgs) : Promise.<<code>!Class.<<code>pentaho.type.Instance >> | Gets, asynchronously, the configured instance constructor of a type. |
getChangesetsPending(container) : Array.<<code>pentaho.type.changes.Changeset > | Gets any changesets still being delivered through notifications in the commit phase of transactions. |
getDependency(depRef, keyArgs) : Object | Array | pentaho.type.Instance | pentaho.type.Type | Resolves a |
getDependencyApply(depRef, fun, ctx) : any | Resolves a module dependency reference and applies a given function to the array results. |
getDependencyApplyAsync(depRef, fun, ctx) : Promise | Resolves a module dependency reference, asynchronously, and applies a given function to the array results. |
getDependencyAsync(depRef, keyArgs) : Promise.<( | Resolves a |
Constructor Details
new Context(env, config) | |||||||||
---|---|---|---|---|---|---|---|---|---|
Creates a Source: javascript/web/pentaho/type/Context.js, line 359
See also: pentaho.type.spec.IContext |
Members Details
environment: |
---|
Gets the associated platform environment. |
instances: |
---|
Gets the associated instances' container. |
isConfiguring: |
---|
Gets a value that indicates that the context is currently loading and, in particular, configuring a type. Certain changes to types are not safe when performed from configurations. This property allows blocking these changes. |
transaction: |
---|
Gets the ambient transaction, if any, or |
Methods Details
createAsync(envSpec) : Promise.<<code>!pentaho.type.Context > Static | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Creates a new context with a given environment and returns a promise for it. Source: javascript/web/pentaho/type/Context.js, line 1626
|
enterChange() : pentaho.type.changes.TransactionScope | ||||
---|---|---|---|---|
Enters a scope of change. To mark the changes in the scope as error, call its To end the scope of change successfully, dispose the returned transaction scope, by calling its If the scope initiated a transaction, then that transaction is committed. Otherwise, if an ambient transaction already existed when the change scope was created, that transaction is left uncommitted. To end the scope with an error, call its Source: javascript/web/pentaho/type/Context.js, line 1028
|
enterCommitted() : pentaho.type.changes.CommittedScope | ||||
---|---|---|---|---|
Enters a read-committed scope. Within this scope there is no current transaction and reading the properties of instances obtains their committed values. Source: javascript/web/pentaho/type/Context.js, line 1041
|
get(typeRef, keyArgs) : Class.<<code>pentaho.type.Instance > | |||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Gets the configured instance constructor of a type. For more information on the The modules of standard types and mixins are preloaded and can be requested synchronously. These are:
For all of these, the If it is not known whether all non-standard types that are referenced by identifier have already been loaded, the asynchronous method version, Source: javascript/web/pentaho/type/Context.js, line 596
See also: pentaho.type.Context#getAsync |
getAll(baseTypeId, keyArgs) : Array.<<code>Class.<<code>pentaho.type.Value >> | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Gets the configured instance constructors of all of the loaded types that are subtypes of a given base type. This method is a synchronous version of If it is not known whether all known subtypes of Source: javascript/web/pentaho/type/Context.js, line 716
See also: pentaho.type.Context#getAllAsync , pentaho.type.Context#get , pentaho.type.Context#getAsync Example Getting all require(["pentaho/type/Context"], function(Context) { Context.createAsync({application: "data-explorer-101"}) .then(function(context) { var ComponentModels = context.getAll("my/component", {isBrowsable: true}); ComponentModels.forEach(function(ComponentModel) { console.log("will display menu entry for: " + ComponentModel.type.label); }); }); }); |
getAllAsync(baseTypeId, keyArgs) : Promise.<<code>Array.<<code>Class.<<code>pentaho.type.Instance >>> | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Gets a promise for the configured instance constructors of all of the types that are subtypes of a given base type. Any errors that may occur will result in a rejected promise. Source: javascript/web/pentaho/type/Context.js, line 770
See also: pentaho.type.Context#get , pentaho.type.Context#getAsync Example Getting all require(["pentaho/type/Context"], function(Context) { Context.createAsync({application: "data-explorer-101"}) .then(function(context) { return context.getAllAsync("my/component", {isBrowsable: true}) }) .then(function(ComponentModels) { ComponentModels.forEach(function(ComponentModel) { console.log("will display menu entry for: " + ComponentModel.type.label); }); }); }); |
getAsync(typeRef, keyArgs) : Promise.<<code>!Class.<<code>pentaho.type.Instance >> | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Gets, asynchronously, the configured instance constructor of a type. For more information on the This method can be used even if a generic type specification references non-standard types whose modules have not yet been loaded by the AMD module system. Source: javascript/web/pentaho/type/Context.js, line 661
See also: pentaho.type.Context#get Example Getting a configured type instance constructor, asynchronously, for a specific application. require(["pentaho/type/Context"], function(Context) { Context .createAsync({application: "data-explorer-101"}) .then(function(context) { context.getAsync("my/viz/chord").then(function(VizChordModel) { var model = new VizChordModel({outerRadius: 200}); // ... }); }); }); |
getChangesetsPending(container) : Array.<<code>pentaho.type.changes.Changeset > | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Gets any changesets still being delivered through notifications in the commit phase of transactions. If a transaction is started and committed from within the Source: javascript/web/pentaho/type/Context.js, line 1145
|
getDependency(depRef, keyArgs) : Object | Array | pentaho.type.Instance | pentaho.type.Type | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Resolves a Source: javascript/web/pentaho/type/Context.js, line 847
|
getDependencyApply(depRef, fun, ctx) : any | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Resolves a module dependency reference and applies a given function to the array results. This method calls Source: javascript/web/pentaho/type/Context.js, line 964
See also: pentaho.type.Context#getDependency , pentaho.type.Context#getDependencyApplyAsync |
getDependencyApplyAsync(depRef, fun, ctx) : Promise | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Resolves a module dependency reference, asynchronously, and applies a given function to the array results. This method calls Source: javascript/web/pentaho/type/Context.js, line 988
See also: pentaho.type.Context#getDependencyAsync , pentaho.type.Context#getDependencyApply |
getDependencyAsync(depRef, keyArgs) : Promise.<( | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Resolves a Source: javascript/web/pentaho/type/Context.js, line 871
|