The idea is to not hardcode business logic in your code, by externally hosting the rules. This way the logic is outside your code and changes to either code or rules don't interfere with each other. The logic can be maintained by IT or by the business so there is a better separation of responsibilities possible. It is also a plus for the quality of your code: it concentrates on coding and not on implementing business logic or exceptions. Without business logic in your code, it is cleaner. That is a plus for agility and also for quality of the code.
Now the maintenance of the (complex) logic is done in the web application "Business Rules Maintenance Tool". It works with projects, where one project contains all the logic required for a certain task or topic. The tool has export functionality to create such a project file. It is a zip file containing all the logic for that project. Actually it is not only rules that are inside the project file but also actions. Actions execute certain task based on the result of the business rules.
But you can also create this file from code or a script. This way, you are able to set up continuous intergration (CI) to generate the project files on a regular basis.
Again, this is a Java program that you run and pass following arguments:
- the project name (argument: -n)
- the environment (argument: -e) for which to generate the project file (dev or prod)
- a backup folder to store backup copied of files (argument: -l)
- a template folder where the Apache Velocity templates are located (argument: -p)
- an output folder to store the generated project file(s) (argument: -o)
- a temporary folder used by the program to store data (argument: -y)
- a validity date to use with the project; groups of rules have a date (from-to) when they are valid (argument: -v)
- the details of the database where the rules are stored: hostname/ip, server port, database name, userid and user password. (arguments: -s, -r, -b, -u, -w)
Project name, environment and backup folder are optional. If no project name is provided, project files for all projects are created. If no environment is specified, then the default "prod" is used. If no backfolder is specified, then the given output folder is used for backup copies of existing files.
An example would look like this:
java -cp brmt_2.3.3.jar RuleGroupFileCreator -n="Project 1" -p=/home/user/templates -o=/home/user/testoutput -y=/home/user/temp -v=2018-07-01 -s=localhost -r=3306 -b=ruleengine_rules -u=tom -w=mysecret -e=dev -l=/home/user/testoutput/backup