Package com.logicaldoc.core.document

# Class HibernateDocumentNoteDAO

java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<DocumentNote>
com.logicaldoc.core.document.HibernateDocumentNoteDAO

All Implemented Interfaces:
  `DocumentNoteDAO`, `PersistentObjectDAO<DocumentNote>`

@Repository("documentNoteDAO") public class HibernateDocumentNoteDAO extends HibernatePersistentObjectDAO<DocumentNote> implements DocumentNoteDAO
Hibernate implementation of `DocumentNoteDAO`

Since:
  6.2
Author:
  Matteo Caruso - LogicalDOC

## Field Summary

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

`ENTITY`

## Constructor Summary

Constructors
Constructor
Description
`HibernateDocumentNoteDAO()`

## 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
`void`
`delete(long id, int code)`
This method deletes an entity and you can give a deletion code
`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
`Set<Permission>`
`getAllowedPermissions(long noteId, long userId)`
Finds all permissions of a user enabled on the specified note
`void`
`initialize(DocumentNote note)`
Doesn't do anything by default
`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)`
This method persists the entity object
`void`
`store(DocumentNote note, DocumentHistory transaction)`
Stores a note and saves the document's history

### Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO

`bulkUpdate, count, deleteAll, evict, evict, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findIdsByWhere, getDatabaseMetadata, jdbcUpdate, jdbcUpdate, query, queryForDouble, queryForDouble, queryForInt, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForObject, queryForResultSet, queryForString, queryForString, setSessionFactory`

### 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, count, count, count, 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`

## Constructor Details

### HibernateDocumentNoteDAO

public HibernateDocumentNoteDAO()

## Method Details

### store

public void store(DocumentNote note) throws PersistenceException
Description copied from interface: `PersistentObjectDAO`
This method persists the entity object

Specified by:
  `store` in interface `PersistentObjectDAO<DocumentNote>`
Overrides:
  `store` in class `HibernatePersistentObjectDAO<DocumentNote>`
Parameters:
  `note` - entity to be stored
Throws:
  `PersistenceException` - raised in case of errors in the database

### store

public void store(DocumentNote note, DocumentHistory transaction) throws PersistenceException
Description copied from interface: `DocumentNoteDAO`
Stores a note and saves the document's history

Specified by:
  `store` in interface `DocumentNoteDAO`
Parameters:
  `note` - the note
  `transaction` - session informations
Throws:
  `PersistenceException` - error at data layer

### findByDocId

public List<DocumentNote> findByDocId(long docId, long userId, String fileVersion) throws PersistenceException
Description copied from interface: `DocumentNoteDAO`
This method finds the list of document notes regarding a document with the given ID

Specified by:
  `findByDocId` in interface `DocumentNoteDAO`
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

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

Specified by:
  `findByDocIdAndType` in interface `DocumentNoteDAO`
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

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

Specified by:
  `findByDocIdAndTypes` in interface `DocumentNoteDAO`
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

### findByUserId

public List<DocumentNote> findByUserId(long userId) throws PersistenceException
Description copied from interface: `DocumentNoteDAO`
This method finds the list of document notes regarding posted by a specific user

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

### delete

public void delete(long id, int code) throws PersistenceException
Description copied from interface: `PersistentObjectDAO`
This method deletes an entity and you can give a deletion code

Specified by:
  `delete` in interface `PersistentObjectDAO<DocumentNote>`
Overrides:
  `delete` in class `HibernatePersistentObjectDAO<DocumentNote>`
Parameters:
  `id` - ID of the entity which should be deleted
  `code` - Deletion code
Throws:
  `PersistenceException` - raised in case of errors in the database

### copyAnnotations

public int copyAnnotations(long docId, String oldFileVersion, String newFileVersion) throws PersistenceException
Description copied from interface: `DocumentNoteDAO`
Copies all the notes not associated to a specific page from a given file version to another

Specified by:
  `copyAnnotations` in interface `DocumentNoteDAO`
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

### initialize

public void initialize(DocumentNote note) throws PersistenceException
Description copied from class: `HibernatePersistentObjectDAO`
Doesn't do anything by default

Specified by:
  `initialize` in interface `PersistentObjectDAO<DocumentNote>`
Overrides:
  `initialize` in class `HibernatePersistentObjectDAO<DocumentNote>`
Parameters:
  `note` - The entity to be initialised
Throws:
  `PersistenceException` - Error in the database

### isWriteAllowed

public boolean isWriteAllowed(long noteId, long userId) throws PersistenceException
Description copied from interface: `DocumentNoteDAO`
This method is looking up for writing rights for a note and an user

Specified by:
  `isWriteAllowed` in interface `DocumentNoteDAO`
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

public boolean isReadAllowed(long noteId, long userId) throws PersistenceException
Description copied from interface: `DocumentNoteDAO`
This method is looking up for read rights for a note and an user

Specified by:
  `isReadAllowed` in interface `DocumentNoteDAO`
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

public Set<Permission> getAllowedPermissions(long noteId, long userId) throws PersistenceException
Description copied from interface: `DocumentNoteDAO`
Finds all permissions of a user enabled on the specified note

Specified by:
  `getAllowedPermissions` in interface `DocumentNoteDAO`
Parameters:
  `noteId` - ID of the note
  `userId` - ID of the user
Returns:
  Collection of enabled permissions
Throws:
  `PersistenceException` - error at data layer