I m trying to create the drools drl file using java programmatically by following method.
I can able to create the below simple rules by simple rule by java program.
rule "Demo_testing"
when
$employee : EmployeeModel( department contains "Accounts" )
then
//
And this in one working fine for me, but i need get the employee information from list. Like $employee : EmployeeModel( department contains "Accounts", role = "manager" ) from $employeeList
I found the list on descriptor available in drools compiler here But i don't know which descriptor i needs to use and how to define.?
Please any one help me to relove this one. Thanks in advance.
PatternDescr employeePatternDescr=new PatternDescr();
employeePatternDescr.setIdentifier("$employee");
employeePatternDescr.setObjectType("EmployeeModel");
RelationalExprDescr relationalExprDescr = null;
constraintDescr.setExpression("department");
ExprConstraintDescr constraintDescr2=new ExprConstraintDescr();
constraintDescr2.setExpression("Accounts" );
relationalExprDescr = new RelationalExprDescr("contains" ,false, null, constraintDescr, constraintDescr2);
employeePatternDescr.addConstraint(relationalExprDescr);
andDescr.addDescr(employeePatternDescr);
ruleDescr.setLhs(andDescr);