Class CmsUserQueryBuilder

java.lang.Object
org.opencms.db.generic.CmsUserQueryBuilder

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

Since:
8.0.0
  • Constructor Details

  • Method Details

    • createUserQuery

      public CmsPair<String,List<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
    • addAllowedOuCondition

      Adds OU conditions to an SQL query.

      Parameters:
      select - the query
      users - the user table alias
      allowedOus - the allowed ous
    • addEmailCondition

      protected void addEmailCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, 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
    • addGroupCondition

      Adds group conditions to an SQL query.

      Parameters:
      select - the query
      users - the user table alias
      searchParams - the search parameters
    • addOrgUnitCondition

      protected void addOrgUnitCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, CmsOrganizationalUnit orgUnit, boolean recursive)
      Adds a check for an OU to an SQL query.

      Parameters:
      select - the query
      users - the user table alias
      orgUnit - the organizational unit
      recursive - if true, checks for sub-OUs too
    • addSearchFilterCondition

      Adds a search condition to a query.

      Parameters:
      select - the query
      users - the user table alias
      searchParams - the search criteria
    • addSorting

      protected void addSorting(CmsSelectQuery select, CmsSelectQuery.TableAlias users, CmsUserSearchParameters searchParams)
      Adds a sort order to an SQL query.

      Parameters:
      select - the query
      users - the user table alias
      searchParams - the user search criteria
    • addWebuserCondition

      Adds a check for the web user condition to an SQL query.

      Parameters:
      select - the query
      orgUnit - the organizational unit
      users - the user table alias
    • colDateCreated

      protected String colDateCreated()
      Column name accessor.

      Returns:
      the name of the column
    • colEmail

      protected String colEmail()
      Column name accessor.

      Returns:
      the name of the column
    • colFirstName

      protected String colFirstName()
      Column name accessor.

      Returns:
      the name of the column
    • colFlags

      protected String colFlags()
      Column name accessor.

      Returns:
      the name of the column
    • colGroupUserGroupId

      Column name accessor.

      Returns:
      the name of the column
    • colGroupUserUserId

      Column name accessor.

      Returns:
      the name of the column
    • colId

      protected String colId()
      Column name accessor.

      Returns:
      the name of the column
    • colLastLogin

      protected String colLastLogin()
      Column name accessor.

      Returns:
      the name of the column
    • colLastName

      protected String colLastName()
      Column name accessor.

      Returns:
      the name of the column
    • colName

      protected String colName()
      Column name accessor.

      Returns:
      the name of the column
    • colOu

      protected String colOu()
      Column name accessor.

      Returns:
      the name of the column
    • colPassword

      protected String colPassword()
      Column name accessor.

      Returns:
      the name of the column
    • createCoreCondition

      Creates a core user check condition.

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

      Creates an SQL flag check condition.

      Parameters:
      users - the user table alias
      flags - the flags to check
      Returns:
      the resulting SQL expression
    • generateConcat

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

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

      protected String generateTrim(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

      Returns the columns that should be returned by user subqueries.

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

      Returns the expression used for sorting the results.

      Parameters:
      users - the user table alias
      searchParams - the search parameters
      Returns:
      the sorting expressiong
    • getUserActivatedExpression

      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

      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

      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

      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 String tabGroups()
      Table name accessor.

      Returns:
      the name of a table
    • tabGroupUsers

      protected String tabGroupUsers()
      Table name accessor.

      Returns:
      the name of a table
    • tabUsers

      protected 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 String wrapLower(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