Due to imprecise wording, this may or may not be what you want. The rule fires,
if there are 5 or more Employees, each of them with the property that
- the employee has visited CCNA in year X
- the employee has visited CCNP in year X
- the employee has visited CCIE or J5SE in 2000 OR
has visited J4WS in 2001 or 2002 or 2003 (OR both)
(There is no relation between the years X of different employees.)
rule findCombi
when
accumulate(
Certificate( course == "CCNA", $e: employee, $y: year )
and
Certificate( course == "CCNP", employee == $e, year == $y )
and
Certificate( employee == $e,
((course == "CCIE" || == "J5SE" ) && year ==
2000 )
||
course == "J4WS" && year == 2001 || == 2002 || == 2003
);
$es: collectSet( $e ); $es.size() >= 5 )
then
System.out.println( "more than 5" );
end
On 26/05/2014, Chris B <sunnycal99(a)gmail.com> wrote:
I have a class
Employee
(name)
Certificates
(course, year, employee)
If the employees have CCNA & CCNP from the "same" year and then if they
took
"CCIE or J5SE in 2000" or "J4WS in 2001 or 2002, or 2003"
The Action should be taken if there are more than 5 such employees.
The connection between Employee and Certificates is through
Certificates.employee, but I can change it to a list of certificates in
Employee also if needed.
I start with
$e: Employee()
Certificate (employee == $e, course == "CCNA", $ccnaYear : year)
Certificate (employee == $e, course == "CCNP", $ccnpYear : year)
//this will get the years for one employee..
//now we need to get all other employees from same year..
//but we still need to make sure all certificates are from the same
employee.
ArrayList( size >= 2 ) from collect(Certificate (
((course == "CCNA", year == $ccnaYear, $e_this:employee) && (course ==
"CCNP", year == $ccnpYear, employee == $e_this))
&&
(
((course == "CCIE", year == 2000, employee == $e_this) || (course ==
J5SE",
year == 2000, employee == $e_this))
||
((course == "J4WS", year == 2001, employee == $e_this) || (course ==
"J4WS",
year == 2002, employee == $e_this) || (course == "J4WS", year == 2003,
employee == $e_this))
)
)
This is going crazy at this stage.
First problem, - I start with one employee, and try to get his years of CCNA
and CCNP
Next I am collecting Certificates instead of Employees which I should be
collecting and checking the length of the employees.
I think something like this will help me
http://blog.athico.com/2007/06/chained-from-accumulate-collect.html
But I am unable to convert it into my usecase.
Please help.
Thanks
--
View this message in context:
http://drools.46999.n3.nabble.com/Nested-Collect-probably-tp4029681.html
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users