Package com.logicaldoc.core.document

# Class HibernateDocumentHistoryDAO

java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<DocumentHistory>
com.logicaldoc.core.history.HibernateHistoryDAO<DocumentHistory>
com.logicaldoc.core.document.HibernateDocumentHistoryDAO

All Implemented Interfaces:
  `DocumentHistoryDAO`, `PersistentObjectDAO<DocumentHistory>`

@Repository("documentHistoryDAO") public class HibernateDocumentHistoryDAO extends HibernateHistoryDAO<DocumentHistory> implements DocumentHistoryDAO
Hibernate implementation of `HistoryDAO`

Since:
  3.0
Author:
  Alessandro Gasparini - LogicalDOC

## Field Summary

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

`ENTITY`

## Method Summary

Modifier and Type
Method
Description
`void`
`cleanOldHistories(int ttl)`
This method deletes all the document history entries older than the given days from now.
`List<DocumentHistory>`
`findByDocId(long docId)`
This method selects all histories of a given document.
`List<DocumentHistory>`
`findByDocIdAndEvent(long docId, DocumentEvent event)`
This method selects all histories of a given document.
`List<DocumentHistory>`
`findByFolderId(long folderId)`
This method selects all histories of a given folder.
`List<DocumentHistory>`
`findByPath(String pathExpression, Date oldestDate, Collection<String> events, Integer max)`
This method finds all histories about a path (you can use expression)
`List<DocumentHistory>`
`findByUserId(long userId)`
This method selects all histories of a given user.
`List<DocumentHistory>`
`findByUserIdAndEvent(long userId, String event, String sessionId)`
This method selects all histories of a given user and related to the given event.
`List<DocumentHistory>`
`findNotNotified(Integer max)`
This method selects all histories not notified yet.
`void`
`markHistoriesAsRead(String event, long userId)`
Marks all the histories of a specific event as read by the specified user.

### Methods inherited from class com.logicaldoc.core.history.HibernateHistoryDAO

`store`

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

`bulkUpdate, count, delete, deleteAll, evict, evict, findById, findByObjectQuery, findByQuery, findByQuery, findByWhere, findIdsByWhere, getDatabaseMetadata, initialize, 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, 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

### findByDocId

public List<DocumentHistory> findByDocId(long docId) throws PersistenceException
Description copied from interface: `DocumentHistoryDAO`
This method selects all histories of a given document.

Specified by:
  `findByDocId` in interface `DocumentHistoryDAO`
Parameters:
  `docId` - - ID of the document.
Returns:
  list of histories ordered by date
Throws:
  `PersistenceException` - Error in the database

### findByDocIdAndEvent

public List<DocumentHistory> findByDocIdAndEvent(long docId, DocumentEvent event) throws PersistenceException
Description copied from interface: `DocumentHistoryDAO`
This method selects all histories of a given document.

Specified by:
  `findByDocIdAndEvent` in interface `DocumentHistoryDAO`
Parameters:
  `docId` - - ID of the document.
  `event` - - Optional event code
Returns:
  list of histories ordered by date
Throws:
  `PersistenceException` - Error in the database

### findByUserId

public List<DocumentHistory> findByUserId(long userId) throws PersistenceException
Description copied from interface: `DocumentHistoryDAO`
This method selects all histories of a given user.

Specified by:
  `findByUserId` in interface `DocumentHistoryDAO`
Parameters:
  `userId` - identifier of the user
Returns:
  list of histories ordered by date
Throws:
  `PersistenceException` - Error in the database

### findByFolderId

public List<DocumentHistory> findByFolderId(long folderId) throws PersistenceException
Description copied from interface: `DocumentHistoryDAO`
This method selects all histories of a given folder.

Specified by:
  `findByFolderId` in interface `DocumentHistoryDAO`
Parameters:
  `folderId` - - ID of the document.
Returns:
  list of histories ordered by date
Throws:
  `PersistenceException` - Error in the database

### findNotNotified

public List<DocumentHistory> findNotNotified(Integer max) throws PersistenceException
Description copied from interface: `DocumentHistoryDAO`
This method selects all histories not notified yet.

Specified by:
  `findNotNotified` in interface `DocumentHistoryDAO`
Parameters:
  `max` - Optional maximum number of records
Returns:
  list of histories ordered by date
Throws:
  `PersistenceException` - Error in the database

### cleanOldHistories

public void cleanOldHistories(int ttl) throws PersistenceException
Description copied from interface: `DocumentHistoryDAO`
This method deletes all the document history entries older than the given days from now. If `ttl` is 0 or -1, the deletion is not made.

Specified by:
  `cleanOldHistories` in interface `DocumentHistoryDAO`
Parameters:
  `ttl` - The maximum number of days over which the history is considered old
Throws:
  `PersistenceException` - Error in the database

### findByUserIdAndEvent

public List<DocumentHistory> findByUserIdAndEvent(long userId, String event, String sessionId) throws PersistenceException
Description copied from interface: `DocumentHistoryDAO`
This method selects all histories of a given user and related to the given event.

Specified by:
  `findByUserIdAndEvent` in interface `DocumentHistoryDAO`
Parameters:
  `userId` - The user identifier
  `event` - Code of the event (optional)
  `sessionId` - The session identifier (optional)
Returns:
  list of histories ordered by date
Throws:
  `PersistenceException` - Error in the database

### markHistoriesAsRead

public void markHistoriesAsRead(String event, long userId) throws PersistenceException
Description copied from interface: `DocumentHistoryDAO`
Marks all the histories of a specific event as read by the specified user.

Specified by:
  `markHistoriesAsRead` in interface `DocumentHistoryDAO`
Parameters:
  `event` - the event name
  `userId` - identifier of the user
Throws:
  `PersistenceException` - Error in the database

### findByPath

public List<DocumentHistory> findByPath(String pathExpression, Date oldestDate, Collection<String> events, Integer max) throws PersistenceException
Description copied from interface: `DocumentHistoryDAO`
This method finds all histories about a path (you can use expression)

Specified by:
  `findByPath` in interface `DocumentHistoryDAO`
Parameters:
  `pathExpression` - The path expression (like /Default/acme%)
  `oldestDate` - The older date for the retrieved histories
  `events` - events Optional list of event codes to be used as filter
  `max` - Optional maximum number of records
Returns:
  list of histories ordered by date asc
Throws:
  `PersistenceException` - Error in the database