Class HibernateReadingRequestDAO
java.lang.Object
com.logicaldoc.core.HibernatePersistentObjectDAO<ReadingRequest>
com.logicaldoc.enterprise.reading.HibernateReadingRequestDAO
- All Implemented Interfaces:
com.logicaldoc.core.PersistentObjectDAO<ReadingRequest>
,ReadingRequestDAO
public class HibernateReadingRequestDAO
extends com.logicaldoc.core.HibernatePersistentObjectDAO<ReadingRequest>
implements ReadingRequestDAO
Hibernate implementation of
ReadingRequestDAO
- Since:
- 8.8.6
- Author:
- Marco Meschieri - LogicalDOC
-
Field Summary
Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO
ENTITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanOldRequests
(int ttl) This method deletes all the reading requests older than the given days from now.confirmReading
(long readingId, String version, com.logicaldoc.core.document.DocumentHistory history) Updates the document's rating with the votes averagelong
countUnconfirmedReadings
(long userId) Counts the number of unconfirmed readingsfindByAlternateKey
(long docId, long userId, long requestorId, String fileVersion) Finds the readings for the alternate key: docId + userId + requestorId + fileVersionfindByDocId
(long docId) Finds the readings stored for the given document idfindByDocIdAndFileVersion
(long docId, String fileVersion) Finds the readings for the given fileVersion and the given document idfindByDocIdAndUserId
(long docId, long userId) Finds the readings for the given user id and the given document idfindLastUnconfirmed
(long docId, long userId) Finds the last unconfirmed reading for the given user id and the given document idfindUnconfirmedByUserId
(long userId) Finds all the unconfirmed readings of a user document idvoid
notifyReadingRequests
(Collection<ReadingRequest> readings, com.logicaldoc.core.document.DocumentHistory transaction) Notifies the reading confirmation requests.void
store
(ReadingRequest reading, com.logicaldoc.core.document.DocumentHistory transaction) Stores a reading and saves the document's historyMethods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO
bulkUpdate, delete, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, getSessionFactory, initialize, isOracle, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForRowSet, 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, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, isOracle, jdbcUpdate, jdbcUpdate, query, query, queryForDouble, queryForDouble, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForRowSet, queryForRowSet, queryForString, store
-
Constructor Details
-
HibernateReadingRequestDAO
public HibernateReadingRequestDAO()
-
-
Method Details
-
store
public void store(ReadingRequest reading, com.logicaldoc.core.document.DocumentHistory transaction) throws com.logicaldoc.core.PersistenceException Description copied from interface:ReadingRequestDAO
Stores a reading and saves the document's history- Specified by:
store
in interfaceReadingRequestDAO
- Parameters:
reading
- the ratingtransaction
- session informations- Throws:
com.logicaldoc.core.PersistenceException
- error at data layer
-
notifyReadingRequests
public void notifyReadingRequests(Collection<ReadingRequest> readings, com.logicaldoc.core.document.DocumentHistory transaction) throws com.logicaldoc.core.PersistenceException, javax.mail.MessagingException Description copied from interface:ReadingRequestDAO
Notifies the reading confirmation requests. Important: the requestor must be the same for all and is specified in the transaction.- Specified by:
notifyReadingRequests
in interfaceReadingRequestDAO
- Parameters:
readings
- the reading requests to notifytransaction
- current session- Throws:
com.logicaldoc.core.PersistenceException
- error at data layerjavax.mail.MessagingException
- Error in the sending of email
-
confirmReading
public ReadingRequest confirmReading(long readingId, String version, com.logicaldoc.core.document.DocumentHistory history) throws com.logicaldoc.core.PersistenceException Description copied from interface:ReadingRequestDAO
Updates the document's rating with the votes average- Specified by:
confirmReading
in interfaceReadingRequestDAO
- Parameters:
readingId
- Identifier of the reading to confirmversion
- The version to confirm the readinghistory
- session informations- Returns:
- the new / existing reading
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
findByDocIdAndUserId
public List<ReadingRequest> findByDocIdAndUserId(long docId, long userId) throws com.logicaldoc.core.PersistenceException Description copied from interface:ReadingRequestDAO
Finds the readings for the given user id and the given document id- Specified by:
findByDocIdAndUserId
in interfaceReadingRequestDAO
- Parameters:
docId
- ID of the documentuserId
- ID of the user- Returns:
- the readings of the given user on the document ordered by creation date desc
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
findLastUnconfirmed
public ReadingRequest findLastUnconfirmed(long docId, long userId) throws com.logicaldoc.core.PersistenceException Description copied from interface:ReadingRequestDAO
Finds the last unconfirmed reading for the given user id and the given document id- Specified by:
findLastUnconfirmed
in interfaceReadingRequestDAO
- Parameters:
docId
- ID of the documentuserId
- ID of the user- Returns:
- the last unconfirmed reading
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
findUnconfirmedByUserId
public List<ReadingRequest> findUnconfirmedByUserId(long userId) throws com.logicaldoc.core.PersistenceException Description copied from interface:ReadingRequestDAO
Finds all the unconfirmed readings of a user document id- Specified by:
findUnconfirmedByUserId
in interfaceReadingRequestDAO
- Parameters:
userId
- ID of the user- Returns:
- the list of unconfirmed readings orderd by creation asc
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
findByDocIdAndFileVersion
public List<ReadingRequest> findByDocIdAndFileVersion(long docId, String fileVersion) throws com.logicaldoc.core.PersistenceException Description copied from interface:ReadingRequestDAO
Finds the readings for the given fileVersion and the given document id- Specified by:
findByDocIdAndFileVersion
in interfaceReadingRequestDAO
- Parameters:
docId
- ID of the documentfileVersion
- version of the file- Returns:
- the vote of the given user on the document
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
findByAlternateKey
public ReadingRequest findByAlternateKey(long docId, long userId, long requestorId, String fileVersion) throws com.logicaldoc.core.PersistenceException Description copied from interface:ReadingRequestDAO
Finds the readings for the alternate key: docId + userId + requestorId + fileVersion- Specified by:
findByAlternateKey
in interfaceReadingRequestDAO
- Parameters:
docId
- ID of the documentuserId
- identifier of the recipient userrequestorId
- identifier of the requestor userfileVersion
- version of the file- Returns:
- the readings of the user on the specified version
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
findByDocId
Description copied from interface:ReadingRequestDAO
Finds the readings stored for the given document id- Specified by:
findByDocId
in interfaceReadingRequestDAO
- Parameters:
docId
- ID of the document- Returns:
- the list of ratings
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
countUnconfirmedReadings
public long countUnconfirmedReadings(long userId) throws com.logicaldoc.core.PersistenceException Description copied from interface:ReadingRequestDAO
Counts the number of unconfirmed readings- Specified by:
countUnconfirmedReadings
in interfaceReadingRequestDAO
- Parameters:
userId
- Identifier of the document- Returns:
- the total unconfirmed readings
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
cleanOldRequests
public void cleanOldRequests(int ttl) throws com.logicaldoc.core.PersistenceException Description copied from interface:ReadingRequestDAO
This method deletes all the reading requests older than the given days from now. Ifttl
is 0 or -1, the deletion is not made.- Specified by:
cleanOldRequests
in interfaceReadingRequestDAO
- Parameters:
ttl
- The maximum number of days over which the history is considered old- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-