Class MoccaCalendarScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Named("moccacalendar")
    @Singleton
    @Component
    public class MoccaCalendarScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Script service to obtain information about calendars and event instances.
    Since:
    2.7
    Version:
    $Id: $
    • Constructor Detail

      • MoccaCalendarScriptService

        public MoccaCalendarScriptService()
    • Method Detail

      • getAllCalendars

        public List<org.xwiki.model.reference.DocumentReference> getAllCalendars()
        Get all calendars.
        Returns:
        a list of document references pointing to pages containing calendar objects.
      • queryEvents

        public List<EventInstance> queryEvents​(Date dateFrom,
                                               Date dateTo,
                                               String filter,
                                               String wiki,
                                               String parentReference,
                                               boolean sortAscending)
                                        throws org.xwiki.query.QueryException
        Get a list of events matching the date and filter criteria.
        Parameters:
        dateFrom - the start range
        dateTo - the end range; can be null. in that case dates form a single day are returned
        filter - how to filter the event. if null or "wiki" return all events
        parentReference - the page reference to use for the filter. can be null if filter is null or "wiki".
        sortAscending - if true, sort events ascending by start date, else descending
        Returns:
        a list of event instances matching the criteria; might be empty but never null
        Throws:
        org.xwiki.query.QueryException - if an error occurs while fetching the events
      • queryEvents

        public List<EventInstance> queryEvents​(Date dateFrom,
                                               Date dateTo,
                                               List<String> wikis,
                                               boolean sortAscending)
                                        throws org.xwiki.query.QueryException
        Gets the union of events on a set of wikis.
        Parameters:
        dateFrom - the range start
        dateTo - the range end; can be null. in that case dates from a single day are returned
        wikis - list of wiki identifiers where events should be searched for
        sortAscending - if true, sort events ascending by start date, else descending
        Returns:
        a list of event instances matching the criteria; might be empty but never null
        Throws:
        org.xwiki.query.QueryException
      • getDisplaySheetForEvent

        public String getDisplaySheetForEvent​(EventInstance event)
        Give the full name to a document to be used as a sheet to be used to display this event. If the event needs no special sheet, return null.
        Parameters:
        event - the event instance to be displayed
        Returns:
        the full name of a document sheet or null
      • getAvailableSources

        public List<String> getAvailableSources()
        Returns a list of all available event source names, except for the default ones.
        Returns:
        a list of strings, not null
      • getAvailableSourceConfigurations

        public Map<String,​org.xwiki.model.reference.LocalDocumentReference> getAvailableSourceConfigurations()
        Returns a map of all available event source names to their configuration classes.
        Returns:
        a map of strings to class references, not null
      • getModifiedEventObjectIndex

        public int getModifiedEventObjectIndex​(com.xpn.xwiki.api.Document eventDoc,
                                               Date eventStartDate)
        Find modification data for an event instance, if the event instance has been modified.
        Parameters:
        eventDoc - the document of the recurrent event
        eventStartDate - the original start date of the event instance
        Returns:
        the index of a MoccaCalendarEventModificationClass object for the event instance, or -1 if no modification has been found for the event instance
      • createModificationDummy

        public com.xpn.xwiki.api.Object createModificationDummy​(com.xpn.xwiki.api.Document eventDoc,
                                                                Date eventStartDate)
        Create a dummy modification object to be used as placeholder in edit view.
        Parameters:
        eventDoc - the document containing the (recurrent) event to be modified.
        eventStartDate - the original start date of the unmodified event instance
        Returns:
        a non-persistent event modification object containing default values
      • getEventInstance

        public EventInstance getEventInstance​(com.xpn.xwiki.api.Document eventDoc,
                                              Date eventStartDate,
                                              String source)
        Create an event instance for the given date and document from the given source. If the document contains only information about one event, then the start date can be ignored. If there is no matching information that the source can use to create an event from the document, then return null.
        Parameters:
        eventDoc - the document storing the event
        eventStartDate - the start date of the event
        source - the source which has generated the event, can be null.
        Returns:
        the event instance matching the arguments, or null if no match as been found.
      • getEventInstance

        public EventInstance getEventInstance​(com.xpn.xwiki.api.Document eventDoc,
                                              Date eventStartDate)
        Create an event instance for the given date and document. If the event instance has been modified, update the event instance with the modifications. this methods does not take deletion marks into account, but always returns an event instance.
        Parameters:
        eventDoc - the document of the recurrent event
        eventStartDate - the original start date of the event instance (might be null for the unaltered event)
        Returns:
        the EventInstance with the (possibly modified) values of the event