Package org.ametys.cms.search.content
Class ContentSearchHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.search.content.ContentSearchHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class ContentSearchHelper
extends AbstractLogEnabled
implements Component, Serviceable, Contextualizable
Component which helps content searching by providing a simple way to access
content properties (either attributes or properties).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Record representing the computed joined paths from a reference -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeJoinedPaths
(String dataPath, Set<String> contentTypeIds) Retrieves the join paths from the given data pathvoid
contextualize
(Context context) getFacetDefinition
(String referencePath, Set<String> contentTypeIds) Retrieves the facet definition for the reference at the given path.getFacetDefinitions
(List<String> referencedPaths, Set<String> contentTypeIds) Retrieves the facet definitions for the references at the given paths.getFacetDefinitions
(SearchModel searchModel, Map<String, Object> contextualParameters) Retrieves the facet definitions for the given search modelgetReferenceFromFieldPath
(String referencePath, Set<String> contentTypeIds) Retrieves the reference with the given pathgetSortDefinition
(String referencePath, Set<String> contentTypeIds, SortOrder order) Retrieves the sort definition for the reference at the given path.boolean
isTitleMultilingual
(ModelItem modelItem) Determines if the given model item represents an attribute of type content with contents with multilingual titlesvoid
service
(ServiceManager manager) transformContentSearcherSorts
(List<ContentSearcherFactory.ContentSearchSort> contentSearcherSorts, Set<String> contentTypeIds) Transform the givenContentSearcherFactory.ContentSearchSort
s to compute joins and getSearcherFactory.SortDefinition
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The component role.
-
-
Constructor Details
-
ContentSearchHelper
public ContentSearchHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
transformContentSearcherSorts
public List<SearcherFactory.SortDefinition> transformContentSearcherSorts(List<ContentSearcherFactory.ContentSearchSort> contentSearcherSorts, Set<String> contentTypeIds) throws IllegalArgumentException Transform the givenContentSearcherFactory.ContentSearchSort
s to compute joins and getSearcherFactory.SortDefinition
- Parameters:
contentSearcherSorts
- the sorts to transformcontentTypeIds
- the identifiers of the content types where to search the field- Returns:
- the sorts with computed joins to give to the
SearcherFactory.Searcher
- Throws:
IllegalArgumentException
- if one of the given sort has not been found in the given content types
-
getSortDefinition
public SearcherFactory.SortDefinition getSortDefinition(String referencePath, Set<String> contentTypeIds, SortOrder order) throws UndefinedItemPathException, BadItemTypeException Retrieves the sort definition for the reference at the given path.- Parameters:
referencePath
- the reference pathcontentTypeIds
- the identifiers of content types defining the referenceorder
- The sort order- Returns:
- the sort field name for the reference at the given path.
- Throws:
UndefinedItemPathException
- if there is no item defined at the given path in given content typesBadItemTypeException
- if the definition of a part of the item path is not an item accessor
-
getFacetDefinition
public SearcherFactory.FacetDefinition getFacetDefinition(String referencePath, Set<String> contentTypeIds) throws UndefinedItemPathException, BadItemTypeException Retrieves the facet definition for the reference at the given path.- Parameters:
referencePath
- the reference pathcontentTypeIds
- the identifiers of content types defining the reference- Returns:
- the facet definition for the reference at the given path.
- Throws:
UndefinedItemPathException
- if there is no item defined at the given path in given content typesBadItemTypeException
- if the definition of a part of the item path is not an item accessor
-
getFacetDefinitions
public List<SearcherFactory.FacetDefinition> getFacetDefinitions(List<String> referencedPaths, Set<String> contentTypeIds) Retrieves the facet definitions for the references at the given paths.- Parameters:
referencedPaths
- the references pathscontentTypeIds
- the identifiers of content types defining the references- Returns:
- the facet definitions for the references at the given paths.
-
getFacetDefinitions
public List<SearcherFactory.FacetDefinition> getFacetDefinitions(SearchModel searchModel, Map<String, Object> contextualParameters) Retrieves the facet definitions for the given search model- Parameters:
searchModel
- the search modelcontextualParameters
- the contextual parameters- Returns:
- the facet definitions for the given search model
-
getReferenceFromFieldPath
public ElementDefinition getReferenceFromFieldPath(String referencePath, Set<String> contentTypeIds) throws UndefinedItemPathException Retrieves the reference with the given path- Parameters:
referencePath
- the reference's pathcontentTypeIds
- the identifiers of the content types defining the reference- Returns:
- the reference at the given path
- Throws:
UndefinedItemPathException
- if there is no model item in the given content types for the given pathBadItemTypeException
- if the model item at the given path is not an element
-
computeJoinedPaths
public ContentSearchHelper.JoinedPaths computeJoinedPaths(String dataPath, Set<String> contentTypeIds) throws UndefinedItemPathException, BadItemTypeException Retrieves the join paths from the given data path- Parameters:
dataPath
- the data pathcontentTypeIds
- the ids of the content types containing the items of the given path- Returns:
- the join paths
- Throws:
UndefinedItemPathException
- if there is no item defined at the given path in content typesBadItemTypeException
- if the definition of a part of the data path is not an item accessor
-
isTitleMultilingual
Determines if the given model item represents an attribute of type content with contents with multilingual titles- Parameters:
modelItem
- The model item- Returns:
true
if the given model item represents an attribute of type content with contents with multilingual titles
-