Package com.logicaldoc.core.document

# Interface DocumentNoteDAO

All Superinterfaces:
  `PersistentObjectDAO<DocumentNote>`

All Known Implementing Classes:
  `HibernateDocumentNoteDAO`

public interface DocumentNoteDAO extends PersistentObjectDAO<DocumentNote>
DAO for `DocumentNote` handling.

Since:
  6.2
Author:
  Matteo Caruso - LogicalDOC

## Field Summary

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

`ENTITY`

## Method Summary

Modifier and Type
Method
Description
`int`
`copyAnnotations(long docId, String oldFileVersion, String newFileVersion)`
Copies all the notes not associated to a specific page from a given file version to another
`List<DocumentNote>`
`findByDocId(long docId, long userId, String fileVersion)`
This method finds the list of document notes regarding a document with the given ID
`List<DocumentNote>`
`findByDocIdAndType(long docId, long userId, String fileVersion, String type)`
This method finds the list of document notes regarding a document with the given ID and optionally filter on the type
`List<DocumentNote>`
`findByDocIdAndTypes(long docId, long userId, String fileVersion, Collection<String> types)`
This method finds the list of document notes regarding a document with the given ID and optionally filter on a collection of types
`List<DocumentNote>`
`findByUserId(long userId)`
This method finds the list of document notes regarding posted by a specific user
`static DocumentNoteDAO`
`get()`
Gets the object available in the application context
`Set<Permission>`
`getAllowedPermissions(long noteId, long userId)`
Finds all permissions of a user enabled on the specified note
`boolean`
`isReadAllowed(long noteId, long userId)`
This method is looking up for read rights for a note and an user
`boolean`
`isWriteAllowed(long noteId, long userId)`
This method is looking up for writing rights for a note and an user
`void`
`store(DocumentNote note, DocumentHistory transaction)`
Stores a note and saves the document's history

### 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, 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 DocumentNoteDAO get()
Gets the object available in the application context

Returns:
  the instance of this object in the application context

### store

void store(DocumentNote note, DocumentHistory transaction) throws PersistenceException
Stores a note and saves the document's history

Parameters:
  `note` - the note
  `transaction` - session informations
Throws:
  `PersistenceException` - error at data layer

### findByDocId

List<DocumentNote> findByDocId(long docId, long userId, String fileVersion) throws PersistenceException
This method finds the list of document notes regarding a document with the given ID

Parameters:
  `docId` - ID of the document
  `userId` - identifier of the current user
  `fileVersion` - indicates a specific file version, optional
Returns:
  The list of document note
Throws:
  `PersistenceException` - Error in the database

### findByDocIdAndType

List<DocumentNote> findByDocIdAndType(long docId, long userId, String fileVersion, String type) throws PersistenceException
This method finds the list of document notes regarding a document with the given ID and optionally filter on the type

Parameters:
  `docId` - ID of the document
  `userId` - identifier of the current user
  `fileVersion` - indicates a specific file version, optional
  `type` - note type, optional
Returns:
  The list of document note
Throws:
  `PersistenceException` - Error in the database

### findByDocIdAndTypes

List<DocumentNote> findByDocIdAndTypes(long docId, long userId, String fileVersion, Collection<String> types) throws PersistenceException
This method finds the list of document notes regarding a document with the given ID and optionally filter on a collection of types

Parameters:
  `docId` - ID of the document
  `userId` - identifier of the current user
  `fileVersion` - indicates a specific file version, optional
  `types` - collection of admitted note types, optional
Returns:
  The list of document note
Throws:
  `PersistenceException` - Error in the database

### copyAnnotations

int copyAnnotations(long docId, String oldFileVersion, String newFileVersion) throws PersistenceException
Copies all the notes not associated to a specific page from a given file version to another

Parameters:
  `docId` - The document ID
  `oldFileVersion` - the old version
  `newFileVersion` - the version to copy to
Returns:
  Number of copied notes
Throws:
  `PersistenceException` - If an error occurs in the database

### findByUserId

List<DocumentNote> findByUserId(long userId) throws PersistenceException
This method finds the list of document notes regarding posted by a specific user

Parameters:
  `userId` - ID of the user
Returns:
  The list of document notes ordered by descending date
Throws:
  `PersistenceException` - Error in the database

### isWriteAllowed

boolean isWriteAllowed(long noteId, long userId) throws PersistenceException
This method is looking up for writing rights for a note and an user

Parameters:
  `noteId` - ID of the note
  `userId` - ID of the user
Returns:
  id the user has write permission
Throws:
  `PersistenceException` - Error in the database

### isReadAllowed

boolean isReadAllowed(long noteId, long userId) throws PersistenceException
This method is looking up for read rights for a note and an user

Parameters:
  `noteId` - ID of the note
  `userId` - ID of the user
Returns:
  if the user can access the note
Throws:
  `PersistenceException` - Error in the database

### getAllowedPermissions

Set<Permission> getAllowedPermissions(long noteId, long userId) throws PersistenceException
Finds all permissions of a user enabled on the specified note

Parameters:
  `noteId` - ID of the note
  `userId` - ID of the user
Returns:
  Collection of enabled permissions
Throws:
  `PersistenceException` - error at data layer