Package evolaris.framework.sys.datamodel

Examples of evolaris.framework.sys.datamodel.Menu


   * @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;
  }
View Full Code Here


  /**
   * remove items the user has no access to (according to roles)
   */
  private void removeForbiddenItems(Set<Menu> menu, User user) {
    for (Iterator<Menu> it = menu.iterator(); it.hasNext(); ) {
      Menu item = it.next();
      if (item == null || item.getRoles() != null && Collections.disjoint(item.getRoles(), user.getRoles())) {
        it.remove();       
      } else if (item.getChildren() != null) {
        removeForbiddenItems(item.getChildren(), user);
      }
    }   
  }
View Full Code Here

TOP

Related Classes of evolaris.framework.sys.datamodel.Menu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.