Package org.ametys.cms.search.solr
Class CriteriaSearchUIModelWrapper
- java.lang.Object
-
- org.ametys.cms.search.ui.model.AbstractSearchUIModel
-
- org.ametys.cms.search.solr.CriteriaSearchUIModelWrapper
-
- All Implemented Interfaces:
SearchModel
,SearchUIModel
,LogEnabled
,Contextualizable
,Serviceable
public class CriteriaSearchUIModelWrapper extends AbstractSearchUIModel
Search model wrapper which handles custom on-the-fly columns and facets.
-
-
Field Summary
Fields Modifier and Type Field Description protected ThreadSafeComponentManager<SearchUIColumn>
_searchUIColumnManager
ComponentManager forSearchUIColumn
s.protected ThreadSafeComponentManager<SearchUICriterion>
_searchUICriterionManager
ComponentManager forSearchUICriterion
s.-
Fields inherited from class org.ametys.cms.search.ui.model.AbstractSearchUIModel
_advancedSearchCriteria, _columns, _context, _cTypeEP, _cTypes, _excludedCTypes, _facetedCriteria, _logger, _manager, _searchCriteria, _searchModelHelper
-
-
Constructor Summary
Constructors Constructor Description CriteriaSearchUIModelWrapper(SearchUIModel model, ServiceManager manager, Context context, org.slf4j.Logger logger)
Build a model wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addIndexingFieldCriteriaComponents(List<Object> searchToolCriterionRoles, Set<String> baseContentTypeIds, String fieldRef)
Add a indexing field criteria component to the manager.protected void
addMetadataColumnComponents(List<Object> columnsRolesToLookup, Set<String> baseContentTypeIds, String metadataPath, Optional<String> columnLabel)
Add a metadata column component to the manager.protected void
addSystemColumnComponent(List<Object> columnsRolesToLookup, Set<String> baseContentTypeIds, String property, Optional<String> columnLabel)
Add a system column component to the manager.protected void
addSystemCriteriaComponents(List<Object> searchToolCriterionRoles, Set<String> baseContentTypeIds, String property)
Add a system criteria component to the manager.boolean
allowSortOnMultipleJoin()
protected void
configureColumns(List<Object> columnRoles, Set<String> baseContentTypeIds, Collection<ColumnHelper.Column> columnIds, SearchUIModel referenceModel, Map<String,Object> contextualParameters)
Configure the list of search columns.protected Collection<String>
configureFacets(List<Object> criteriaRoles, Set<String> baseContentTypeIds, Collection<String> criteriaIds, SearchUIModel referenceModel, Map<String,Object> contextualParameters)
Configure the list of faceted criteria.Map<String,SearchUICriterion>
getAdvancedCriteria(Map<String,Object> contextualParameters)
Get the list of search criteria in advanced modeprotected SearchUIColumn
getColumn(SearchUIModel searchModel, String columnId, Map<String,Object> contextualParameters)
Search a column in the reference model from its column identifier.Set<String>
getContentTypes(Map<String,Object> contextualParameters)
Get the list of content types.Map<String,SearchUICriterion>
getCriteria(Map<String,Object> contextualParameters)
Get the list of search criteria in simple modeSearchUICriterion
getCriterion(String id, Map<String,Object> contextualParameters)
Get a simple search criterion by its idprotected SearchUICriterion
getCriterion(SearchUIModel searchModel, String criterionId, Map<String,Object> contextualParameters)
Search a criterion in the reference model from its criterion identifier.Set<String>
getExcludedContentTypes(Map<String,Object> contextualParameters)
Get the list of excluded content types.String
getExportCSVUrl(Map<String,Object> contextualParameters)
Get the URL for CSV export of resultsString
getExportCSVUrlPlugin(Map<String,Object> contextualParameters)
Get the plugin name for CSV export of resultsString
getExportDOCUrl(Map<String,Object> contextualParameters)
Get the URL for DOC export of resultsString
getExportDOCUrlPlugin(Map<String,Object> contextualParameters)
Get the plugin name for DOC export of resultsString
getExportXMLUrl(Map<String,Object> contextualParameters)
Get the URL for XML export of resultsString
getExportXMLUrlPlugin(Map<String,Object> contextualParameters)
Get the plugin name for XML export of resultsMap<String,SearchUICriterion>
getFacetedCriteria(Map<String,Object> contextualParameters)
Get the list of faceted search criteria.String
getPrintUrl(Map<String,Object> contextualParameters)
Get the URL for print resultsString
getPrintUrlPlugin(Map<String,Object> contextualParameters)
Get the plugin name for print resultsSearchUIColumn
getResultField(String id, Map<String,Object> contextualParameters)
Get the column by its identifierMap<String,SearchUIColumn>
getResultFields(Map<String,Object> contextualParameters)
Get the column for resultsString
getSearchUrl(Map<String,Object> contextualParameters)
Get the URL for searchString
getSearchUrlPlugin(Map<String,Object> contextualParameters)
Get the plugin name for searchvoid
service(ServiceManager manager)
Collection<String>
setFacetedCriteria(Set<String> baseContentTypeIds, Collection<String> criteriaIds, Map<String,Object> contextualParameters)
Set the custom faceted criteria.void
setResultColumns(Set<String> baseContentTypeIds, Collection<ColumnHelper.Column> columns, Map<String,Object> contextualParameters)
Set the custom columns.-
Methods inherited from class org.ametys.cms.search.ui.model.AbstractSearchUIModel
addContentTypesConfiguration, contextualize, getCustomCriteriaConfiguration, getIndexingFieldCriteriaConfiguration, getIndexingFieldCriteriaConfiguration, getIndexingFieldCriteriaConfiguration, getLogger, getMetadataColumnConfiguration, getMetadataColumnConfiguration, getPageSize, getSummaryView, getSystemColumnConfiguration, getSystemColumnConfiguration, getSystemCriteriaConfiguration, getSystemCriteriaConfiguration, getSystemCriteriaConfiguration, getWorkspace, setAdvancedCriteria, setContentTypes, setCriteria, setExcludedContentTypes, setFacetedCriteria, setLogger, setResultFields
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.cms.search.ui.model.SearchUIModel
getAdvancedCriterion, getFacetedCriterion
-
-
-
-
Field Detail
-
_searchUICriterionManager
protected ThreadSafeComponentManager<SearchUICriterion> _searchUICriterionManager
ComponentManager forSearchUICriterion
s.
-
_searchUIColumnManager
protected ThreadSafeComponentManager<SearchUIColumn> _searchUIColumnManager
ComponentManager forSearchUIColumn
s.
-
-
Constructor Detail
-
CriteriaSearchUIModelWrapper
public CriteriaSearchUIModelWrapper(SearchUIModel model, ServiceManager manager, Context context, org.slf4j.Logger logger)
Build a model wrapper.- Parameters:
model
- the search model to wrap.manager
- the service manager.context
- the component context.logger
- the logger.
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractSearchUIModel
- Throws:
ServiceException
-
setFacetedCriteria
public Collection<String> setFacetedCriteria(Set<String> baseContentTypeIds, Collection<String> criteriaIds, Map<String,Object> contextualParameters) throws Exception
Set the custom faceted criteria.- Parameters:
baseContentTypeIds
- the reference content type identifiers.criteriaIds
- the criteria IDscontextualParameters
- the contextual parameters- Returns:
- the valid criteria IDs
- Throws:
Exception
- if an error occurs initializing criteria.
-
setResultColumns
public void setResultColumns(Set<String> baseContentTypeIds, Collection<ColumnHelper.Column> columns, Map<String,Object> contextualParameters) throws Exception
Set the custom columns.- Parameters:
baseContentTypeIds
- the reference content type identifiers.columns
- The columnscontextualParameters
- the contextual parameters- Throws:
Exception
- if an error occurs initializing columns.
-
configureFacets
protected Collection<String> configureFacets(List<Object> criteriaRoles, Set<String> baseContentTypeIds, Collection<String> criteriaIds, SearchUIModel referenceModel, Map<String,Object> contextualParameters) throws ConfigurationException
Configure the list of faceted criteria.- Parameters:
criteriaRoles
- the roles of criteria to lookup (or the already existing SearchUICriterion objects).baseContentTypeIds
- The reference content type identifiers.criteriaIds
- the criteria IDs.referenceModel
- the reference model.contextualParameters
- the contextual parameters- Returns:
- the valid criteria IDs
- Throws:
ConfigurationException
- if an error occurs creating a component configuration.
-
getCriterion
protected SearchUICriterion getCriterion(SearchUIModel searchModel, String criterionId, Map<String,Object> contextualParameters)
Search a criterion in the reference model from its criterion identifier.- Parameters:
searchModel
- the reference search model.criterionId
- the criterion identifier.contextualParameters
- the contextual parameters- Returns:
- the criterion if found, null otherwise.
-
configureColumns
protected void configureColumns(List<Object> columnRoles, Set<String> baseContentTypeIds, Collection<ColumnHelper.Column> columnIds, SearchUIModel referenceModel, Map<String,Object> contextualParameters) throws ConfigurationException
Configure the list of search columns.- Parameters:
columnRoles
- the roles of columns to lookup (or the already existing SearchUIColumn objects).baseContentTypeIds
- The reference content type identifiers.columnIds
- The columnsreferenceModel
- the reference model.contextualParameters
- the contextual parameters- Throws:
ConfigurationException
- if an error occurs creating a component configuration.
-
getColumn
protected SearchUIColumn getColumn(SearchUIModel searchModel, String columnId, Map<String,Object> contextualParameters)
Search a column in the reference model from its column identifier.- Parameters:
searchModel
- the reference search model.columnId
- the column identifier.contextualParameters
- the contextual parameters- Returns:
- the column if found, null otherwise.
-
addIndexingFieldCriteriaComponents
protected void addIndexingFieldCriteriaComponents(List<Object> searchToolCriterionRoles, Set<String> baseContentTypeIds, String fieldRef) throws ConfigurationException
Add a indexing field criteria component to the manager.- Parameters:
searchToolCriterionRoles
- the criteria role list to fill.baseContentTypeIds
- the reference content type identifiers.fieldRef
- the field path.- Throws:
ConfigurationException
- if an error occurs.
-
addSystemCriteriaComponents
protected void addSystemCriteriaComponents(List<Object> searchToolCriterionRoles, Set<String> baseContentTypeIds, String property) throws ConfigurationException
Add a system criteria component to the manager.- Parameters:
searchToolCriterionRoles
- the criteria role list to fill.baseContentTypeIds
- the reference content type identifiers.property
- the system property id.- Throws:
ConfigurationException
- if an error occurs.
-
addMetadataColumnComponents
protected void addMetadataColumnComponents(List<Object> columnsRolesToLookup, Set<String> baseContentTypeIds, String metadataPath, Optional<String> columnLabel) throws ConfigurationException
Add a metadata column component to the manager.- Parameters:
columnsRolesToLookup
- the columns rolesbaseContentTypeIds
- the reference content type identifiers.metadataPath
- the metadata path.columnLabel
- The (optional) label of the column. If not present, the column label will be the metadata one.- Throws:
ConfigurationException
- if an error occurs.
-
addSystemColumnComponent
protected void addSystemColumnComponent(List<Object> columnsRolesToLookup, Set<String> baseContentTypeIds, String property, Optional<String> columnLabel) throws ConfigurationException
Add a system column component to the manager.- Parameters:
columnsRolesToLookup
- the columns rolesbaseContentTypeIds
- the reference content type identifiers.property
- the system property.columnLabel
- The (optional) label of the column. If not present, the column label will be the metadata one.- Throws:
ConfigurationException
- if an error occurs.
-
getFacetedCriteria
public Map<String,SearchUICriterion> getFacetedCriteria(Map<String,Object> contextualParameters)
Description copied from interface:SearchModel
Get the list of faceted search criteria.- Specified by:
getFacetedCriteria
in interfaceSearchModel
- Specified by:
getFacetedCriteria
in interfaceSearchUIModel
- Overrides:
getFacetedCriteria
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the list of faceted search criteria.
-
getResultFields
public Map<String,SearchUIColumn> getResultFields(Map<String,Object> contextualParameters)
Description copied from interface:SearchModel
Get the column for results- Specified by:
getResultFields
in interfaceSearchModel
- Specified by:
getResultFields
in interfaceSearchUIModel
- Overrides:
getResultFields
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters. Can be null.- Returns:
- the column for results
-
getResultField
public SearchUIColumn getResultField(String id, Map<String,Object> contextualParameters)
Description copied from interface:SearchModel
Get the column by its identifier- Parameters:
id
- The column idcontextualParameters
- the contextual parameters- Returns:
- the column
-
getContentTypes
public Set<String> getContentTypes(Map<String,Object> contextualParameters)
Description copied from interface:SearchModel
Get the list of content types.- Specified by:
getContentTypes
in interfaceSearchModel
- Overrides:
getContentTypes
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters.- Returns:
- The list of content types.
-
getExcludedContentTypes
public Set<String> getExcludedContentTypes(Map<String,Object> contextualParameters)
Description copied from interface:SearchModel
Get the list of excluded content types.- Specified by:
getExcludedContentTypes
in interfaceSearchModel
- Overrides:
getExcludedContentTypes
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- The list of excluded content types.
-
getSearchUrl
public String getSearchUrl(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the URL for search- Specified by:
getSearchUrl
in interfaceSearchUIModel
- Overrides:
getSearchUrl
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the URL for search
-
getSearchUrlPlugin
public String getSearchUrlPlugin(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the plugin name for search- Specified by:
getSearchUrlPlugin
in interfaceSearchUIModel
- Overrides:
getSearchUrlPlugin
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the plugin name for search
-
getExportCSVUrl
public String getExportCSVUrl(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the URL for CSV export of results- Specified by:
getExportCSVUrl
in interfaceSearchUIModel
- Overrides:
getExportCSVUrl
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the URL for CSV export
-
getExportCSVUrlPlugin
public String getExportCSVUrlPlugin(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the plugin name for CSV export of results- Specified by:
getExportCSVUrlPlugin
in interfaceSearchUIModel
- Overrides:
getExportCSVUrlPlugin
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the plugin name for CSV export
-
getExportDOCUrl
public String getExportDOCUrl(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the URL for DOC export of results- Specified by:
getExportDOCUrl
in interfaceSearchUIModel
- Overrides:
getExportDOCUrl
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the URL for DOC export
-
getExportDOCUrlPlugin
public String getExportDOCUrlPlugin(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the plugin name for DOC export of results- Specified by:
getExportDOCUrlPlugin
in interfaceSearchUIModel
- Overrides:
getExportDOCUrlPlugin
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the plugin name for DOC export
-
getExportXMLUrl
public String getExportXMLUrl(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the URL for XML export of results- Specified by:
getExportXMLUrl
in interfaceSearchUIModel
- Overrides:
getExportXMLUrl
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the URL for XML export
-
getExportXMLUrlPlugin
public String getExportXMLUrlPlugin(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the plugin name for XML export of results- Specified by:
getExportXMLUrlPlugin
in interfaceSearchUIModel
- Overrides:
getExportXMLUrlPlugin
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the plugin name for XML export
-
getPrintUrl
public String getPrintUrl(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the URL for print results- Specified by:
getPrintUrl
in interfaceSearchUIModel
- Overrides:
getPrintUrl
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the URL for print results
-
getPrintUrlPlugin
public String getPrintUrlPlugin(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the plugin name for print results- Specified by:
getPrintUrlPlugin
in interfaceSearchUIModel
- Overrides:
getPrintUrlPlugin
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the plugin name for print results
-
allowSortOnMultipleJoin
public boolean allowSortOnMultipleJoin()
Description copied from interface:SearchUIModel
Indicates if sorting on join columns which contain at least onemultiple
metadata
in its path (intermediate ones only) must be allowed.
If the final metadata of the path is multiple, the column will not be sortable though.- Returns:
- true if sorting on join columns which contains at least one multiple metadata in its path (intermediate ones only) must be allowed.
-
getCriteria
public Map<String,SearchUICriterion> getCriteria(Map<String,Object> contextualParameters)
Description copied from interface:SearchModel
Get the list of search criteria in simple mode- Specified by:
getCriteria
in interfaceSearchModel
- Specified by:
getCriteria
in interfaceSearchUIModel
- Overrides:
getCriteria
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the list of search criteria in simple mode
-
getCriterion
public SearchUICriterion getCriterion(String id, Map<String,Object> contextualParameters)
Description copied from interface:SearchModel
Get a simple search criterion by its id- Parameters:
id
- The search criterion idcontextualParameters
- the contextual parameters- Returns:
- the criterion or
null
if not found
-
getAdvancedCriteria
public Map<String,SearchUICriterion> getAdvancedCriteria(Map<String,Object> contextualParameters)
Description copied from interface:SearchUIModel
Get the list of search criteria in advanced mode- Specified by:
getAdvancedCriteria
in interfaceSearchUIModel
- Overrides:
getAdvancedCriteria
in classAbstractSearchUIModel
- Parameters:
contextualParameters
- the contextual parameters- Returns:
- the list of search criteria in advanced mode
-
-