Class HibernateEventDAO

  • All Implemented Interfaces:
    EventDAO, com.logicaldoc.core.PersistentObjectDAO<Event>

    public class HibernateEventDAO
    extends com.logicaldoc.core.HibernatePersistentObjectDAO<Event>
    implements EventDAO
    Hibernate implementation of the EventDAO.
    Since:
    6.7
    Author:
    Marco Meschieri - LogicalDOC
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int cleanOldEvents​(int ttl)
      This method deletes all the events oldest than the given days from now.
      List<Long> createOccurrences​(Event master, Date start, Date end)
      This will create all the occurrences of a recurrent master event in a given time range.
      Attention: the collections are not propagated.
      boolean delete​(long id, int code)  
      int deleteOccurrences​(long parentId, boolean remindedOnly)
      Deletes all the occurrences of a given event, but not the event itelf.
      List<Event> find​(Date startDate, Date endDate, Date deadLineFrom, Date deadLineTo, Integer frequency, String title, String type, String subtype, Integer status, Long tenantId, Integer maxRecords)
      Finder method for events.
      List<Event> findByParticipant​(long participantId, Date startDate)
      Retrieves the events associated to the given participant
      List<Long> findIdsByParticipantAndDocument​(Long participantId, Long documentId, Date startDate, Date endDate)
      Retrieves the identifiers of the events that have a given participant.
      List<Long> findIdsToNotify​(Date actualDate)
      Finds all the events that needs to be notified.
      List<Event> findOccurrences​(long masterId, Date begin, Date end)
      Retrieves the occurrences of a master event
      void initialize​(Event event)  
      boolean store​(Event event)  
      int updateOccurrences​(Event master)
      This will update all existing occurrences with the master's properties.
      • Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO

        bulkUpdate, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, getSessionFactory, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString, setSessionFactory
      • Methods inherited from interface com.logicaldoc.core.PersistentObjectDAO

        bulkUpdate, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString
    • Method Detail

      • findByParticipant

        public List<Event> findByParticipant​(long participantId,
                                             Date startDate)
        Description copied from interface: EventDAO
        Retrieves the events associated to the given participant
        Specified by:
        findByParticipant in interface EventDAO
        Parameters:
        participantId - The id of one or the participant
        startDate - oldest date for the events
        Returns:
        list of vents ordered by startDate asc
      • find

        public List<Event> find​(Date startDate,
                                Date endDate,
                                Date deadLineFrom,
                                Date deadLineTo,
                                Integer frequency,
                                String title,
                                String type,
                                String subtype,
                                Integer status,
                                Long tenantId,
                                Integer maxRecords)
        Description copied from interface: EventDAO
        Finder method for events.
        Specified by:
        find in interface EventDAO
        Parameters:
        startDate - Start date (optional)
        endDate - End date (optional)
        deadLineFrom - (optional)
        deadLineTo - (optional)
        frequency - The frequency of the event (1,15, 30 ... optional)
        title - The title (used with like operator, optional)
        type - The type (used with like operator, optional)
        subtype - The subtype (used with like operator, optional)
        status - The status of the events to find (optional)
        tenantId - identifier of the tenant (optional)
        maxRecords - Maximum number of records (optional)
        Returns:
        The list of events ordered by ascending date
      • findIdsByParticipantAndDocument

        public List<Long> findIdsByParticipantAndDocument​(Long participantId,
                                                          Long documentId,
                                                          Date startDate,
                                                          Date endDate)
        Description copied from interface: EventDAO
        Retrieves the identifiers of the events that have a given participant.
        Specified by:
        findIdsByParticipantAndDocument in interface EventDAO
        Parameters:
        participantId - The id of one or the participant
        documentId - The id of one of the documents
        startDate - oldest date for the event
        endDate - latest date for the event
        Returns:
        list of event Ids
      • initialize

        public void initialize​(Event event)
        Specified by:
        initialize in interface com.logicaldoc.core.PersistentObjectDAO<Event>
        Overrides:
        initialize in class com.logicaldoc.core.HibernatePersistentObjectDAO<Event>
      • store

        public boolean store​(Event event)
                      throws com.logicaldoc.core.PersistenceException
        Specified by:
        store in interface com.logicaldoc.core.PersistentObjectDAO<Event>
        Overrides:
        store in class com.logicaldoc.core.HibernatePersistentObjectDAO<Event>
        Throws:
        com.logicaldoc.core.PersistenceException
      • updateOccurrences

        public int updateOccurrences​(Event master)
                              throws com.logicaldoc.core.PersistenceException
        Description copied from interface: EventDAO
        This will update all existing occurrences with the master's properties.
        Attention: the collections are not propagated nor the timing attributes.
        Specified by:
        updateOccurrences in interface EventDAO
        Parameters:
        master - The parent event
        Returns:
        The number of updated records
        Throws:
        com.logicaldoc.core.PersistenceException - error in the database
      • createOccurrences

        public List<Long> createOccurrences​(Event master,
                                            Date start,
                                            Date end)
                                     throws com.logicaldoc.core.PersistenceException
        Description copied from interface: EventDAO
        This will create all the occurrences of a recurrent master event in a given time range.
        Attention: the collections are not propagated. All already reminded occurrences are left untouched.
        Specified by:
        createOccurrences in interface EventDAO
        Parameters:
        master - The starting point event
        start - Oldest date, optional
        end - Latest date, mandatory
        Returns:
        The list of ids of the newly created events
        Throws:
        com.logicaldoc.core.PersistenceException - error in the database
      • deleteOccurrences

        public int deleteOccurrences​(long parentId,
                                     boolean remindedOnly)
                              throws com.logicaldoc.core.PersistenceException
        Description copied from interface: EventDAO
        Deletes all the occurrences of a given event, but not the event itelf.
        Specified by:
        deleteOccurrences in interface EventDAO
        Parameters:
        parentId - identifier of the parent event
        remindedOnly - Delete the reminded occurrences only
        Returns:
        Number of deleted events
        Throws:
        com.logicaldoc.core.PersistenceException - error in the database
      • delete

        public boolean delete​(long id,
                              int code)
                       throws com.logicaldoc.core.PersistenceException
        Specified by:
        delete in interface com.logicaldoc.core.PersistentObjectDAO<Event>
        Overrides:
        delete in class com.logicaldoc.core.HibernatePersistentObjectDAO<Event>
        Throws:
        com.logicaldoc.core.PersistenceException
      • findOccurrences

        public List<Event> findOccurrences​(long masterId,
                                           Date begin,
                                           Date end)
        Description copied from interface: EventDAO
        Retrieves the occurrences of a master event
        Specified by:
        findOccurrences in interface EventDAO
        Parameters:
        masterId - identifier of the master event
        begin - Oldest date, optional
        end - Latest date, optional
        Returns:
        list of events ordered by startDate asc
      • findIdsToNotify

        public List<Long> findIdsToNotify​(Date actualDate)
        Description copied from interface: EventDAO
        Finds all the events that needs to be notified. The events older than one month(the start date older than one month ago) will be discarded.
        Specified by:
        findIdsToNotify in interface EventDAO
        Parameters:
        actualDate - actual date to consider, if null the current date will be used
        Returns:
        List of ids to be notified
      • cleanOldEvents

        public int cleanOldEvents​(int ttl)
        Description copied from interface: EventDAO
        This method deletes all the events oldest than the given days from now. If ttl is 0 or -1, the cancellation is not made.
        Attention: Master events with a frequency will not be deleted.
        Specified by:
        cleanOldEvents in interface EventDAO
        Parameters:
        ttl - The maximum number of days over which the event is considered old
        Returns:
        Number of deleted events