* @param user
* @return a list of menu items (possibly with subitems/subsubitems)
*/
public Set<Menu> createMenu(User user) {
// fetch root -- main menu items are children of the root node
Menu root = (Menu)session.createCriteria(Menu.class)
.add(Restrictions.or(Restrictions.eq("de", "root"), Restrictions.eq("en", "root")))
.add(Restrictions.eq("clientProject", user.getGroup().getClientProject()))
.uniqueResult();
if (root == null) {
return null;
}
session.evict(root); // detach from session (so removing not allowed entries will not remove them from the database)
Set<Menu> menu = root.getChildren(); // because of eager loading we have the complete tree now.
removeForbiddenItems(menu, user);
return menu;
}