I have to take decision in guvnor rule based on some value in an excel sheet. So is it possible to do it in guvnor rule? Let me explain a simple example of what I want to do exactly:
Rule: Read average salary in particular country for a person. Than based on avg. salary compute other calculations in rule.
I will get person's country in input. Then I have to take that country and check in Excel Sheet for the average salary and perform calculations based on it.
Excel content:
Country Salary
IND $2000
USA $3000
CHN $1900
Now if the input is Person with country IND. So how can I read excel in guvnor?
Is it better to read excel in guvnor or read it in java code itself before calling the rule and adding it the value as one of the pojo field.
Any help much appreciated.
I would parse the xls file externally and insert the data as facts (or globals if you wish). So you you can write rules like:
when
Person($country: country)
AvgSalary(country == $country, $salary: salary) //This fact comes from the xls.
then
...
end
Another option is to encapsulate the parsing of the xls file and provide a mechanism to extract a particular salary for a particular country. In this case, you can provide that mechanism using a global and write rules like this one:
global XLSParser; // your parser class
rule "..."
when
Person($country: country)
$salary: Double() from XLSParser.getAvgSalary($country)
then
...
end
Hope it helps,