Class CalendarWorkspaceModule
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.workspaces.AbstractWorkspaceModule
-
- org.ametys.plugins.workspaces.calendars.CalendarWorkspaceModule
-
- All Implemented Interfaces:
WorkspaceModule,LogEnabled,PluginAware,Contextualizable,Serviceable
public class CalendarWorkspaceModule extends AbstractWorkspaceModule
Helper component for managing calendars
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classCalendarWorkspaceModule.StartDateComparatorCompares events on their starting date
-
Field Summary
Fields Modifier and Type Field Description private static String__CALENDAR_CACHE_REQUEST_ATTRprivate static String__CALENDAR_MODULE_TAGTag on the main page holding the calendar moduleprivate static String__MODULE_TITLE_KEYModule i18n title keyprivate static String__WORKSPACES_CALENDARS_NODE_NAMEWorkspaces calendars node nameprivate WorkspaceCalendarDAO_calendarDAOstatic StringCALENDAR_MODULE_IDThe id of calendar module-
Fields inherited from class org.ametys.plugins.workspaces.AbstractWorkspaceModule
_context, _currentUserProvider, _i18nUtils, _observationManager, _pageDAO, _pluginName, _projectManager, _projectRightHelper, _resolver, _rightManager, _serviceEP, _skinsManager, _userHelper, _userManager
-
-
Constructor Summary
Constructors Constructor Description CalendarWorkspaceModule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_addAdditionalEventData(CalendarEvent event, Map<String,Object> eventData)Add additional information on project and parent calendarprivate boolean_filterEvent(List<String> calendarIds, CalendarEvent event)Determine whether the given event has to be kept or not depending on the given calendarsprivate boolean_hasAccess(Calendar calendar)Map<String,Object>addCalendar(String inputName, String description, String templateDesc, String color, String visibility, String workflowName, Boolean renameIfExists)Add a calendarbooleancanView(Calendar calendar)Indicates if the current user can view the calendarbooleancanView(CalendarEvent event)Indicates if the current user can view the eventSet<String>getAllowedEventTypes()Get the set of allowed event type for the moduleAmetysObjectIterable<Calendar>getCalendars(Project project)Get the calendars of a projectList<Map<String,Object>>getCalendarsData()Get the data of every available calendar of the applicationMap<String,Object>getCalendarServiceRights(List<String> calendarIds)Get the rights of the current user for the calendar serviceStringgetEventUri(Project project, String calendarId, String eventId, String language)Get the URI of a thread in project'siteStringgetId()Get the module IdMap<String,Object>getModuleBaseRights()Retrieves the set of general rights used in the calendar module for the current userStringgetModuleName()Get the module nameprotected StringgetModulePageName()Returns the module page's nameprotected I18nizableTextgetModulePageTitle()Returns the module page's title as i18nModifiableResourceCollectiongetModuleRoot(Project project, boolean create)Get the module root node for the given projectprotected StringgetModuleTagName()Returns the tag of apply to module pageI18nizableTextgetModuleTitle()Get the module titleList<Map<String,Object>>getUpcomingEvents(int months, int maxResults, List<String> calendarIds, List<String> tagIds)Get the upcoming events of the calendars on which the user has a rightList<Map<String,Object>>getUpcomingEvents(String months, String maxResults, List<String> calendarIds, List<String> tagIds)Get the upcoming events of the calendars on which the user has a rightprotected voidinitializeModulePage(ModifiablePage calendarPage)Initialize the module pagevoidservice(ServiceManager manager)-
Methods inherited from class org.ametys.plugins.workspaces.AbstractWorkspaceModule
_createModulePage, _deletePages, _getAmetysObject, _getDefaultXslt, _internalActivateModule, _internalDeactivateModule, activateModule, contextualize, deactivateModule, getModulePages, getModulePageTemplate, getModuleUrl, initializeSitemap, setPluginInfo
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
CALENDAR_MODULE_ID
public static final String CALENDAR_MODULE_ID
The id of calendar module
-
__CALENDAR_MODULE_TAG
private static final String __CALENDAR_MODULE_TAG
Tag on the main page holding the calendar module- See Also:
- Constant Field Values
-
__WORKSPACES_CALENDARS_NODE_NAME
private static final String __WORKSPACES_CALENDARS_NODE_NAME
Workspaces calendars node name- See Also:
- Constant Field Values
-
__CALENDAR_CACHE_REQUEST_ATTR
private static final String __CALENDAR_CACHE_REQUEST_ATTR
-
__MODULE_TITLE_KEY
private static final String __MODULE_TITLE_KEY
Module i18n title key- See Also:
- Constant Field Values
-
_calendarDAO
private WorkspaceCalendarDAO _calendarDAO
-
-
Constructor Detail
-
CalendarWorkspaceModule
public CalendarWorkspaceModule()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classAbstractWorkspaceModule- Throws:
ServiceException
-
getId
public String getId()
Description copied from interface:WorkspaceModuleGet the module Id- Returns:
- The module ID
-
getModuleName
public String getModuleName()
Description copied from interface:WorkspaceModuleGet the module name- Returns:
- the module name
-
getModuleTitle
public I18nizableText getModuleTitle()
Description copied from interface:WorkspaceModuleGet the module title- Returns:
- The title
-
getModulePageName
protected String getModulePageName()
Description copied from class:AbstractWorkspaceModuleReturns the module page's name- Specified by:
getModulePageNamein classAbstractWorkspaceModule- Returns:
- The module page's name
-
getModulePageTitle
protected I18nizableText getModulePageTitle()
Description copied from class:AbstractWorkspaceModuleReturns the module page's title as i18n- Specified by:
getModulePageTitlein classAbstractWorkspaceModule- Returns:
- The module page's title
-
getModuleTagName
protected String getModuleTagName()
Description copied from class:AbstractWorkspaceModuleReturns the tag of apply to module page- Specified by:
getModuleTagNamein classAbstractWorkspaceModule- Returns:
- The tag for module page
-
initializeModulePage
protected void initializeModulePage(ModifiablePage calendarPage)
Description copied from class:AbstractWorkspaceModuleInitialize the module page- Specified by:
initializeModulePagein classAbstractWorkspaceModule- Parameters:
calendarPage- The module page
-
getCalendars
public AmetysObjectIterable<Calendar> getCalendars(Project project)
Get the calendars of a project- Parameters:
project- The project- Returns:
- The list of calendar
-
getModuleRoot
public ModifiableResourceCollection getModuleRoot(Project project, boolean create)
Description copied from interface:WorkspaceModuleGet the module root node for the given project- Parameters:
project- The project containing the modulecreate- True to create the node if it does not exists- Returns:
- The root node, or null if it does not exists and was not created
-
getModuleBaseRights
public Map<String,Object> getModuleBaseRights()
Retrieves the set of general rights used in the calendar module for the current user- Returns:
- The map of right data. Keys are the rights id, and values indicates whether the current user has the right or not.
-
getCalendarServiceRights
public Map<String,Object> getCalendarServiceRights(List<String> calendarIds)
Get the rights of the current user for the calendar service- Parameters:
calendarIds- The list of calendars- Returns:
- The rights
-
getEventUri
public String getEventUri(Project project, String calendarId, String eventId, String language)
Get the URI of a thread in project'site- Parameters:
project- The projectcalendarId- The id of calendareventId- The id of eventlanguage- The sitemap language- Returns:
- The thread uri
-
addCalendar
public Map<String,Object> addCalendar(String inputName, String description, String templateDesc, String color, String visibility, String workflowName, Boolean renameIfExists) throws IllegalAccessException
Add a calendar- Parameters:
inputName- The desired name for the calendardescription- The calendar descriptiontemplateDesc- The calendar template descriptioncolor- The calendar colorvisibility- The calendar visibilityworkflowName- The calendar workflow namerenameIfExists- True to rename if existing- Returns:
- The result map with id, parentId and name keys
- Throws:
IllegalAccessException- If the user has no sufficient rights
-
_addAdditionalEventData
protected void _addAdditionalEventData(CalendarEvent event, Map<String,Object> eventData)
Add additional information on project and parent calendar- Parameters:
event- The eventeventData- The event data to complete
-
getUpcomingEvents
public List<Map<String,Object>> getUpcomingEvents(String months, String maxResults, List<String> calendarIds, List<String> tagIds)
Get the upcoming events of the calendars on which the user has a right- Parameters:
months- the amount of months from today in which look for upcoming eventsmaxResults- the maximum results to displaycalendarIds- the ids of the calendars to gather events from, null for all calendarstagIds- the ids of the valid tags for the events, null for any tag- Returns:
- the upcoming events
-
getUpcomingEvents
public List<Map<String,Object>> getUpcomingEvents(int months, int maxResults, List<String> calendarIds, List<String> tagIds)
Get the upcoming events of the calendars on which the user has a right- Parameters:
months- the amount of months from today in which look for upcoming eventsmaxResults- the maximum results to displaycalendarIds- the ids of the calendars to gather events from, null for all calendarstagIds- the ids of the valid tags for the events, null for any tag- Returns:
- the upcoming events
-
_filterEvent
private boolean _filterEvent(List<String> calendarIds, CalendarEvent event)
Determine whether the given event has to be kept or not depending on the given calendars- Parameters:
calendarIds- the ids of the calendarsevent- the event- Returns:
- true if the event can be kept, false otherwise
-
_hasAccess
private boolean _hasAccess(Calendar calendar)
-
getCalendarsData
public List<Map<String,Object>> getCalendarsData()
Get the data of every available calendar of the application- Returns:
- the list of calendar data
-
canView
public boolean canView(Calendar calendar)
Indicates if the current user can view the calendar- Parameters:
calendar- The calendar to test- Returns:
- true if the calendar can be viewed
-
canView
public boolean canView(CalendarEvent event)
Indicates if the current user can view the event- Parameters:
event- The event to test- Returns:
- true if the event can be viewed
-
getAllowedEventTypes
public Set<String> getAllowedEventTypes()
Description copied from interface:WorkspaceModuleGet the set of allowed event type for the module- Returns:
- The set of allowed event types
-
-