Decision Model “Hello Customer”

Building Decision Model in Excel
Testing Decision Model
Integrating Decision Model

Business Logic

This decision model specifies how to greet a customer based on the time of the day, gender, and marital status.  For example, if a customer Robinson is a married woman and current time is 14:25, we want our decision model to produce a hello statement like “Good Afternoon, Mrs. Robinson!” 

Building Decision Model in Excel

Our decision model represents business logic that determines the following goals:

    1. Goal “Greeting” with possible values “Good Morning”, “Good Afternoon”,  etc. that can be defined by the following decision table:
    2. Goal “Salutation” with possible values “Mr.”, “Ms.” And “Mrs.” that can be defined by the following decision table:
    3. The ultimate goal “Hello Statement” that combines Greeting, Salutation and Customer’s Name in one hello-statement that can be define as follows:

To complete our decision model we need to put all decision variables (goals and input variables used in the above tables) in one Glossary:

Thus, our complete decision model consists of the glossary surrounded by decision tables for all goals. 

Please note the following convention for all OpenRules tables:

    • All columns in the first row of any OpenRules table are merged. The merged cells define the start and end columns of OpenRules tables.
    • The start of any OpenRules table is recognized by a keyword such as “DecisionTable” or “Glossary”. The bottom of any table is recognized by the last non-empty row. To to be on the safe side, always surround OpenRules tables by empty rows and columns.  

Testing Decision Model

To test this model,  we create test-cases in Excel using the following tables:

    1. Datatype table that specifies our business concept Customer:
    2. Data table that specifies test-customers:
    3. Test cases with expected results defined in this table:

To execute these test-cases, we may simply double-click on the provided bat-files:

    • build.bat that will automatically determine all dependencies within the decision model and transforms the model in the executable code
    • run.bat that will execute the model producing the following results for the 1st test-case:

You can also look at the generated HTML report that explains which rules were actually executed and why:

Integrating Decision Model with a Java Application

After decision models have been tested, their authors usually passed them to Java developers. Any decision model built with OpenRules Decision Manager will include its Java representation that is usually out of interest for business people. But developers would use the generate Java code (frequently found in the folder “generated” as defined in setting.bat) to incorporate this model into a Java application. Here is an example of a Java launcher that can be used to execute the above model “Hello Customer” from a Java application: 


Thus, every decision model, built with OpenRules DM, includes a Java class such as DecisionModelHello. A developer may ask this model to create an object of the type Goal for any available business goal. Then the actual object of the type Customer (that is another Java class generated based on the Datatype) should be passed to the goal using goal.use(“Customer”,customer); and then the goal maybe simply executed using goal.execute(); 

This code will print these results:

Customer [name=Robert Smith, gender=Male, maritalStatus=Single, currentHour=15, helloStatement=Good Afternoon, Mr. Robert Smith!]