Package org.ametys.cms.filter
Class DefaultContentFilter
- java.lang.Object
-
- org.ametys.cms.filter.DefaultContentFilter
-
- All Implemented Interfaces:
ContentFilter
- Direct Known Subclasses:
DefaultWebContentFilter
,StaticContentFilter
public class DefaultContentFilter extends Object implements ContentFilter
This is the default implementation of aContentFilter
. 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
Fields Modifier and Type Field Description protected Expression
_additionalFilterExpression
The additional expressionprotected ContentTypeExtensionPoint
_contentTypeEP
The extension point for content typesprotected List<String>
_contentTypes
The list of content types to matchprotected ContentFilter.ContextLanguage
_contextLang
The list of content languages to matchprotected String
_id
The filter idprotected int
_length
The number max of resultsprotected Map<String,String>
_metadata
The metadata to matchprotected ContentFilter.Condition
_metadataCondition
The metadata conditionprotected AmetysObjectResolver
_resolver
The Ametys object resolverprotected SortCriteria
_sortCriteria
The sort criteriaprotected SourceResolver
_srcResolver
The source resolverprotected String
_viewName
The view
-
Constructor Summary
Constructors Constructor Description DefaultContentFilter()
ConstructorDefaultContentFilter(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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 criteriaExpression
getAdditionalFilterExpression()
Get the current filter expressionList<String>
getContentTypes()
Get the content types to match contentsprotected Expression
getContentTypesExpression()
Get the expression corresponding to the filter's content typesContentFilter.ContextLanguage
getContextLanguage()
Get the context languageprotected Expression
getContextLanguagesExpression(String lang)
Get theExpression
associated with the given language contextprotected Expression
getFilterExpression()
Get the expression corresponding to this filterString
getId()
Get the filter idint
getLength()
Get the max number of resultsAmetysObjectIterable<Content>
getMatchingContents()
Get the contents matching this filter.AmetysObjectIterable<Content>
getMatchingContents(String lang)
Get the contents matching this filter.ContentFilter.Condition
getMetadataCondition()
The metadata conditionprotected Expression
getMetadataExpression()
Get the expression corresponding to the filter's tagsMap<String,String>
getMetadataValues()
Get the content types to match contentsSortCriteria
getSortCriteria()
Get the sort criteria allows to sort query results.String
getView()
Get the name ofView
used for matching contentsString
getXPathQuery()
Creates the XPath query corresponding to this filter.String
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
setContextLanguage(ContentFilter.ContextLanguage context)
Set the context languagevoid
setId(String id)
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
setView(String viewName)
Set the filter view
-
-
-
Field Detail
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
_srcResolver
protected SourceResolver _srcResolver
The source resolver
-
_contentTypes
protected List<String> _contentTypes
The list of content types to match
-
_contextLang
protected ContentFilter.ContextLanguage _contextLang
The list of content languages to match
-
_metadataCondition
protected ContentFilter.Condition _metadataCondition
The metadata condition
-
_length
protected int _length
The number max of results
-
_sortCriteria
protected SortCriteria _sortCriteria
The sort criteria
-
_additionalFilterExpression
protected Expression _additionalFilterExpression
The additional expression
-
_contentTypeEP
protected ContentTypeExtensionPoint _contentTypeEP
The extension point for content types
-
-
Constructor Detail
-
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 Detail
-
getContentTypes
public List<String> 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
public Map<String,String> 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
public ContentFilter.Condition getMetadataCondition()
Description copied from interface:ContentFilter
The metadata condition- Specified by:
getMetadataCondition
in interfaceContentFilter
- Returns:
- The metadata condition
-
getContextLanguage
public ContentFilter.ContextLanguage getContextLanguage()
Description copied from interface:ContentFilter
Get the context language- Specified by:
getContextLanguage
in interfaceContentFilter
- Returns:
- The context language
-
getId
public String getId()
Description copied from interface:ContentFilter
Get the filter id- Specified by:
getId
in interfaceContentFilter
- Returns:
- The filter id
-
getLength
public int getLength()
Description copied from interface:ContentFilter
Get the max number of results- Specified by:
getLength
in interfaceContentFilter
- Returns:
- The max number of results
-
getView
public String 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
public SortCriteria 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
public void addContentType(String cTypeId)
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
public void addMetadata(String metadataId, String value)
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
public void setMetadataCondition(ContentFilter.Condition condition)
Description copied from interface:ContentFilter
Set the metadata condition- Specified by:
setMetadataCondition
in interfaceContentFilter
- Parameters:
condition
- The condition to set
-
getAdditionalFilterExpression
public Expression getAdditionalFilterExpression()
Description copied from interface:ContentFilter
Get the current filter expression- Specified by:
getAdditionalFilterExpression
in interfaceContentFilter
- Returns:
- The expression. Can be null.
-
setAdditionalFilterExpression
public void setAdditionalFilterExpression(Expression expression)
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
public void setContextLanguage(ContentFilter.ContextLanguage context)
Description copied from interface:ContentFilter
Set the context language- Specified by:
setContextLanguage
in interfaceContentFilter
- Parameters:
context
- The context language to set
-
setId
public void setId(String id)
Description copied from interface:ContentFilter
Set the filter id.- Specified by:
setId
in interfaceContentFilter
- Parameters:
id
- The id to set.
-
setResolver
public void setResolver(AmetysObjectResolver resolver)
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
public void setLength(int length)
Description copied from interface:ContentFilter
Set the max number o results- Specified by:
setLength
in interfaceContentFilter
- Parameters:
length
- The max number of results
-
setView
public void setView(String viewName)
Description copied from interface:ContentFilter
Set the filter view- Specified by:
setView
in interfaceContentFilter
- Parameters:
viewName
- The name ofView
-
addSortCriteria
public void addSortCriteria(String metadataId, boolean ascending, boolean useLowerCase)
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
public AmetysObjectIterable<Content> getMatchingContents()
Description copied from interface:ContentFilter
Get the contents matching this filter.- Specified by:
getMatchingContents
in interfaceContentFilter
- Returns:
- The matching contents.
-
getMatchingContents
public AmetysObjectIterable<Content> getMatchingContents(String lang)
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
public String getXPathQuery()
Creates the XPath query corresponding to this filter.- Returns:
- the created XPath query
-
getXPathQuery
public String getXPathQuery(String lang)
Creates the XPath query corresponding to this filter.- Parameters:
lang
- The current language- Returns:
- the created XPath query
-
getFilterExpression
protected Expression getFilterExpression()
Get the expression corresponding to this filter- Returns:
- The created expression to match contents
-
getContentTypesExpression
protected Expression getContentTypesExpression()
Get the expression corresponding to the filter's content types- Returns:
- The expression corresponding to the filter's content types
-
getContextLanguagesExpression
protected Expression getContextLanguagesExpression(String lang)
Get theExpression
associated with the given language context- Parameters:
lang
- The current language- Returns:
- a
Expression
associated with the given language context
-
getMetadataExpression
protected Expression getMetadataExpression()
Get the expression corresponding to the filter's tags- Returns:
- The expression corresponding to the filter's tags
-
-