org.opencms.ade.publish
Class CmsPublishGroupHelper

java.lang.Object
  extended by org.opencms.ade.publish.CmsPublishGroupHelper

public class CmsPublishGroupHelper
extends Object

Helper class for splitting a publish list into publish groups.

Since:
8.0.0

Nested Class Summary
static class CmsPublishGroupHelper.GroupAge
          An enum representing the age of a publish list resource.
 
Field Summary
protected static int GROUP_SESSIONS_GAP
          The gap between session groups.
 
Constructor Summary
CmsPublishGroupHelper(Locale locale)
          Creates a new publish group helper for a given locale.
 
Method Summary
 Map<Long,Integer> computeDays(List<Long> sortedDates)
          Given a descending list of dates represented as longs, this method computes a map from the dates to their age in (local) days.
 Map<Long,Integer> computeDaysForResources(List<CmsResource> resources)
          Computes a map from modification date to number of (local) days since the modification date.
 int getDayDifference(long first, long second)
          Gets the difference in days between to dates given as longs.
 List<Long> getModificationDates(List<CmsResource> resources)
          Given a list of resources, this method returns a list of their modification dates.
 String getPublishGroupName(List<CmsResource> resources, CmsPublishGroupHelper.GroupAge age)
          Returns the localized name for a given publish group based on its age.
 Calendar getStartOfDay(long time)
          Returns a calendar object representing the start of the day in which a given time lies.
 List<List<CmsResource>> partitionMediumResources(List<CmsResource> resources, Map<Long,Integer> days)
          Computes publish groups for a list of resources with age "medium".
 Map<CmsPublishGroupHelper.GroupAge,List<CmsResource>> partitionPublishResourcesByAge(List<CmsResource> resources, Map<Long,Integer> days)
          Partitions a list of resources by their age in (local) days since the last modification.
 List<List<CmsResource>> partitionYoungResources(List<CmsResource> resources)
          Partitions the list of young resources into publish groups.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP_SESSIONS_GAP

protected static final int GROUP_SESSIONS_GAP
The gap between session groups.

See Also:
Constant Field Values
Constructor Detail

CmsPublishGroupHelper

public CmsPublishGroupHelper(Locale locale)
Creates a new publish group helper for a given locale.

Parameters:
locale - the locale to use
Method Detail

computeDays

public Map<Long,Integer> computeDays(List<Long> sortedDates)
Given a descending list of dates represented as longs, this method computes a map from the dates to their age in (local) days.

Parameters:
sortedDates - a descending list of dates represented as longs
Returns:
a map from dates to ages (measured in days)

computeDaysForResources

public Map<Long,Integer> computeDaysForResources(List<CmsResource> resources)
Computes a map from modification date to number of (local) days since the modification date.

Parameters:
resources - a list of resources
Returns:
a map from modification dates to the number of days since the modification date

getDayDifference

public int getDayDifference(long first,
                            long second)
Gets the difference in days between to dates given as longs.

The first date must be later than the second date.

Parameters:
first - the first date
second - the second date
Returns:
the difference between the two dates in days

getModificationDates

public List<Long> getModificationDates(List<CmsResource> resources)
Given a list of resources, this method returns a list of their modification dates.

Parameters:
resources - a list of resources
Returns:
the modification dates of the resources, in the same order as the resources

getPublishGroupName

public String getPublishGroupName(List<CmsResource> resources,
                                  CmsPublishGroupHelper.GroupAge age)
Returns the localized name for a given publish group based on its age.

Parameters:
resources - the resources of the publish group
age - the age of the publish group
Returns:
the localized name of the publish group

getStartOfDay

public Calendar getStartOfDay(long time)
Returns a calendar object representing the start of the day in which a given time lies.

Parameters:
time - a long representing a time
Returns:
a calendar object which represents the day in which the time lies

partitionMediumResources

public List<List<CmsResource>> partitionMediumResources(List<CmsResource> resources,
                                                        Map<Long,Integer> days)
Computes publish groups for a list of resources with age "medium".

Parameters:
resources - the list of resources
days - a map from modification dates to the number of days since the modification
Returns:
a list of publish groups

partitionPublishResourcesByAge

public Map<CmsPublishGroupHelper.GroupAge,List<CmsResource>> partitionPublishResourcesByAge(List<CmsResource> resources,
                                                                                            Map<Long,Integer> days)
Partitions a list of resources by their age in (local) days since the last modification.

Parameters:
resources - the list of resources to partition
days - the map from modification dates to the number of (local) days since the modification
Returns:
a map from age enum values to the list of resources which fall into the corresponding age group

partitionYoungResources

public List<List<CmsResource>> partitionYoungResources(List<CmsResource> resources)
Partitions the list of young resources into publish groups.

Parameters:
resources - the list of resources to partition
Returns:
a partition of the resources into publish groups