Class CmsUserQueryBuilder


  • public class CmsUserQueryBuilder
    extends java.lang.Object
    Default implementation of the user query builder.

    Since:
    8.0.0
    • Method Detail

      • createUserQuery

        public CmsPair<java.lang.String,​java.util.List<java.lang.Object>> createUserQuery​(CmsUserSearchParameters searchParams,
                                                                                                boolean countOnly)
        Creates a query for searching users.

        Parameters:
        searchParams - the user search criteria
        countOnly - if true, the query will only count the total number of results instead of returning them
        Returns:
        a pair consisting of the query string and its parameters
      • addEmailCondition

        protected void addEmailCondition​(CmsSelectQuery select,
                                         CmsSelectQuery.TableAlias users,
                                         java.lang.String email)
        Adds an equality test for the email address. If the email address is null, no test is added.
        Parameters:
        select - the select statement to add the test to
        users - the user table alias
        email - the email address to compare the column to
      • addFlagCondition

        protected void addFlagCondition​(CmsSelectQuery select,
                                        CmsSelectQuery.TableAlias users,
                                        int flags,
                                        boolean allowCore)
        Adds flag checking conditions to an SQL query.

        Parameters:
        select - the query
        users - the user table alias
        flags - the flags
        allowCore - set to true if core users should not be filtered out
      • colDateCreated

        protected java.lang.String colDateCreated()
        Column name accessor.

        Returns:
        the name of the column
      • colEmail

        protected java.lang.String colEmail()
        Column name accessor.

        Returns:
        the name of the column
      • colFirstName

        protected java.lang.String colFirstName()
        Column name accessor.

        Returns:
        the name of the column
      • colFlags

        protected java.lang.String colFlags()
        Column name accessor.

        Returns:
        the name of the column
      • colGroupUserGroupId

        protected java.lang.String colGroupUserGroupId()
        Column name accessor.

        Returns:
        the name of the column
      • colGroupUserUserId

        protected java.lang.String colGroupUserUserId()
        Column name accessor.

        Returns:
        the name of the column
      • colId

        protected java.lang.String colId()
        Column name accessor.

        Returns:
        the name of the column
      • colLastLogin

        protected java.lang.String colLastLogin()
        Column name accessor.

        Returns:
        the name of the column
      • colLastName

        protected java.lang.String colLastName()
        Column name accessor.

        Returns:
        the name of the column
      • colName

        protected java.lang.String colName()
        Column name accessor.

        Returns:
        the name of the column
      • colOu

        protected java.lang.String colOu()
        Column name accessor.

        Returns:
        the name of the column
      • colPassword

        protected java.lang.String colPassword()
        Column name accessor.

        Returns:
        the name of the column
      • generateConcat

        protected java.lang.String generateConcat​(java.lang.String... expressions)
        Generates an SQL expression for concatenating several other SQL expressions.

        Parameters:
        expressions - the expressions to concatenate
        Returns:
        the concat expression
      • generateTrim

        protected java.lang.String generateTrim​(java.lang.String expression)
        Generates an SQL expression for trimming whitespace from the beginning and end of a string.

        Parameters:
        expression - the expression to wrap
        Returns:
        the expression for trimming the given expression
      • getGroupUserSubqueryColumns

        protected java.lang.String getGroupUserSubqueryColumns()
        Returns the columns that should be returned by user subqueries.

        Returns:
        the columns that should be returned by user subqueries
      • getUserActivatedExpression

        protected java.lang.String getUserActivatedExpression​(CmsSelectQuery.TableAlias users)
        Returns an expression for checking whether a user is activated.

        Parameters:
        users - the user table alias
        Returns:
        the expression for checking whether the user is activated
      • getUserFlagExpression

        protected java.lang.String getUserFlagExpression​(CmsSelectQuery.TableAlias users,
                                                         int flags)
        Returns a bitwise AND expression with a fixed second operand.

        Parameters:
        users - the user table alias
        flags - the user flags
        Returns:
        the resulting SQL expression
      • getUserFullNameExpression

        protected java.lang.String getUserFullNameExpression​(CmsSelectQuery.TableAlias users)
        Returns the SQL expression for generating the user's full name in the format 'firstname lastname (loginname)'.

        Parameters:
        users - the user table alias
        Returns:
        the expression for generating the user's full name
      • makePaged

        protected CmsPair<java.lang.String,​java.util.List<java.lang.Object>> makePaged​(CmsSelectQuery select,
                                                                                             CmsUserSearchParameters params)
        Creates a query which uses paging from another query.

        Parameters:
        select - the base query
        params - the query parameters
        Returns:
        the paged version of the query
      • shouldNameSubqueries

        protected boolean shouldNameSubqueries()
        Should return true if subqueries in a FROM clause should be named.

        Returns:
        true if subqueries in a FROM clause should be named
      • tabGroups

        protected java.lang.String tabGroups()
        Table name accessor.

        Returns:
        the name of a table
      • tabGroupUsers

        protected java.lang.String tabGroupUsers()
        Table name accessor.

        Returns:
        the name of a table
      • tabUsers

        protected java.lang.String tabUsers()
        Table name accessor.

        Returns:
        the name of a table
      • useWindowFunctionsForPaging

        protected boolean useWindowFunctionsForPaging()
        Returns true if window functions should be used for paging.

        Returns:
        true if window functions should be used for paging
      • wrapLower

        protected java.lang.String wrapLower​(java.lang.String expr,
                                             boolean caseInsensitive)
        Wraps an SQL expression in a "LOWER" call conditionally.

        Parameters:
        expr - the expression to wrap
        caseInsensitive - if false, no wrapping should occur
        Returns:
        the resulting expression