Skip to main content
Pentaho Documentation

IService

pentaho.config.IService

The config.IService interface describes a service that manages configurations, usually of types.

The add method is used to register a config.spec.IRuleSet to the service.

The select method selects the rules of added configurations that apply to a given type and context variables, sorts these by specificity, then merges the rules' specifications and returns the result. For more information on the specificity of rules, see config.spec.IRuleSet.

The merged configuration specification can then be used to configure a type or an instance.

Normally, you would not call these operations directly.

Then, the Context class already handles obtaining configurations from its configuration service, and applying these to the requested value types.

The following example illustrates how an implementation of this service would be used:

var myTypeConfig = {
  rules: [
    // Disable a still experimental component.
    {
      select: {
        type: "my.foo.component"
      },
      apply: {
        enabled: false
      }
    },

    // Enable it, only for the dev user, "john", and the "super-app" application.
    {
      select: {
        type:        "my.foo.component",
        user:        "john",
        application: "super-app"
      },
      apply: {
        enabled: true
      }
    }
  ]
};

var configService = new SomeConfigurationService();

configService.add(myTypeConfig);

var mergedConfigSpec = configService.select("my.foo.component", {
     user:        "john",
     application: "not-so-super-app"
   });

// Results in a configuration specification like:
// {
//   enabled: false
// }

Source: doc-js/pentaho/config/IService.jsdoc, line 17

See also:  pentaho.config.spec.IRuleSet

Methods

Name Description
add(config)

Adds a configuration rule set.

select(typeId, context) : Object

Obtains the merged configuration specification of the selection of configuration rules that apply to a given type and context variables.

Methods Details

add(config)

Adds a configuration rule set.

Added configurations overrides previously added configurations, if all other rule-ordering criteria are equal. For more information on the specificity of rules, see config.spec.IRuleSet.

Note that the specified configuration object may be modified to serve the service's internal needs.

Source: doc-js/pentaho/config/IService.jsdoc, line 117

Parameters:
Name Default Value Summary
config : pentaho.config.spec.IRuleSet

A type configuration to add.

select(typeId, context) : Object

Obtains the merged configuration specification of the selection of configuration rules that apply to a given type and context variables.

Source: doc-js/pentaho/config/IService.jsdoc, line 92

Parameters:
Name Default Value Summary
typeId : string

The id of the type whose configuration specification is desired.

context : pentaho.context.IContext
 
Optional

The platform context that is used to select rules.

A Nully variable value is equivalent to a variable that is not present. It matches only configuration rules that do not select that variable.

When the map is unspecified, every variable will appear as though it had been specified with a null value.

Variable values are matched against each value specified by a rule in its selection variables, using JavaScript's strict equality operator, ===.

Returns:
Name Description
Object

The merged configuration specification, if any rule was selected; or null, if no rule was selected.