Class HibernateMenuDAO
java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<Menu>
com.logicaldoc.core.security.menu.HibernateMenuDAO
- All Implemented Interfaces:
- PersistentObjectDAO<Menu>,- MenuDAO
@Repository("menuDAO")
public class HibernateMenuDAO
extends HibernatePersistentObjectDAO<Menu>
implements MenuDAO
Hibernate implementation of 
MenuDAO- Since:
- 3.0
- Author:
- Marco Meschieri - LogicalDOC
- 
Field SummaryFields inherited from interface com.logicaldoc.core.PersistentObjectDAOENTITY
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptioncomputePathExtended(long menuId) Dynamically computes the path extended for the specified menu.createPath(long parentId, long tenantId, int type, String path, boolean inheritSecurity) Creates the menu for the specified path.voiddelete(long menuId, int code) This method deletes an entity and you can give a deletion codevoiddeleteAll(Collection<Menu> menus) Deletes all entries form the databasefindByGroupId(long groupId) Finds all menus accessible by the passed groupfindByName(Menu parent, String name, boolean caseSensitive) Finds all menus by menu text, contained in the parent menufindByName(String name) Finds all menus by menu text.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)findByParentId(long parentId, boolean enaledOnly) Finds all children(direct and indirect) by parentIdfindByUserId(long userId) Finds authorized menus for a user.findByUserId(long userId, long parentId, boolean enabledOnly) Finds direct children of a menufindByUserId(long userId, long parentId, Integer type, boolean enabledOnly) findChildren(long parentId, long userId) Finds direct children of a menu accessible by the given user.findChildren(long parentId, Integer max) Finds direct children of a menu.findIdByUserId(long userId, long parentId) This method selects only the menuId from the menus for which a user is authorized.findIdByUserId(long userId, long parentId, Integer type) findMenuIdByUserId(long userId, boolean enabledOnly) This method selects only the menuId from the menus for which a user is authorizedfindMenuIdByUserIdAndPermission(long userId, Permission permission, boolean enabledOnly) Finds all menus ids with a specific permission enabled on the specifies userfindNameById(long menuId) This method selects only the menu text from a menufindParents(long menuId) Returns a List of menus being a parent of the given menu.booleanhasWriteAccess(Menu menu, long userId) Checks that the user has access to the menu and all its sub-itemsintisMenuWriteable(long menuId, long userId) Returns if a menu is writeable for a userbooleanisReadEnable(long menuId, long userId) This method is looking up for read rights for a menu and an userbooleanisWriteEnable(long menuId, long userId) This method is looking up for writing rights for a menu and an uservoidrestore(long menuId, boolean parents) Restores a previously deleted menuvoidThis method persists the entity objectMethods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAObulkUpdate, delete, deleteAll, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, isMySQL, isOracle, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString, setSessionFactoryMethods inherited from class java.lang.Objectequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.logicaldoc.core.PersistentObjectDAObulkUpdate, delete, deleteAll, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, isMySQL, isOracle, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString
- 
Constructor Details- 
HibernateMenuDAOpublic HibernateMenuDAO()
 
- 
- 
Method Details
- 
findByUserIdDescription copied from interface:MenuDAOFinds authorized menus for a user.- Specified by:
- findByUserIdin interface- MenuDAO
- Parameters:
- userId- ID of the user.
- Returns:
- List of found menus.
 
- 
findByUserIdDescription copied from interface:MenuDAOFinds direct children of a menu- Specified by:
- findByUserIdin interface- MenuDAO
- 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
 
- 
findByUserId
- 
findChildrenDescription copied from interface:MenuDAOFinds direct children of a menu.- Specified by:
- findChildrenin interface- MenuDAO
- Parameters:
- parentId- MenuId of the menu which children are wanted
- max- Optional, maximum number of children
- Returns:
- List of found menus
 
- 
findChildrenDescription copied from interface:MenuDAOFinds direct children of a menu accessible by the given user.- Specified by:
- findChildrenin interface- MenuDAO
- Parameters:
- parentId- MenuId of the menu which children are wanted
- userId- Identifier of the user that must have read access
- Returns:
- List of found menus.
 
- 
findByParentIdDescription copied from interface:MenuDAOFinds all children(direct and indirect) by parentId- Specified by:
- findByParentIdin interface- MenuDAO
- Parameters:
- parentId- identifier of the parent menu
- enaledOnly- if the menus must also be enabled
- Returns:
- list of children menus
 
- 
isWriteEnablepublic boolean isWriteEnable(long menuId, long userId) Description copied from interface:MenuDAOThis method is looking up for writing rights for a menu and an user- Specified by:
- isWriteEnablein interface- MenuDAO
- Parameters:
- menuId- ID of the menu
- userId- ID of the user
- Returns:
- id the user has write permission
 
- 
isReadEnablepublic boolean isReadEnable(long menuId, long userId) Description copied from interface:MenuDAOThis method is looking up for read rights for a menu and an user- Specified by:
- isReadEnablein interface- MenuDAO
- Parameters:
- menuId- ID of the menu
- userId- ID of the user
- Returns:
- if the user can access the menu
 
- 
findNameByIdDescription copied from interface:MenuDAOThis method selects only the menu text from a menu- Specified by:
- findNameByIdin interface- MenuDAO
- Parameters:
- menuId- Id of the menu
- Returns:
- Selected menu text
 
- 
findMenuIdByUserIdDescription copied from interface:MenuDAOThis method selects only the menuId from the menus for which a user is authorized- Specified by:
- findMenuIdByUserIdin interface- MenuDAO
- Parameters:
- userId- ID of the user
- enabledOnly- if the menus must also be enabled
- Returns:
- List of selected menuId's
 
- 
isMenuWriteablepublic int isMenuWriteable(long menuId, long userId) Description copied from interface:MenuDAOReturns if a menu is writeable for a user- Specified by:
- isMenuWriteablein interface- MenuDAO
- Parameters:
- menuId- check this menu
- userId- privileges for this should be checked
- Returns:
- a 0 if false, a 1 if true
- See Also:
 
- 
findByGroupIdDescription copied from interface:MenuDAOFinds all menus accessible by the passed group- Specified by:
- findByGroupIdin interface- MenuDAO
- Parameters:
- groupId- The group id
- Returns:
- The List of menus
- Throws:
- PersistenceException- Error in the database
 
- 
findIdByUserId
- 
findByNameDescription copied from interface:MenuDAOFinds all menus by menu text.- Specified by:
- findByNamein interface- MenuDAO
- Parameters:
- name- name of the menu
- Returns:
- List of menus with given menu text.
 
- 
computePathExtendedDescription copied from interface:MenuDAODynamically computes the path extended for the specified menu. The path extended is a human readable path in the form: /menu1/menu2/menu3- Specified by:
- computePathExtendedin interface- MenuDAO
- Parameters:
- menuId- identifier of the menu
- Returns:
- full path of the menu
 
- 
findByNameAndParentIdDescription copied from interface:MenuDAOFinds that folder that lies under a specific parent (given by the id) an with a given text(like operator is used)- Specified by:
- findByNameAndParentIdin interface- MenuDAO
- Parameters:
- name- name of the menu
- parentId- identifier of the parent menu
- Returns:
- list of manues
 
- 
findParentsDescription copied from interface:MenuDAOReturns a List of menus being a parent of the given menu. The list is ordered starting from the root of menus.- Specified by:
- findParentsin interface- MenuDAO
- Parameters:
- menuId- identifier of the group
- Returns:
- hierarchy of parents
 
- 
restoreDescription copied from interface:MenuDAORestores a previously deleted menu- Specified by:
- restorein interface- MenuDAO
- Parameters:
- menuId- The menu identifier
- parents- true if parents must be restored also
- Throws:
- PersistenceException- is happened a database error
 
- 
findMenuIdByUserIdAndPermissionpublic List<Long> findMenuIdByUserIdAndPermission(long userId, Permission permission, boolean enabledOnly) Description copied from interface:MenuDAOFinds all menus ids with a specific permission enabled on the specifies user- Specified by:
- findMenuIdByUserIdAndPermissionin interface- MenuDAO
- Parameters:
- userId- The user identifier
- permission- The permission to check
- enabledOnly- if the menus must also be enabled
- Returns:
- list of folder IDs
 
- 
deleteAllDescription copied from interface:PersistentObjectDAODeletes all entries form the database- Specified by:
- deleteAllin interface- PersistentObjectDAO<Menu>
- Overrides:
- deleteAllin class- HibernatePersistentObjectDAO<Menu>
- Parameters:
- menus- The entities to be deleted
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
deleteDescription copied from interface:PersistentObjectDAOThis method deletes an entity and you can give a deletion code- Specified by:
- deletein interface- PersistentObjectDAO<Menu>
- Overrides:
- deletein class- HibernatePersistentObjectDAO<Menu>
- Parameters:
- menuId- ID of the entity which should be deleted
- code- Deletion code
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
findIdByUserIdDescription copied from interface:MenuDAOThis method selects only the menuId from the menus for which a user is authorized. Only menus direct child of the specified parent are returned.- Specified by:
- findIdByUserIdin interface- MenuDAO
- Parameters:
- userId- ID of the user.
- parentId- Parent menu
- Returns:
- List of selected menuId's.
 
- 
createPathpublic Menu createPath(long parentId, long tenantId, int type, String path, boolean inheritSecurity) throws PersistenceException Description copied from interface:MenuDAOCreates the menu for the specified path. All unexisting nodes specified in the path will be created.- Specified by:
- createPathin interface- MenuDAO
- 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