Package org.ametys.cms.search.model
Class DefaultSearchModel
java.lang.Object
org.ametys.cms.search.model.DefaultSearchModel
- All Implemented Interfaces:
SearchModel
,Model
,ModelItemAccessor
,ModelItemContainer
- Direct Known Subclasses:
DefaultSearchUIModel
Default implementation of a
SearchModel
.-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.DefaultSearchModel
(SearchModel searchModelToCopy, Map<String, Object> contextualParameters) Constructor by copying an existingSearchModel
. -
Method Summary
Modifier and TypeMethodDescription_resultItemsToJSON
(ViewItemAccessor viewItemAccessor) Converts the search model's result items on a JSON mapvoid
addCriteria
(SearchModelCriterionDefinitionHelper criterionDefinitionHelper, Map<String, Object> contextualParameters, String... references) Add criteria to the simple criteria.void
addFacetedCriteria
(SearchModelCriterionDefinitionHelper criterionDefinitionHelper, Map<String, Object> contextualParameters, String... references) Add criteria to the faceted criteria.getContentTypes
(Map<String, Object> contextualParameters) Get the list of content types.getCriteria
(Map<String, Object> contextualParameters) Retrieves the criteria in simple modegetExcludedContentTypes
(Map<String, Object> contextualParameters) Get the list of excluded content types.getFacetedCriteria
(Map<String, Object> contextualParameters) Retrieves the faceted criteria.getResultItems
(Map<String, Object> contextualParameters) Retrieves the search result itemsgetWorkspace
(Map<String, Object> contextualParameters) Get the specific workspace to use.resultItemsToJSON
(Map<String, Object> contextualParameters) Converts the search model's result items on a JSON listvoid
setContentTypes
(Set<String> cTypes) Set the content types of the modelsvoid
setCriteria
(ViewItemContainer criteria) Set the criteriavoid
setExcludedContentTypes
(Set<String> cTypes) Set the content types to excludevoid
setFacetedCriteria
(ViewItemContainer criteria) Set the faceted criteriavoid
setResultItems
(ViewItemContainer resultItems) Set the result itemsvoid
setWorkspace
(String workspace) Set the workspaceConverts the search model in a JSON mapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.runtime.model.ModelItemAccessor
getChild, getModelItem, hasModelItem
Methods inherited from interface org.ametys.cms.search.model.SearchModel
addCriterion, addFacetedCriterion, getCriterion, getFacetedCriterion, getFamilyId, getId, getModelItems, getResultItem
-
Constructor Details
-
DefaultSearchModel
public DefaultSearchModel()Default constructor. -
DefaultSearchModel
Constructor by copying an existingSearchModel
.- Parameters:
searchModelToCopy
- TheSearchModel
to copycontextualParameters
- The contextual parameters
-
-
Method Details
-
getContentTypes
Description copied from interface:SearchModel
Get the list of content types.- Specified by:
getContentTypes
in interfaceSearchModel
- Parameters:
contextualParameters
- the contextual parameters.- Returns:
- The list of content types.
-
setContentTypes
Set the content types of the models- Parameters:
cTypes
- The content types.
-
getExcludedContentTypes
Description copied from interface:SearchModel
Get the list of excluded content types.- Specified by:
getExcludedContentTypes
in interfaceSearchModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- The list of excluded content types.
-
setExcludedContentTypes
Set the content types to exclude- Parameters:
cTypes
- The content types to exclude
-
getCriteria
Description copied from interface:SearchModel
Retrieves the criteria in simple mode- Specified by:
getCriteria
in interfaceSearchModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the criteria in simple mode
-
addCriteria
public void addCriteria(SearchModelCriterionDefinitionHelper criterionDefinitionHelper, Map<String, Object> contextualParameters, String... references) Add criteria to the simple criteria. The created criteria reference the given paths- Parameters:
criterionDefinitionHelper
- the criterion definition helpercontextualParameters
- the contextual parametersreferences
- the paths to the items the criteria will reference
-
setCriteria
Set the criteria- Parameters:
criteria
- The criteria to set
-
getFacetedCriteria
Description copied from interface:SearchModel
Retrieves the faceted criteria.- Specified by:
getFacetedCriteria
in interfaceSearchModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the faceted criteria.
-
addFacetedCriteria
public void addFacetedCriteria(SearchModelCriterionDefinitionHelper criterionDefinitionHelper, Map<String, Object> contextualParameters, String... references) Add criteria to the faceted criteria. The created criteria reference the given paths- Parameters:
criterionDefinitionHelper
- the criterion definition helpercontextualParameters
- the contextual parametersreferences
- the paths to the items the criteria will reference
-
setFacetedCriteria
Set the faceted criteria- Parameters:
criteria
- The faceted criteria to set
-
getResultItems
Description copied from interface:SearchModel
Retrieves the search result items- Specified by:
getResultItems
in interfaceSearchModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the search result items
-
setResultItems
Set the result items- Parameters:
resultItems
- The result items to set
-
getWorkspace
Description copied from interface:SearchModel
Get the specific workspace to use.- Specified by:
getWorkspace
in interfaceSearchModel
- Parameters:
contextualParameters
- the contextual parameters.- Returns:
- the workspace to use when searching, or null to use the default workspace.
-
setWorkspace
Set the workspace- Parameters:
workspace
- The workspace to set
-
toJSON
Description copied from interface:SearchModel
Converts the search model in a JSON map- Specified by:
toJSON
in interfaceSearchModel
- Parameters:
contextualParameters
- The contextual parameters- Returns:
- the search model as a JSON map
-
resultItemsToJSON
Description copied from interface:SearchModel
Converts the search model's result items on a JSON list- Specified by:
resultItemsToJSON
in interfaceSearchModel
- Parameters:
contextualParameters
- The contextual parameters- Returns:
- the result items as a JSON list
-
_resultItemsToJSON
Converts the search model's result items on a JSON map- Parameters:
viewItemAccessor
- The result items- Returns:
- the result items as a JSON map
-