Package com.logicaldoc.core.metadata
Class HibernateTemplateDAO
- java.lang.Object
-
- com.logicaldoc.core.HibernatePersistentObjectDAO<Template>
-
- com.logicaldoc.core.metadata.HibernateTemplateDAO
-
- All Implemented Interfaces:
TemplateDAO,PersistentObjectDAO<Template>
public class HibernateTemplateDAO extends HibernatePersistentObjectDAO<Template> implements TemplateDAO
Hibernate implementation ofTemplateDAO- Since:
- 3.0
- Author:
- Marco Meschieri - LogicalDOC
-
-
Constructor Summary
Constructors Constructor Description HibernateTemplateDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcountDocs(long id)Counts the total number of documents using this templateintcountFolders(long id)booleandelete(long id, int code)This method deletes an entity and you can give a deletion codeList<Template>findAll()Finds all entities in the databaseList<Template>findAll(long tenantId)Finds all entities in a specific tenant.TemplatefindByName(String name, long tenantId)This method finds a template by nameList<Template>findByType(int type, long tenantId)This method finds a template by typeSet<Permission>getEnabledPermissions(long templateId, long userId)Finds all permissions of a user enabled on the specified templatevoidinitialize(Template template)Doesn't do anything by defaultbooleanisReadEnable(long templateId, long userId)This method is looking up for read rights for a template and an userbooleanisWriteEnable(long templateId, long userId)Returns if a template is writable for a uservoidsetUserDAO(UserDAO userDAO)-
Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO
bulkUpdate, delete, deleteAll, deleteAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, getSessionFactory, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString, setSessionFactory, store
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.logicaldoc.core.PersistentObjectDAO
bulkUpdate, delete, deleteAll, deleteAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString, store
-
-
-
-
Method Detail
-
setUserDAO
public void setUserDAO(UserDAO userDAO)
-
findAll
public List<Template> findAll()
Description copied from interface:PersistentObjectDAOFinds all entities in the database- Specified by:
findAllin interfacePersistentObjectDAO<Template>- Overrides:
findAllin classHibernatePersistentObjectDAO<Template>- Returns:
- The list of all entities
-
findAll
public List<Template> findAll(long tenantId)
Description copied from interface:PersistentObjectDAOFinds all entities in a specific tenant.- Specified by:
findAllin interfacePersistentObjectDAO<Template>- Overrides:
findAllin classHibernatePersistentObjectDAO<Template>- Parameters:
tenantId- Identifier of the tenant to search in- Returns:
- The list of all entities
-
findByName
public Template findByName(String name, long tenantId)
Description copied from interface:TemplateDAOThis method finds a template by name- Specified by:
findByNamein interfaceTemplateDAO- Parameters:
name- Name of the templatetenantId- ID of the owning tenant- Returns:
- Template with given name
-
delete
public boolean delete(long id, int code) throws PersistenceExceptionDescription copied from interface:PersistentObjectDAOThis method deletes an entity and you can give a deletion code- Specified by:
deletein interfacePersistentObjectDAO<Template>- Overrides:
deletein classHibernatePersistentObjectDAO<Template>- Parameters:
id- ID of the entity which should be deletedcode- Deletion code- Returns:
- if the record has been successfully deleted
- Throws:
PersistenceException- raised in case of errors in the database
-
countFolders
public int countFolders(long id)
-
countDocs
public int countDocs(long id)
Description copied from interface:TemplateDAOCounts the total number of documents using this template- Specified by:
countDocsin interfaceTemplateDAO- Parameters:
id- The template ID- Returns:
- the documents count
-
findByType
public List<Template> findByType(int type, long tenantId)
Description copied from interface:TemplateDAOThis method finds a template by type- Specified by:
findByTypein interfaceTemplateDAO- Parameters:
type- Type of the templatetenantId- ID of the owning tenant- Returns:
- Template with given type
-
initialize
public void initialize(Template template)
Description copied from class:HibernatePersistentObjectDAODoesn't do anything by default- Specified by:
initializein interfacePersistentObjectDAO<Template>- Overrides:
initializein classHibernatePersistentObjectDAO<Template>- Parameters:
template- The entity to be initialised
-
isWriteEnable
public boolean isWriteEnable(long templateId, long userId)Description copied from interface:TemplateDAOReturns if a template is writable for a user- Specified by:
isWriteEnablein interfaceTemplateDAO- Parameters:
templateId- check this templateuserId- privileges for this should be checked- Returns:
- if the user can edit the template
-
isReadEnable
public boolean isReadEnable(long templateId, long userId)Description copied from interface:TemplateDAOThis method is looking up for read rights for a template and an user- Specified by:
isReadEnablein interfaceTemplateDAO- Parameters:
templateId- ID of the templateuserId- ID of the user- Returns:
- if the user can access the template
-
getEnabledPermissions
public Set<Permission> getEnabledPermissions(long templateId, long userId)
Description copied from interface:TemplateDAOFinds all permissions of a user enabled on the specified template- Specified by:
getEnabledPermissionsin interfaceTemplateDAO- Parameters:
templateId- ID of the templateuserId- ID of the user- Returns:
- Collection of enabled permissions
-
-