Class QueryFilter

java.lang.Object
com.jalios.jcms.QueryFilter
All Implemented Interfaces:
PluginComponent, Comparable
Direct Known Subclasses:
ContentQueryFilter, MailThreadQueryFilter, MediaQueryFilter, SpellSuggestEngine

public abstract class QueryFilter extends Object implements PluginComponent, Comparable
A QueryFilter is notified for each query.
Since:
jcms-5.0.0
Author:
Olivier Dedieu
  • Field Details

    • PORTLET_QUERY

      public static final String PORTLET_QUERY
      QueryHandler attribute used to indicate that we are processing a portlet's query.
      Do not directly read this attribute, use method isPortletQuery(QueryHandler).
    • order

      protected int order
  • Constructor Details

    • QueryFilter

      public QueryFilter()
      Constructs a QueryFilter with order = 0
      Since:
      jcms-5.0.0
    • QueryFilter

      public QueryFilter(int order)
      Constructs a QueryFilter with the given order
      Parameters:
      order - the order
      Since:
      jcms-5.5.0
  • Method Details

    • init

      public boolean init(Plugin plugin)
      Description copied from interface: PluginComponent
      Initialize the component with the given plugin configuration
      Specified by:
      init in interface PluginComponent
      Parameters:
      plugin - the calling plugin
      Returns:
      true if the component has been correctly initialized.
      Since:
      jcms-5.7.2
      See Also:
    • filterQueryHandler

      public QueryHandler filterQueryHandler(QueryHandler qh, Map context)
      This method should be overriden to filter the value of the QueryHandler
      Parameters:
      qh - the QueryHandler
      context - 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, Map context)
      This method should be overriden to filter the result set
      Parameters:
      qh - the QueryHandler
      set - the result set
      context - 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, Map<String,Object> context)
      This method should be overriden to filter DB results.
      Parameters:
      pub - a DB Publication
      context - 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 method filterDBResult(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(Class clazz, Map<String,Object> context)
      This convenient method is a simplfied version of callFilterDBResult(PublicationCriteria).
      Parameters:
      clazz - the class
      context - 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 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 String getSearchLabel(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 String getSearchDescription(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(Object obj)
      Compare this object with the specified object for order.
      Specified by:
      compareTo in interface Comparable
      Parameters:
      obj - the Object to be compared.
      See Also:
    • equals

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one. The comparison is performed with compareTo() method.
      Overrides:
      equals in class 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/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.