Class CategoryQueryHandler

    • Field Detail

      • filter

        protected java.lang.String filter
      • text

        protected java.lang.String text
      • rootCids

        protected java.lang.String[] rootCids
      • selectable

        protected java.lang.Boolean selectable
      • addRoot

        protected java.lang.Boolean addRoot
      • removeCids

        protected java.lang.String[] removeCids
      • rootCategories

        protected transient java.util.Set<Category> rootCategories
      • removeCategories

        protected transient java.util.Set<Category> removeCategories
      • sort

        protected java.lang.String sort
      • reverse

        protected boolean reverse
      • pageStart

        protected int pageStart
      • pageSize

        protected int pageSize
      • pagerAll

        protected boolean pagerAll
    • Constructor Detail

      • CategoryQueryHandler

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

        public CategoryQueryHandler​(java.lang.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​(java.lang.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 Detail

      • parseQueryStringParam

        protected void parseQueryStringParam​(java.lang.String key,
                                             java.lang.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 java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.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​(java.lang.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 java.lang.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 java.lang.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:
        CategoryFilter
      • setFilter

        public void setFilter​(java.lang.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 java.lang.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​(java.lang.String text)
        Set the text to search in category
        Parameters:
        text - any string to look for in category's name
      • getRootCids

        public java.lang.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​(java.lang.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 java.lang.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​(java.lang.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​(java.util.Set<Category> rootCategories)
        Set the root categories used in this query
        Parameters:
        rootCategories - Set of root categories
      • setRemoveCategories

        public void setRemoveCategories​(java.util.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