Interface ReadingRequestDAO
- All Superinterfaces:
com.logicaldoc.core.PersistentObjectDAO<ReadingRequest>
- All Known Implementing Classes:
HibernateReadingRequestDAO
DAO service for the readings
- Since:
- 8.8.6
- Author:
- Matteo Caruso - LogicalDOC
-
Field Summary
Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO
ENTITY
-
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 transaction) 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
notifyReadings
(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 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
-
Method Details
-
store
void store(ReadingRequest reading, com.logicaldoc.core.document.DocumentHistory transaction) throws com.logicaldoc.core.PersistenceException Stores a reading and saves the document's history- Parameters:
reading
- the ratingtransaction
- session informations- Throws:
com.logicaldoc.core.PersistenceException
- error at data layer
-
notifyReadings
void notifyReadings(Collection<ReadingRequest> readings, com.logicaldoc.core.document.DocumentHistory transaction) throws com.logicaldoc.core.PersistenceException, javax.mail.MessagingException Notifies the reading confirmation requests. Important: the requestor must be the same for all and is specified in the transaction.- 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
ReadingRequest confirmReading(long readingId, String version, com.logicaldoc.core.document.DocumentHistory transaction) throws com.logicaldoc.core.PersistenceException Updates the document's rating with the votes average- Parameters:
readingId
- Identifier of the reading to confirmversion
- The version to confirm the readingtransaction
- session informations- Returns:
- the new / existing reading
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
findByDocIdAndUserId
List<ReadingRequest> findByDocIdAndUserId(long docId, long userId) throws com.logicaldoc.core.PersistenceException Finds the readings for the given user id and the given document id- 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
ReadingRequest findLastUnconfirmed(long docId, long userId) throws com.logicaldoc.core.PersistenceException Finds the last unconfirmed reading for the given user id and the given document id- 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
List<ReadingRequest> findUnconfirmedByUserId(long userId) throws com.logicaldoc.core.PersistenceException Finds all the unconfirmed readings of a user document id- 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
List<ReadingRequest> findByDocIdAndFileVersion(long docId, String fileVersion) throws com.logicaldoc.core.PersistenceException Finds the readings for the given fileVersion and the given document id- 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
ReadingRequest findByAlternateKey(long docId, long userId, long requestorId, String fileVersion) throws com.logicaldoc.core.PersistenceException Finds the readings for the alternate key: docId + userId + requestorId + fileVersion- 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
Finds the readings stored for the given document id- Parameters:
docId
- ID of the document- Returns:
- the list of ratings
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
countUnconfirmedReadings
long countUnconfirmedReadings(long userId) throws com.logicaldoc.core.PersistenceException Counts the number of unconfirmed readings- Parameters:
userId
- Identifier of the document- Returns:
- the total unconfirmed readings
- Throws:
com.logicaldoc.core.PersistenceException
- raised in case of database error
-
cleanOldRequests
void cleanOldRequests(int ttl) throws com.logicaldoc.core.PersistenceException This method deletes all the reading requests older than the given days from now. Ifttl
is 0 or -1, the deletion is not made.- 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
-