The downloaded workspace “openrules.samples” includes various examples of decision models that you can build, test, and deploy. They provide good prototypes for your own operational decision models.
Build and Test Decision Models
To build and test a decision model you may simply double-click on the file “test.bat” (on Mac or Linux use “test”). It will automatically transform all Excel tables to Java packages placed in the folder “target”. Nobody should ever modify the generated files. You even don’t have to look at them – they are simply being used by the DM to execute the decision models. OpenRules DM keeps track of the original Excel tables, and produces all messages and explanations in the business terms used in Excel. When you execute the decision model, along with a user-friendly execution protocol, OpenRules DM produces the same explanation reports in the HTML format as the classic OpenRules BRDMS does – see the generated folder “report”.
Integration with IT
This release comes with a new, very simple Java API for invocation of OpenRules decision models from your Java applications. It uses two new Java classes “DecisionModel” and “Goal” that support the Goal-Oriented Decision Modeling approach described in this book (that has been updated as well). The provided Java launchers demonstrate how to execute decision models against real data instances. Here is what you usually should do:
-
- Create an instance of the class DecisionModel using the automatically generated Java class (which name is defined in settings.bat as MODEL_NAME), e.g.
DecisionModel model = new DecisionModelVacationDays(); - Ask the model to create an instance of the class Goal, e.g.
Goal goal = model.createGoal(“Vacations Days”); - Ask the goal to use your own business objects, e.g.
goal.use(“Employee”,employee); - Execute the goal using the standard Goal’s method
goal.execute();
- Create an instance of the class DecisionModel using the automatically generated Java class (which name is defined in settings.bat as MODEL_NAME), e.g.
Here is an example of how the decision model “Vacation Days” can be invoked using Launcher.java:
It will calculate the number of vacation days for the employee Mary Grant. Of course, an employee may come from a database, from your UI or from JSON.
Deployment
By converting your decision models to highly efficient Java code, the DM allows you to deploy them as regular Java programs in the way you prefer:
-
- locally by using a simple Java API
- on any server like Apache Tomcat or IBM WebSphere
- on cloud as a decision microservice utilizing any serverless architecture provided by any major cloud vendors such as Amazon, Google, Microsoft, IBM or Oracle.