May 1, 2024. OpenRules Release 10.3.0 adds an ability to create complex expressions using predefined functions for collections of objects. Now it is also possible to use external JSON files directly to test decision models. As usual, the new release updates 3rd party dependencies and fixes a few bugs.
Functions for Collections of Objects
OpenRules customers use the qualifier “of” to write complex expressions as combinations of two or more individual decision variables. For example, the business concept “Employee” may include decision variables “Name”, “Salary”, “Gender”, etc. Another business concept “Department” may have a decision variable “Manager” of the type “Employee”. In your decision tables you may use expressions such as “Salary of Employee” or “Manager of Department“. However, if Department includes a collection of objects such as the decision variable “All Employees” of the type Employee[] and you want to calculate the total number of all employees, you need to write a loop such as below:

The release 10.3.0 let’s you to avoid “for-each” loops by adding many predefined functions defined on collections of business objects (whether they are arrays, lists, or sets). Here are the currently supported functions for collections: Count, Sum, Max, Min, Average, Array, List, Set, DistinctArray, DistinctList, DistinctSet, First, and Last.
It means now without any loops you may simply use the following expressions directly in decision table cells:
- Count of Employees – returns the total number of employees inside the collection “Employees”
- Max of Salary of Employees – returns the maximum salary among all employees
- Average of Salary of Employees – returns the average salary among all employees
It is convenient to use these functions inside the “ActionAssign” as in the following decision table:

As you may guess, the expression Sum of Number of Children of Employees calculates the total number of children for all employees assuming that business concept Employee contains the decision variable “Number of Children”. Here is the proper Glossary from the new standard sample “Analyze Employees“:

The “red” decision variables are being calculated in the above table “ApplyFunctions”.
The expression First of Employees returns the first employee in the array Employees, and Salary of First of Employees returns his/her salary.
The function Array of Salary of Employees returns an array of all salaries for all employees (the array’s type is defined in the glossary as double[]). An employee may have residences in different locations with different states. If we want to construct a list of all states (without duplications) where employees have residencies, we may simply write DistinctList of State of Locations of Employees instead of writing two nested loops.
You may use combinations of functions like such as Average of Array of Salary of Employees or Count of DistinctList of State of Locations of Employees.
The future release will add more functions and expand their usability, in particular to use multiple parameters. Your feedback and suggestions are welcome.
Decision Models Testing using JSON files
OpenRules customer effectively use OpenRules Excel tables of the type “DecisionData” and “DecisionTest” to build their own test cases. Moreover, OpenRules automatically generates the proper JSON files in the folder “jsons”. They could be used for testing after deploying decision models as RESTful services, e.g. using POSTMAN.
However, sometimes our customers want to test their decision models using already available JSON files without creating test cases in Excel. It is especially important when JSON files come from production or from other external sources. The release 10.3.0 supports this capability. Now you may refer to the JSON file in your table “DecisionTest” in the column “ActionUseJson” as in the following example from the new standard project “AnalyzeEmployees” :

This table defines 2 test cases by referring to the proper JSON files “Test1.json” and “Test2.json”. It is important that you still may provide the expected results in the columns “ActionExpect”.
Bug Fixes. We’ve fixed several bugs introduced in previous releases and improved error diagnostics.
Updated Dependencies. As usual, we updated all OpenRules dependencies using an automated vulnerability check from the NVD. In particular, we upgraded ANTLR to the version 4.13.0. We again highly recommend you to upgrade your JDK to at least JAVA 11 (while we still continue to support JAVA 8).
