The definition of Business Rules associated to a given cube consists in determining which the situations you wish to control are, defining an appropriate view along with the conditions that will be evaluated each time these are checked and actions you wish to be taken.
This section details the necessary steps to define a Business Rule. The definition is carried out from O3 Browser.
Steps to follow to define business rules:
- Find a view containing the data you wish the business rule to control.
- Select the "New Rule" option from the "New" entry in the "File" menu to view the Rule definition
- Select the General Pane and enter a name and description for the new rule.
- Select the Control pane to indicate the elements for which the conditions that define the rule wish to be controlled. The content of this pane corresponds to dimensions, measures and calculated expressions from the view in point 1. (See Defining the values for which the conditions of the rule are evaluated)
- Select the Conditions Pane to specify the conditions that must be evaluated. Besides, this is the pane where actions associated to the business rule are defined, a rule that will be executed when values for which the condition is not fulfilled exist. The section "Defining Rule Conditions" details that definition.
- Press the "Apply" button to confirm the definitions made without closing the definition dialogue box.
- Use the "Save" button. (See Saving Rules) to save the rule and go back to the O3 Browser desktop.
The following picture shows a sample view to define rules. Please note that the view contains embedded dimensions in the rows.
Picture 1: Sample view for rule definition.
Defining the values for which the conditions of the rule are evaluated
In the 'Verify' pane dimensions, measures and calculated expressions associated to the view are displayed with their corresponding elements.
In the example of the view presented in the previous picture, there are three dimensions: Date (in columns), Products and Customers (in rows).
Elements in each dimension are presented in the corresponding sections of the pane. The set of elements for which the business rule has to be evaluated have to be indicated in this pane.
More than one element can be selected, by pressing the "control" key while you select them with the left button of the mouse.
No selected elements means the evaluation applies to all elements.
Picture 2: Tab to choose values to check in a rule, showing the sections corresponding to each dimension of the view.
Defining Rule Conditions
The conditions to be evaluated for the elements in the view selected in the Verify' pane seen before are defined in the corresponding pane of the Conditions tab. If these conditions are complied with or not, results in the generation of the corresponding actions associated to the business rules.
Conditions are defined by means of simple or compound logical expressions. Simple expressions let you compose several compound expressions by using the AND and/or OR logical operators.
Besides, different conditions can be defined for the same rule, and different actions can be associated to each of them.
Actions that you wish to be executed for values that do not comply with the defined business rule are also defined in the Conditions Pane. Not associating an action to any given rule results in the elements not complying the set conditions being colored red by default.
Picture 3: Conditions of the Rule definition dialogue box.
The following table describes the elements displayed in the 'Conditions' pane.
Conditions |
This list contains the conditions defined in the Rule. It lets you select a previously defined one, to be viewed, modified or deleted. |
New |
It lets you add a new condition to the definition of the rule. |
Delete |
It deletes a condition from the list. |
Name |
It defines the name of the condition |
Description |
It associates a description to the condition. |
The condition describes... |
It states whether the rule triggers actions for values complying with the condition, or if on the contrary, actions are triggered for values that do not comply with it. |
|
It lets you add expressions to the condition. If there is more than one expression associated to the condition, it is necessary to define a logical operator composing those expressions. The picture above shows an example in which the condition consists of two sub-expressions CELL > 600 y CELL < 1000, linked by the logical operator AND (&&). Please note that you may also write expressions between brackets if you choose the columns corresponding to the brackets. |
|
Delete the selected expression |
|
Open Action: It associates an existing action to the current condition. |
|
New Action: It defines a new action and associates it to the current condition. |
Save |
It saves the definition of the rule. When the rule is saved in the server it is checked when the cube is built. |
Apply |
It applies the changes made in the definition of the condition. Changes are viewed in the current view. This option does not make modifications permanent. |
Cancel |
It Cancels rule definition. |
To define the conditions of a rule the following steps must be taken:
- Go to the Conditions Pane.
- Add a new condition, pressing the "New" button, or selecting a condition from the list. In case of defining a new condition, a name must be associated.
- Define the comparison operator for the current condition. The left term of this operator corresponds to the elements selected in the 'Verify' tab. The term on the right is an expression whose definition is detailed in the following point. Available comparison operators are: different from, more than, more than or equal to, less than, less than or equal to, between and differs in.
- Define the expression to which you wish to compare the different elements selected in the Control tab. Expressions are defined in a specific language. The expressions editor is displayed when clicking on the right end of the "Expression" field, where the three dots (...) are shown.
- If you wish to define a compound expression, you must add new expressions for the same condition and define the logical operator that connects them. If you wish to use expressions between brackets, you must tick the corresponding checkbox at the beginning and end of each sub expression.
As indicated in step 4, expressions are defined using Ideasoft O3 language of expressions, which is also used in the definition of virtual fields in the O3 Studio component and in the user-defined expressions in O3 Browser.
In this way, it is possible to define expressions for the evaluation of the business rule by referring to columns and/or rows in the view.
For instance, if you wish to define a condition to compare sales in 2004 to those in 2003 (see Picture 1: Sample view for rule definition. ), so that those values in 2004 that are not 25% above the values in 2003 will be colored red, to indicate they do not comply with the business rule, follow these steps:
- In the Verify tab, indicate that the element 2004 is the one to be used to evaluate the conditions of the rule.
- Select the "more than or equal to" operator.
- Define the expression that states the values to which you wish the year 2004 to be compared. This expression must represent the values obtained for 2003. According to the known language of expressions for O3 Browser, such expression is [o3man:"2003"] * 1.25.
- Apply changes and save the rule with the corresponding button.
Defining several conditions for the same rule
A user may define a rule with different warning levels. For instance if sales in 2004 are not 25% above those in 2003, cells must be colored yellow, to indicate a worrying situation. But if sales are no more than 15% above those in 2003, then the situation is serious, and those cells must be colored red. To represent this situation, two different conditions must be defined from the moment the actions (in this case coloring) form the definition of the condition.
Order of the conditions
Conditions defined for the same rule are evaluated in the order they appear in the list of conditions.
In the example given above, we define the following conditions:
A: if sales are not 25% above those of 2003, we color yellow
B: if sales are not 15% above those of 2003, we color red.
As the elements that make condition B fail are contained in condition A, the order in which they are defined is important. In this example, condition B must be defined first.
Defining actions
Actions let users define how the system will warn them about unwanted conditions of business rules.
The following types of actions can be defined:
- Definition of a particular format for values that do not comply with the rule
- Sending of an e-mail message
- Sending of an SMS message
- Launching of a process predefined with O3 Process.
- Launching of a specific process in O3 Process.
The different types of actions can be combined at the time of associating an action to any given condition. This means we may associate more than one action to a given condition. The action of coloring those values that do not comply with the rule in red is associated to every condition by default.
Actions connected to sending an e-mail message, an SMS message or the launching of process, need both the rule and the defined action to be stored remotely in O3 OLAP Service.
When is rule compliance controlled?
The control over business rules compliance is performed during cube updating. That is when there are new data in the cube that may change the evaluation of the conditions of the rules.
In order to facilitate the development process, it is also possible to force rule evaluation when O3 OLAP Service is reset. You may enable/disable this possibility in the O3 Server Administrator component.
Once the conditions have been evaluated, the corresponding actions are executed.
Actions that apply a specific format to color values that do not comply with the set conditions can also be applied as the result of "Execute Rule" option (See Viewing Rule Compliance).
To associate an existing action to the condition you need to:
- Use the "Open Action" button to open the dialogue box that lets you choose an existing action.
- Choose the action you wish to associate. You may associate a local action (local files) or an action saved in the server (remote files).
- Click "OK" to close the dialogue box and finish the association of the action.
- Save the rule to make changes permanent.
To create an action and associate it to the condition, follow these steps:
- Use the "New Action" button to open the dialogue box that lets you create a new action.
- Enter the name of the action and optionally, its description.
- Select all the different types of action you wish to use in the definition. The example in the picture shows the selection of an action of the type "Highlight formatting"
- Customize the type of action chosen, using the button to open the corresponding editor.
- After indicating the desired customizing, use the "OK" button to save and associate the defined action.
- Save the changes to the rule
Picture 1: Dialogue box to create actions
The following sections describe how to customize the different types of available actions: sending of an e-mail message, sending of an SMS message, and changing the format for values that do not comply with the business rule.
To Customize actions such as "Send e-mail" and "Send SMS" it is at least necessary to define: mail recipient, subject or title, and body of the message.
Examples of this type of actions are provided with product installation.
Customizing the sending of an e-mail message
First of all it is necessary to edit an action of this type. If we assume that some e-mail sending action has been previously defined, it must be edited from the File, Edit, Edit Action menu.
After selecting the desired action in the repository of remote files, the following data must be entered:
- Recipient's e-mail address. More than one address can be entered as a list separated by the character ";" (semicolon)
- E-mail addresses of other recipients to whom you wish to send a copy of the message.
- Subject or title of the message.
- Width and Height of the image included in the message.
- Contents of the e-mail message.
After entering the necessary information, you must click "OK".
Picture 2: Dialogue box to customize the type of action. (e-mail)
Configuring the e-mail sending service
It is necessary to configure the JBoss mail service where OLAP Service is running. To do so, follow these steps:
- Edit the file named mail-service.xml that is within Ideasoft O3 installation, in the following folder <O3>\jboss\server\default\deploy\
- Find the section <configuration> and assign the proper values to the following properties.
- mail.pop3.host -> Name or IP of the POP- mail server mail.smtp.host -> Name or IP of the SMTP mail server
- mail.from -> Mail account that will be used to send the e-mail messages.
- If the server requires authentication, the user must also be entered in the following attributes:
<attributename="User">nobody</attribute> <attribute name="Password">password</attribute>
Example distributed in the Ideasoft O3 installation CD
As mentioned before, a sending of an e-mail message example action is included in the Ideasoft O3 installation CD. Such action is named Mail.action, and can be edited from the File/Edit/Edit Action menu, in the repository of remote files.
The body of the message this action sends when the business rule is evaluated is shown below. Such content is presented in this manual as an example, the user being able to define a different one.
The following pictures show the contents of the received e-mail message:
Picture 3: HTML Contents of the received e-mail message.
Picture 4: Contents of the file attached to the e-mail message received.
When a mail is sent including a spreadsheet, the printout of such an email will not show the background colors by default. Instructions about how to change these settings can be found here.
Contents of the body of the e-mail message
<html>
<head>
$attachments.addJPGAttachments('cubeImages')
<style> $cubeCSS </style>
</head>
<body align='center'>
<h1>Rule Notification</h1>
<h3>Rule: $ruleName</h3>
<h3>Cube: $cubeName</h3>
<br>
#foreach ($html in $cubeHtmls)
$html
<br>
#end
<hr>
#set ($count = 0)
#foreach ($image in $cubeImages)
<img src='cid:cubeImages[o3man:$count]'/>
<br>
#set($count = $count + 1)
#end
<hr>
<!--
$evaluationMessages
-->
</body>
</html>
Customizing the sending of SMS messages
In order to customize this type of action it is necessary to:
- Enter the recipient(s) of the message in the field "SMS Recipient".
- Enter the message in the body of the message.
Customizing the format for the "Indicate through Format" action
This action lets you view the values that do not comply with the rule, by highlighting them in a particular style. The following picture shows the dialogue box that lets you customize format. The dialogue box has two tabs, "Font" and "Alignment"
The Font Tab has elements that let you:
- Choose the font, its size and style.
- Font Color
- Background color.
Please note that in the lower part of the dialogue box an example is shown reflecting the chosen customizing style.
The "Alignment" tab lets you choose:
- Horizontal alignment (left, right, centered)
- Vertical alignment (top, center, bottom)
After you finish customizing the format you must accept changes by Clicking the "OK " button.
Picture 5: Dialogue box to customize Format.
Launching a pre-defined process in O3 Process
This behavior can be modified when associating an action that launches a predefined process in O3 Process.
Saving Rules
After the necessary steps have been taken to define the conditions, actions, scope, etc., of a Business Rule, this definition must be saved. Rules are saved as views with conditions; that is, they describe the position of the cube in which they have been defined and the definition of the rule.
To save a rule associated to a view:
- Use the "Save" or "Save As" button in the Rule definition dialogue box.
- Choose the "Local Files" option to save the rule locally in the file system or choose the "Remote Files" option to save the rule in the server.
- Enter a name for the Rule.
- Press the Save button. The rule is saved and you return to O3 Browser desktop.
It is important to point out that if the rule contains e-mail or SMS message sending actions, or processes, it needs to be saved in the server so that those actions are executed.
Picture 6: Notification of Rule Compliance.
Viewing Rule Compliance
To view the compliance of defined rules, these must be executed. This action will apply the format associated to the rule, highlighting the values that comply (or do not comply, depending on how the rule has been defined) with the corresponding conditions.
It is in order to emphasize that e-mail or SMS sending actions, or processes are only performed when the rule is validated, that is, when the data in the cube are updated or the server is reset.
To execute a rule it is necessary to follow these steps:
- Use the "Execute Rule" option from the "Open" entry in the "File" menu to display the dialogue box that lets you choose the rule.
- Choose the Local Files button if the rule is in the file system, otherwise you will have to choose the Remote Files button.
- Choose the rule you wish to verify to display the corresponding view.
If there are any exceptions, by clicking on the "Show Exceptions" icon, the values that do not comply with the conditions defined for the rule, will be shown according to the style defined for the failing condition.
The status of defined rules is shown on the status bar in the analysis pane. A brief description to the symbols that may appear in this section is given below:
|
Rule without exceptions, that is, all values in the query comply with the defined rule. |
|
Rule with exceptions. It indicates that there are values that do not comply with the defined rule. If you click on the icon, the values that do not comply with the rule will be highlighted according to the associated style determined when defining the rule. Please note that in the picture given as example, the icon changes to indicate we are highlighting those values. Clicking on the icon again the values toggle back to normal. |