Package org.opencms.db.generic
Class CmsUserQueryBuilder
java.lang.Object
org.opencms.db.generic.CmsUserQueryBuilder
Default implementation of the user query builder.
- Since:
- 8.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAllowedOuCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, List<CmsOrganizationalUnit> allowedOus) Adds OU conditions to an SQL query.protected voidaddEmailCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, String email) Adds an equality test for the email address.protected voidaddFlagCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, int flags, boolean allowCore) Adds flag checking conditions to an SQL query.protected voidaddGroupCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, CmsUserSearchParameters searchParams) Adds group conditions to an SQL query.protected voidaddOrgUnitCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, CmsOrganizationalUnit orgUnit, boolean recursive) Adds a check for an OU to an SQL query.protected voidaddSearchFilterCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, CmsUserSearchParameters searchParams) Adds a search condition to a query.protected voidaddSorting(CmsSelectQuery select, CmsSelectQuery.TableAlias users, CmsUserSearchParameters searchParams) Adds a sort order to an SQL query.protected voidaddWebuserCondition(CmsSelectQuery select, CmsOrganizationalUnit orgUnit, CmsSelectQuery.TableAlias users) Adds a check for the web user condition to an SQL query.protected StringColumn name accessor.protected StringcolEmail()Column name accessor.protected StringColumn name accessor.protected StringcolFlags()Column name accessor.protected StringColumn name accessor.protected StringColumn name accessor.protected StringcolId()Column name accessor.protected StringColumn name accessor.protected StringColumn name accessor.protected StringcolName()Column name accessor.protected StringcolOu()Column name accessor.protected StringColumn name accessor.protected I_CmsQueryFragmentCreates a core user check condition.protected I_CmsQueryFragmentcreateFlagCondition(CmsSelectQuery.TableAlias users, int flags) Creates an SQL flag check condition.createUserQuery(CmsUserSearchParameters searchParams, boolean countOnly) Creates a query for searching users.protected StringgenerateConcat(String... expressions) Generates an SQL expression for concatenating several other SQL expressions.protected StringgenerateTrim(String expression) Generates an SQL expression for trimming whitespace from the beginning and end of a string.protected StringReturns the columns that should be returned by user subqueries.protected StringgetSortExpression(CmsSelectQuery.TableAlias users, CmsUserSearchParameters searchParams) Returns the expression used for sorting the results.protected StringReturns an expression for checking whether a user is activated.protected StringgetUserFlagExpression(CmsSelectQuery.TableAlias users, int flags) Returns a bitwise AND expression with a fixed second operand.protected StringReturns the SQL expression for generating the user's full name in the format 'firstname lastname (loginname)'.makePaged(CmsSelectQuery select, CmsUserSearchParameters params) Creates a query which uses paging from another query.protected booleanShould return true if subqueries in a FROM clause should be named.protected StringTable name accessor.protected StringTable name accessor.protected StringtabUsers()Table name accessor.protected booleanReturns true if window functions should be used for paging.protected StringWraps an SQL expression in a "LOWER" call conditionally.
-
Constructor Details
-
CmsUserQueryBuilder
public CmsUserQueryBuilder()
-
-
Method Details
-
createUserQuery
public CmsPair<String,List<Object>> createUserQuery(CmsUserSearchParameters searchParams, boolean countOnly) Creates a query for searching users.- Parameters:
searchParams- the user search criteriacountOnly- 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
protected void addAllowedOuCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, List<CmsOrganizationalUnit> allowedOus) Adds OU conditions to an SQL query.- Parameters:
select- the queryusers- the user table aliasallowedOus- 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 tousers- the user table aliasemail- 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 queryusers- the user table aliasflags- the flagsallowCore- set to true if core users should not be filtered out
-
addGroupCondition
protected void addGroupCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, CmsUserSearchParameters searchParams) Adds group conditions to an SQL query.- Parameters:
select- the queryusers- the user table aliassearchParams- 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 queryusers- the user table aliasorgUnit- the organizational unitrecursive- if true, checks for sub-OUs too
-
addSearchFilterCondition
protected void addSearchFilterCondition(CmsSelectQuery select, CmsSelectQuery.TableAlias users, CmsUserSearchParameters searchParams) Adds a search condition to a query.- Parameters:
select- the queryusers- the user table aliassearchParams- 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 queryusers- the user table aliassearchParams- the user search criteria
-
addWebuserCondition
protected void addWebuserCondition(CmsSelectQuery select, CmsOrganizationalUnit orgUnit, CmsSelectQuery.TableAlias users) Adds a check for the web user condition to an SQL query.- Parameters:
select- the queryorgUnit- the organizational unitusers- the user table alias
-
colDateCreated
Column name accessor.- Returns:
- the name of the column
-
colEmail
Column name accessor.- Returns:
- the name of the column
-
colFirstName
Column name accessor.- Returns:
- the name of the column
-
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
Column name accessor.- Returns:
- the name of the column
-
colLastLogin
Column name accessor.- Returns:
- the name of the column
-
colLastName
Column name accessor.- Returns:
- the name of the column
-
colName
Column name accessor.- Returns:
- the name of the column
-
colOu
Column name accessor.- Returns:
- the name of the column
-
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 aliasflags- the flags to check- Returns:
- the resulting SQL expression
-
generateConcat
Generates an SQL expression for concatenating several other SQL expressions.- Parameters:
expressions- the expressions to concatenate- Returns:
- the concat expression
-
generateTrim
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
protected String getSortExpression(CmsSelectQuery.TableAlias users, CmsUserSearchParameters searchParams) Returns the expression used for sorting the results.- Parameters:
users- the user table aliassearchParams- 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 aliasflags- 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
protected CmsPair<String,List<Object>> makePaged(CmsSelectQuery select, CmsUserSearchParameters params) Creates a query which uses paging from another query.- Parameters:
select- the base queryparams- the query parameters- Returns:
- the paged version of the query
-
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
Table name accessor.- Returns:
- the name of a table
-
tabGroupUsers
Table name accessor.- Returns:
- the name of a table
-
tabUsers
Table name accessor.- Returns:
- the name of a table
-
useWindowFunctionsForPaging
Returns true if window functions should be used for paging.- Returns:
- true if window functions should be used for paging
-
wrapLower
Wraps an SQL expression in a "LOWER" call conditionally.- Parameters:
expr- the expression to wrapcaseInsensitive- if false, no wrapping should occur- Returns:
- the resulting expression
-