Rule Templates


Related article: Query Types for the Creation of Rule Templates

Jedox 7.0 introduces a new variety of OLAP rules called Rule Templates.

Until version 7.0, all rules were simple strings (called “static rules” from now on). Each required static rule had to be written manually. By contrast, rule templates allow the user to parametrize rules. Based on a selected query, the rule template where these parameters are used is then instantiated by the OLAP Server into several rule instances, in which the parameters are filled. For run-time calculation, only the rule instances are used. The user can update the query-based rule at various points in the life cycle of a database model, such as after the result of the query is modified, or after changing the syntax of the rule template.

Imagine, for example, a rule that has to be defined for each of the twelve base-month elements in a time dimension. Using static rules, the user would have to write the same rule twelve times. But with rule templates, the user only writes one rule template (for example, using the “Dimension element like” query with appropriate parametrization), from which the OLAP Server then generates the twelve rule instances automatically. Also, if the rule syntax changes, the user only has to change the rule template; the change is then propagated to all rule instances.

The use of rule templates (creation and instantiation) requires Supervision Server to be configured in palo.ini (entry for “worker <path>” has to be active with proper path).

Creation of rule templates

Rule templates are created in the new graphical Rule Editor in the Jedox Web Modeler. The first step to creating a rule template is to select a query type. There are several types available, each allowing a different form of instantiation. Each query defines a set of input parameters, which the user can specify. Based on the values for the input parameters, the query is executed.

The result of a query is a recordset, consisting of rows and columns. Each column then represents a potential variable that can be used in a rule definition; each row represents a record that will later be instantiated. Thus, for each returned row, there will be one rule instance generated, replacing the parameters from the rule template definition with the specific values from that row.

In the following example, a rule template is generated to create instance rules for each “Desktop…” element in a Products dimension. To achieve this, the query type “Dimension element like” is used. The query expects two input parameters: a dimension (“Products” in this case), and a RegEx filter pattern, which will be applied to all element names in the dimension. Each matching element is returned as a row in the query’s record set.

The columns represent variables to be used in the rule definition. The variables can also be chosen from the combobox controls in the rule definition section. Variables are defined in the rule definition using the ${varname} decoration.

If you select a row in the query’s returned record set and use the “Replace variables with fields from sample record” option, an example instantiation of the rule template is shown in the rule definition field.

When saving the rule template, the rule instances are automatically generated based on the returned record set. In the list of rules, instances are not shown by default, but can be shown by checking the “Show instance rules” checkbox. The column “Template” then shows the ID of the rule template from which the rule was generated.

Some queries, which can be used in rule templates, return an array, or a list, of elements in a single record (for example “Dimension element like (list)”). To use the variables of these record sets with correct syntax in the rule controls, the “Element list” selector must be used:

Management and update of rule templates

Besides enabling quicker definition of a set of rules, another feature of rule templates is that the rule model can be dynamically updated if the database structure changes. In the example above, the “Products” dimension could be extended with a new type of Desktop product, for which there also should be a rule. In this case, it is enough to update the instance rules. This can be done by right-clicking  a specific cube or a database in the database tree in Modeler and selecting the “Update rule templates” option from the context menu.

Of course, you can also edit the rule template itself, like any other static rule. Upon saving the changes, the rule instances of the template are also updated.

Update of instances via Integrator

After a database is modified in the execution of a Jedox Integrator project (load or job), it may be necessary to update rule instances; for example, if the source dimension for a rule template changes. To update the rule instances, use the Integrator load type “JedoxDatabase“.

Was this post helpful?
NoYes (-2 rating, 6 votes)