Package com.jalios.jcms
Class QueryFilter
- java.lang.Object
-
- com.jalios.jcms.QueryFilter
-
- All Implemented Interfaces:
PluginComponent
,java.lang.Comparable
- Direct Known Subclasses:
ContentQueryFilter
,MailThreadQueryFilter
,MediaQueryFilter
,SpellSuggestEngine
public abstract class QueryFilter extends java.lang.Object implements PluginComponent, java.lang.Comparable
A QueryFilter is notified for each query.- Since:
- jcms-5.0.0
- Author:
- Olivier Dedieu
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BACKOFFICE_SEARCH
QueryHandler attribute used to indicate that we are processing a back office search.static java.lang.String
FRONTOFFICE_SEARCH
QueryHandler attribute used to indicate that we are processing a front office search.protected int
order
static java.lang.String
PORTLET_QUERY
QueryHandler attribute used to indicate that we are processing a portlet's query.
-
Constructor Summary
Constructors Constructor Description QueryFilter()
Constructs a QueryFilter with order = 0QueryFilter(int order)
Constructs a QueryFilter with the given order
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
callFilterDBResult(PublicationCriteria pubCriteria)
Returns true if the methodfilterDBResult(Publication, Map)
must be called during a DB query search.boolean
callFilterDBResult(java.lang.Class clazz, java.util.Map<java.lang.String,java.lang.Object> context)
This convenient method is a simplfied version ofcallFilterDBResult(PublicationCriteria)
.int
compareTo(java.lang.Object obj)
Compare this object with the specified object for order.boolean
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.void
filterCriteria(PublicationCriteria pubCriteria, org.hibernate.Criteria criteria)
This method should be overriden to modify the Hibernate Criteria used for a DB Query.boolean
filterDBResult(Publication pub, java.util.Map<java.lang.String,java.lang.Object> context)
This method should be overriden to filter DB results.QueryHandler
filterQueryHandler(QueryHandler qh, java.util.Map context)
This method should be overriden to filter the value of the QueryHandlerQueryResultSet
filterResultSet(QueryHandler qh, QueryResultSet set, java.util.Map context)
This method should be overriden to filter the result setint
getOrder()
Retrieve the order value used to sort QueryFilter.boolean
getSearchDefault()
This method may overriden if this QueryFilter is selectable from the search user interface.java.lang.String
getSearchDescription(java.lang.String lang)
This method may be overriden if this QueryFilter is selectable from the search user interface.java.lang.String
getSearchLabel(java.lang.String lang)
This method may be overriden if this QueryFilter is selectable from the search user interface.java.lang.String
getSearchParam()
This method must be overriden if this QueryFilter is selectable from the search user interface.boolean
init(Plugin plugin)
Initialize the component with the given plugin configurationstatic boolean
isBackOfficeSearch(QueryHandler qh)
Check if the specified QueryHandler is a back office search.static boolean
isFrontOfficeSearch(QueryHandler qh)
Check if the specified QueryHandler is a front office search.static boolean
isPortletQuery(QueryHandler qh)
Check if the specified QueryHandler is a portlet query.
-
-
-
Field Detail
-
FRONTOFFICE_SEARCH
public static final java.lang.String FRONTOFFICE_SEARCH
QueryHandler attribute used to indicate that we are processing a front office search.
Do not directly read this attribute, use methodisFrontOfficeSearch(QueryHandler)
.
-
BACKOFFICE_SEARCH
public static final java.lang.String BACKOFFICE_SEARCH
QueryHandler attribute used to indicate that we are processing a back office search.
Do not directly read this attribute, use methodisBackOfficeSearch(QueryHandler)
.
-
PORTLET_QUERY
public static final java.lang.String PORTLET_QUERY
QueryHandler attribute used to indicate that we are processing a portlet's query.
Do not directly read this attribute, use methodisPortletQuery(QueryHandler)
.
-
order
protected int order
-
-
Method Detail
-
init
public boolean init(Plugin plugin)
Description copied from interface:PluginComponent
Initialize the component with the given plugin configuration- Specified by:
init
in interfacePluginComponent
- Parameters:
plugin
- the calling plugin- Returns:
- true if the component has been correctly initialized.
- Since:
- jcms-5.7.2
- See Also:
PluginComponent.init(Plugin)
-
filterQueryHandler
public QueryHandler filterQueryHandler(QueryHandler qh, java.util.Map context)
This method should be overriden to filter the value of the QueryHandler- Parameters:
qh
- the QueryHandlercontext
- the context. Can be used to exchange data between custom QueryFilters.- Returns:
- the (filtered) QueryHandler
- Since:
- jcms-5.0.0
-
filterResultSet
public QueryResultSet filterResultSet(QueryHandler qh, QueryResultSet set, java.util.Map context)
This method should be overriden to filter the result set- Parameters:
qh
- the QueryHandlerset
- the result setcontext
- the context. Can be used to exchange data between custom QueryFilters.- Returns:
- the (filtered) result set
- Since:
- jcms-5.0.0
-
filterCriteria
public void filterCriteria(PublicationCriteria pubCriteria, org.hibernate.Criteria criteria)
This method should be overriden to modify the Hibernate Criteria used for a DB Query.- Parameters:
pubCriteria
- the criteria of the query.criteria
- the hibernate criteria computed by JPlatform core- Since:
- jcms-10.0.7 / JCMS-9561
-
filterDBResult
public boolean filterDBResult(Publication pub, java.util.Map<java.lang.String,java.lang.Object> context)
This method should be overriden to filter DB results.- Parameters:
pub
- a DB Publicationcontext
- the context used during the query- Returns:
- true if the results must be kept and false if it must be ignored.
- Since:
- jcms-10.0.0
-
callFilterDBResult
public boolean callFilterDBResult(PublicationCriteria pubCriteria)
Returns true if the methodfilterDBResult(Publication, Map)
must be called during a DB query search.- Parameters:
pubCriteria
- the criteria of the query.- Returns:
- true if the method
filterDBResult(Publication, Map)
must be called during a DB query search. - Since:
- jcms-10.0.0
-
callFilterDBResult
public boolean callFilterDBResult(java.lang.Class clazz, java.util.Map<java.lang.String,java.lang.Object> context)
This convenient method is a simplfied version ofcallFilterDBResult(PublicationCriteria)
.- Parameters:
clazz
- the classcontext
- a context map.- Returns:
- true if the method
filterDBResult(Publication, Map)
must be called during a DB query search. - Since:
- jcms-10.0.0
-
getSearchParam
public java.lang.String getSearchParam()
This method must be overriden if this QueryFilter is selectable from the search user interface.- Returns:
- the name of the http query parameter
- Since:
- jcms-5.5.0
-
getSearchLabel
public java.lang.String getSearchLabel(java.lang.String lang)
This method may be overriden if this QueryFilter is selectable from the search user interface.- Parameters:
lang
- the user language- Returns:
- the label of the QueryFilter
- Since:
- jcms-5.5.0
-
getSearchDescription
public java.lang.String getSearchDescription(java.lang.String lang)
This method may be overriden if this QueryFilter is selectable from the search user interface.- Parameters:
lang
- the user language- Returns:
- the description of the QueryFilter
- Since:
- jcms-5.5.0
-
getSearchDefault
public boolean getSearchDefault()
This method may overriden if this QueryFilter is selectable from the search user interface.- Returns:
- true if the query filter must be selected by default, false otherwise
- Since:
- jcms-5.5.0
-
compareTo
public int compareTo(java.lang.Object obj)
Compare this object with the specified object for order.- Specified by:
compareTo
in interfacejava.lang.Comparable
- Parameters:
obj
- the Object to be compared.- See Also:
Comparable.compareTo(java.lang.Object)
-
equals
public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. The comparison is performed with compareTo() method.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the Object to be compared.
-
getOrder
public int getOrder()
Retrieve the order value used to sort QueryFilter.- Returns:
- an integer value, default is 0
- Since:
- jcms-7.1
-
isFrontOfficeSearch
public static boolean isFrontOfficeSearch(QueryHandler qh)
Check if the specified QueryHandler is a front office search.
Check if the current call to this filter is being processed for a front office search.
In the current implementation, it indicates that this query has been processed through"front/query.jsp"
.- Parameters:
qh
- the QueryHandler to check- Returns:
- true if the query being filtered is a front office search, false for any other query.
-
isBackOfficeSearch
public static boolean isBackOfficeSearch(QueryHandler qh)
Check if the specified QueryHandler is a back office search.
In the current implementation, it indicates that this query has been processed through"work/queryWork.jsp"
.- Parameters:
qh
- the QueryHandler to check- Returns:
- true if the query being filtered is a back office search, false for any other query.
-
isPortletQuery
public static boolean isPortletQuery(QueryHandler qh)
Check if the specified QueryHandler is a portlet query.
In the current implementation, it indicates that this query has been processed through"types/PortletQueryForeach/doQuery.jspf"
.- Parameters:
qh
- the QueryHandler to check- Returns:
- true if the query being filtered is a portlet's query, false for any other query.
-
-