Package org.ametys.web.filter
Class DefaultPageFilter
- java.lang.Object
-
- org.ametys.web.filter.DefaultPageFilter
-
- All Implemented Interfaces:
PageFilter
- Direct Known Subclasses:
StaticPageFilter
public class DefaultPageFilter extends Object implements PageFilter
This is the default implementation of aPageFilter
. The filter's property are set by setter function and constructor
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.web.filter.PageFilter
PageFilter.Context, PageFilter.ContextLanguage
-
-
Field Summary
Fields Modifier and Type Field Description protected PageFilter.Context
_context
The context for searchprotected PageFilter.ContextLanguage
_contextLang
The context languageprotected int
_depth
The search depthprotected String
_id
The filter idprotected int
_length
The number max of resultsprotected org.slf4j.Logger
_logger
The loggerprotected Map<String,String>
_metadata
The metadata to matchprotected String
_pageId
The parent page Idprotected AmetysObjectResolver
_resolver
The Ametys object resolverprotected SortCriteria
_sortCriteria
The sort criteriaprotected List<String>
_tags
The list of tags to matchprotected I18nizableText
_title
The title
-
Constructor Summary
Constructors Constructor Description DefaultPageFilter()
Empty constructorDefaultPageFilter(String id, AmetysObjectResolver resolver)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static String
_encode(String path)
void
addMetadata(String metadataId, String value)
Add a metadata filtervoid
addSortCriteria(String metadataId, boolean ascending, boolean useLowerCase)
Add a sort criteriavoid
addTag(String tag)
Add a tag to the filterPageFilter.Context
getContext()
Get the search contextprotected Expression
getContextExpression(String siteName)
Get theExpression
associated with the given site contextPageFilter.ContextLanguage
getContextLanguage()
Get the context languageprotected Expression
getContextLanguagesExpression(String lang)
Get theExpression
associated with the given language contextint
getDepth()
Get the search depthprotected Expression
getFilterExpression()
Get the expression corresponding to this filterString
getId()
Get the filter idint
getLength()
Get the max number of resultsAmetysObjectIterable<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 tagsMap<String,String>
getMetadataValues()
Get the metadata id and value to matchString
getPageId()
Get the parent page idSortCriteria
getSortCriteria()
Get the sort criteria allows to sort query results.List<String>
getTags()
Get the tag keys to match pagesprotected Expression
getTagsExpression()
Get the expression corresponding to the filter's tagsI18nizableText
getTitle()
Get the titleprotected String
getXPathQuery(String siteName, String lang)
Creates the XPath query corresponding to this filter.protected String
getXPathQuery(Page page, int depth)
void
setContext(PageFilter.Context context)
Set the search contextvoid
setContextLanguage(PageFilter.ContextLanguage contextLang)
Set the context languagevoid
setDepth(int depth)
Set the search depthvoid
setId(String id)
Set the filter id.void
setLength(int length)
Set the max number o resultsvoid
setPageId(String pageId)
set the parent page Id.void
setResolver(AmetysObjectResolver resolver)
Set the ametys object resolver to execute queryvoid
setTitle(I18nizableText title)
Set the title
-
-
-
Field Detail
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
_context
protected PageFilter.Context _context
The context for search
-
_contextLang
protected PageFilter.ContextLanguage _contextLang
The context language
-
_depth
protected int _depth
The search depth
-
_length
protected int _length
The number max of results
-
_title
protected I18nizableText _title
The title
-
_sortCriteria
protected SortCriteria _sortCriteria
The sort criteria
-
_logger
protected org.slf4j.Logger _logger
The logger
-
-
Constructor Detail
-
DefaultPageFilter
public DefaultPageFilter()
Empty constructor
-
DefaultPageFilter
public DefaultPageFilter(String id, AmetysObjectResolver resolver)
Constructor- Parameters:
id
- The filter idresolver
- The ametys object resolver to resolve filter's query
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:PageFilter
Get the filter id- Specified by:
getId
in interfacePageFilter
- Returns:
- The filter id
-
getLength
public int getLength()
Description copied from interface:PageFilter
Get the max number of results- Specified by:
getLength
in interfacePageFilter
- Returns:
- The max number of results
-
getDepth
public int getDepth()
Description copied from interface:PageFilter
Get the search depth- Specified by:
getDepth
in interfacePageFilter
- Returns:
- The search depth
-
getTags
public List<String> getTags()
Description copied from interface:PageFilter
Get the tag keys to match pages- Specified by:
getTags
in interfacePageFilter
- Returns:
- The tag keys to match pages
-
getMetadataValues
public Map<String,String> getMetadataValues()
Description copied from interface:PageFilter
Get the metadata id and value to match- Specified by:
getMetadataValues
in interfacePageFilter
- Returns:
- The metadata to match pages
-
getContext
public PageFilter.Context getContext()
Description copied from interface:PageFilter
Get the search context- Specified by:
getContext
in interfacePageFilter
- Returns:
- The search context
-
getContextLanguage
public PageFilter.ContextLanguage getContextLanguage()
Description copied from interface:PageFilter
Get the context language- Specified by:
getContextLanguage
in interfacePageFilter
- Returns:
- The context language
-
getSortCriteria
public SortCriteria getSortCriteria()
Description copied from interface:PageFilter
Get the sort criteria allows to sort query results.- Specified by:
getSortCriteria
in interfacePageFilter
- Returns:
- the sort criteria
-
addTag
public void addTag(String tag)
Description copied from interface:PageFilter
Add a tag to the filter- Specified by:
addTag
in interfacePageFilter
- Parameters:
tag
- The tag key to add
-
addMetadata
public void addMetadata(String metadataId, String value)
Description copied from interface:PageFilter
Add a metadata filter- Specified by:
addMetadata
in interfacePageFilter
- Parameters:
metadataId
- The metadata id.value
- The value to test. Set null to test existence
-
setContext
public void setContext(PageFilter.Context context)
Description copied from interface:PageFilter
Set the search context- Specified by:
setContext
in interfacePageFilter
- Parameters:
context
- The search context to set
-
setContextLanguage
public void setContextLanguage(PageFilter.ContextLanguage contextLang)
Description copied from interface:PageFilter
Set the context language- Specified by:
setContextLanguage
in interfacePageFilter
- Parameters:
contextLang
- The context language
-
setDepth
public void setDepth(int depth)
Description copied from interface:PageFilter
Set the search depth- Specified by:
setDepth
in interfacePageFilter
- Parameters:
depth
- The search depth. Set to0
for no depth limitation.
-
setId
public void setId(String id)
Description copied from interface:PageFilter
Set the filter id.- Specified by:
setId
in interfacePageFilter
- Parameters:
id
- The id to set.
-
addSortCriteria
public void addSortCriteria(String metadataId, boolean ascending, boolean useLowerCase)
Description copied from interface:PageFilter
Add a sort criteria- Specified by:
addSortCriteria
in interfacePageFilter
- Parameters:
metadataId
- The metadata id to sortascending
- true to ascending sortuseLowerCase
-true
for case insensitive order on a string property
-
setResolver
public void setResolver(AmetysObjectResolver resolver)
Description copied from interface:PageFilter
Set the ametys object resolver to execute query- Specified by:
setResolver
in interfacePageFilter
- Parameters:
resolver
- The ametys object resolver to set
-
setLength
public void setLength(int length)
Description copied from interface:PageFilter
Set the max number o results- Specified by:
setLength
in interfacePageFilter
- Parameters:
length
- The max number of results
-
getMatchingPages
public AmetysObjectIterable<Page> getMatchingPages(String siteName, String lang, Page page)
Description copied from interface:PageFilter
Get the pages matching this filter.- Specified by:
getMatchingPages
in interfacePageFilter
- Parameters:
siteName
- The current site name.lang
- The current language. Can be null.page
- The current page.- Returns:
- The matching pages.
-
getXPathQuery
protected String getXPathQuery(String siteName, String lang)
Creates the XPath query corresponding to this filter.- Parameters:
siteName
- The current site namelang
- The current language- Returns:
- the created XPath query
-
getXPathQuery
protected String getXPathQuery(Page page, int depth)
- Parameters:
page
- The page where to start the searchdepth
- the search depth- Returns:
- the created XPath query
-
getFilterExpression
protected Expression getFilterExpression()
Get the expression corresponding to this filter- Returns:
- The created expression to match contents
-
getTagsExpression
protected Expression getTagsExpression()
Get the expression corresponding to the filter's tags- Returns:
- The expression corresponding to the filter's tags
-
getMetadataExpression
protected Expression getMetadataExpression()
Get the expression corresponding to the filter's tags- Returns:
- The expression corresponding to the filter's tags
-
getContextExpression
protected Expression getContextExpression(String siteName)
Get theExpression
associated with the given site context- Parameters:
siteName
- The current site name- Returns:
- a
Expression
associated with the given site context
-
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
-
getTitle
public I18nizableText getTitle()
Description copied from interface:PageFilter
Get the title- Specified by:
getTitle
in interfacePageFilter
- Returns:
- The title
-
setTitle
public void setTitle(I18nizableText title)
Description copied from interface:PageFilter
Set the title- Specified by:
setTitle
in interfacePageFilter
- Parameters:
title
- The title
-
getPageId
public String getPageId()
Description copied from interface:PageFilter
Get the parent page id- Specified by:
getPageId
in interfacePageFilter
- Returns:
- The parent page id
-
setPageId
public void setPageId(String pageId)
Description copied from interface:PageFilter
set the parent page Id.- Specified by:
setPageId
in interfacePageFilter
- Parameters:
pageId
- Id of the parent page (when fetching child of a page).
-
-