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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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 average
    long
    Counts the number of unconfirmed readings
    findByAlternateKey(long docId, long userId, long requestorId, String fileVersion)
    Finds the readings for the alternate key: docId + userId + requestorId + fileVersion
    findByDocId(long docId)
    Finds the readings stored for the given document id
    findByDocIdAndFileVersion(long docId, String fileVersion)
    Finds the readings for the given fileVersion and the given document id
    findByDocIdAndUserId(long docId, long userId)
    Finds the readings for the given user id and the given document id
    findLastUnconfirmed(long docId, long userId)
    Finds the last unconfirmed reading for the given user id and the given document id
    Finds all the unconfirmed readings of a user document id
    void
    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 history

    Methods 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 interface ReadingRequestDAO
      Parameters:
      reading - the rating
      transaction - 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 interface ReadingRequestDAO
      Parameters:
      readings - the reading requests to notify
      transaction - current session
      Throws:
      com.logicaldoc.core.PersistenceException - error at data layer
      javax.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 interface ReadingRequestDAO
      Parameters:
      readingId - Identifier of the reading to confirm
      version - The version to confirm the reading
      history - 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 interface ReadingRequestDAO
      Parameters:
      docId - ID of the document
      userId - 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 interface ReadingRequestDAO
      Parameters:
      docId - ID of the document
      userId - 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 interface ReadingRequestDAO
      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 interface ReadingRequestDAO
      Parameters:
      docId - ID of the document
      fileVersion - 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 interface ReadingRequestDAO
      Parameters:
      docId - ID of the document
      userId - identifier of the recipient user
      requestorId - identifier of the requestor user
      fileVersion - 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

      public List<ReadingRequest> findByDocId(long docId) throws com.logicaldoc.core.PersistenceException
      Description copied from interface: ReadingRequestDAO
      Finds the readings stored for the given document id
      Specified by:
      findByDocId in interface ReadingRequestDAO
      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 interface ReadingRequestDAO
      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. If ttl is 0 or -1, the deletion is not made.
      Specified by:
      cleanOldRequests in interface ReadingRequestDAO
      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