com.tibbo.aggregate.common.dao

## Interface EventDao

- All Superinterfaces:
    Dao

      public interface EventDao
      extends Dao

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `EventWriter` | `createEventWriter(EventWriterConfiguration config)` Create a custom event writer.
    `void` | `createStorage(EventStorage storage, boolean update)` Register a new event storage and create it if necessary.
    `void` | `deleteEvent(java.lang.String context, java.lang.String name, long id)` Delete a single persistent event.
    `long` | `deleteEvents(java.lang.String context)` Delete all persistent events occurred in a certain context.
    `long` | `deleteEvents(java.lang.String context, java.lang.String name, java.util.Date startDate, java.util.Date endDate)` Delete all persistent events occurred in a certain context.
    `void` | `dropStorage(EventStorage storage)` Remove an event storage.
    `Event` | `getEvent(Context context, EventDefinition event, long id)` Load a single event.
    `java.util.Iterator<Event>` | `getEvents(ContextManager cm, CallerController caller, EntityList eventList, EventsFilter filter, java.util.Date startDate, java.util.Date endDate, java.lang.Integer maxResults, java.lang.String sortBy, boolean sortAscending, java.lang.Object... additionalCriteria)` Load selected events from the storage.
    `DataTable` | `getStatistics()` Returns usage statistics table.
    `long` | `moveEvents(java.lang.String oldContext, java.lang.String newContext)` Reassociate persistent events with a new context path.
    `void` | `postEvent(EventDefinition ed, Event event)` Persistently save a single event.
    `void` | `postEvents(EventStorage storage, EventDefinition ed, java.util.List<Event> events)` Persistently save several events.
    `int` | `removeExpiredEvents()` Causes event DAO to delete all expired events from all storages.
    `void` | `updateEvent(Event event, EventDefinition def)` Update a previously saved persistent event.

    - ### Methods inherited from interface com.tibbo.aggregate.common.dao.Dao

      `isManaged, shutdown`

- - ### Method Detail

    - #### createStorage

          void createStorage(EventStorage storage,
                             boolean update)
                      throws DaoException

      Register a new event storage and create it if necessary.
      Parameters:
        `storage` - A storage to register
        `update` - Requests storage schema update
      Throws:
        `DaoException` - If registration or creation has failed

    - #### dropStorage

          void dropStorage(EventStorage storage)
                    throws DaoException

      Remove an event storage.
      Parameters:
        `storage` - A storage to remove
      Throws:
        `DaoException` - If removal has failed

    - #### postEvent

          void postEvent(EventDefinition ed,
                         Event event)
                  throws DaoException

      Persistently save a single event.
      Parameters:
        `ed` - A definition of the event
        `event` - An event to be saved persistently
      Throws:
        `DaoException` - If saving has failed

    - #### postEvents

          void postEvents(EventStorage storage,
                          EventDefinition ed,
                          java.util.List<Event> events)
                   throws DaoException

      Persistently save several events.
      Parameters:
        `storage` - A storage to save events to
        `events` - List of events to be saved persistently
      Throws:
        `DaoException` - If saving has failed

    - #### getEvents

          java.util.Iterator<Event> getEvents(ContextManager cm,
                                              CallerController caller,
                                              EntityList eventList,
                                              EventsFilter filter,
                                              java.util.Date startDate,
                                              java.util.Date endDate,
                                              java.lang.Integer maxResults,
                                              java.lang.String sortBy,
                                              boolean sortAscending,
                                              java.lang.Object... additionalCriteria)
                                       throws DaoException

      Load selected events from the storage.
      Parameters:
        `cm` - Context manager of the context tree the events are defined in
        `caller` - Caller controller used for event filtering
        `eventList` - List of events to load
        `filter` - A filter to be applied to events after loading
        `startDate` - Only events that occurred after this date will be loaded
        `endDate` - Only events that occurred before this date will be loaded
        `maxResults` - Maximum number of events to load
        `sortBy` - Name of field that will be used to compare events while sorting
        `sortAscending` - True if events should be sorted in ascending order and false otherwise
        `additionalCriteria` - Additional storage-level filtering criteria
      Returns:
        An iterator of loaded events
      Throws:
        `DaoException` - If loading has failed

    - #### removeExpiredEvents

          int removeExpiredEvents()
                           throws DaoException

      Causes event DAO to delete all expired events from all storages.
      Returns:
        Number of events deleted
      Throws:
        `DaoException` - If cleaning has failed

    - #### getEvent

          Event getEvent(Context context,
                         EventDefinition event,
                         long id)
                  throws DaoException

      Load a single event.
      Parameters:
        `context` - Context the event has occurred in
        `event` - Definition of the event
        `id` - Unique ID of the event
      Returns:
        An instance of loaded event or null if event does not exist
      Throws:
        `DaoException` - If loading has failed

    - #### deleteEvent

          void deleteEvent(java.lang.String context,
                           java.lang.String name,
                           long id)
                    throws DaoException

      Delete a single persistent event.
      Parameters:
        `context` - Context the event has occurred in
        `name` - Name of the event
        `id` - Unique ID of the event
      Throws:
        `DaoException` - If removal has failed

    - #### deleteEvents

          long deleteEvents(java.lang.String context)
                     throws DaoException

      Delete all persistent events occurred in a certain context.
      Parameters:
        `context` - Context the events has occurred in
      Returns:
        Number of events deleted
      Throws:
        `DaoException` - If removal has failed

    - #### deleteEvents

          long deleteEvents(java.lang.String context,
                            java.lang.String name,
                            java.util.Date startDate,
                            java.util.Date endDate)
                     throws DaoException

      Delete all persistent events occurred in a certain context.
      Parameters:
        `context` - Context the events has occurred in
        `name` - Name of the event
        `startDate` - Only events that occurred after this date will be loaded
        `endDate` - Only events that occurred before this date will be loaded
      Returns:
        Number of events deleted
      Throws:
        `DaoException` - If removal has failed

    - #### updateEvent

          void updateEvent(Event event,
                           EventDefinition def)
                    throws DaoException

      Update a previously saved persistent event.
      Parameters:
        `event` - An updated instance of the event
        `def` - Definition of the event
      Throws:
        `DaoException` - If updating has failed

    - #### moveEvents

          long moveEvents(java.lang.String oldContext,
                          java.lang.String newContext)
                   throws DaoException

      Reassociate persistent events with a new context path.
      Parameters:
        `oldContext` - Context path of the events to reassociate
        `newContext` - Context path the events will be associated with
      Returns:
        Number of events moved
      Throws:
        `DaoException` - If reassociation has failed

    - #### createEventWriter

          EventWriter createEventWriter(EventWriterConfiguration config)
                                 throws DaoException

      Create a custom event writer.
      Parameters:
        `config` - Configuration of the writes
      Returns:
        An instance of custom event writer of null if creating a writer with provided configuration is not possible
      Throws:
        `DaoException` - If writer creation has failed

    - #### getStatistics

          DataTable getStatistics()

      Returns usage statistics table.