org.opencms.file.collectors
Class CmsPriorityResourceCollector

java.lang.Object
  extended by org.opencms.file.collectors.A_CmsResourceCollector
      extended by org.opencms.file.collectors.CmsPriorityResourceCollector
All Implemented Interfaces:
java.lang.Comparable, I_CmsResourceCollector

public class CmsPriorityResourceCollector
extends A_CmsResourceCollector

A collector to fetch sorted XML contents in a folder or subtree based on their priority and date or title values.

The date or title information has to be stored as property for each resource.

Since:
6.0.0
Version:
$Revision: 1.14 $
Author:
Andreas Zahner

Field Summary
static int PRIORITY_STANDARD
          The standard priority value if no value was set on resource.
static java.lang.String PROPERTY_CHANNEL
          The name of the channel property to read.
static java.lang.String PROPERTY_PRIORITY
          The name of the priority property to read.
 
Fields inherited from class org.opencms.file.collectors.A_CmsResourceCollector
m_order
 
Constructor Summary
CmsPriorityResourceCollector()
           
 
Method Summary
protected  java.util.List allInFolderPriorityDate(CmsObject cms, java.lang.String param, boolean tree, boolean asc)
          Returns a list of all resource in a specified folder sorted by priority, then date ascending or descending.
protected  java.util.List allInFolderPriorityTitle(CmsObject cms, java.lang.String param, boolean tree)
          Returns a list of all resource in a specified folder sorted by priority descending, then Title ascending.
protected  java.util.List allMappedToUriPriorityDate(CmsObject cms, java.lang.String param, boolean asc)
          Returns a list of all resource from specified folder that have been mapped to the currently requested uri, sorted by priority, then date ascending or descending.
 java.util.List 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 the I_CmsResourceCollector.getCreateLink(CmsObject, String, String) method.
 java.util.List getResults(CmsObject cms, java.lang.String collectorName, java.lang.String param)
          Returns a list of CmsResource Objects that are gathered in the VFS using the named collector.
 
Methods inherited from class org.opencms.file.collectors.A_CmsResourceCollector
checkParams, compareTo, equals, getCreateInFolder, getCreateLink, getCreateParam, getDefaultCollectorName, getDefaultCollectorParam, getOrder, getResults, hashCode, setDefaultCollectorName, setDefaultCollectorParam, setOrder, shrinkToFit
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIORITY_STANDARD

public static final int PRIORITY_STANDARD
The standard priority value if no value was set on resource.

See Also:
Constant Field Values

PROPERTY_CHANNEL

public static final java.lang.String PROPERTY_CHANNEL
The name of the channel property to read.

See Also:
Constant Field Values

PROPERTY_PRIORITY

public static final java.lang.String PROPERTY_PRIORITY
The name of the priority property to read.

See Also:
Constant Field Values
Constructor Detail

CmsPriorityResourceCollector

public CmsPriorityResourceCollector()
Method Detail

getCollectorNames

public java.util.List 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
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 CmsObject
collectorName - the name of the collector to use
param - an optional collector parameter
Returns:
the link to execute after a "new" button was clicked
Throws:
CmsException - if something goes wrong
CmsDataAccessException - if the param attrib 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)
                                throws CmsDataAccessException
Description copied from interface: I_CmsResourceCollector
Returns the parameter that must be passed to the I_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 CmsObject
collectorName - the name of the collector to use
param - 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
Throws:
CmsDataAccessException - if the param attrib of the corresponding collector tag is invalid
See Also:
I_CmsResourceCollector.getCreateParam(org.opencms.file.CmsObject, java.lang.String, java.lang.String)

getResults

public java.util.List getResults(CmsObject cms,
                                 java.lang.String collectorName,
                                 java.lang.String param)
                          throws CmsException,
                                 CmsDataAccessException
Description copied from interface: I_CmsResourceCollector
Returns a list of CmsResource Objects that are gathered in the VFS using the named collector.

Parameters:
cms - the current CmsObject
collectorName - the name of the collector to use
param - an optional collector parameter
Returns:
a list of CmsXmlContent objects
Throws:
CmsException - if something goes wrong
CmsDataAccessException - if the param attrib of the corresponding collector tag is invalid
See Also:
I_CmsResourceCollector.getResults(org.opencms.file.CmsObject, java.lang.String, java.lang.String)

allInFolderPriorityDate

protected java.util.List allInFolderPriorityDate(CmsObject cms,
                                                 java.lang.String param,
                                                 boolean tree,
                                                 boolean asc)
                                          throws CmsException
Returns a list of all resource in a specified folder sorted by priority, then date ascending or descending.

Parameters:
cms - the current OpenCms user context
param - the folder name to use
tree - if true, look in folder and all child folders, if false, look only in given folder
asc - if true, the date sort order is ascending, otherwise descending
Returns:
all resources in the folder matching the given criteria
Throws:
CmsException - if something goes wrong

allInFolderPriorityTitle

protected java.util.List allInFolderPriorityTitle(CmsObject cms,
                                                  java.lang.String param,
                                                  boolean tree)
                                           throws CmsException
Returns a list of all resource in a specified folder sorted by priority descending, then Title ascending.

Parameters:
cms - the current OpenCms user context
param - the folder name to use
tree - if true, look in folder and all child folders, if false, look only in given folder
Returns:
all resources in the folder matching the given criteria
Throws:
CmsException - if something goes wrong

allMappedToUriPriorityDate

protected java.util.List allMappedToUriPriorityDate(CmsObject cms,
                                                    java.lang.String param,
                                                    boolean asc)
                                             throws CmsException
Returns a list of all resource from specified folder that have been mapped to the currently requested uri, sorted by priority, then date ascending or descending.

Parameters:
cms - the current OpenCms user context
param - the folder name to use
asc - if true, the date sort order is ascending, otherwise descending
Returns:
all resources in the folder matching the given criteria
Throws:
CmsException - if something goes wrong