You will need a rule file to get started. You can write it by hand - it is a XML document. But this is cumbersome and errors are quickly made when handwriting such a file. So I recommend that you download my tool - a web application - which helps you in an easy fashion to write rules, actions and all that is required.
To run the application you need a MySQL server or a MariaDB server running on your machine. The data and configuration of the web application is stored in a database. So if you don't have one of these servers installed, then do so first. Once the database server is up and running, create the database "ruleengine_rules". Download the database schema required from here: Database Schema. Then import the schema into the "ruleengine_rules" database.
Next install Apache Tomcat from the Apache Website. Once Tomcat is running, download the war file for the:
Business Rules Maintenance Tool. Put it in the Tomcat "webapps" folder. Now the web application is available on localhost:8080/rule_maintenance. Adjust the hostname and port if it differs on your system. You can then login with /admin/admin and start your first project.
In the rules you define which fields you will use and which checks you want to do. E.g. field1 is equal to "Hello" and field2 is equal to "Ruleengine". Depending on the result of this check (passed or failed), you can execute e.g. an action like "set field3 to "World". With the ruleengine you have all possibilities to write complex business rules - complex logic - and act upon the results of the outcome.
In the web application everything is handled within projects. Once your logic is complete, go ahead and export the project to a file. This file is then used with the ruleengine to run the business logic against the data. Data may be from a file or from a database. It is very easy to use the ruleengine with the Pentaho PDI (ETL) tool. But I have already written a lot in my other posts about that and there are also videos on Youtube. This time we use a CSV file and we use it from bare java code.
So you got the project exported from the Business Rules Maintenance Tool web application and it is available as a zip file on your computer. What you also need to have is a CSV file containing rows of data. The individual columns of each row need to correspond to the fields that you used in the business rules - like in the example above: field1, field2 and field3.
Here is an example for a CSV structure:
Before we start we also need the Jare java library that you need to attach to your Java project (or add it to the Java classpath). Download: Jare Java library.
Now start your Java IDE or editor and we start with a new Java Class and enter the following code in a "main" method that we later execute.
In the code below you will need to replace the path and the names of the project zip file and the CSV file that you use.
Other than that, I think the code below is straight-ahead and you can read what the individual lines are doing from the embedded comments.
Now this example loops over a CSV file. It encapsulates the data into Java objects (RowFieldCollection) and then the ruleengine processes these according to the rules defined in the Business Rules Maintenance web application.
Alternatively you can use any other data source to do something similar: other file types such as JSON or XML, etc or data from databases. In fact any Java object or collection may be used.
Hope this is helpful and if you have questions, please don't hesiate to ask.