com.endeca.portal.data
Class CollectionRanker

java.lang.Object
  extended by com.endeca.portal.data.CollectionRanker

public class CollectionRanker
extends java.lang.Object

Ranks all the data sets (collections) for a given data source, in order to choose the best data set for an application. This class is called by EndecaPortletUtil the first time an application is accessed; EndecaPortletUtil then persists the results of its call to the database.


Constructor Summary
CollectionRanker(DataSource ds, java.util.Locale locale)
          Constructor.
 
Method Summary
 CollectionBaseView selectDefaultCollection()
          Returns the collection that should be used as the default for a data source.
 java.util.List<CollectionBaseView> sortAlphabetically()
          Returns all collections in the given data source, sorted alphabetically according to the current locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionRanker

public CollectionRanker(DataSource ds,
                        java.util.Locale locale)
Constructor.

Parameters:
ds - the DataSource containing the collections to be ranked.
locale - the current locale; used to manage alphabetical sorting.
Method Detail

selectDefaultCollection

public CollectionBaseView selectDefaultCollection()
                                           throws DataSourceException
Returns the collection that should be used as the default for a data source. This method uses the following logic: - valid collections sort above invalid collections - active collections sort above inactive collections - earlier collections sort above later collections - if all other comparisons failed, sort collections alphabetically by display name Note that it is possible for this method to return an invalid or inactive collection; this will happen if all of the collections for a data source are invalid or inactive.

Returns:
the collection that should be used as the default for a data source.
Throws:
DataSourceException - if the data source has no collections, or an error occurred retrieving collections.

sortAlphabetically

public java.util.List<CollectionBaseView> sortAlphabetically()
                                                      throws DataSourceException
Returns all collections in the given data source, sorted alphabetically according to the current locale. This method does not strip out invalid or inactive collections.

Returns:
alphabetically-sorted list of collections.
Throws:
DataSourceException - if there was a problem retrieving collections.