Composition of business rules
It is the « business rules » that determine the behavior of the simulator. They are triggered when the context changes.
A change of context always results in the acquisition or modification of data.
G6k inquiries about the context change by reverting the conditions associated with the rules when the value of a data changes.
Thus, when the user enters a value, g6K accesses a reference data or a value is calculated, the impacted rules are evaluated and the associated actions are executed if necessary.
The actions that can be carried out are:
A business rule has the following syntax:
<business rule>: When ...<condition>[then do ...<action>...<action>][else do ...<action> ... <action>]
<condition>
<condition>: <simple condition> | <composite condition> <simple condition>: <operand><operator>[(<value> | <expression>)] <composite condition>: <connector> <condition> ... <condition>
<operator>
<operator>:contains | corresponds to | does not corresponds to | is after | is before | is equal to | is greater than | is greater than or equal to | is less than | is less than or equal to | is not after | is not before | is not equal to | is not present | is present | is true | matches | not contains
<connector>
<connector>: All | Any | None
<action>
<action>: (notify Error | notify Warning)<message>onthe data<data> ou <action>: (notify Error | notify Warning)<message>onthe dataset ou <action>: (notify Error | notify Warning)<message>onthe datagroup<datagroup> ou <action>: (Hide | Show) the step<step> ou <action>: (Hide | Show) the panel of step<step>whose label is<panel> ou <action>: (Hide | Show) the fieldset of step<step>of panel<panel>whose label is<fieldset> ou <action>: (Hide | Show) the field of step<step>of panel<panel>of fieldset<fieldset>whose label is<field> ou <action>: (Hide | Show) the column of step<step>of panel<panel>of fieldset<fieldset>whose label is<column> ou <action>: (Hide | Show) the fieldrow of step<step>of panel<panel>of fieldset<fieldset>whose label is<fieldrow> ou <action>: (Hide | Show) the blockinfo of step<step>of panel<panel>whose label is<blockinfo> ou <action>: (Hide | Show) the chapter of step<step>of panel<panel>of blockinfo<blockinfo>whose label is<chapter> ou <action>: (Hide | Show) the section of step<step>of panel<panel>of blockinfo<blockinfo>of chapter<chapter>whose label is<section> ou <action>: (Hide | Show) the actionbutton of step<step>whose label is<actionbutton> ou <action>: (Hide | Show) the footnote of step<step>whose label is<footnote> ou <action>: (Hide | Show) the choice of data<data>whose label is<choice>
Evaluating a rule consists to evaluate the condition of the rule. The result of the evaluation has three states: « true », « false » or « undefined ».
If the state is « true » then the then do ... actions are executed.
If the state is « false » then the else do ... actions are executed.
If the state is « undefined » then no action is executed.
The evaluation returns « undefined » if at least one of the operands contains no value.
The G6K interface for entering or modifying a rule is as follows:
To access it, click on the « Simulators » button on the menu bar:
Then select the simulator from the left side menu.
To enter a new rule, click the « Add » button in the « Business rules » panel:
To edit a rule, unfold the « Business rules » panel and click the « Edit » button in the title bar of the rule you want to modify:
The form for entering a rule consists of 4 blocks:
Attributes:
The name and label appear in the title bar of the rule panel to allow you to locate it when the panel is folded. Give an explicit label to the rule.
In the condition entry block, there is the line:
Click on the underlined word to select the connector:
The connector allows you to enter a "compound condition" by combining the "simple conditions" that you enter directly below the connector. The conditions are presented by levels. The connector introduces a level of conditions. One level is materialized by a shrinkage from the connector.
Connector | Description |
---|---|
All | All line conditions of the next lower level must be true (this is the equivalent of AND) |
Any | At least one of the conditions of the lines of the next lower level must be true (this is the equivalent of OR) |
None | None of the conditions of the lines of the next lower level must be true |
For example:
All the following conditions are met: simple condition A Any of the following conditions is satisfied: simple condition B simple condition C
translates the boolean expression: simple condition A AND (simple condition B OR simple condition C)
simple condition A is level 1, simple condition B and simple condition C are level 2.
Click to add a compound condition by entering a subcondition level under that connector.
The line below is displayed below the connector with an indent indicated by the arrow:
or
Click to the right of the connector to add a simple condition of that connector's level.
The following line is displayed below the connector with an indent:
As seen at the beginning of this document, a simple condition has the following syntax:
<simple condition>: <operand><operator>[(<value> | <expression>)]
Click on the first underlined item in the condition, a drop-down list appears:
The items in this list are composed from the data you defined in the « Datas » panel.
Click on the second underlined item in the condition, a drop-down list appears:
The items of this list of operators depend on the data type of the operand. These operators are described below:
Operator | Description |
---|---|
is present | The evaluation returns "true" if the data associated with the operand contains a value, "false" otherwise. |
is not present | The evaluation returns "true" if the data associated with the operand contains no value, "false" otherwise. |
is equal to | The evaluation returns "true" if the value of the data associated with the operand is equal to the value of the result of the evaluation of the expression, "false" otherwise. |
is not equal to | The evaluation returns "true" if the value of the data associated with the operand is different from the value of the result of the evaluation of the expression, "false" otherwise. |
contains | Applies only to list operands: The evaluation returns "true" if the value of the 'list' type data associated with the operand contains the value of the result of the evaluation of the expression , "false" otherwise. |
does not contain | Applies only to list operands: The evaluation returns "true" if the value of the list data associated with the operand does not contain the value of the result of the evaluation of the list expression, "false" otherwise. |
Operator | Description |
---|---|
is present | The evaluation returns "true" if the data associated with the operand contains a value, "false" otherwise. |
is not present | The evaluation returns "true" if the data associated with the operand contains no value, "false" otherwise. |
is equal to | The evaluation returns "true" if the value of the data associated with the operand is equal to the value of the result of the evaluation of the expression, "false" otherwise. |
is not equal to | The evaluation returns "true" if the value of the data associated with the operand is different from the value of the result of the evaluation of the expression, "false" otherwise. |
is greater than | The evaluation returns "true" if the value of the data associated with the operand is greater than the value of the result of the evaluation of the expression, "false" otherwise. | |
is greater than or equal to | The evaluation returns "true" if the value of the data associated with the operand is greater than or equal to the value of the evaluation result of the expression, "false" otherwise. |
is less than | The evaluation returns "true" if the value of the data associated with the operand is less than the value of the result of the evaluation of the expression, "false" otherwise. |
is less than or equal to | The evaluation returns "true" if the value of the data associated with the operand is less than or equal to the value of the result of the evaluation of the expression, "false" otherwise. |
contains | Applies only to list operands: The evaluation returns "true" if the value of the 'list' type data associated with the operand contains the value of the result of the evaluation of the expression , "False" otherwise. |
does not contain | Applies only to list operands: The evaluation returns "true" if the value of the list data associated with the operand does not contain the value of the result of the evaluation of the list expression, "false" otherwise. |
Operator | Description |
---|---|
is present | The evaluation returns "true" if the data associated with the operand contains a value, "false" otherwise. |
is not present | The evaluation returns "true" if the data associated with the operand contains no value, "false" otherwise. |
corresponds to | The evaluation returns "true" if the value of the date associated with the operand is equal to the value of the evaluation result of the expression, "false" otherwise. |
does not corresponds to | The evaluation returns "true" if the value of the date associated with the operand is different from the value of the result of the evaluation of the expression, "false" otherwise. |
is after | The evaluation returns "true" if the value of the date associated with the operand is later than the value of the result of the evaluation of the expression, "false" otherwise. |
is not before | The evaluation returns "true" if the value of the date associated with the operand is not prior to the value of the result of the evaluation of the expression, "false" otherwise. |
is before | The evaluation returns "true" if the value of the date associated with the operand is prior to the value of the result of the evaluation of the expression, "false" otherwise. |
is not after | The evaluation returns "true" if the value of the date associated with the operand is not later than the value of the result of the evaluation of the expression, "false" otherwise. |
Operator | Description |
---|---|
is present | The evaluation returns "true" if the data associated with the operand contains a value, "false" otherwise. |
is not present | The evaluation returns "true" if the data associated with the operand contains no value, "false" otherwise. |
is equal to | The evaluation returns "true" if the value of the data associated with the operand is equal to the value of the result of the evaluation of the expression, "false" otherwise. |
is not equal to | The evaluation returns "true" if the value of the data associated with the operand is different from the value of the result of the evaluation of the expression, "false" otherwise. |
Operator | Description |
---|---|
is present | The evaluation returns "true" if the data associated with the operand contains a value, "false" otherwise. |
is not present | The evaluation returns "true" if the data associated with the operand contains no value, "false" otherwise. |
is true | The evaluation returns "true" if the value of the data associated with the operand is equal to 'true', 'false' otherwise. |
is false | The evaluation returns "true" if the value of the data associated with the operand is equal to 'false', 'false' otherwise. |
The operators « is present », « is not present », « is true » and « is false » are unary operators, that is, they operate only on the operand. There is no expression on their right.
The other operators are binary operators.
If the selected operator is a binary operator, a list box appears after the operator.
If the operand is of the "choice" type, the list box displayed is a list of possible values of the operand.
Otherwise the list box allows you to compose an expression:
See Composition of expressions for how to enter an expression.
To remove a single or compound condition, click the button to the right of the condition.
You can enter an action either in the "then do ..." block if you want it to be executed when the result of the condition evaluation returns 'true' or in the 'else do ...' block in the case 'false'.
You can add more than one action in each block of the same rule.
Click on the button of one of these two blocks, the following line is displayed:
Click on « Choose an action ... » to open the list of possible actions:
Action | Description |
---|---|
notify Error | Allows you to define an error message associated with a data, a data group or all the data |
notify Warning | Defines a warning message associated with a data item, data group, or all data. Unlike the error message, the warning message does not block the progress of the simulation |
Hide | Allows to hide an element of the simulation form |
Show | Allows you to show (display) an element of the simulation form |
Set | Allows to assign a value or the result of the evaluation of an expression to the content of a data item or to its default value, its minimum or maximum value, or to define the field of a data source feeding the data. |
Unset | Deletes the contents of a data item. The data becomes "not filled". |
These actions are detailed below:
Choose « notify Error » or « notify Warning » in the action list.
The line completes to allow you to enter the message as well as its target:
Click "click to enter the message", the input field appears.
Enter the message and validate by clicking on « Ok ».
Click « click to select ... », to choose the target.
Target | Description |
---|---|
the data | The message concerns a particular data, the message is displayed below the input field |
the dataset | The message concerns all the simulation form (eg inconsistency of entered data), the message appears below the form. |
the datagroup | The message concerns a group of data, the message is displayed below the group. |
If the target is a data or a data group, the data (or group) must be selected from the list that appears:
Note: For data values resulting from user input, it is not necessary to define an error message in the following cases:
These cases are processed automatically by G6K or the browser.
These two actions are used to manage the display of the form elements of a simulation step.
Choose « Hide » or « Show » in the list of actions, the list of items is displayed:
Once the form element is selected, the row completes to select the 'container' elements of the item to be hidden or shown.
For example, if you choose to hide a field, you must successively select the step, the panel, the group of fields that contains this field.
The table below shows the hierarchy of the containers according to the chosen element:
Form element | containers |
---|---|
the step | none |
the panel | step |
the blockinfo | step / panel |
the chapter | step / panel / blockinfo |
the section | step / panel / blockinfo / chapter |
the fieldset | step / panel |
the column | step / panel / fieldset |
the fieldrow | step / panel / fieldset |
the field (1) | step / panel / fieldset [ / fieldrow ] |
the actionbutton | step |
the footnote | step |
the choice (2) | list of choices of data of type 'choice' |
(1) the row is to be specified only if the field is contained in an array.
(2) makes it possible to show/hide a list element when the data item is of the 'choice' type
Examples of actions to show form elements
Choose « Set » or « Unset » in the list of actions, the list of attributes is displayed:
Attribute | Description |
---|---|
the content | Contains the value assigned to the data |
the default | Contains the value to be taken into account when the "value" attribute is not filled. |
the minimum | Contains the minimum value that can be assigned to the data. |
the maximum | Contains the maximum value that can be assigned to the data. |
the result index | Contains the name of a data source query field when the data is powered by this source. |
the explanation | Contains an explanation of how the data is calculated |
The « Set » action can be used to assign a value to one of these attributes, the « Unset » action can be used to erase (clear) the contents.
Once the attribute is chosen, the line completes as follows:
Click "click to select ..." to display the list of data:
Choose the data for which you want to change the attribute value.
If the action is « Unset », the entry of the action is completed.
If this is the « Set » action, you can now choose the value or compose the expression to assign to the attribute:
Refer to the Composition of expressions page for how to enter the expression.
Example of action assigning the result of a calculation to a data
To delete an action, click the button to the left of the action.
To modify a rule, click on the « Edit » button of the title bar of the rule to be modified:
The editing form for a rule is the same as the rule entry form, so refer to Entering a rule in this document.
To delete a rule, expand the « Business rules » panel and click the « Delete » button on the title bar of the rule you want to delete:
Then confirm the deletion:
To reorder the rules, unfold the "Business Rules" panel, click the title bar of the rule you want to move and hold down the left mouse button (the cursor appears), drag the rule to the desired location.