public class DefaultContentFilter extends Object implements ContentFilter
ContentFilter
. The filter's property are set by setter function and constructorContentFilter.Condition, ContentFilter.ContextLanguage
Modifier and Type | Field and Description |
---|---|
protected Expression |
_additionalFilterExpression
The additional expression
|
protected ContentTypeExtensionPoint |
_contentTypeEP
The extension point for content types
|
protected List<String> |
_contentTypes
The list of content types to match
|
protected ContentFilter.ContextLanguage |
_contextLang
The list of content languages to match
|
protected String |
_id
The filter id
|
protected int |
_length
The number max of results
|
protected Map<String,String> |
_metadata
The metadata to match
|
protected ContentFilter.Condition |
_metadataCondition
The metadata condition
|
protected String |
_metadataSetName
The view
|
protected AmetysObjectResolver |
_resolver
The Ametys object resolver
|
protected SortCriteria |
_sortCriteria
The sort criteria
|
protected SourceResolver |
_srcResolver
The source resolver
|
Constructor and Description |
---|
DefaultContentFilter()
Constructor
|
DefaultContentFilter(String id,
AmetysObjectResolver resolver,
ContentTypeExtensionPoint contentTypeExtensionPoint)
Creates a new filter
|
DefaultContentFilter(String id,
DefaultContentFilter originalFilter,
AmetysObjectResolver resolver,
ContentTypeExtensionPoint contentTypeExtensionPoint)
Creates a new filter from copy of another
|
Modifier and Type | Method and Description |
---|---|
void |
addContentType(String cTypeId)
Add a content type to the filter
|
void |
addMetadata(String metadataId,
String value)
Add a metadata filter
|
void |
addSortCriteria(String metadataId,
boolean ascending,
boolean useLowerCase)
Add a sort criteria
|
Expression |
getAdditionalFilterExpression()
Get the current filter expression
|
List<String> |
getContentTypes()
Get the content types to match contents
|
protected Expression |
getContentTypesExpression()
Get the expression corresponding to the filter's content types
|
ContentFilter.ContextLanguage |
getContextLanguage()
Get the context language
|
protected Expression |
getContextLanguagesExpression(String lang)
Get the
Expression associated with the given language context |
protected Expression |
getFilterExpression()
Get the expression corresponding to this filter
|
String |
getId()
Get the filter id
|
int |
getLength()
Get the max number of results
|
AmetysObjectIterable<Content> |
getMatchingContents()
Get the contents matching this filter.
|
AmetysObjectIterable<Content> |
getMatchingContents(String lang)
Get the contents matching this filter.
|
ContentFilter.Condition |
getMetadataCondition()
The metadata condition
|
protected Expression |
getMetadataExpression()
Get the expression corresponding to the filter's tags
|
Map<String,String> |
getMetadataValues()
Get the content types to match contents
|
SortCriteria |
getSortCriteria()
Get the sort criteria allows to sort query results.
|
String |
getView()
Get the name of
MetadataSet used for matching contents |
String |
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 language
|
void |
setId(String id)
Set the filter id.
|
void |
setLength(int length)
Set the max number o results
|
void |
setMetadataCondition(ContentFilter.Condition condition)
Set the metadata condition
|
void |
setResolver(AmetysObjectResolver resolver)
Set the ametys object resolver to execute query
|
void |
setView(String metadataSetName)
Set the filter view
|
protected AmetysObjectResolver _resolver
protected SourceResolver _srcResolver
protected List<String> _contentTypes
protected ContentFilter.ContextLanguage _contextLang
protected ContentFilter.Condition _metadataCondition
protected int _length
protected String _metadataSetName
protected SortCriteria _sortCriteria
protected Expression _additionalFilterExpression
protected ContentTypeExtensionPoint _contentTypeEP
public DefaultContentFilter()
public DefaultContentFilter(String id, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint)
id
- The filter unique identifierresolver
- The ametys object resolvercontentTypeExtensionPoint
- The extension point for content typespublic DefaultContentFilter(String id, DefaultContentFilter originalFilter, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint)
id
- The filter unique identifieroriginalFilter
- The original filter to be copiedresolver
- The ametys object resolvercontentTypeExtensionPoint
- The extension point for content typespublic List<String> getContentTypes()
ContentFilter
getContentTypes
in interface ContentFilter
public Map<String,String> getMetadataValues()
ContentFilter
getMetadataValues
in interface ContentFilter
public ContentFilter.Condition getMetadataCondition()
ContentFilter
getMetadataCondition
in interface ContentFilter
public ContentFilter.ContextLanguage getContextLanguage()
ContentFilter
getContextLanguage
in interface ContentFilter
public String getId()
ContentFilter
getId
in interface ContentFilter
public int getLength()
ContentFilter
getLength
in interface ContentFilter
public String getView()
ContentFilter
MetadataSet
used for matching contentsgetView
in interface ContentFilter
MetadataSet
used for matching contentspublic SortCriteria getSortCriteria()
ContentFilter
getSortCriteria
in interface ContentFilter
public void addContentType(String cTypeId)
ContentFilter
addContentType
in interface ContentFilter
cTypeId
- The content type id to addpublic void addMetadata(String metadataId, String value)
ContentFilter
addMetadata
in interface ContentFilter
metadataId
- The metadata id.value
- The value to test. Set null to test existencepublic void setMetadataCondition(ContentFilter.Condition condition)
ContentFilter
setMetadataCondition
in interface ContentFilter
condition
- The condition to setpublic Expression getAdditionalFilterExpression()
ContentFilter
getAdditionalFilterExpression
in interface ContentFilter
public void setAdditionalFilterExpression(Expression expression)
ContentFilter
setAdditionalFilterExpression
in interface ContentFilter
expression
- The expression to set. Can be null to remove curren expressionpublic void setContextLanguage(ContentFilter.ContextLanguage context)
ContentFilter
setContextLanguage
in interface ContentFilter
context
- The context language to setpublic void setId(String id)
ContentFilter
setId
in interface ContentFilter
id
- The id to set.public void setResolver(AmetysObjectResolver resolver)
ContentFilter
setResolver
in interface ContentFilter
resolver
- The ametys object resolver to setpublic void setLength(int length)
ContentFilter
setLength
in interface ContentFilter
length
- The max number of resultspublic void setView(String metadataSetName)
ContentFilter
setView
in interface ContentFilter
metadataSetName
- The name of MetadataSet
public void addSortCriteria(String metadataId, boolean ascending, boolean useLowerCase)
ContentFilter
addSortCriteria
in interface ContentFilter
metadataId
- The metadata id to sortascending
- true to ascending sortuseLowerCase
- true
for case insensitive order on a string propertypublic AmetysObjectIterable<Content> getMatchingContents()
ContentFilter
getMatchingContents
in interface ContentFilter
public AmetysObjectIterable<Content> getMatchingContents(String lang)
ContentFilter
getMatchingContents
in interface ContentFilter
lang
- The current language.public String getXPathQuery()
public String getXPathQuery(String lang)
lang
- The current languageprotected Expression getFilterExpression()
protected Expression getContentTypesExpression()
protected Expression getContextLanguagesExpression(String lang)
Expression
associated with the given language contextlang
- The current languageExpression
associated with the given language contextprotected Expression getMetadataExpression()