blackboard.persist.user
Class UserSearch

java.lang.Object
  extended by blackboard.persist.user.UserSearch

public class UserSearch
extends java.lang.Object

Class to encapsulate user searches as viewed from the control and admin panels. The factory methods getNameSearch(), getEnrollmentSearch(), getLoginDateSearch(), and getRoleSearch() return properly initialized searches. Examples:

 UserSearch us = UserSearch.getNameSearch( UserSearch.SearchKey.UserName, SearchOperator.Contains, "dmin" );
 
 UserSearch us = UserSearch.getLoginDateSearch( SearchOperator.IsNull, null );
 
The class is constructed to assemble the SQL statements in a modular fashion; most of the parameters can be arbitrarily added. This means however, that the resulting statement may not be the most efficient. This is a conscious tradeoff for maintainability. However, these are queries against modest data sets and for user interactions that are infrequent.


Nested Class Summary
static class UserSearch.SearchKey
          Valid keys for search operations
static class UserSearch.SortKey
          Enumeration of possible "sort" keys.
 
Constructor Summary
UserSearch()
           
 
Method Summary
static UserSearch getEnrollmentSearch(int count, SearchOperator op, boolean course)
          Returns a search object that finds users based on the number of enrollments.
static UserSearch getLoginDateSearch(SearchOperator op, java.util.Calendar value)
          Creates a search object that compares the login date.
static UserSearch getNameSearch(UserSearch.SearchKey key, SearchOperator op, java.lang.String value)
          Generates a search object that finds users based on the specified name key.
 SelectQuery getQuery()
          Returns a query for use by the loader.
static UserSearch getRoleSearch(java.util.List<java.lang.String> list)
          Creates a search object based on a list of role identifiers (the string id, not the Id object) This search is used from the admin panel, and thus adds a filter for entitlement 'system.user.VIEW'.
 int getRowCount()
           
 boolean getUsePaging()
          Returns whether this search will return "paged" results.
 boolean isCheckSysRoleEntitlement()
           
 boolean isOnlyShowEnabled()
           
 void setAscending(boolean value)
          Sets flag determining whether sort order is ascending.
 void setCheckSysRoleEntitlement(boolean checkSysRoleEntitlement)
           
 void setCurrentPage(int value)
           
 void setOnlyShowEnabled(boolean onlyShowEnabled)
           
 void setPageSize(int value)
           
 void setUsePaging(boolean usePaging)
          Sets whether to "page" this search
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserSearch

public UserSearch()
Method Detail

getNameSearch

public static UserSearch getNameSearch(UserSearch.SearchKey key,
                                       SearchOperator op,
                                       java.lang.String value)
Generates a search object that finds users based on the specified name key. This search is used from the admin panel, and thus adds a filter for entitlement 'system.user.VIEW'.

Parameters:
key - Key to search on. Must be one of FamilyName, GivenName, or UserName
op - Operator to use
value - Value to search. Should be provided "as-is", appropriate search syntax will be added as required.
Returns:
Initialized user search object

getEnrollmentSearch

public static UserSearch getEnrollmentSearch(int count,
                                             SearchOperator op,
                                             boolean course)
Returns a search object that finds users based on the number of enrollments. This search is used from the admin panel, and thus adds a filter for entitlement 'system.user.VIEW'.

Parameters:
count - Count comparison
op - One of Equals, GreaterThan, or LessThan; default is equals
course - Flag to check course enrollments if true; org enrollments if false
Returns:
Initialized Search object

getLoginDateSearch

public static UserSearch getLoginDateSearch(SearchOperator op,
                                            java.util.Calendar value)
Creates a search object that compares the login date. This search is used from the admin panel, and thus adds a filter for entitlement 'system.user.VIEW'.

Parameters:
op - Operator to apply, valid values are GreaterThan, Equals, LessThan, and IsNull (to find users who have never logged in)
value - Date value to search. Ignored if op = IsNull
Returns:
UserSearch object

getRoleSearch

public static UserSearch getRoleSearch(java.util.List<java.lang.String> list)
Creates a search object based on a list of role identifiers (the string id, not the Id object) This search is used from the admin panel, and thus adds a filter for entitlement 'system.user.VIEW'.

Parameters:
list - List of roles to check
Returns:
Initialized UserSearch object
Throws:
java.lang.IllegalArgumentException - throw if list is null or empty

isCheckSysRoleEntitlement

public boolean isCheckSysRoleEntitlement()
Returns:
Returns the _checkSysRoleEntitlement.

setCheckSysRoleEntitlement

public void setCheckSysRoleEntitlement(boolean checkSysRoleEntitlement)
Parameters:
sysRoleEntitlement - The _checkSysRoleEntitlement to set.

isOnlyShowEnabled

public boolean isOnlyShowEnabled()
Returns:
Returns the _onlyShowEnabled.

setOnlyShowEnabled

public void setOnlyShowEnabled(boolean onlyShowEnabled)
Parameters:
onlyShowEnabled - The value to set.

setAscending

public void setAscending(boolean value)
Sets flag determining whether sort order is ascending.

Parameters:
value - True if sort should be ascending

setPageSize

public void setPageSize(int value)

setCurrentPage

public void setCurrentPage(int value)

getRowCount

public int getRowCount()

getUsePaging

public boolean getUsePaging()
Returns whether this search will return "paged" results.

Returns:
true if the search is "paged".

setUsePaging

public void setUsePaging(boolean usePaging)
Sets whether to "page" this search

Parameters:
usePaging - Whether to page the search.

getQuery

public SelectQuery getQuery()
Returns a query for use by the loader.

Returns:
Select query


Copyright © 2003 Blackboard, Inc. All Rights Reserved.