Interface MenuDAO

All Superinterfaces:
PersistentObjectDAO<Menu>
All Known Implementing Classes:
HibernateMenuDAO

public interface MenuDAO extends PersistentObjectDAO<Menu>
Instances of this class is a DAO-service for menu objects.
Version:
1.0
Author:
Michael Scholz
  • Method Details

    • findByName

      List<Menu> findByName(String name)
      Finds all menus by menu text.
      Parameters:
      name - name of the menu
      Returns:
      List of menus with given menu text.
    • findByName

      List<Menu> findByName(Menu parent, String name, boolean caseSensitive)
      Finds all menus by menu text, contained in the parent menu
      Parameters:
      parent - The parent menu(optional)
      name - the name to search
      caseSensitive - if we have to consider the search case sensitive
      Returns:
      List of menus with given menu name.
    • findByUserId

      List<Menu> findByUserId(long userId)
      Finds authorized menus for a user.
      Parameters:
      userId - ID of the user.
      Returns:
      List of found menus.
    • findMenuIdByUserIdAndPermission

      List<Long> findMenuIdByUserIdAndPermission(long userId, Permission permission, boolean enabledOnly)
      Finds all menus ids with a specific permission enabled on the specifies user
      Parameters:
      userId - The user identifier
      permission - The permission to check
      enabledOnly - if the menus must also be enabled
      Returns:
      list of folder IDs
    • findByUserId

      List<Menu> findByUserId(long userId, long parentId, boolean enabledOnly)
      Finds direct children of a menu
      Parameters:
      userId - identifier of the user
      parentId - MenuId of the menu which children are wanted
      enabledOnly - if the menus must also be enabled
      Returns:
      List of found menus sorted by name
    • findByParentId

      List<Menu> findByParentId(long parentId, boolean enabledOnly)
      Finds all children(direct and indirect) by parentId
      Parameters:
      parentId - identifier of the parent menu
      enabledOnly - if the menus must also be enabled
      Returns:
      list of children menus
    • findChildren

      List<Menu> findChildren(long parentId, Integer max)
      Finds direct children of a menu.
      Parameters:
      parentId - MenuId of the menu which children are wanted
      max - Optional, maximum number of children
      Returns:
      List of found menus
    • findChildren

      List<Menu> findChildren(long parentId, long userId)
      Finds direct children of a menu accessible by the given user.
      Parameters:
      parentId - MenuId of the menu which children are wanted
      userId - Identifier of the user that mush have read access
      Returns:
      List of found menus.
    • isWriteEnable

      boolean isWriteEnable(long id, long userId)
      This method is looking up for writing rights for a menu and an user
      Parameters:
      id - ID of the menu
      userId - ID of the user
      Returns:
      id the user has write permission
    • isReadEnable

      boolean isReadEnable(long id, long userId)
      This method is looking up for read rights for a menu and an user
      Parameters:
      id - ID of the menu
      userId - ID of the user
      Returns:
      if the user can access the menu
    • findNameById

      String findNameById(long id)
      This method selects only the menu text from a menu
      Parameters:
      id - Id of the menu
      Returns:
      Selected menu text
    • findMenuIdByUserId

      List<Long> findMenuIdByUserId(long userId, boolean enabledOnly)
      This method selects only the menuId from the menus for which a user is authorized
      Parameters:
      userId - ID of the user
      enabledOnly - if the menus must also be enabled
      Returns:
      List of selected menuId's
    • findIdByUserId

      List<Long> findIdByUserId(long userId, long parentId)
      This method selects only the menuId from the menus for which a user is authorized. Only menus direct child of the specified parent are returned.
      Parameters:
      userId - ID of the user.
      parentId - Parent menu
      Returns:
      List of selected menuId's.
    • isMenuWriteable

      int isMenuWriteable(long id, long userId)
      Returns if a menu is writeable for a user
      Parameters:
      id - check this menu
      userId - privileges for this should be checked
      Returns:
      a 0 if false, a 1 if true
    • hasWriteAccess

      boolean hasWriteAccess(Menu menu, long userId)
      Checks that the user has access to the menu and all its sub-items
      Parameters:
      menu - the menu
      userId - identifier of the menu
      Returns:
      if the user has write permission
    • findByGroupId

      List<Menu> findByGroupId(long groupId)
      Finds all menus accessible by the passed group
      Parameters:
      groupId - The group id
      Returns:
      The List of menus
    • findParents

      List<Menu> findParents(long id)
      Returns a List of menus being a parent of the given menu. The list is ordered starting from the root of menus.
      Parameters:
      id - identifier of the group
      Returns:
      hierarchy of parents
    • restore

      void restore(long id, boolean parents) throws PersistenceException
      Restores a previously deleted menu
      Parameters:
      id - The menu identifier
      parents - true if parents must be restored also
      Throws:
      PersistenceException - is happened a database error
    • findByNameAndParentId

      List<Menu> findByNameAndParentId(String name, long parentId)
      Finds that folder that lies under a specific parent (given by the id) an with a given text(like operator is used)
      Parameters:
      name - name of the menu
      parentId - identifier of the parent menu
      Returns:
      list of manues
    • computePathExtended

      String computePathExtended(long id)
      Dynamically computes the path extended for the specified menu. The path extended is a human readable path in the form: /menu1/menu2/menu3
      Parameters:
      id - identifier of the menu
      Returns:
      full path of the menu
    • createPath

      Menu createPath(long parentId, long tenantId, int type, String path, boolean inheritSecurity) throws PersistenceException
      Creates the menu for the specified path. All unexisting nodes specified in the path will be created.
      Parameters:
      parentId - Identifier of the parent menu
      tenantId - Identifier of the tenant that will own the new menu
      type - The type of the created menus
      path - The folder path(for example /dog/cat/mouse)
      inheritSecurity - If true the new menus will 'point' to the parent for the security policies.
      Returns:
      The created folder
      Throws:
      PersistenceException - error at data layer
    • applyRightToTree

      boolean applyRightToTree(long id)
      Propagates the security policies of a node to the whole subtree
      Parameters:
      id - identifier of a folder
      Returns:
      true if all went correctly