Class MoccaCalendarScriptService
java.lang.Object
org.xwiki.contrib.moccacalendar.script.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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.xpn.xwiki.api.ObjectcreateModificationDummy(com.xpn.xwiki.api.Document eventDoc, Date eventStartDate) Create a dummy modification object to be used as placeholder in edit view.List<org.xwiki.model.reference.DocumentReference>Get all calendars.List<org.xwiki.model.reference.DocumentReference>getAllCalendarsInDocumentSpace(org.xwiki.model.reference.DocumentReference targetDocumentReference) Get all calendars that are in the same space as the given document.Returns a map of all available event source names to their configuration classes.Returns a list of all available event source names, except for the default ones.Give the full name to a document to be used as a sheet to be used to display this event.getEventInstance(com.xpn.xwiki.api.Document eventDoc, Date eventStartDate) Create an event instance for the given date and document.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.intgetModifiedEventObjectIndex(com.xpn.xwiki.api.Document eventDoc, Date eventStartDate) Find modification data for an event instance, if the event instance has been modified.queryEvents(Date dateFrom, Date dateTo, String filter, String parentReference, boolean sortAscending) Queries events on the current wiki, seequeryEvents(Date, Date, String, String, String, boolean).queryEvents(Date dateFrom, Date dateTo, String filter, String wiki, String parentReference, boolean sortAscending) Get a list of events matching the date and filter criteria.queryEvents(Date dateFrom, Date dateTo, List<String> wikis, boolean sortAscending) Gets the union of events on a set of wikis.
-
Constructor Details
-
MoccaCalendarScriptService
public MoccaCalendarScriptService()
-
-
Method Details
-
getAllCalendars
Get all calendars.- Returns:
- a list of document references pointing to pages containing calendar objects.
-
getAllCalendarsInDocumentSpace
public List<org.xwiki.model.reference.DocumentReference> getAllCalendarsInDocumentSpace(org.xwiki.model.reference.DocumentReference targetDocumentReference) Get all calendars that are in the same space as the given document.- Parameters:
targetDocumentReference- the document relative to which to search for 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 parentReference, boolean sortAscending) throws org.xwiki.query.QueryException Queries events on the current wiki, seequeryEvents(Date, Date, String, String, String, boolean).- Throws:
org.xwiki.query.QueryException
-
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 rangedateTo- the end range; can be null. in that case dates form a single day are returnedfilter- how to filter the event. if null or "wiki" return all eventsparentReference- 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 startdateTo- the range end; can be null. in that case dates from a single day are returnedwikis- list of wiki identifiers where events should be searched forsortAscending- 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
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
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
Find modification data for an event instance, if the event instance has been modified.- Parameters:
eventDoc- the document of the recurrent eventeventStartDate- 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 eventeventStartDate- the start date of the eventsource- 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
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 eventeventStartDate- 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
-