Package org.ametys.cms.search.model
Class SearchModelHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.search.model.SearchModelHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class SearchModelHelper
extends AbstractLogEnabled
implements Component, Contextualizable, Serviceable
Helper for
SearchModel
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addContentTypeRestrictions
(DefaultSearchModel model, String restrictedContentTypeId, Map<String, Object> contextualParameters) Add content type restrictions on the given search model Add content types to the model and restrict enumerator values of its content types criteriavoid
addSolrFilterCriterion
(SearchModel model, String solrRequest, Map<String, Object> contextualParameters) Add a solr filter criterion to the given modelvoid
contextualize
(Context context) copySearchModel
(SearchModel model, Map<String, Object> contextualParameters) Copy the given search modelcreateContentTypeOrMixinQuery
(Collection<String> contentTypes) Create a content type or mixin query.createContentTypeOrMixinQuery
(Collection<String> contentTypes, Query.Operator operator) Create a content type or mixin query.getColumnConfigurations
(String modelId, Map<String, Object> contextualParameters) Get the column configurations of search model as JSON objectgetCriteriaLanguage
(SearchModel model, String searchMode, Map<String, Object> values, Map<String, Object> contextualParameters) Get the language.static ModelViewItem
getCriterion
(ViewItemContainer criteria, String criterionName) Retrieves the criterion with the given namegetRestrictedSearchModel
(String modelId, Map<String, Object> contextualParameters) Get the search model with the given identifier Add some restrictions on the search model, due to the given contextual parameters (content types / solr request)getRestrictedSearchModelConfiguration
(String modelId, Map<String, Object> contextualParameters) Get the search model configuration as JSON object.getSearchModelConfiguration
(String modelId, Map<String, Object> contextualParameters) Get the search model configuration as JSON objectgetSearchUIModel
(String modelId, Map<String, Object> contextualParameters) Retrieves theSearchUIModel
with the given model identifier, with restrictions on content typesvoid
service
(ServiceManager manager) void
setFacetedCriteria
(DefaultSearchModel model, Collection<String> referencePaths, Map<String, Object> contextualParameters) Set faceted criteria to the given search model from the given reference paths If there is no reference path, the faceted criteria of the model are not changedMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The component role. -
DEFAULT_LANGUAGE
The query default language.- See Also:
-
-
Constructor Details
-
SearchModelHelper
public SearchModelHelper()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getSearchModelConfiguration
public Map<String,Object> getSearchModelConfiguration(String modelId, Map<String, Object> contextualParameters) throws ProcessingExceptionGet the search model configuration as JSON object- Parameters:
modelId
- The id of search modelcontextualParameters
- the contextual parameters- Returns:
- The search model configuration in a Map
- Throws:
ProcessingException
- if an error occurred
-
getRestrictedSearchModelConfiguration
public Map<String,Object> getRestrictedSearchModelConfiguration(String modelId, Map<String, Object> contextualParameters) throws ProcessingExceptionGet the search model configuration as JSON object. Add some restrictions on the search model, due to the given contextual parameters (content types / solr request)- Parameters:
modelId
- The id of search modelcontextualParameters
- the contextual parameters- Returns:
- The search model configuration in a Map
- Throws:
ProcessingException
- if an error occurred while converting the model to JSON
-
getRestrictedSearchModel
public SearchModel getRestrictedSearchModel(String modelId, Map<String, Object> contextualParameters) Get the search model with the given identifier Add some restrictions on the search model, due to the given contextual parameters (content types / solr request)- Parameters:
modelId
- The id of search modelcontextualParameters
- the contextual parameters- Returns:
- The search model
-
getColumnConfigurations
public List<Object> getColumnConfigurations(String modelId, Map<String, Object> contextualParameters) throws ProcessingExceptionGet the column configurations of search model as JSON object- Parameters:
modelId
- The id of search modelcontextualParameters
- the contextual parameters- Returns:
- The column configurations in a List
- Throws:
ProcessingException
- if an error occurred
-
getSearchUIModel
Retrieves theSearchUIModel
with the given model identifier, with restrictions on content types- Parameters:
modelId
- the model identifiercontextualParameters
- the contextual parameters- Returns:
- the
SearchUIModel
-
copySearchModel
public DefaultSearchModel copySearchModel(SearchModel model, Map<String, Object> contextualParameters) Copy the given search model- Parameters:
model
- the model to copycontextualParameters
- the contextual parameters- Returns:
- the copy of the model
-
addContentTypeRestrictions
public void addContentTypeRestrictions(DefaultSearchModel model, String restrictedContentTypeId, Map<String, Object> contextualParameters) Add content type restrictions on the given search model Add content types to the model and restrict enumerator values of its content types criteria- Parameters:
model
- the modelrestrictedContentTypeId
- the selected content type identifiercontextualParameters
- the contextual parameters
-
addSolrFilterCriterion
public void addSolrFilterCriterion(SearchModel model, String solrRequest, Map<String, Object> contextualParameters) Add a solr filter criterion to the given model- Parameters:
model
- the modelsolrRequest
- the solr requestcontextualParameters
- the contextual parameters
-
setFacetedCriteria
public void setFacetedCriteria(DefaultSearchModel model, Collection<String> referencePaths, Map<String, Object> contextualParameters) Set faceted criteria to the given search model from the given reference paths If there is no reference path, the faceted criteria of the model are not changed- Parameters:
model
- the search modelreferencePaths
- the reference pathscontextualParameters
- the contextual parameters
-
getCriteriaLanguage
public String getCriteriaLanguage(SearchModel model, String searchMode, Map<String, Object> values, Map<String, Object> contextualParameters) Get the language.- Parameters:
model
- the search modelsearchMode
- The search mode (advanced or simple)values
- The user values.contextualParameters
- The search contextual parameters.- Returns:
- the query language.
-
createContentTypeOrMixinQuery
Create a content type or mixin query.- Parameters:
contentTypes
- the content types or mixins to search on.- Returns:
- the content type
Query
.
-
createContentTypeOrMixinQuery
public Query createContentTypeOrMixinQuery(Collection<String> contentTypes, Query.Operator operator) Create a content type or mixin query.- Parameters:
contentTypes
- the content types or mixins to search on.operator
- The operator to use in created query- Returns:
- the content type
Query
.
-
getCriterion
Retrieves the criterion with the given name- Parameters:
criteria
- the criteriacriterionName
- the name of the searched criterion- Returns:
- the criterion with the given name, or
null
if no corresponding criterion has been found
-