Class TagQueryUtils


  • public final class TagQueryUtils
    extends Object
    TagQueryUtils handles queries allowing to search and count tags within the wiki.
    Since:
    5.0M1
    Version:
    $Id: a390c41f9388e475f9bad8aa176aae866429a530 $
    • Field Detail

      • HIDDEN_QUERYFILTER_HINT

        public static final String HIDDEN_QUERYFILTER_HINT
        Hint of the "hidden" QueryFilter.
        See Also:
        Constant Field Values
    • Method Detail

      • getAllTags

        public static List<String> getAllTags​(XWikiContext context)
                                       throws XWikiException
        Get all tags within the wiki.
        Parameters:
        context - XWiki context.
        Returns:
        list of tags (alphabetical order).
        Throws:
        XWikiException - if search query fails (possible failures: DB access problems, etc).
      • getTagCountForQuery

        public static Map<String,​Integer> getTagCountForQuery​(String fromHql,
                                                                    String whereHql,
                                                                    List<?> parameterValues,
                                                                    XWikiContext context)
                                                             throws XWikiException
        Get cardinality map of tags matching a parameterized hql query.
        Parameters:
        fromHql - the from fragment of the hql query
        whereHql - the where fragment of the hql query
        parameterValues - list of parameter values for the query
        context - XWiki context.
        Returns:
        map of tags (alphabetical order) with their occurrences counts.
        Throws:
        XWikiException - if search query fails (possible failures: DB access problems, etc).
        Since:
        1.18
        See Also:
        TagPluginApi.getTagCountForQuery(String, String, java.util.List)
      • getDocumentsWithTag

        public static List<String> getDocumentsWithTag​(String tag,
                                                       XWikiContext context)
                                                throws XWikiException
        Get non-hidden documents with the passed tags.
        Parameters:
        tag - a list of tags to match.
        context - XWiki context.
        Returns:
        list of docNames.
        Throws:
        XWikiException - if search query fails (possible failures: DB access problems, etc).
      • getDocumentsWithTag

        public static List<String> getDocumentsWithTag​(String tag,
                                                       boolean includeHiddenDocuments,
                                                       XWikiContext context)
                                                throws XWikiException
        Get documents with the passed tags with the result depending on whether the caller decides to include hidden documents or not.
        Parameters:
        tag - a list of tags to match.
        includeHiddenDocuments - if true then include hidden documents
        context - XWiki context.
        Returns:
        list of docNames.
        Throws:
        XWikiException - if search query fails (possible failures: DB access problems, etc).
        Since:
        6.2M1