Class CategoryQueryHandler

All Implemented Interfaces:
JcmsConstants, JaliosConstants
Direct Known Subclasses:
CategoryChooserQueryHandler

public class CategoryQueryHandler extends AbstractQueryHandler<Category>
Holder class and form handler of all parameters to be used for a query of categories.

Since:
jcms-10.0.5
  • Field Details

    • filter

      protected String filter
    • text

      protected String text
    • rootCids

      protected String[] rootCids
    • selectable

      protected Boolean selectable
    • addRoot

      protected Boolean addRoot
    • removeCids

      protected String[] removeCids
    • rootCategories

      protected transient Set<Category> rootCategories
    • removeCategories

      protected transient Set<Category> removeCategories
    • categoryFilter

      protected transient CategoryFilter categoryFilter
    • sort

      protected String sort
    • reverse

      protected boolean reverse
    • pageStart

      protected int pageStart
    • pageSize

      protected int pageSize
    • pagerAll

      protected boolean pagerAll
  • Constructor Details

    • CategoryQueryHandler

      public CategoryQueryHandler()
      Constructs a new empty CategoryQueryHandler with default option.
      Since:
      jcms-10.0.5
    • CategoryQueryHandler

      public CategoryQueryHandler(String queryString)
      Constructs a new CategoryQueryHandler by parsing the specified query string.

      See CategoryQueryHandler(String, HttpServletRequest) for a list of the decoded parameters.

      Parameters:
      queryString - a query String consisting of parameters (key=value) to be set in this handler.
      • Parameters must be separated with ampersand (&).
      • Values must be encoded in UTF-8.
      • Query must not starts with question mark (?) e.g : "text=welcome&rootCid=j_42"
      Since:
      jcms-10.0.5
    • CategoryQueryHandler

      public CategoryQueryHandler(String queryString, javax.servlet.http.HttpServletRequest request)
      Constructs a new CategoryQueryHandler by parsing the specified query string and using informations available from the specified request (logged member, user language, etc).

      The following parameters (and only those listed here) will be automatically decoded from the specified query string. Other parameters should be set using apropriate setters.

      Parameters:
      queryString - a query String consisting of parameters (key=value) to be set in this handler.
      • Parameters must be separated with ampersand (&).
      • Values must be encoded in UTF-8.
      • Query must not starts with question mark (?) e.g : "text=welcome&rootCid=j_42"
      request - the HttpServletRequest to use to retrieve loggedMember, userLang, userLocale that will be used by this handler, ignored if null.
      Since:
      jcms-10.0.5
  • Method Details

    • getLogger

      protected org.apache.log4j.Logger getLogger()
      Specified by:
      getLogger in class AbstractQueryHandler<Category>
    • parseQueryStringParam

      protected void parseQueryStringParam(String key, String[] values)
      Description copied from class: AbstractQueryHandler
      Method to be implemented by subclass to decode parameter from queryString.
      Specified by:
      parseQueryStringParam in class AbstractQueryHandler<Category>
      Parameters:
      key - the parameter name, never null nor empty.
      values - the parameter values, NEVER NULL NOR EMPTY. You can safely invoke paramValues[0]
    • printParams

      protected String printParams(AbstractQueryHandler.QueryHandlerPrinter printer)
      Print current QueryHandler params using specified QueryHandlerPrinter.
      Specified by:
      printParams in class AbstractQueryHandler<Category>
      Parameters:
      printer - a QueryHandlerPrinter to use
      Returns:
      a string containing all parameters of this handler printed using specified QueryHandlerPrinter.
      Since:
      jcms-10.0.5
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getPageResult

      public PageResult<Category> getPageResult()
      Return results of a query done using this CategoryQueryHandler.

      Warning: This method process the query each time it is invoked, therefore do not call it multiple times if you don't need it.

      Returns:
      a new PageResult containing all category found by this query, sorted using specified comparator if any.
    • setStart

      public void setStart(int start)
      Set the start index to use for paging
      Parameters:
      start - the index of the first member to be displayed in current page
    • getStart

      public int getStart()
      Get the start index to use for paging
      Returns:
      the index of the first member to be displayed in current page
    • setPageSize

      public void setPageSize(int pageSize)
      Set the page size
      Parameters:
      pageSize - the number of element to be displayed
    • getPageSize

      public int getPageSize()
      Get the page size
      Returns:
      the number of element to be displayed
    • setSort

      public void setSort(String sort)
      Set the sorting criteria

      Possible sorting option :

      • "id" : Member id (quite useless when working with both Member and DBMember as they do not compare)
      • "cdate" : Member creation date
      • "login" : Member's login
      • "firstname" : Member's firstname
      • "name" or "lastname" : Member's lastname
      • "usage" : Member's usage (account / contact)
      Parameters:
      sort - a field name that should be used for sorting
    • getSort

      public String getSort()
      Retrieve current sorting criteria
      Returns:
      a lucene field name that should be used for sorting
    • setReverse

      public void setReverse(boolean reverse)
      Set the ordering of the sort criteria
      Parameters:
      reverse - true if the reverse order should be used
    • isReverse

      public boolean isReverse()
      Check the ordering of the sort criteria
      Returns:
      true if the reverse order should be used
    • setPagerAll

      public void setPagerAll(boolean pagerAll)
      Set the pagerAll option of this handler
      Parameters:
      pagerAll - true if all item should be displayed
    • isPagerAll

      public boolean isPagerAll()
      Get the paging option of this handler
      Returns:
      true if all item should be displayed
    • getFilter

      public String getFilter()
      Retrieve the current category filter being used by this CategoryQueryHandler.
      Returns:
      a string indicating the filter being applied
      Since:
      jcms-10.0.5
      See Also:
    • setFilter

      public void setFilter(String filter)
      Define the categoryFilter to use in this CategoryQueryHandler.
      Parameters:
      filter - a string indicating the filter being applied, see constructor CategoryFilter for more information on possible values
    • getText

      public String getText()
      Retrieves the text being search in this query
      Returns:
      a string or null if no text is being searched
    • setText

      public void setText(String text)
      Set the text to search in category
      Parameters:
      text - any string to look for in category's name
    • getRootCids

      public String[] getRootCids()
      Retrieves the id of root categories used in this query
      Returns:
      a string array or null if no root categories are used for this query
    • setRootCids

      public void setRootCids(String[] rootCids)
      Set the id of root categories used in this query
      Parameters:
      rootCids - any string array with root categories ids
    • isSelectable

      public boolean isSelectable()
      Retrieves the selectable flag, which indicate if only selectables categories are put in the query results
      Returns:
      the value of the selectable flag
    • setSelectable

      public void setSelectable(boolean selectable)
      Set the selectable flag (true if only selectable categories are put in results) (true by default)
      Parameters:
      selectable - true if only selectable categories are put in results, false otherwise
    • isAddRoot

      public boolean isAddRoot()
      Retrieves the flag to indicate if root categories should be added in results or not
      Returns:
      true if root categories should be added in result.
    • setAddRoot

      public void setAddRoot(boolean addRoot)
      Set the flag to indicate if root categories should be added in results or not. default value is false
      Parameters:
      addRoot - true if root categories should be added in result, false otherwise
    • getRemoveCids

      public String[] getRemoveCids()
      Retrieves the id array of root categories, whose descendant (included this category) are removed from results
      Returns:
      a string array of root categories, whose descendant (included this category) are removed from results
    • setRemoveCids

      public void setRemoveCids(String[] removeCids)
      Set the id array of root categories, whose descendant (included this category) are removed from results
      Parameters:
      removeCids - a string array of root categories, whose descendant (included this category) are removed from results
    • setRootCategories

      public void setRootCategories(Set<Category> rootCategories)
      Set the root categories used in this query
      Parameters:
      rootCategories - Set of root categories
    • setRemoveCategories

      public void setRemoveCategories(Set<Category> removeCategories)
      Set the Set of root categories, whose descendant (included this category) are removed from results
      Parameters:
      removeCategories - a Set of root categories, whose descendant (included this category) are removed from results
    • setCategoryFilter

      public void setCategoryFilter(CategoryFilter categoryFilter)
      Define the categoryFilter to use in this CategoryQueryHandler.
      Parameters:
      categoryFilter - a string indicating the filter being applied, see constructor CategoryFilter for more information on possible values