Class CmsTimeFrameCategoryCollector
- java.lang.Object
-
- org.opencms.file.collectors.A_CmsResourceCollector
-
- org.opencms.file.collectors.CmsTimeFrameCategoryCollector
-
- All Implemented Interfaces:
java.lang.Comparable<I_CmsResourceCollector>
,I_CmsCollectorPublishListProvider
,I_CmsResourceCollector
public class CmsTimeFrameCategoryCollector extends A_CmsResourceCollector
A collector that allows to collect resources within a time range based upon a configurable property that contains a time stamp.Additionally a property may be specified that contains a comma separated list of category Strings that have to match the specified list of categories to allow.
Demo usage:
<cms:contentload collector="timeFrameAndCategories" param=" resource=/de/events/| resourceType=xmlcontent| resultLimit=10| sortDescending=true| excludeTimerange=true| timeStart=2007-08-01 14:22:12| timeEnd=2007-08-01 14:22:12| propertyTime=collector.time| propertyCategories=collector.categories| categories=sports,action,lifestyle" >
The param attribute supports a key - value syntax for collector params.
All parameters are specified as follows:
key=value
Many key - value pairs may exist:
key=value|key2=value2|key3=value3
The following keys are reserved:
-
resource
The value defines the folder / single file for collection of results. -
resourceType
The value defines the name of the type of resource that is required for the result as defined in opencms-modules.xml, opencms-workplace.xml. -
resultLimit
The value defines the maximum amount of results to return. -
sortDescending
The value defines if the result is sorted in descending ("true") or ascending (anything else than "true") order. -
excludeTimeRange
The value defines if the result should exclude the time range in an offline project. -
timeStart
The value defines the start time in the formatyyyy-MM-dd HH:mm:ss
as known by the description of
that will be used for the validity time frame of result candidates.SimpleDateFormat
-
timeEnd
The value defines the end time in the formatyyyy-MM-dd HH:mm:ss
as known by the description of
that will be used for the validity time frame of result candidates.SimpleDateFormat
-
propertyTime
The value defines the name of the property that is inspected for a time stamp inSystem.currentTimeMillis()
-
propertyCategories
The value defines the name of the property that is inspected for a pipe separated list of category strings. -
categories
The value defines a list of comma separated category Strings used to filter result candidates by. If this parameter is missing completely no category filtering will be done and also resources with empty category property will be accepted.
All other key - value pairs are ignored.
- Since:
- 7.0.3
-
-
Field Summary
Fields Modifier and Type Field Description static java.text.DateFormat
DATEFORMAT_SQL
SQL Standard date format: "yyyy-MM-dd HH:mm:ss".-
Fields inherited from class org.opencms.file.collectors.A_CmsResourceCollector
m_order, SEPARATOR_TEMPLATEFILE
-
Fields inherited from interface org.opencms.file.collectors.I_CmsResourceCollector
DEFAULT_LIMIT
-
-
Constructor Summary
Constructors Constructor Description CmsTimeFrameCategoryCollector()
Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>
getCollectorNames()
Returns a list of all collector names (Strings) this collector implementation supports.java.lang.String
getCreateLink(CmsObject cms, java.lang.String collectorName, java.lang.String param)
Returns the link that must be executed when a user clicks on the direct edit "new" button on a list created by the named collector.java.lang.String
getCreateParam(CmsObject cms, java.lang.String collectorName, java.lang.String param)
Returns the parameter that must be passed to theI_CmsResourceCollector.getCreateLink(CmsObject, String, String)
method.int
getCreateTypeId(CmsObject cms, java.lang.String collectorName, java.lang.String param)
Returns the id of the resource type for new collector items.java.util.List<CmsResource>
getResults(CmsObject cms, java.lang.String collectorName, java.lang.String param)
Returns a list ofCmsResource
Objects that are gathered in the VFS using the named collector.java.util.List<CmsResource>
getResults(CmsObject cms, java.lang.String collectorName, java.lang.String param, int numResults)
Returns a list ofCmsResource
Objects that are gathered in the VFS using the named collector.-
Methods inherited from class org.opencms.file.collectors.A_CmsResourceCollector
checkParams, compareTo, createResourceForCollector, equals, getCreateInFolder, getCreateInFolder, getCreateLink, getCreateParam, getDefaultCollectorName, getDefaultCollectorParam, getOrder, getPostCreateHandler, getPublishResources, getResults, hashCode, setDefaultCollectorName, setDefaultCollectorParam, setOrder, shrinkToFit, shrinkToFit
-
-
-
-
Field Detail
-
DATEFORMAT_SQL
public static final java.text.DateFormat DATEFORMAT_SQL
SQL Standard date format: "yyyy-MM-dd HH:mm:ss".
-
-
Constructor Detail
-
CmsTimeFrameCategoryCollector
public CmsTimeFrameCategoryCollector()
Public constructor.
-
-
Method Detail
-
getCollectorNames
public java.util.List<java.lang.String> getCollectorNames()
Description copied from interface:I_CmsResourceCollector
Returns a list of all collector names (Strings) this collector implementation supports.- Returns:
- a list of all collector names this collector implementation supports
- See Also:
I_CmsResourceCollector.getCollectorNames()
-
getCreateLink
public java.lang.String getCreateLink(CmsObject cms, java.lang.String collectorName, java.lang.String param) throws CmsException, CmsDataAccessException
Description copied from interface:I_CmsResourceCollector
Returns the link that must be executed when a user clicks on the direct edit "new" button on a list created by the named collector.If this method returns
null
, it indicated that the selected collector implementation does not support a "create link", and so no "new" button will should shown on lists generated with this collector.- Parameters:
cms
- the current CmsObjectcollectorName
- the name of the collector to useparam
- an optional collector parameter- Returns:
- the link to execute after a "new" button was clicked
- Throws:
CmsException
- if something goes wrongCmsDataAccessException
- if the parameter attribute of the corresponding collector tag is invalid- See Also:
I_CmsResourceCollector.getCreateLink(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
-
getCreateParam
public java.lang.String getCreateParam(CmsObject cms, java.lang.String collectorName, java.lang.String param)
Description copied from interface:I_CmsResourceCollector
Returns the parameter that must be passed to theI_CmsResourceCollector.getCreateLink(CmsObject, String, String)
method.If this method returns
null
, it indicates that the selected collector implementation does not support a "create link", and so no "new" button will should shown on lists generated with this collector.- Parameters:
cms
- the current CmsObjectcollectorName
- the name of the collector to useparam
- an optional collector parameter from the current page context- Returns:
- the parameter that will be passed to the
I_CmsResourceCollector.getCreateLink(CmsObject, String, String)
method, or null - See Also:
I_CmsResourceCollector.getCreateParam(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
-
getCreateTypeId
public int getCreateTypeId(CmsObject cms, java.lang.String collectorName, java.lang.String param) throws CmsException
Description copied from interface:I_CmsResourceCollector
Returns the id of the resource type for new collector items.Returns -1 if creation of new items is not supported.
- Specified by:
getCreateTypeId
in interfaceI_CmsResourceCollector
- Overrides:
getCreateTypeId
in classA_CmsResourceCollector
- Parameters:
cms
- the current CmsObjectcollectorName
- the name of the collector to useparam
- an optional collector parameter- Returns:
- the resource type id
- Throws:
CmsException
- if something goes wrong- See Also:
A_CmsResourceCollector.getCreateTypeId(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
-
getResults
public java.util.List<CmsResource> getResults(CmsObject cms, java.lang.String collectorName, java.lang.String param) throws CmsDataAccessException, CmsException
Description copied from interface:I_CmsResourceCollector
Returns a list ofCmsResource
Objects that are gathered in the VFS using the named collector.- Parameters:
cms
- the current CmsObjectcollectorName
- the name of the collector to useparam
- an optional collector parameter- Returns:
- a list of CmsXmlContent objects
- Throws:
CmsDataAccessException
- if the parameter attribute of the corresponding collector tag is invalidCmsException
- if something goes wrong- See Also:
I_CmsResourceCollector.getResults(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
-
getResults
public java.util.List<CmsResource> getResults(CmsObject cms, java.lang.String collectorName, java.lang.String param, int numResults) throws CmsDataAccessException, CmsException
Description copied from interface:I_CmsResourceCollector
Returns a list ofCmsResource
Objects that are gathered in the VFS using the named collector.This method takes as a parameter the desired number of results. If this number is -1, the number of results will only depend on the collector parameters. If it is positive, any given result number in the collector parameter string will not be used.
- Parameters:
cms
- the current CmsObjectcollectorName
- the name of the collector to useparam
- an optional collector parameternumResults
- the desired number of results (overrides result number possibl- Returns:
- a list of CmsXmlContent objects
- Throws:
CmsDataAccessException
- if the parameter attribute of the corresponding collector tag is invalidCmsException
- if something goes wrong- See Also:
I_CmsResourceCollector.getResults(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
-
-