Package org.ametys.cms.search.ui.model
Class StaticSearchUIModel
java.lang.Object
org.ametys.cms.search.model.DefaultSearchModel
org.ametys.cms.search.ui.model.impl.DefaultSearchUIModel
org.ametys.cms.search.ui.model.StaticSearchUIModel
- All Implemented Interfaces:
SearchModel
,SearchUIModel
,Model
,ModelItemAccessor
,ModelItemContainer
,LogEnabled
,PluginAware
,Disposable
,Configurable
,Contextualizable
,Serviceable
public class StaticSearchUIModel
extends DefaultSearchUIModel
implements Serviceable, Contextualizable, Configurable, Disposable, LogEnabled, PluginAware
Static implementation of a
SearchUIModel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ColumnHelper
The helper for columnsprotected ContentTypeExtensionPoint
The content type extension pointprotected ContentTypesHelper
The content type helper.protected Context
The context.protected CriterionDefinitionHelper
The criterion definition helperComponentManager forSearchModelCriterionDefinition
s.protected String
The search model identifierprotected Logger
The logger.protected ServiceManager
The service managerprotected String
The plugin nameprotected SearchModelCriterionDefinitionHelper
The helper for search model criterion definitionprotected SearchModelCriterionViewItemHelper
The helper for search model criterion definitionprotected SystemPropertyExtensionPoint
The system property extension point.Fields inherited from class org.ametys.cms.search.ui.model.impl.DefaultSearchUIModel
__DEFAULT_EXPORT_CSV_URL, __DEFAULT_EXPORT_DOC_URL, __DEFAULT_EXPORT_PDF_URL, __DEFAULT_EXPORT_XML_URL, __DEFAULT_PRINT_URL, __DEFAULT_SEARCH_URL, __DEFAULT_URL_PLUGIN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription_configureBaseContentTypes
(Configuration configuration) Configure the base content type ids.protected void
_configureContentTypes
(Configuration configuration) Configure the content type idsprotected ViewItemContainer
_copyCriteria
(ViewItemContainer criteria, Predicate<ModelItem> filter) Copy the given criteria Groups are ignored and criteria are filtered by the givenPredicate
_copyCriteriaViewItems
(ViewItemContainer criteria, Predicate<ModelItem> filter) Retrieves the copies of the given criteriaprotected boolean
_isAdvanced
(ModelItem modelItem) Test if a criterion definition can be used in advanced search mode.protected boolean
_isFacetable
(ModelItem modelItem) Test if a criterion definition can be used as a facetprotected boolean
Determines if the content type is a valid content type in current configurationprotected void
_lookupCriteriaComponents
(Map<String, ModelViewItem> criteriaRoles, boolean checkFacetable) Lookup the previously initialized criteria components and add the criteria to their pendingSearchModelCriterionViewItem
protected List
<org.ametys.cms.search.ui.model.StaticSearchUIModel.SearchModelCriterionViewItemWithRole> _parseCriteria
(Set<ContentType> contentTypes, Configuration configuration) Parses criteria in the given configuration.protected ViewItemContainer
_parseCriteria
(Set<ContentType> contentTypes, Configuration configuration, Map<String, ModelViewItem> rolesByUICriteria, boolean acceptGroups) Parses criteria in the given configuration.protected SearchModelCriterionViewItem
_parseCriterionViewItem
(Configuration configuration) Parses theSearchModelCriterionViewItem
from the given configurationprotected List
<org.ametys.cms.search.ui.model.StaticSearchUIModel.SearchModelCriterionViewItemWithRole> _parseReferencingCriteria
(Set<ContentType> contentTypes, Configuration conf, String reference) Parses a criteria that references a model item of model's content types, or a system property Add a referencing criteria component to the manager.protected List
<org.ametys.cms.search.ui.model.StaticSearchUIModel.SearchModelCriterionViewItemWithRole> _parseStaticCriteria
(Set<ContentType> contentTypes, Configuration conf) Parses a static criteria Add a referencing criteria component to the manager.void
configure
(Configuration configuration) void
contextualize
(Context context) void
dispose()
getId()
Retrieves the model id (an id must be unique in the familyModel.getFamilyId()
protected final Logger
Get the logger.void
service
(ServiceManager manager) void
Called at creation time to provide aLogger
.void
setPluginInfo
(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.Methods inherited from class org.ametys.cms.search.ui.model.impl.DefaultSearchUIModel
_getAdvancedCriteriaListInfo, addAdvancedCriteria, allowSortOnMultipleJoin, getAdvancedCriteria, getExportCSVUrl, getExportCSVUrlPlugin, getExportDOCUrl, getExportDOCUrlPlugin, getExportPDFUrl, getExportPDFUrlPlugin, getExportXMLUrl, getExportXMLUrlPlugin, getPageSize, getPrintUrl, getPrintUrlPlugin, getSearchUrl, getSearchUrlPlugin, getSummaryView, setAdvancedCriteria, setAllowSortOnMultipleJoin, setExportCSVUrl, setExportCSVUrlPlugin, setExportDOCUrl, setExportDOCUrlPlugin, setExportPDFUrl, setExportPDFUrlPlugin, setExportXMLUrl, setExportXMLUrlPlugin, setPageSize, setPrintUrl, setPrintUrlPlugin, setSearchUrl, setSearchUrlPlugin, setSummaryView, toJSON
Methods inherited from class org.ametys.cms.search.model.DefaultSearchModel
_resultItemsToJSON, addCriteria, addFacetedCriteria, getContentTypes, getCriteria, getExcludedContentTypes, getFacetedCriteria, getResultItems, getWorkspace, resultItemsToJSON, setContentTypes, setCriteria, setExcludedContentTypes, setFacetedCriteria, setResultItems, setWorkspace
Methods 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
getContentTypes, getCriteria, getCriterion, getExcludedContentTypes, getFacetedCriteria, getFacetedCriterion, getFamilyId, getModelItems, getResultItem, getResultItems, getWorkspace, resultItemsToJSON
Methods inherited from interface org.ametys.cms.search.ui.model.SearchUIModel
addAdvancedCriterion, addAdvancedCriterion, addCriterion, addCriterion, addFacetedCriterion, addFacetedCriterion, getAdvancedCriterion
-
Field Details
-
_criterionDefinitionManager
ComponentManager forSearchModelCriterionDefinition
s. -
_context
The context. -
_manager
The service manager -
_pluginName
The plugin name -
_contentTypesHelper
The content type helper. -
_columnHelper
The helper for columns -
_contentTypeExtensionPoint
The content type extension point -
_systemPropertyExtensionPoint
The system property extension point. -
_criterionDefinitionHelper
The criterion definition helper -
_searchModelCriterionDefinitionHelper
The helper for search model criterion definition -
_searchUIModelCriterionDefinitionHelper
The helper for search model criterion definition -
_logger
The logger. -
_id
The search model identifier
-
-
Constructor Details
-
StaticSearchUIModel
public StaticSearchUIModel()
-
-
Method Details
-
setLogger
Description copied from interface:LogEnabled
Called at creation time to provide aLogger
.- Specified by:
setLogger
in interfaceLogEnabled
- Parameters:
logger
- aLogger
for messages.
-
getLogger
Get the logger.- Returns:
- the logger.
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
setPluginInfo
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
dispose
- Specified by:
dispose
in interfaceDisposable
-
_configureContentTypes
Configure the content type ids- Parameters:
configuration
- The content types configuration- Throws:
ConfigurationException
- If an error occurs
-
_configureBaseContentTypes
protected Set<String> _configureBaseContentTypes(Configuration configuration) throws ConfigurationException Configure the base content type ids.- Parameters:
configuration
- The content types configuration- Returns:
- The set of base content type ids
- Throws:
ConfigurationException
- If an error occurs
-
_isValidContentType
protected boolean _isValidContentType(String id, List<String> excludedTags, List<String> excludedContentTypes) Determines if the content type is a valid content type in current configuration- Parameters:
id
- The content type idexcludedTags
- The tags to excludeexcludedContentTypes
- The content types to exclude- Returns:
true
if the content type is a valid content type
-
_parseCriteria
protected ViewItemContainer _parseCriteria(Set<ContentType> contentTypes, Configuration configuration, Map<String, ModelViewItem> rolesByUICriteria, boolean acceptGroups) throws ConfigurationExceptionParses criteria in the given configuration. Add components in Search criteria manager and fill the Map with roles andSearchModelCriterionViewItem
- Parameters:
contentTypes
- the model's content typesconfiguration
- the model's configuration.rolesByUICriteria
- the map to fill with theSearchModelCriterionViewItem
and the role of the referencedSearchModelCriterionDefinition
acceptGroups
-true
if the parsed criteria is able to have groups,false
otherwise- Returns:
- the parsed criteria
- Throws:
ConfigurationException
- if an error occurs.
-
_parseCriteria
protected List<org.ametys.cms.search.ui.model.StaticSearchUIModel.SearchModelCriterionViewItemWithRole> _parseCriteria(Set<ContentType> contentTypes, Configuration configuration) throws ConfigurationException Parses criteria in the given configuration. Add components in Search criteria manager- Parameters:
contentTypes
- the model's content typesconfiguration
- the model's configuration.- Returns:
- the Map with roles and
SearchModelCriterionViewItem
- Throws:
ConfigurationException
- if an error occurs.
-
_parseReferencingCriteria
protected List<org.ametys.cms.search.ui.model.StaticSearchUIModel.SearchModelCriterionViewItemWithRole> _parseReferencingCriteria(Set<ContentType> contentTypes, Configuration conf, String reference) throws ConfigurationException Parses a criteria that references a model item of model's content types, or a system property Add a referencing criteria component to the manager.- Parameters:
contentTypes
- the model's content types.conf
- the criteria configuration.reference
- the path of the referenced item- Returns:
- A Map with the created UI criteria and potential role of the corresponding criterion
- Throws:
ConfigurationException
- if an error occurs.
-
_parseStaticCriteria
protected List<org.ametys.cms.search.ui.model.StaticSearchUIModel.SearchModelCriterionViewItemWithRole> _parseStaticCriteria(Set<ContentType> contentTypes, Configuration conf) throws ConfigurationException Parses a static criteria Add a referencing criteria component to the manager.- Parameters:
contentTypes
- the model's content types.conf
- the criteria configuration.- Returns:
- A Map with the created UI criteria and potential role of the corresponding criterion
- Throws:
ConfigurationException
- if an error occurs.
-
_parseCriterionViewItem
protected SearchModelCriterionViewItem _parseCriterionViewItem(Configuration configuration) throws ConfigurationException Parses theSearchModelCriterionViewItem
from the given configuration- Parameters:
configuration
- the configuration- Returns:
- the parsed UI criterion
- Throws:
ConfigurationException
- if an error occurs
-
_lookupCriteriaComponents
protected void _lookupCriteriaComponents(Map<String, ModelViewItem> criteriaRoles, boolean checkFacetable) throws ConfigurationExceptionLookup the previously initialized criteria components and add the criteria to their pendingSearchModelCriterionViewItem
- Parameters:
criteriaRoles
- the criteria map to fill.checkFacetable
- true to check if the criteria are facetable.- Throws:
ConfigurationException
- if an error occurs.
-
_copyCriteria
protected ViewItemContainer _copyCriteria(ViewItemContainer criteria, Predicate<ModelItem> filter) throws ConfigurationException Copy the given criteria Groups are ignored and criteria are filtered by the givenPredicate
- Parameters:
criteria
- the criteria to copyfilter
- the filter to apply on copied criteria- Returns:
- the copied criteria
- Throws:
ConfigurationException
- if an error occurs.
-
_copyCriteriaViewItems
protected List<ViewItem> _copyCriteriaViewItems(ViewItemContainer criteria, Predicate<ModelItem> filter) throws ConfigurationException Retrieves the copies of the given criteria- Parameters:
criteria
- the criteria to copyfilter
- the filter to apply on copied criteria- Returns:
- the copied criteria
- Throws:
ConfigurationException
- if an error occurs.
-
_isAdvanced
Test if a criterion definition can be used in advanced search mode. For instance: geocode, rich-text, file-typed criterion are not allowed.- Parameters:
modelItem
- the criterion definition to test.- Returns:
true
if the criterion can be used in advanced search mode,false
otherwise.
-
_isFacetable
Test if a criterion definition can be used as a facet- Parameters:
modelItem
- the criterion definition to test.- Returns:
true
if the criterion can be used as a facet,false
otherwise.
-
getId
Description copied from interface:Model
Retrieves the model id (an id must be unique in the familyModel.getFamilyId()
- Specified by:
getId
in interfaceModel
- Specified by:
getId
in interfaceSearchModel
- Returns:
- model id (for example the content type id for a content)
-