public class EventsFilterHelper extends AbstractLogEnabled implements Serviceable, Component
Modifier and Type | Class and Description |
---|---|
class |
EventsFilterHelper.DateRange
Class representing a date range.
|
Modifier and Type | Field and Description |
---|---|
protected AmetysObjectResolver |
_ametysResolver
The Ametys object resolver
|
protected ContentTypeExtensionPoint |
_contentTypeEP
Extension point for content type
|
protected ContentFilterExtensionPoint |
_filterExtPt
Extension point for content filters
|
private SiteManager |
_siteManager
The site manager
|
protected TagProviderExtensionPoint |
_tagProviderEP
The tag provider extension point.
|
static String |
END_DATE_META
The end date metadata.
|
static String |
EVENTS_FILTER_ID
The events filter ID.
|
static String |
ROLE
The avalon role
|
static String |
START_DATE_META
The start date metadata.
|
Constructor and Description |
---|
EventsFilterHelper() |
Modifier and Type | Method and Description |
---|---|
protected Calendar |
_getDate(int year,
int month,
int day)
Get a date object from a year-month-day set.
|
protected EventsFilterHelper.DateRange |
_getDateRange(Calendar date,
int monthsBefore,
int monthsAfter)
Get a date range from a period, around a given date (x months before and
x months after the date).
|
protected EventsFilterHelper.DateRange |
_getDateRange(Calendar date,
String rangeType)
Get a date range from a date and a range type.
|
protected EventsFilterHelper.DateRange |
_getDateRange(int monthsBefore,
int monthsAfter)
Get a date range from a period (x months before now and x months after).
|
protected Expression |
_getMetadataExpression(Date date)
Get a metadata expression from a single date.
|
protected Expression |
_getMetadataExpression(EventsFilterHelper.DateRange dateRange)
Get a metadata expression from a date range.
|
void |
configureFilter(EventsFilter eventsFilter,
Expression expression,
Collection<String> contentTypes,
Collection<String> andTags,
Set<String> orTags,
String view,
boolean maskOrphan,
WebContentFilter.AccessLimitation accessLimitation)
Configure the filter to return the wanted contents.
|
EventsFilter |
createEventsFilter(String id)
Create a events filter from the static "events" filter
|
WebContentFilter.AccessLimitation |
getAccessLimitation(ZoneItem zoneItem)
Get the access limitation policy.
|
Set<String> |
getAllTags(Collection<Tag> tags)
Get all the descendant tags belonging to a collection of input tags.
|
protected Set<Tag> |
getAllTags(Tag tag)
Get all the descendant tags belonging to a single tag.
|
Set<String> |
getContentTypes(ZoneItem zoneItem)
Get the content types through the service parameters.
|
EventsFilterHelper.DateRange |
getDateRange(String type,
int year,
int month,
int day,
int monthsBefore,
int monthsAfter,
String rangeType)
Get the date range from the calendar type and parameters.
|
String |
getDefaultRangeType(ZoneItem zoneItem)
Get the default range type parameter value.
|
Expression |
getExpression(String type,
EventsFilterHelper.DateRange dateRange)
Get the metadata expression from the calendar type and date range.
|
protected boolean |
getIcalDownload(ZoneItem zoneItem)
Is there an iCalendar export link on the service?
|
protected int |
getLastDayOfWeek(Calendar cal)
Get last day of the week at a given date.
|
String |
getLink(ZoneItem zoneItem)
Get the link.
|
String |
getLinkTitle(ZoneItem zoneItem)
Get the link title.
|
boolean |
getMaskOrphan(ZoneItem zoneItem)
Mask orphan?
|
protected boolean |
getPdfDownload(ZoneItem zoneItem)
Is there a PDF download link on the service?
|
Set<Tag> |
getTagCategories(ZoneItem zoneItem,
String siteName,
String[] inputCategoriesArray)
Get the selected tags to be used as categories.
|
Set<String> |
getTags(ZoneItem zoneItem,
String[] inputTagsArray)
Get the tags of a zone item.
|
String |
getTitle(ZoneItem zoneItem)
Get the service title.
|
void |
service(ServiceManager manager) |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
public static final String START_DATE_META
public static final String END_DATE_META
public static final String EVENTS_FILTER_ID
protected TagProviderExtensionPoint _tagProviderEP
protected ContentFilterExtensionPoint _filterExtPt
protected AmetysObjectResolver _ametysResolver
protected ContentTypeExtensionPoint _contentTypeEP
private SiteManager _siteManager
public EventsFilterHelper()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public EventsFilter createEventsFilter(String id)
id
- the id of filter to createpublic String getTitle(ZoneItem zoneItem)
zoneItem
- the zone item.public String getLink(ZoneItem zoneItem)
zoneItem
- the zone item.public String getLinkTitle(ZoneItem zoneItem)
zoneItem
- the zone item.public String getDefaultRangeType(ZoneItem zoneItem)
zoneItem
- the zone item.public boolean getMaskOrphan(ZoneItem zoneItem)
zoneItem
- the zone item.public WebContentFilter.AccessLimitation getAccessLimitation(ZoneItem zoneItem)
zoneItem
- the zone item.protected boolean getPdfDownload(ZoneItem zoneItem)
zoneItem
- the zone item.protected boolean getIcalDownload(ZoneItem zoneItem)
zoneItem
- the zone item.public Set<String> getContentTypes(ZoneItem zoneItem)
zoneItem
- the zone item.public Set<String> getTags(ZoneItem zoneItem, String[] inputTagsArray)
zoneItem
- the zone item.inputTagsArray
- the input tags arraypublic Set<Tag> getTagCategories(ZoneItem zoneItem, String siteName, String[] inputCategoriesArray)
zoneItem
- the zone item.siteName
- the site name.inputCategoriesArray
- the input tag categories arraypublic Set<String> getAllTags(Collection<Tag> tags)
tags
- the collection of input tag.protected Set<Tag> getAllTags(Tag tag)
tag
- the tag.public EventsFilterHelper.DateRange getDateRange(String type, int year, int month, int day, int monthsBefore, int monthsAfter, String rangeType)
type
- the calendar mode: "calendar", "single-day" or "agenda".year
- the year.month
- the month.day
- the day.monthsBefore
- get x months before.monthsAfter
- get x months after.rangeType
- the range type, "month" or "week".protected EventsFilterHelper.DateRange _getDateRange(int monthsBefore, int monthsAfter)
monthsBefore
- the wanted number of months before the current month.monthsAfter
- the wanted number of months after the current month.protected EventsFilterHelper.DateRange _getDateRange(Calendar date, int monthsBefore, int monthsAfter)
date
- the date.monthsBefore
- the wanted number of months before the current month.monthsAfter
- the wanted number of months after the current month.protected EventsFilterHelper.DateRange _getDateRange(Calendar date, String rangeType)
date
- the date around which the range is to be.rangeType
- the range type, "month" or "week".protected Calendar _getDate(int year, int month, int day)
year
- the year.month
- the month (1 to 12).day
- the day (1 to 31).public Expression getExpression(String type, EventsFilterHelper.DateRange dateRange)
type
- the calendar type, may be "calendar", "single-day" or
"agenda".dateRange
- the date range. Only the start date is used for
"single-day" type.protected Expression _getMetadataExpression(EventsFilterHelper.DateRange dateRange)
dateRange
- the date range.protected Expression _getMetadataExpression(Date date)
date
- the date.protected int getLastDayOfWeek(Calendar cal)
cal
- the date as a Calendar.public void configureFilter(EventsFilter eventsFilter, Expression expression, Collection<String> contentTypes, Collection<String> andTags, Set<String> orTags, String view, boolean maskOrphan, WebContentFilter.AccessLimitation accessLimitation)
eventsFilter
- the events filter.expression
- the metadata Expression, can be null.contentTypes
- a list of content types that will restrict the scope of the request.andTags
- a list of tags that are all required for the content to
match.orTags
- a list of tags among which only one is required for the
content to match.view
- the view.maskOrphan
- true to prevent getting orphan contents.accessLimitation
- The access limitation policy.