Class EventsGenerator
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.xml.AbstractXMLProducer
-
- org.apache.cocoon.generation.AbstractGenerator
-
- org.apache.cocoon.generation.ServiceableGenerator
-
- org.ametys.plugins.calendar.events.AbstractEventGenerator
-
- org.ametys.plugins.calendar.events.EventsGenerator
-
- All Implemented Interfaces:
Poolable
,Recyclable
,Disposable
,Component
,LogEnabled
,Serviceable
,Generator
,SitemapModelComponent
,XMLProducer
public class EventsGenerator extends AbstractEventGenerator
Query and generate news according to many parameters.
-
-
Field Summary
Fields Modifier and Type Field Description protected AmetysObjectResolver
_ametysResolver
The ametys object resolver.protected EventsFilterHelper
_eventsFilterHelper
The events helperprotected IcsReader
_icsReader
The ICS Readerprotected TagProviderExtensionPoint
_tagProviderEP
The tag provider extension point.-
Fields inherited from class org.ametys.plugins.calendar.events.AbstractEventGenerator
_filterHelper, _resolver
-
Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator
manager
-
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
-
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
-
-
Constructor Summary
Constructors Constructor Description EventsGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private List<IcsReader.IcsEvents>
_getICSEvents(ZoneItem zoneItem, String siteName, EventsFilterHelper.DateRange dateRange)
Read the configured distant ics sources into a list ofIcsReader.IcsEvents
private Set<Tag>
_getIcsTags(ZoneItem zoneItem, String currentSiteName)
private Pair<List<LocalVEvent>,String>
_getLocalICSEvents(List<IcsReader.IcsEvents> icsEventsList, EventsFilterHelper.DateRange dateRange)
Get a list ofLocalVEvent
form the list ofIcsReader.IcsEvents
private void
_sax(LocalDate today, int monthsBefore, int monthsAfter, int year, int month, int day, Set<String> filteredCategoryTags, Page page, ZoneItem zoneItem, ZonedDateTime dateTime, String title, String rangeType, boolean maskOrphan, boolean pdfDownload, boolean icalDownload, String link, String linkTitle, boolean doRetrieveView, Set<String> tags, Set<Tag> categories, Set<Tag> icsTags, String pagePath, EventsFilter eventsFilter, EventsFilterHelper.DateRange dateRange, AmetysObjectIterable<Content> eventContents, List<IcsReader.IcsEvents> icsEvents)
protected void
_saxCategories(Collection<Tag> categories, Collection<Tag> icsTags)
Generate the list of selected tags that act as categories and their descendant tags.protected void
_saxDays(ZonedDateTime date, String type)
Generate days to build a "calendar" view.protected void
_saxDaysNew(EventsFilterHelper.DateRange dateRange, String rangeType)
Generate days to build a "calendar" view.private void
_saxErrorsICS(List<IcsReader.IcsEvents> icsEvents)
protected void
_saxMonths(EventsFilterHelper.DateRange dateRange)
SAX information on the months spanning the date range.private void
_saxRssUrl(ZoneItem zoneItem)
protected void
_saxTags(Collection<String> tags)
Generate the list of selected tags.protected void
_saxTags(Set<Tag> tags)
Sax a list of tagsprotected void
addNavAttributes(AttributesImpl attrs, ZonedDateTime current, ZonedDateTime previousDay, ZonedDateTime nextDay)
Add nav attributes.void
generate()
void
saxIcsEvent(ContentHandler handler, LocalVEvent icsEvent)
Sax an event coming from a distant ICS filevoid
saxIcsEvents(ContentHandler handler, List<LocalVEvent> icsEvents)
Sax a list of events coming from a distant ICS filevoid
saxMatchingContents(ContentHandler handler, WebContentFilter filter, AmetysObjectIterable<Content> contents, Page currentPage, boolean saxContentItSelf)
SAX all contents matching the given filtervoid
service(ServiceManager serviceManager)
-
Methods inherited from class org.ametys.plugins.calendar.events.AbstractEventGenerator
_getFormatedDateAttribute, saxContent, saxXMLContent
-
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator
dispose
-
Methods inherited from class org.apache.cocoon.generation.AbstractGenerator
recycle, setup
-
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
-
-
-
-
Field Detail
-
_ametysResolver
protected AmetysObjectResolver _ametysResolver
The ametys object resolver.
-
_eventsFilterHelper
protected EventsFilterHelper _eventsFilterHelper
The events helper
-
_icsReader
protected IcsReader _icsReader
The ICS Reader
-
_tagProviderEP
protected TagProviderExtensionPoint _tagProviderEP
The tag provider extension point.
-
-
Constructor Detail
-
EventsGenerator
public EventsGenerator()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractEventGenerator
- Throws:
ServiceException
-
generate
public void generate() throws IOException, SAXException, ProcessingException
-
_getIcsTags
private Set<Tag> _getIcsTags(ZoneItem zoneItem, String currentSiteName)
-
_getICSEvents
private List<IcsReader.IcsEvents> _getICSEvents(ZoneItem zoneItem, String siteName, EventsFilterHelper.DateRange dateRange)
Read the configured distant ics sources into a list ofIcsReader.IcsEvents
- Parameters:
zoneItem
- zoneItem where the configuration will be fetchedsiteName
- name of the current sitedateRange
- range of dates to limit- Returns:
- a list of
IcsReader.IcsEvents
-
_getLocalICSEvents
private Pair<List<LocalVEvent>,String> _getLocalICSEvents(List<IcsReader.IcsEvents> icsEventsList, EventsFilterHelper.DateRange dateRange)
Get a list ofLocalVEvent
form the list ofIcsReader.IcsEvents
- Parameters:
icsEventsList
- the list ofIcsReader.IcsEvents
dateRange
- range of dates to limit- Returns:
- a list of
LocalVEvent
-
_sax
private void _sax(LocalDate today, int monthsBefore, int monthsAfter, int year, int month, int day, Set<String> filteredCategoryTags, Page page, ZoneItem zoneItem, ZonedDateTime dateTime, String title, String rangeType, boolean maskOrphan, boolean pdfDownload, boolean icalDownload, String link, String linkTitle, boolean doRetrieveView, Set<String> tags, Set<Tag> categories, Set<Tag> icsTags, String pagePath, EventsFilter eventsFilter, EventsFilterHelper.DateRange dateRange, AmetysObjectIterable<Content> eventContents, List<IcsReader.IcsEvents> icsEvents) throws SAXException, IOException
- Throws:
SAXException
IOException
-
_saxErrorsICS
private void _saxErrorsICS(List<IcsReader.IcsEvents> icsEvents) throws SAXException
- Throws:
SAXException
-
_saxRssUrl
private void _saxRssUrl(ZoneItem zoneItem) throws SAXException
- Throws:
SAXException
-
saxMatchingContents
public void saxMatchingContents(ContentHandler handler, WebContentFilter filter, AmetysObjectIterable<Content> contents, Page currentPage, boolean saxContentItSelf) throws SAXException, IOException
SAX all contents matching the given filter- Parameters:
handler
- The content handler to SAX intofilter
- The filtercontents
- iterator on the contents.currentPage
- The current page.saxContentItSelf
- true to sax the content, false will only sax some meta- Throws:
SAXException
- If an error occurs while SAXingIOException
- If an error occurs while retrieving content.
-
saxIcsEvents
public void saxIcsEvents(ContentHandler handler, List<LocalVEvent> icsEvents) throws SAXException
Sax a list of events coming from a distant ICS file- Parameters:
handler
- The content handler to SAX intoicsEvents
- the events to sax- Throws:
SAXException
- Something went wrong
-
saxIcsEvent
public void saxIcsEvent(ContentHandler handler, LocalVEvent icsEvent) throws SAXException
Sax an event coming from a distant ICS file- Parameters:
handler
- The content handler to SAX intoicsEvent
- an event to sax- Throws:
SAXException
- Something went wrong
-
_saxMonths
protected void _saxMonths(EventsFilterHelper.DateRange dateRange) throws SAXException
SAX information on the months spanning the date range.- Parameters:
dateRange
- the date range.- Throws:
SAXException
- if a error occurs while saxing
-
_saxDaysNew
protected void _saxDaysNew(EventsFilterHelper.DateRange dateRange, String rangeType) throws SAXException
Generate days to build a "calendar" view.- Parameters:
dateRange
- a date belonging to the time span to generate.rangeType
- the range type, "month" or "week".- Throws:
SAXException
- if an error occurs while saxing
-
_saxDays
protected void _saxDays(ZonedDateTime date, String type) throws SAXException
Generate days to build a "calendar" view.- Parameters:
date
- a date belonging to the time span to generate.type
- the range type, "month" or "week".- Throws:
SAXException
- if an error occurs while saxing
-
addNavAttributes
protected void addNavAttributes(AttributesImpl attrs, ZonedDateTime current, ZonedDateTime previousDay, ZonedDateTime nextDay)
Add nav attributes.- Parameters:
attrs
- the attributes object to fill in.current
- the current date.previousDay
- the previous date.nextDay
- the next date.
-
_saxTags
protected void _saxTags(Collection<String> tags) throws SAXException
Generate the list of selected tags.- Parameters:
tags
- the list of tags.- Throws:
SAXException
- if an error occurs while saxing
-
_saxCategories
protected void _saxCategories(Collection<Tag> categories, Collection<Tag> icsTags) throws SAXException
Generate the list of selected tags that act as categories and their descendant tags.- Parameters:
categories
- the list of categories to generate.icsTags
- list of tags for the ICS feeds (tags, not parents)- Throws:
SAXException
- if an error occurs while saxing
-
_saxTags
protected void _saxTags(Set<Tag> tags) throws SAXException
Sax a list of tags- Parameters:
tags
- the list of tags to sax- Throws:
SAXException
- if an error occurs while saxing
-
-