Package org.ametys.cms.filter
Class DefaultContentFilter
java.lang.Object
org.ametys.cms.filter.DefaultContentFilter
- All Implemented Interfaces:
ContentFilter
- Direct Known Subclasses:
DefaultWebContentFilter
,StaticContentFilter
This is the default implementation of a
ContentFilter
. The filter's property are set by setter function and constructor-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ametys.cms.filter.ContentFilter
ContentFilter.Condition, ContentFilter.ContextLanguage
-
Field Summary
Modifier and TypeFieldDescriptionprotected Expression
The additional expressionprotected ContentTypeExtensionPoint
The extension point for content typesThe list of content types to matchprotected ContentFilter.ContextLanguage
The list of content languages to matchprotected String
The filter idprotected int
The number max of resultsThe metadata to matchprotected ContentFilter.Condition
The metadata conditionprotected AmetysObjectResolver
The Ametys object resolverprotected SortCriteria
The sort criteriaprotected SourceResolver
The source resolverprotected String
The view -
Constructor Summary
ConstructorDescriptionConstructorDefaultContentFilter
(String id, DefaultContentFilter originalFilter, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint) Creates a new filter from copy of anotherDefaultContentFilter
(String id, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint) Creates a new filter -
Method Summary
Modifier and TypeMethodDescriptionvoid
addContentType
(String cTypeId) Add a content type to the filtervoid
addMetadata
(String metadataId, String value) Add a metadata filtervoid
addSortCriteria
(String metadataId, boolean ascending, boolean useLowerCase) Add a sort criteriaGet the current filter expressionGet the content types to match contentsprotected Expression
Get the expression corresponding to the filter's content typesGet the context languageprotected Expression
Get theExpression
associated with the given language contextprotected Expression
Get the expression corresponding to this filtergetId()
Get the filter idint
Get the max number of resultsGet the contents matching this filter.getMatchingContents
(String lang) Get the contents matching this filter.The metadata conditionprotected Expression
Get the expression corresponding to the filter's tagsGet the content types to match contentsGet the sort criteria allows to sort query results.getView()
Get the name ofView
used for matching contentsCreates the XPath query corresponding to this filter.getXPathQuery
(String lang) Creates the XPath query corresponding to this filter.void
setAdditionalFilterExpression
(Expression expression) Set the filter expression that should complete metadata filtering (by doing an AND between both)void
Set the context languagevoid
Set the filter id.void
setLength
(int length) Set the max number o resultsvoid
setMetadataCondition
(ContentFilter.Condition condition) Set the metadata conditionvoid
setResolver
(AmetysObjectResolver resolver) Set the ametys object resolver to execute queryvoid
Set the filter view
-
Field Details
-
_resolver
The Ametys object resolver -
_srcResolver
The source resolver -
_id
The filter id -
_contentTypes
The list of content types to match -
_contextLang
The list of content languages to match -
_metadata
The metadata to match -
_metadataCondition
The metadata condition -
_length
The number max of results -
_viewName
The view -
_sortCriteria
The sort criteria -
_additionalFilterExpression
The additional expression -
_contentTypeEP
The extension point for content types
-
-
Constructor Details
-
DefaultContentFilter
public DefaultContentFilter()Constructor -
DefaultContentFilter
public DefaultContentFilter(String id, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint) Creates a new filter- Parameters:
id
- The filter unique identifierresolver
- The ametys object resolvercontentTypeExtensionPoint
- The extension point for content types
-
DefaultContentFilter
public DefaultContentFilter(String id, DefaultContentFilter originalFilter, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint) Creates a new filter from copy of another- Parameters:
id
- The filter unique identifieroriginalFilter
- The original filter to be copiedresolver
- The ametys object resolvercontentTypeExtensionPoint
- The extension point for content types
-
-
Method Details
-
getContentTypes
Description copied from interface:ContentFilter
Get the content types to match contents- Specified by:
getContentTypes
in interfaceContentFilter
- Returns:
- The content types to match contents
-
getMetadataValues
Description copied from interface:ContentFilter
Get the content types to match contents- Specified by:
getMetadataValues
in interfaceContentFilter
- Returns:
- The content types to match contents
-
getMetadataCondition
Description copied from interface:ContentFilter
The metadata condition- Specified by:
getMetadataCondition
in interfaceContentFilter
- Returns:
- The metadata condition
-
getContextLanguage
Description copied from interface:ContentFilter
Get the context language- Specified by:
getContextLanguage
in interfaceContentFilter
- Returns:
- The context language
-
getId
Description copied from interface:ContentFilter
Get the filter id- Specified by:
getId
in interfaceContentFilter
- Returns:
- The filter id
-
getLength
Description copied from interface:ContentFilter
Get the max number of results- Specified by:
getLength
in interfaceContentFilter
- Returns:
- The max number of results
-
getView
Description copied from interface:ContentFilter
Get the name ofView
used for matching contents- Specified by:
getView
in interfaceContentFilter
- Returns:
- The name of
View
used for matching contents
-
getSortCriteria
Description copied from interface:ContentFilter
Get the sort criteria allows to sort query results.- Specified by:
getSortCriteria
in interfaceContentFilter
- Returns:
- the sort criteria
-
addContentType
Description copied from interface:ContentFilter
Add a content type to the filter- Specified by:
addContentType
in interfaceContentFilter
- Parameters:
cTypeId
- The content type id to add
-
addMetadata
Description copied from interface:ContentFilter
Add a metadata filter- Specified by:
addMetadata
in interfaceContentFilter
- Parameters:
metadataId
- The metadata id.value
- The value to test. Set null to test existence
-
setMetadataCondition
Description copied from interface:ContentFilter
Set the metadata condition- Specified by:
setMetadataCondition
in interfaceContentFilter
- Parameters:
condition
- The condition to set
-
getAdditionalFilterExpression
Description copied from interface:ContentFilter
Get the current filter expression- Specified by:
getAdditionalFilterExpression
in interfaceContentFilter
- Returns:
- The expression. Can be null.
-
setAdditionalFilterExpression
Description copied from interface:ContentFilter
Set the filter expression that should complete metadata filtering (by doing an AND between both)- Specified by:
setAdditionalFilterExpression
in interfaceContentFilter
- Parameters:
expression
- The expression to set. Can be null to remove curren expression
-
setContextLanguage
Description copied from interface:ContentFilter
Set the context language- Specified by:
setContextLanguage
in interfaceContentFilter
- Parameters:
context
- The context language to set
-
setId
Description copied from interface:ContentFilter
Set the filter id.- Specified by:
setId
in interfaceContentFilter
- Parameters:
id
- The id to set.
-
setResolver
Description copied from interface:ContentFilter
Set the ametys object resolver to execute query- Specified by:
setResolver
in interfaceContentFilter
- Parameters:
resolver
- The ametys object resolver to set
-
setLength
Description copied from interface:ContentFilter
Set the max number o results- Specified by:
setLength
in interfaceContentFilter
- Parameters:
length
- The max number of results
-
setView
Description copied from interface:ContentFilter
Set the filter view- Specified by:
setView
in interfaceContentFilter
- Parameters:
viewName
- The name ofView
-
addSortCriteria
Description copied from interface:ContentFilter
Add a sort criteria- Specified by:
addSortCriteria
in interfaceContentFilter
- Parameters:
metadataId
- The metadata id to sortascending
- true to ascending sortuseLowerCase
-true
for case insensitive order on a string property
-
getMatchingContents
Description copied from interface:ContentFilter
Get the contents matching this filter.- Specified by:
getMatchingContents
in interfaceContentFilter
- Returns:
- The matching contents.
-
getMatchingContents
Description copied from interface:ContentFilter
Get the contents matching this filter.- Specified by:
getMatchingContents
in interfaceContentFilter
- Parameters:
lang
- The current language.- Returns:
- The matching contents.
-
getXPathQuery
Creates the XPath query corresponding to this filter.- Returns:
- the created XPath query
-
getXPathQuery
Creates the XPath query corresponding to this filter.- Parameters:
lang
- The current language- Returns:
- the created XPath query
-
getFilterExpression
Get the expression corresponding to this filter- Returns:
- The created expression to match contents
-
getContentTypesExpression
Get the expression corresponding to the filter's content types- Returns:
- The expression corresponding to the filter's content types
-
getContextLanguagesExpression
Get theExpression
associated with the given language context- Parameters:
lang
- The current language- Returns:
- a
Expression
associated with the given language context
-
getMetadataExpression
Get the expression corresponding to the filter's tags- Returns:
- The expression corresponding to the filter's tags
-