Package org.ametys.cms.search
Class GroupSearchContentHelper
- java.lang.Object
-
- org.ametys.cms.search.GroupSearchContentHelper
-
- All Implemented Interfaces:
Component
,Serviceable
public class GroupSearchContentHelper extends Object implements Component, Serviceable
Helper to group search contents
-
-
Field Summary
Fields Modifier and Type Field Description private ContentHelper
_contentHelper
private I18nUtils
_i18nUtils
private SystemPropertyExtensionPoint
_systemPropertyExtensionPoint
private UserManager
_userManager
static String
ROLE
The Avalon role name
-
Constructor Summary
Constructors Constructor Description GroupSearchContentHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private String
_getGroupValueAsString(String fieldId, Object value, Set<ContentType> contentTypes, Locale locale)
private Map<Object,List<Content>>
_groupBy(Iterable<Content> contents, String fieldId, Locale locale)
Group contents by given grouping fieldprivate void
_organizeContents(GroupSearchContent parent, Iterable<Content> contents, List<String> groupingFields, Set<ContentType> contentTypes, Locale locale)
Recursive function that create sub GroupSearchContent to organize the contents in a hierarchy according to a list of attributes Example Continent/Country/CityGroupSearchContent
organizeContentsInGroups(Iterable<Content> contents, List<String> groupingFields, Set<ContentType> contentTypes, Locale locale)
Create GroupSearchContent to organize the contents in a hierarchy according to a list of attributes Example Continent/Country/Cityvoid
service(ServiceManager serviceManager)
-
-
-
Field Detail
-
_systemPropertyExtensionPoint
private SystemPropertyExtensionPoint _systemPropertyExtensionPoint
-
_contentHelper
private ContentHelper _contentHelper
-
_userManager
private UserManager _userManager
-
_i18nUtils
private I18nUtils _i18nUtils
-
-
Constructor Detail
-
GroupSearchContentHelper
public GroupSearchContentHelper()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
organizeContentsInGroups
public GroupSearchContent organizeContentsInGroups(Iterable<Content> contents, List<String> groupingFields, Set<ContentType> contentTypes, Locale locale)
Create GroupSearchContent to organize the contents in a hierarchy according to a list of attributes Example Continent/Country/City- Parameters:
contents
- contents that need to be sortedgroupingFields
- list of attributes to group with (ordered)contentTypes
- the content typelocale
- The locale for groups. Can be null. Only useful if grouping by multilingual contents or multilingual string- Returns:
- the root group of contents
-
_organizeContents
private void _organizeContents(GroupSearchContent parent, Iterable<Content> contents, List<String> groupingFields, Set<ContentType> contentTypes, Locale locale)
Recursive function that create sub GroupSearchContent to organize the contents in a hierarchy according to a list of attributes Example Continent/Country/City- Parameters:
parent
- parent group in which contents will be added, or in which new groups will be createdcontents
- contents that need to be sortedgroupingFields
- list of attributes to group with (ordered)contentTypes
- the content typeslocale
- The local to get i18n titles
-
_groupBy
private Map<Object,List<Content>> _groupBy(Iterable<Content> contents, String fieldId, Locale locale)
Group contents by given grouping field- Parameters:
contents
- list of contentfieldId
- The id of grouping field. Can be the path of a metadata or the system propertylocale
- The local to get i18n titles- Returns:
- a Map where the key will be the value of the metadata
-
_getGroupValueAsString
private String _getGroupValueAsString(String fieldId, Object value, Set<ContentType> contentTypes, Locale locale)
-
-