OpenRules Release 8.0.0 adds one more nice feature requested by our customers. Usually business decision models are created by a business person in Excel using powerful OpenRules decision tables. The same people who create the decision models usually create test cases for them using special Datatype and Data tables. After the model is tested, the business person passes the Excel-based model to IT for integration. If their IT uses Java, they need to create Java classes for input and output objects. which are similar to the Datatype tables created by the business person. The release 8.0.0 added an ability to generate such Java classes automatically to provide ready-to-go interfaces for already tested decision models.
To demonstrate this new feature, I will use the standard decision model “CreditCardApplication” included in the downloadable folder “openrules.models”. The business person created these Datatype tables:
to describe business concepts Applicant and Application used by this decision model. The business person also adjusted the standard batch files “setting.bat“:
————————————————————
set GOAL_NAME=”Application Status”
set MODEL_FILE=rules/DecisionModel.xls
set GOAL_FILE=rules/Goals.xls
set TEST_FILE=rules/Test.xls
set FEEL=On
set PACKAGE_NAME=credit.card.application
set OUTPUT_FOLDER=src
————————————————————
and used the default files “build.bat” and “run.bat” to build and test the model.
When this model is passed to a Java developer for integration, first of all s/he is trying to execute the same model from Java. For example, the standard decision model “CreditCardApplication” can be tested using this Java launcher:
It will simply execute the same, Excel-based test cases that the model’s author used for her/his testing. However, for the actual integration a Java developer has to manually create Java classes which correspond to the above Datatype tables Applicant and Application. Now it can be done automatically. To do this, the develop should add two more settings to the file “settings.bat”:
set PACKAGE_NAME=credit.card.application
set OUTPUT_FOLDER=src
and double-click on the new batch file “generate.bat“.
It will generate the following interface and implementation classes inside the folder src/credit/card/application/:
- Applicant.java – an interface for the business concept Applicant
- ApplicantImpl.java – an implementation of the interface Applicant
- Application.java – an interface for the business concept Application
- ApplicationImpl.java – an implementation of the interface Application
They are simple Java beans that define attributes and getters/setters for all decision variables from the Glossary using the types defined in the above Datatype tables. To make sure that the same decision model will continue to work with the generated Java interface, the developer can create a Java launcher that may look as below:
Pay attention that instead of the file “Test.xls” this launcher uses the file “Goals.xls”. Here the instances of Applicant and Applications are created right in this launcher. In the actual production interface they will come from your data sources. To see more details, download the evaluation version and look at the generated files in the decision model “CreditCardApplication” inside “openrules.models”.
We expect this Java generation mechanism will simplify an integration of the tested business decision models into the technical infrastructures used by our customers.