Package org.opencms.ade.publish
Class A_CmsPublishGroupHelper<RESOURCE,GROUP>
java.lang.Object
org.opencms.ade.publish.A_CmsPublishGroupHelper<RESOURCE,GROUP>
- Type Parameters:
RESOURCE
- the resource class typeGROUP
- the resource group class type
- Direct Known Subclasses:
CmsDefaultPublishGroupHelper
,CmsSinglePublishGroupHelper
Helper class for splitting a publish list into publish groups.
- Since:
- 8.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
An enum representing the age of a publish list resource.class
Comparator used for sorting publish resources. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
The gap between session groups. -
Constructor Summary
ConstructorDescriptionA_CmsPublishGroupHelper
(Locale locale) Creates a new publish group helper for a given locale. -
Method Summary
Modifier and TypeMethodDescriptioncomputeDays
(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.computeDaysForResources
(List<RESOURCE> resources) Computes a map from modification date to number of (local) days since the modification date.protected abstract GROUP
createGroup
(String name, List<RESOURCE> resources) Creates a named group of resources.protected abstract long
Gets the last modification date of a resource.int
getDayDifference
(long first, long second) Gets the difference in days between to dates given as longs.Splits a list of resources into groups.getModificationDates
(List<RESOURCE> resources) Given a list of resources, this method returns a list of their modification dates.getPublishGroupName
(List<RESOURCE> resources, A_CmsPublishGroupHelper.GroupAge age) Returns the localized name for a given publish group based on its age.protected abstract String
getRootPath
(RESOURCE res) Gets the root path of a resource.getStartOfDay
(long time) Returns a calendar object representing the start of the day in which a given time lies.Computes publish groups for a list of resources with age "medium".Partitions a list of resources by their age in (local) days since the last modification.partitionYoungResources
(List<RESOURCE> resources) Partitions the list of young resources into publish groups.
-
Field Details
-
GROUP_SESSIONS_GAP
The gap between session groups.- See Also:
-
-
Constructor Details
-
A_CmsPublishGroupHelper
Creates a new publish group helper for a given locale.- Parameters:
locale
- the locale to use
-
-
Method Details
-
computeDays
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
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
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 datesecond
- the second date- Returns:
- the difference between the two dates in days
-
getGroups
Splits a list of resources into groups.- Parameters:
resources
- the list of resources- Returns:
- the list of groups
-
getModificationDates
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
Returns the localized name for a given publish group based on its age.- Parameters:
resources
- the resources of the publish groupage
- the age of the publish group- Returns:
- the localized name of the publish group
-
getStartOfDay
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<RESOURCE>> partitionMediumResources(List<RESOURCE> resources, Map<Long, Integer> days) Computes publish groups for a list of resources with age "medium".- Parameters:
resources
- the list of resourcesdays
- a map from modification dates to the number of days since the modification- Returns:
- a list of publish groups
-
partitionPublishResourcesByAge
public Map<A_CmsPublishGroupHelper.GroupAge,List<RESOURCE>> partitionPublishResourcesByAge(List<RESOURCE> 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 partitiondays
- 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
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
-
createGroup
Creates a named group of resources.- Parameters:
name
- the name of the groupresources
- the resources which should be put in the group- Returns:
- the named group
-
getDateLastModified
Gets the last modification date of a resource.- Parameters:
res
- the resource- Returns:
- the last modification date of res
-
getRootPath
Gets the root path of a resource.- Parameters:
res
- the resource- Returns:
- the root path of res
-