IRuleSet
pentaho.config.spec. IRuleSet
The config.spec.IRuleSet
interface describes a list of configuration rules
used to configure one or more types.
The following example is a hypothetical configuration, where a developer (John) states that only he should see the visualization he is currently developing (my/radial/bar) and only then when working in Pentaho Analyzer:
var myTypeConfig = {
rules: [
// Disable a still experimental Viz.
{
select: {
type:"my/radial/bar"},
apply: {
isBrowsable: false
}
},
// Enable it, only for the dev user,"john", when in Analyzer
{
select: {
type:"my/radial/bar",
user:"john",
application:"pentaho.analyzer"},
apply: {
isBrowsable: true
}
}
]
};
Rule Selection
A rule is selected by a given type and environment variables, if the type and variables match the rule's selection variables
.
Rule Specificity
Rule specificity is a measure of the relevance of a rule.
When two or more selected rules configure the same specification attribute, it is the value used by the most specific rule that wins. When configured values are structural and are instead merged, like with an Object
value, specificity determines the order in the merge operation (most specific is merged over less specific).
A rule is more specific than another if it:
- has a greater
priority
; this is the attribute that most affects specificity, and can be used to easily surpass every other affecting factors, - selects a user (and the other doesn't),
- selects a theme (and the other doesn't),
- selects a locale (and the other doesn't),
- selects an application (and the other doesn't),
- belongs to a rule set that was added later, or
- it is at a greater index within a rule set.
Rule's Configuration Merging
Type configuration rules specify a configuration in its apply
property.
When merging two configurations, the default behavior works this way:
- If both configurations contain a plain JavaScript object, in the same property, the two are deeply merged
- All other values, such as arrays,
null
,undefined
or objects of custom classes, are replaced.
To allow overriding the default merge behavior, the following object syntax is supported in the place where any value would be:
{
fruits: {
$op:"add"value: ["banana","apple"]
}
}
In the previous example, the "add" operation is used to append new elements to an existing array configuration value, instead of replacing it, as is the default.
In the following example, the "replace" operation is used to replace an object configuration value, instead of merging it, as is the default:
{
score: {
$op:"replace"value: {"banana": 1,"apple": 3,"orange": 2}
}
}
Note that replacing with a Nully
value effectively clears existing configurations.
Source: doc-js/pentaho/config/spec/IRuleSet.jsdoc, line 17
See also: pentaho.config.IService
Members
Name | Description |
---|---|
contextId : | The context module identifier to which module and dependency identifiers are relative and that determines any applicable AMD/RequireJS module mappings. |
rules : | The list of configuration rules. |
Members Details
contextId: |
---|
The context module identifier to which module and dependency identifiers are relative and that determines any applicable AMD/RequireJS module mappings. When unspecified and the rule set is registered and loaded from a module, this property defaults to that module's identifier. Source: doc-js/pentaho/config/spec/IRuleSet.jsdoc, line 129 See also: pentaho.config.spec.IRule#deps |
rules: |
---|
The list of configuration rules. Within a type configuration, if all other rule ordering criteria are equal, the later configuration rules override the former configuration rules. |