Nested Lists in Spring Expression Language
I have list of departments that have employees working on projects. I want
to return a list of projects for a specific sector e.g. 'IT'.
public class Dept{
int id;
String name;
List<Employee> employees;
}
public class Employee{
int id;
String name;
List<Project> projects;
}
public class Project{
int id;
String name;
String sector;
}
public List<Project> getEmployeesByProject(String
projectSector,List<Department> departments){
StandardEvaluationContext context = new StandardEvaluationContext(
departments.getEmployees());
List<Project> employees = (List<Project>) parser.parseExpression(
"Employees.![Projects.?[sector=='" + projectSector
+ "']]").getValue(context, List.class);
}
The method returns a list of employees, not projects. I have tried other
combinations but haven't been able to pull a list of projects.
Sunday, August 11, 2013
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment