Class CalendarEventOccurrence

  • All Implemented Interfaces:
    Serializable, Occurrence, Contribution, Plannable, WithPermanentLink, Instance<Contribution>, Nameable, IdentifiableEntity, WithReminder, Securable, SilverpeasResource

    @Entity
    public class CalendarEventOccurrence
    extends BasicJpaEntity<CalendarEventOccurrence,​ExternalStringIdentifier>
    implements IdentifiableEntity, Occurrence, Contribution, WithReminder, WithPermanentLink
    The occurrence of an event in a Silverpeas calendar. It is an instance of an event in the timeline of a calendar; it represents an event starting and ending at a given date or datetime in the calendar. A non-recurrent event is a singleton, meaning that is has only one single instance occurring in the calendar (so the name occurrence). A recurrent event has one or more occurrences in the timeline. It occurs several time in the calendar in a regular way according to its recurrence rule; at each time such an event occurs is represented by an occurrence. By default, the occurrences of an event aren't persisted, but they are generated from the period of time at which occurs the event and, if any, from its recurrence rule. If an occurrence of a non-recurrent event is deleted, then the related event is deleted. If an occurrence of a recurrent event is deleted, then an exception is added into the recurrence rule of the event. This operation is done with one of the following methods: delete(), deleteSinceMe(). If an occurrence of a non-recurrent event is modified, then the modification is directly applied to the event itself (as it is a singleton). If an occurrence of a recurrent event is modified, then the modification is applied to the occurrence only and this occurrence is persisted as a modification related to the recurrence rule of the concerned event.
    See Also:
    Serialized Form
    • Constructor Detail

      • CalendarEventOccurrence

        protected CalendarEventOccurrence()
        Constructor for only persistence context.
    • Method Detail

      • getBy

        public static Optional<CalendarEventOccurrence> getBy​(CalendarEvent event,
                                                              String occurrenceStartDate)
        Gets optionally an event occurrence from the specified data.
        Parameters:
        event - an event.
        occurrenceStartDate - a start date.
        Returns:
        the computed occurrence identifier.
      • getBy

        public static Optional<CalendarEventOccurrence> getBy​(CalendarEvent event,
                                                              Temporal occurrenceStartDate)
        Gets optionally an event occurrence from the specified data.
        Parameters:
        event - an event.
        occurrenceStartDate - a start date.
        Returns:
        the computed occurrence identifier.
      • getById

        public static Optional<CalendarEventOccurrence> getById​(String id)
        Gets optionally an event occurrence by its identifier.

        If the occurrence exists into the persistence, it is returned. Otherwise, it is generated.

        Otherwise and if start date is valid, the occurrence is generated.

        Parameters:
        id - the identifier of the aimed occurrence.
        Returns:
        an optional calendar event occurrence.
      • getLastUpdater

        public User getLastUpdater()
        Description copied from interface: SilverpeasResource
        Gets the user that has lastly updated the resource. If the resource doesn't have such an information, then this method should return the user that has created the resource.
        Specified by:
        getLastUpdater in interface SilverpeasResource
        Returns:
        a User in Silverpeas.
      • canBeAccessedBy

        public boolean canBeAccessedBy​(User user)
        Description copied from interface: Contribution
        Is the specified user can access this contribution?

        By default Securable.canBeAccessedBy(User) is implemented so that a user can access a contribution if it has enough rights to access the application instance in which is managed this contribution.
        Indeed, this behavior is mostly the common one.
        But In the case the application instance distributes its contribution along of a categorization tree and the nodes of this tree support access rights, then the user must have also the rights to access the node to which belongs the content.
        Of course it could exist other access rules...

        Specified by:
        canBeAccessedBy in interface Contribution
        Specified by:
        canBeAccessedBy in interface Securable
        Parameters:
        user - a user in Silverpeas.
        Returns:
        true if the user can access this content, false otherwise.
      • getContributionType

        public String getContributionType()
        Description copied from interface: Contribution
        Gets the type of this contribution. The type is a label that identifies uniquely a kind of contribution handled by a Silverpeas application. By default, this method returns the simple name of the class implementing this interface.
        Specified by:
        getContributionType in interface Contribution
        Returns:
        the label of the type of this contribution.
      • getCalendarEvent

        public CalendarEvent getCalendarEvent()
        Gets the event from which this occurrence was spawned. From the returned event, the title, the description or any other event properties can be modified. Nevertheless, the change can be effective only by invoking the update method of either the CalendarEvent to apply the modifications to all occurrences or this occurrence to apply the modifications only to this occurrence. Only the period at which the event occur in the calendar cannot be used to update this occurrence. For doing, please use either the setPeriod or the setDay method of CalendarEventOccurrence.
        Returns:
        the event from which this occurrence is instantiated.
      • getStartDate

        public Temporal getStartDate()
        Description copied from interface: Occurrence
        The start date or datetime of the occurrence. It is the inclusive lower bound of the period into which this occurrence occurs in a calendar. If this occurrence is on all days, then gets a date. Otherwise, gets a datetime in UTC/Greenwich. on the timeline.
        Specified by:
        getStartDate in interface Occurrence
        Returns:
        a temporal instance of LocalDate if the occurrence takes all the day or a temporal instance of OffsetDateTime in UTC/Greenwich otherwise.
      • getEndDate

        public Temporal getEndDate()
        Description copied from interface: Occurrence
        The end date or datetime of the occurrence. It is the exclusive upper bound of the period into which this occurrence occurs in a calendar. If this occurrence is on all days, then gets a date. Otherwise, gets a datetime in UTC/Greenwich.
        Specified by:
        getEndDate in interface Occurrence
        Returns:
        a temporal instance of LocalDate if the occurrence takes all the day or a temporal instance of OffsetDateTime in UTC/Greenwich otherwise.
      • getOriginalStartDate

        public Temporal getOriginalStartDate()
        Gets the original start date of this occurrence. If the start date wasn't modified, then the returning date should be the same as the start date returned by the method getStartDate().
        Returns:
        the original start date of this occurrence of calendar event.
      • setPeriod

        public void setPeriod​(Period newPeriod)
        Changes the planning of this occurrence in the calendar. The change will be effectively performed once the update method invoked.
        Specified by:
        setPeriod in interface Plannable
        Parameters:
        newPeriod - a new period of time on which this occurrence will occur or has actually occurred.
      • getPeriod

        public Period getPeriod()
        Gets the period of this occurrence in the calendar.
        Specified by:
        getPeriod in interface Plannable
        Returns:
        a period.
      • setDay

        public void setDay​(LocalDate newDay)
        Changes the planning of this occurrence in the calendar. The change will be effectively performed once the update method invoked.
        Parameters:
        newDay - the new day at which this occurrence will occur or has actually occurred.
      • getTitle

        public String getTitle()
        Gets the title of this event occurrence. The title is either the one of the related event or the one that was modified for this occurrence.
        Specified by:
        getTitle in interface Contribution
        Returns:
        the title of the event occurrence.
      • setTitle

        public void setTitle​(String title)
      • getDescription

        public String getDescription()
        Gets the description of this event occurrence. The description is either the one of the related event or the one that was modified for this occurrence.
        Specified by:
        getDescription in interface Contribution
        Specified by:
        getDescription in interface Nameable
        Returns:
        the description of the event occurrence.
      • setDescription

        public void setDescription​(String description)
        Sets a new description for this event occurrence.
        Parameters:
        description - a new description related to this event occurrence.
      • getLocation

        public String getLocation()
        Gets the location of this event occurrence. The location is either the one of the related event or the one that was modified for this occurrence.
        Returns:
        the location of the event occurrence.
      • setLocation

        public void setLocation​(String location)
        Sets a new location for this event occurrence.
        Parameters:
        location - the new location where this occurrence should take place.
      • getAttributes

        public AttributeSet getAttributes()
        Gets the attributes of this event occurrence. The attributes are either those related to the event or those that were modified for this occurrence.
        Returns:
        the extra attributes of the event occurrence.
      • getPriority

        public Priority getPriority()
        Gets the priority of this event occurrence. The priority is the one that is set for the event.
        Returns:
        the priority of the event occurrence.
      • setPriority

        public void setPriority​(Priority priority)
        Sets a new priority to this event occurrence.
        Parameters:
        priority - the new priority of this event occurrence.
      • getCategories

        public CategorySet getCategories()
        Gets the categories of this event occurrence. The categories are those that are set for the event.
        Returns:
        the categories of the event occurrence.
      • getVisibilityLevel

        public VisibilityLevel getVisibilityLevel()
        Gets the level of visibility of this event occurrence. The visibility level is the one that is set for the event.
        Returns:
        the level of visibility of the event occurrence.
      • isOnAllDay

        public boolean isOnAllDay()
        Is this event occurrence occurring on all the day(s)?
        Returns:
        true if this event occurrence is occurring on all its day(s).
      • getSequence

        public long getSequence()
        Gets the revision sequence number of this event occurrence within a sequence of revisions. Any changes to some properties of this event occurrence increment this sequence number. This number is mainly dedicated with the synchronization or syndication mechanism of event instances with external calendars. Its meaning comes from the icalendar specification.
        Returns:
        the sequence number of this event occurrence.
        See Also:
        CalendarComponent.getSequence()
      • getLastUpdateDate

        public Date getLastUpdateDate()
        Gets the last date at which this occurrence has been updated.
        Specified by:
        getLastUpdateDate in interface SilverpeasResource
        Returns:
        the last update date.
      • getContent

        public Optional<WysiwygContent> getContent()
        Gets the content of this event occurrence. The content is the one of the event, and it cannot be modified per occurrence but for the whole event occurrence(s).
        Returns:
        optionally the content of the event.
      • isBefore

        public boolean isBefore​(CalendarEventOccurrence occurrence)
        Is this occurrence actually occurs before the specified occurrence?
        Parameters:
        occurrence - another occurrence with which the start date is compared.
        Returns:
        true if this occurrence starts before the specified another one. False otherwise.
      • asCalendarComponent

        public CalendarComponent asCalendarComponent()
        Gets the CalendarComponent representation of this occurrence. Any change to the returned calendar component will change also the related occurrence.
        Returns:
        a CalendarComponent instance representing this event occurrence (without the specific properties related to an event occurrence).
      • updateSinceMe

        public CalendarEvent.EventOperationResult updateSinceMe()
        Updates this occurrence and all the forthcoming occurrences of the same event with the changes in this occurrence. If the event is non-recurrent, then the event is itself updated. Otherwise, a new event is created for this occurrence and for all the forthcoming occurrences with the modifications carried by this occurrence. The recurrence of the original event is updated to end up at this occurrence minus one day (the recurrence end date is inclusive). In the case the temporal period of the occurrences is modified, the participation status of all the attendees in the occurrences is cleared. This is equivalent to
        EventOperationResult result = event.updateSince(this)
        Returns:
        the result of the update.
        See Also:
        CalendarEvent.updateSince(CalendarEventOccurrence)
      • update

        public CalendarEvent.EventOperationResult update()
        Updates only this occurrence among the occurrences of the event it comes from. If the event is non-recurrent, then the event is itself updated. Otherwise, the changes in this occurrence are persisted and its sequence number is incremented by one, diverging then from the sequence number of the event it comes from.

        In the case the temporal period of the occurrence is modified, the participation status of all the attendees in this occurrence is cleared. This is equivalent to

        EventOperationResult result = event.updateOnly(this)
        Returns:
        the result of the update.
        See Also:
        CalendarEvent.updateOnly(CalendarEventOccurrence)
      • updateFrom

        public CalendarEvent.EventOperationResult updateFrom​(CalendarEventOccurrence occurrence)
        Updates this occurrence with the state of the specified occurrence.
        Parameters:
        occurrence - an event occurrence from which this occurrence will be updated.
        Returns:
        the result of the update.
      • deleteSinceMe

        public CalendarEvent.EventOperationResult deleteSinceMe()
        Deletes this occurrence and all the forthcoming occurrences of the same event. If the event is non-recurrent, then the event is itself deleted. Otherwise, the original starting date of this occurrence and of all the forthcoming occurrences are added in the exception dates of the event's recurrence rule. If some occurrences were persisted, then they are all removed from the persistence context. This is equivalent to
        EventOperationResult result = event.deleteSince(this)
        Returns:
        the result of the deletion.
        See Also:
        CalendarEvent.deleteSince(CalendarEventOccurrence)
      • delete

        public CalendarEvent.EventOperationResult delete()
        Deletes only this occurrence among the occurrences of the event it comes from. If the event is non-recurrent, then the event is itself deleted. Otherwise, the original starting date of this occurrence is added in the exception dates of the event's recurrence rule. If the occurrence was previously persisted, then it is removed from the persistence context. This is equivalent to
        EventOperationResult result = event.deleteOnly(this)
        Returns:
        the result of the deletion.
        See Also:
        CalendarEvent.deleteOnly(CalendarEventOccurrence)
      • isModifiedSince

        public boolean isModifiedSince​(CalendarEventOccurrence previous)
        Is the properties of this event occurrence was modified since its last specified state? The attendees in this event occurrence aren't taken into account as they aren't considered as a property of an event occurrence.
        Parameters:
        previous - a previous state of this event occurrence.
        Returns:
        true if the state of this event occurrence is different with the specified one.