Class EventDAO
- All Implemented Interfaces:
org.exoplatform.commons.api.persistence.GenericDAO<EventEntity, Long>
-
Field Summary
Fields inherited from class org.exoplatform.commons.persistence.impl.GenericDAOJPAImpl
modelClass -
Constructor Summary
ConstructorsConstructorDescriptionEventDAO(EventConferenceDAO eventConferenceDAO, EventAttendeeDAO eventAttendeeDAO, EventReminderDAO eventReminderDAO, EventRecurrenceDAO eventRecurrenceDAO, RemoteEventDAO remoteEventDAO, EventDateOptionDAO dateOptionDAO, EventDatePollDAO datePollDAO) -
Method Summary
Modifier and TypeMethodDescriptioncountEventDatePolls(List<Long> attendeeIds, Date fromDate) countPendingEvents(Long userIdentityId, List<Long> attendeeIds, List<Long> calenderIds, Date fromDate) longcountPendingEventsByOwnerIds(Long userIdentityId, List<Long> ownerIds, List<Long> attendeeIds, Date fromDate) create(EventEntity entity) voiddelete(EventEntity entity) voidvoiddeleteCalendarEvents(long calendarId) deleteEvent(long eventId) deleteEventAfterRead(long eventId) Deletes an event whose attendees, conferences or reminders may have been read through this persistence context.voiddeleteExceptionalOccurences(long parentRecurrentEventId) voidDetaches every entity the thread's persistence context holds, after writing out what a running transaction has not flushed yet, so the next reads and deletes start from what the database holds.voidexecuteDeleteCalendarEventsQuery(long calendarId) voidWrites the pending changes of the thread's persistence context, then detaches every entity it holds, so that the next read loads its rows afresh.getCapacityReachedDate(long eventId) Reads when an event row's pool was marked as having reached its capacity, as the database holds it, not as an entity of the persistence context holds it.getEventDatePollIds(Long userIdentityId, List<Long> attendeeIds, Date fromDate, int offset, int limit) getEventDatePollIdsByOwnerIds(Long userIdentityId, List<Long> ownerIds, List<Long> attendeeIds, Date fromDate, int offset, int limit) getEventDatePollIdsByOwnerIds(Long userIdentityId, List<Long> ownerIds, List<Long> attendeeIds, Date start, Date end) getEventIds(Date startDate, Date endDate, List<Long> ownerIds, List<Long> attendeeIds, List<org.exoplatform.agenda.constant.EventAttendeeResponse> responseTypes, List<Long> excludedCalendarIds, int limit) Retrieves the identifiers of the events matching a period and the given owner, attendee and response criteria.getEventIds(Date startDate, Date endDate, List<Long> ownerIds, List<Long> attendeeIds, List<org.exoplatform.agenda.constant.EventAttendeeResponse> responseTypes, List<Long> excludedCalendarIds, List<Long> calendarIds, int limit) Retrieves the identifiers of the events matching a period and the given owner, attendee and response criteria, plus the events of some calendars whatever those criteria say (EXO-90357).getExceptionalOccurenceIds(long parentRecurrentEventId) getExceptionalOccurenceIdsByPeriod(long parentRecurrentEventId, Date startDate, Date endDate) getExceptionalOccurences(long parentRecurrentEventId) Reads the exceptional occurrences of a recurrent event in one statement, ordered by start date, with their recurrence fetched.getParentRecurrentEventIds(Date startDate, Date endDate) getPendingEventIds(Long userIdentityId, List<Long> attendeeIds, List<Long> calenderIds, Date fromDate, int offset, int limit) getPendingEventIdsByOwnerIds(Long userIdentityId, List<Long> ownerIds, List<Long> attendeeIds, Date fromDate, int offset, int limit) getUserEventCalenderIds(Long userIdentityId) booleanlockEvent(long eventId) Locks an event row with a pessimistic write lock (SELECT … FOR UPDATE), held until the current transaction ends.moveCalendarEvents(long fromCalendarId, long toCalendarId) Moves all events of a calendar to another calendar in a single bulk update, keeping every event row (and its attendees, reminders, conferences, recurrences and remote identifiers) untouched apart from its calendar membership.voidsaveCapacityReachedDate(long eventId, Date capacityReachedDate) Writes when an event row's pool was marked as having reached its capacity, and nothing else of the row: the one update of a column a save of the whole row leaves as it is.update(EventEntity entity) voidupdateAll(List<EventEntity> entities) Methods inherited from class org.exoplatform.commons.persistence.impl.GenericDAOJPAImpl
count, createAll, deleteAll, find, findAll, getEntityManager, getHibernateDialect, isMSSQLDialect, isOrcaleDialect
-
Constructor Details
-
EventDAO
public EventDAO(EventConferenceDAO eventConferenceDAO, EventAttendeeDAO eventAttendeeDAO, EventReminderDAO eventReminderDAO, EventRecurrenceDAO eventRecurrenceDAO, RemoteEventDAO remoteEventDAO, EventDateOptionDAO dateOptionDAO, EventDatePollDAO datePollDAO)
-
-
Method Details
-
delete
- Specified by:
deletein interfaceorg.exoplatform.commons.api.persistence.GenericDAO<EventEntity, Long>- Overrides:
deletein classorg.exoplatform.commons.persistence.impl.GenericDAOJPAImpl<EventEntity, Long>
-
deleteCalendarEvents
public void deleteCalendarEvents(long calendarId) -
moveCalendarEvents
Moves all events of a calendar to another calendar in a single bulk update, keeping every event row (and its attendees, reminders, conferences, recurrences and remote identifiers) untouched apart from its calendar membership.- Parameters:
fromCalendarId- technical identifier of the calendar the events are moved away fromtoCalendarId- technical identifier of the calendar receiving the events- Returns:
Listof technical identifiers of the moved events, empty when the source calendar had no events
-
deleteEventAfterRead
Deletes an event whose attendees, conferences or reminders may have been read through this persistence context. They are deleted in bulk, which leaves such instances managed and pointing at a removed event when the context is flushed, so the pending changes are flushed and the context cleared first. The clear detaches every entity the persistence context holds, not only this event's children: a caller must not keep a managed entity across this call and rely on dirty checking or on a lazy collection of it afterwards.- Parameters:
eventId- the event to delete- Returns:
- the deleted entity, null when there was none
-
deleteEvent
-
create
- Specified by:
createin interfaceorg.exoplatform.commons.api.persistence.GenericDAO<EventEntity, Long>- Overrides:
createin classorg.exoplatform.commons.persistence.impl.GenericDAOJPAImpl<EventEntity, Long>
-
update
- Specified by:
updatein interfaceorg.exoplatform.commons.api.persistence.GenericDAO<EventEntity, Long>- Overrides:
updatein classorg.exoplatform.commons.persistence.impl.GenericDAOJPAImpl<EventEntity, Long>
-
deleteAll
public void deleteAll()- Specified by:
deleteAllin interfaceorg.exoplatform.commons.api.persistence.GenericDAO<EventEntity, Long>- Overrides:
deleteAllin classorg.exoplatform.commons.persistence.impl.GenericDAOJPAImpl<EventEntity, Long>
-
updateAll
- Specified by:
updateAllin interfaceorg.exoplatform.commons.api.persistence.GenericDAO<EventEntity, Long>- Overrides:
updateAllin classorg.exoplatform.commons.persistence.impl.GenericDAOJPAImpl<EventEntity, Long>
-
executeDeleteCalendarEventsQuery
public void executeDeleteCalendarEventsQuery(long calendarId) -
getEventIds
public List<Long> getEventIds(Date startDate, Date endDate, List<Long> ownerIds, List<Long> attendeeIds, List<org.exoplatform.agenda.constant.EventAttendeeResponse> responseTypes, List<Long> excludedCalendarIds, int limit) Retrieves the identifiers of the events matching a period and the given owner, attendee and response criteria.- Parameters:
startDate- beginning of the period, mandatoryendDate- end of the period,nullfor an open periodownerIds- identity identifiers of the calendar owners to keep, empty ornullto keep every ownerattendeeIds- identity identifiers to filter on attendees, empty ornullto ignore attendeesresponseTypes- attendee responses to keep, only used together withattendeeIdsexcludedCalendarIds- technical identifiers of the calendars whose events must be left out, whatever the owner criteria kept; empty ornullto exclude nothinglimit- maximum number of identifiers to return, 0 for no limit- Returns:
Listof matching event technical identifiers
-
getEventIds
public List<Long> getEventIds(Date startDate, Date endDate, List<Long> ownerIds, List<Long> attendeeIds, List<org.exoplatform.agenda.constant.EventAttendeeResponse> responseTypes, List<Long> excludedCalendarIds, List<Long> calendarIds, int limit) Retrieves the identifiers of the events matching a period and the given owner, attendee and response criteria, plus the events of some calendars whatever those criteria say (EXO-90357).One statement. The owner and attendee criteria form one conjunction, the listed calendars are or-ed with it: an event is kept when it matches the criteria, or when its calendar is listed. The attendee join becomes an outer one when calendars are listed, since an event of a shared calendar has no attendee row for the reader;
DISTINCTkeeps an event with several attendee rows once. The exclusion still applies to everything.- Parameters:
startDate- beginning of the period, mandatoryendDate- end of the period,nullfor an open periodownerIds- identity identifiers of the calendar owners to keep, empty ornullto keep every ownerattendeeIds- identity identifiers to filter on attendees, empty ornullto ignore attendeesresponseTypes- attendee responses to keep, only used together withattendeeIdsexcludedCalendarIds- technical identifiers of the calendars whose events must be left out, whatever else keeps themcalendarIds- technical identifiers of the calendars whose events are kept whatever the owner and attendee criteria say; empty ornullfor nonelimit- maximum number of identifiers to return, 0 for no limit- Returns:
Listof matching event technical identifiers
-
getUserEventCalenderIds
-
getPendingEventIds
-
countPendingEvents
-
getPendingEventIdsByOwnerIds
-
countPendingEventsByOwnerIds
-
getEventDatePollIds
-
getEventDatePollIds
-
countEventDatePolls
-
getEventDatePollIdsByOwnerIds
-
getEventDatePollIdsByOwnerIds
-
countEventDatePollsByOwnerIds
-
getParentRecurrentEventIds
-
getExceptionalOccurenceIdsByPeriod
-
getExceptionalOccurenceIds
-
detachAll
public void detachAll()Detaches every entity the thread's persistence context holds, after writing out what a running transaction has not flushed yet, so the next reads and deletes start from what the database holds. A bulk delete, as the attendee and reminder ones are, leaves the entities it removes managed: once an event was saved in the same context (agenda's reminder listener materialising a series' next days, say), deleting it fails at the flush on its attendee rows still referencing it. Nothing is lost: outside a transaction every write was already committed, and inside one it is flushed first. A caller that keeps a managed entity and uses it afterwards must reload it. -
getExceptionalOccurences
Reads the exceptional occurrences of a recurrent event in one statement, ordered by start date, with their recurrence fetched.- Parameters:
parentRecurrentEventId- a parent recurrent event technical identifier- Returns:
Listof its exceptional occurrence rows
-
lockEvent
public boolean lockEvent(long eventId) Locks an event row with a pessimistic write lock (SELECT … FOR UPDATE), held until the current transaction ends. It requires an active transaction, and every lock of the transaction must come before its first plain read: on MySQL and MariaDB, a plain read fixes the snapshot the following reads see. So it reads the row's identifier only, and loads no entity whose eager associations would be read right after it.No lock timeout is set: a transaction asking for a locked row, on a request thread or in the
@AsynchronousContentAgendaEventSyncListener, waits until the holder's transaction ends. The holder's decide step is the intended bound: it holds the lock for its own reads and writes, and publishes its broadcasts and notifications after the commit, but for the metadata broadcast social makes while the event's properties are saved. Past it, the database's own limit applies: InnoDB fails the waiting statement afterinnodb_lock_wait_timeout, 50 seconds by default; PostgreSQL waits as long aslock_timeoutallows, without limit by default.- Parameters:
eventId- event technical identifier- Returns:
- whether the row exists, and so is locked
-
getCapacityReachedDate
Reads when an event row's pool was marked as having reached its capacity, as the database holds it, not as an entity of the persistence context holds it. The changes of the persistence context are written first: on MySQL and MariaDB, whose plain reads see the snapshot of the transaction's first read, a row this transaction has updated is read with the mark last committed.- Parameters:
eventId- event technical identifier- Returns:
- the instant, or null when the row is not marked or does not exist
-
saveCapacityReachedDate
Writes when an event row's pool was marked as having reached its capacity, and nothing else of the row: the one update of a column a save of the whole row leaves as it is. It requires an active transaction: the mark is written under the event lock a decide step holds, never in a transaction of its own.- Parameters:
eventId- event technical identifiercapacityReachedDate- the instant, or null to clear the mark
-
flushAndClear
public void flushAndClear()Writes the pending changes of the thread's persistence context, then detaches every entity it holds, so that the next read loads its rows afresh. -
deleteExceptionalOccurences
public void deleteExceptionalOccurences(long parentRecurrentEventId)
-