Package com.logicaldoc.core.metadata

# Interface TemplateDAO

All Superinterfaces:
  `PersistentObjectDAO<Template>`

All Known Implementing Classes:
  `HibernateTemplateDAO`

public interface TemplateDAO extends PersistentObjectDAO<Template>
This class is a DAO-service for document templates.

Version:
  1.0
Author:
  Marco Meschieri - LogicalDOC

## Field Summary

### Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO

`ENTITY`

## Method Summary

Modifier and Type
Method
Description
`Template`
`clone(long id, String cloneName)`
Creates a clone of an existing template
`long`
`countDocs(long id)`
Counts the total number of documents using this template
`long`
`countFolders(long id)`
Counts the total number of folders using this template
`Template`
`findByName(String name, long tenantId)`
This method finds a template by name
`List<Template>`
`findByType(int type, long tenantId)`
This method finds a template by type
`static TemplateDAO`
`get()`
Gets the object available in the application context
`Set<Permission>`
`getAllowedPermissions(long templateId, long userId)`
Finds all permissions of a user enabled on the specified template
`void`
`initialize(Template template)`
Initialises lazy loaded data such as collections
`boolean`
`isReadEnable(long templateId, long userId)`
This method is looking up for read rights for a template and an user
`boolean`
`isWriteEnable(long templateId, long userId)`
Returns if a template is writable for a user

### Methods inherited from interface com.logicaldoc.core.PersistentObjectDAO

`bulkUpdate, count, count, count, delete, delete, deleteAll, deleteAll, evict, evict, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, isMariaDB, isMySQL, isOracle, isPostgreSQL, isSQLServer, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString, store`

## Method Details

### get

static TemplateDAO get()
Gets the object available in the application context

Returns:
  the instance of this object in the application context

### findByName

Template findByName(String name, long tenantId) throws PersistenceException
This method finds a template by name

Parameters:
  `name` - Name of the template
  `tenantId` - ID of the owning tenant
Returns:
  Template with given name
Throws:
  `PersistenceException` - Error in the data layer

### clone

Template clone(long id, String cloneName) throws PersistenceException
Creates a clone of an existing template

Parameters:
  `id` - Identifier of the original template
  `cloneName` - Name of the cloned template
Returns:
  the created clone
Throws:
  `PersistenceException` - Error in the data layer

### countDocs

long countDocs(long id) throws PersistenceException
Counts the total number of documents using this template

Parameters:
  `id` - The template ID
Returns:
  the documents count
Throws:
  `PersistenceException` - Error in the data layer

### countFolders

long countFolders(long id) throws PersistenceException
Counts the total number of folders using this template

Parameters:
  `id` - The template ID
Returns:
  the folders count
Throws:
  `PersistenceException` - Error in the data layer

### findByType

List<Template> findByType(int type, long tenantId) throws PersistenceException
This method finds a template by type

Parameters:
  `type` - Type of the template
  `tenantId` - ID of the owning tenant
Returns:
  Template with given type
Throws:
  `PersistenceException` - Error in the data layer

### getAllowedPermissions

Set<Permission> getAllowedPermissions(long templateId, long userId)
Finds all permissions of a user enabled on the specified template

Parameters:
  `templateId` - ID of the template
  `userId` - ID of the user
Returns:
  Collection of enabled permissions

### isWriteEnable

boolean isWriteEnable(long templateId, long userId)
Returns if a template is writable for a user

Parameters:
  `templateId` - check this template
  `userId` - privileges for this should be checked
Returns:
  if the user can edit the template

### isReadEnable

boolean isReadEnable(long templateId, long userId)
This method is looking up for read rights for a template and an user

Parameters:
  `templateId` - ID of the template
  `userId` - ID of the user
Returns:
  if the user can access the template

### initialize

void initialize(Template template)
Description copied from interface: `PersistentObjectDAO`
Initialises lazy loaded data such as collections

Specified by:
  `initialize` in interface `PersistentObjectDAO<Template>`
Parameters:
  `template` - The entity to be initialised