public class DefaultPageFilter extends Object implements PageFilter
PageFilter
. The
filter's property are set by setter function and constructorPageFilter.Context, PageFilter.ContextLanguage
Modifier and Type | Field and Description |
---|---|
protected PageFilter.Context |
_context
The context for search
|
protected PageFilter.ContextLanguage |
_contextLang
The context language
|
protected int |
_depth
The search depth
|
protected String |
_id
The filter id
|
protected int |
_length
The number max of results
|
protected Logger |
_logger
The logger
|
protected Map<String,String> |
_metadata
The metadata to match
|
protected String |
_pageId
The parent page Id
|
protected AmetysObjectResolver |
_resolver
The Ametys object resolver
|
protected SortCriteria |
_sortCriteria
The sort criteria
|
protected List<String> |
_tags
The list of tags to match
|
protected I18nizableText |
_title
The title
|
Constructor and Description |
---|
DefaultPageFilter()
Empty constructor
|
DefaultPageFilter(String id,
AmetysObjectResolver resolver)
Constructor
|
Modifier and Type | Method and Description |
---|---|
private static String |
_encode(String path) |
void |
addMetadata(String metadataId,
String value)
Add a metadata filter
|
void |
addSortCriteria(String metadataId,
boolean ascending,
boolean useLowerCase)
Add a sort criteria
|
void |
addTag(String tag)
Add a tag to the filter
|
PageFilter.Context |
getContext()
Get the search context
|
protected Expression |
getContextExpression(String siteName)
Get the
Expression associated with the given site context |
PageFilter.ContextLanguage |
getContextLanguage()
Get the context language
|
protected Expression |
getContextLanguagesExpression(String lang)
Get the
Expression associated with the given language context |
int |
getDepth()
Get the search depth
|
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<Page> |
getMatchingPages(String siteName,
String lang,
Page page)
Get the pages matching this filter.
|
protected Expression |
getMetadataExpression()
Get the expression corresponding to the filter's tags
|
Map<String,String> |
getMetadataValues()
Get the metadata id and value to match
|
String |
getPageId()
Get the parent page id
|
SortCriteria |
getSortCriteria()
Get the sort criteria allows to sort query results.
|
List<String> |
getTags()
Get the tag keys to match pages
|
protected Expression |
getTagsExpression()
Get the expression corresponding to the filter's tags
|
I18nizableText |
getTitle()
Get the title
|
protected String |
getXPathQuery(Page page,
int depth)
|
protected String |
getXPathQuery(String siteName,
String lang)
Creates the XPath query corresponding to this filter.
|
void |
setContext(PageFilter.Context context)
Set the search context
|
void |
setContextLanguage(PageFilter.ContextLanguage contextLang)
Set the context language
|
void |
setDepth(int depth)
Set the search depth
|
void |
setId(String id)
Set the filter id.
|
void |
setLength(int length)
Set the max number o results
|
void |
setPageId(String pageId)
set the parent page Id.
|
void |
setResolver(AmetysObjectResolver resolver)
Set the ametys object resolver to execute query
|
void |
setTitle(I18nizableText title)
Set the title
|
protected AmetysObjectResolver _resolver
protected PageFilter.Context _context
protected PageFilter.ContextLanguage _contextLang
protected int _depth
protected int _length
protected I18nizableText _title
protected SortCriteria _sortCriteria
public DefaultPageFilter()
public DefaultPageFilter(String id, AmetysObjectResolver resolver)
id
- The filter idresolver
- The ametys object resolver to resolve filter's querypublic String getId()
PageFilter
getId
in interface PageFilter
public int getLength()
PageFilter
getLength
in interface PageFilter
public int getDepth()
PageFilter
getDepth
in interface PageFilter
public List<String> getTags()
PageFilter
getTags
in interface PageFilter
public Map<String,String> getMetadataValues()
PageFilter
getMetadataValues
in interface PageFilter
public PageFilter.Context getContext()
PageFilter
getContext
in interface PageFilter
public PageFilter.ContextLanguage getContextLanguage()
PageFilter
getContextLanguage
in interface PageFilter
public SortCriteria getSortCriteria()
PageFilter
getSortCriteria
in interface PageFilter
public void addTag(String tag)
PageFilter
addTag
in interface PageFilter
tag
- The tag key to addpublic void addMetadata(String metadataId, String value)
PageFilter
addMetadata
in interface PageFilter
metadataId
- The metadata id.value
- The value to test. Set null to test existencepublic void setContext(PageFilter.Context context)
PageFilter
setContext
in interface PageFilter
context
- The search context to setpublic void setContextLanguage(PageFilter.ContextLanguage contextLang)
PageFilter
setContextLanguage
in interface PageFilter
contextLang
- The context languagepublic void setDepth(int depth)
PageFilter
setDepth
in interface PageFilter
depth
- The search depth. Set to 0
for no depth limitation.public void setId(String id)
PageFilter
setId
in interface PageFilter
id
- The id to set.public void addSortCriteria(String metadataId, boolean ascending, boolean useLowerCase)
PageFilter
addSortCriteria
in interface PageFilter
metadataId
- The metadata id to sortascending
- true to ascending sortuseLowerCase
- true
for case insensitive order on a string propertypublic void setResolver(AmetysObjectResolver resolver)
PageFilter
setResolver
in interface PageFilter
resolver
- The ametys object resolver to setpublic void setLength(int length)
PageFilter
setLength
in interface PageFilter
length
- The max number of resultspublic AmetysObjectIterable<Page> getMatchingPages(String siteName, String lang, Page page)
PageFilter
getMatchingPages
in interface PageFilter
siteName
- The current site name.lang
- The current language. Can be null.page
- The current page.protected String getXPathQuery(String siteName, String lang)
siteName
- The current site namelang
- The current languageprotected String getXPathQuery(Page page, int depth)
page
- The page where to start the searchdepth
- the search depthprotected Expression getFilterExpression()
protected Expression getTagsExpression()
protected Expression getMetadataExpression()
protected Expression getContextExpression(String siteName)
Expression
associated with the given site contextsiteName
- The current site nameExpression
associated with the given site contextprotected Expression getContextLanguagesExpression(String lang)
Expression
associated with the given language contextlang
- The current languageExpression
associated with the given language contextpublic I18nizableText getTitle()
PageFilter
getTitle
in interface PageFilter
public void setTitle(I18nizableText title)
PageFilter
setTitle
in interface PageFilter
title
- The titlepublic String getPageId()
PageFilter
getPageId
in interface PageFilter
public void setPageId(String pageId)
PageFilter
setPageId
in interface PageFilter
pageId
- Id of the parent page (when fetching child of a page).