Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java =================================================================== diff -u -r48eb3881563dc0f2576c2df926f47a75424e1e84 -r4ffd949a4e68634b24fdb6150064ec812350ed71 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java (.../IUserManagementService.java) (revision 48eb3881563dc0f2576c2df926f47a75424e1e84) +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java (.../IUserManagementService.java) (revision 4ffd949a4e68634b24fdb6150064ec812350ed71) @@ -435,7 +435,18 @@ */ public List searchUserSingleTerm(String term, Integer filteredOrgId); + /** + * Search users across login, first name, last name and email fields using the search term. + * Filters out disabled users. Optionally include child organisations in the results. + * @param term + * @param OrgId + * @param includeChildOrgs + * @return list of Users + */ + public List searchUserSingleTerm(String term, Integer orgId, boolean includeChildOrgs); + + /** * Search user members in orgId across login, first name, last name and email fields using the search term. * Filters out disabled users, and users that are members of filteredOrg. * @param term Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java =================================================================== diff -u -r9913f4a7218db571b52f368938f87fa046412961 -r4ffd949a4e68634b24fdb6150064ec812350ed71 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java (.../UserManagementService.java) (revision 9913f4a7218db571b52f368938f87fa046412961) +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java (.../UserManagementService.java) (revision 4ffd949a4e68634b24fdb6150064ec812350ed71) @@ -76,9 +76,8 @@ * View Source *

* - * Manually caches the user objects (by user id) in the shared cache. Whenever a - * user object is modified, the cached version must be removed. TODO complete - * the caching - need to remove the user from the cache on modification of + * Manually caches the user objects (by user id) in the shared cache. Whenever a user object is modified, the cached + * version must be removed. TODO complete the caching - need to remove the user from the cache on modification of * user/organisation details. * * @author Fei Yang, Manpreet Minhas @@ -152,7 +151,7 @@ User user = (User) object; if (user.getUserId() == null) { baseDAO.insertOrUpdate(user); // creating a workspace needs - // a userId + // a userId object = createWorkspaceForUser(user); } } @@ -166,7 +165,7 @@ for (Object o : objects) { if (o instanceof User) { baseDAO.insertOrUpdate((User) o); // creating a workspace needs - // a userId + // a userId o = createWorkspaceForUser((User) o); } } @@ -226,10 +225,8 @@ } /** - * @see - * org.lamsfoundation.lams.usermanagement.service.IUserManagementService - * #getOrganisationRolesForUser(org.lamsfoundation.lams.usermanagement. - * User, java.util.List) + * @see org.lamsfoundation.lams.usermanagement.service.IUserManagementService + * #getOrganisationRolesForUser(org.lamsfoundation.lams.usermanagement. User, java.util.List) */ public OrganisationDTO getOrganisationsForUserByRole(User user, List restrictToRoleNames) { List list = new ArrayList(); @@ -247,10 +244,9 @@ } /** - * @see - * org.lamsfoundation.lams.usermanagement.service.IUserManagementService - * #getOrganisationRolesForUser(org.lamsfoundation.lams.usermanagement. - * User, java.util.List, java.util.Integer) + * @see org.lamsfoundation.lams.usermanagement.service.IUserManagementService + * #getOrganisationRolesForUser(org.lamsfoundation.lams.usermanagement. User, java.util.List, + * java.util.Integer) */ public OrganisationDTO getOrganisationsForUserByRole(User user, List restrictToRoleNames, Integer courseId, List restrictToClassIds) { @@ -294,8 +290,7 @@ } /** - * Go through the roles for this user organisation and add the roles to the - * dto. + * Go through the roles for this user organisation and add the roles to the dto. * * @param restrictToRoleNames * @param userOrganisation @@ -321,9 +316,8 @@ } /** - * Gets an organisation for a user, with the user's roles. Doesn't not - * return a tree of organisations. Will not return the organisation if there - * isn't any roles for this user. + * Gets an organisation for a user, with the user's roles. Doesn't not return a tree of organisations. Will not + * return the organisation if there isn't any roles for this user. */ public OrganisationDTO getOrganisationForUserWithRole(User user, Integer organisationId) { if (user != null && organisationId != null) { @@ -648,8 +642,8 @@ } /** - * Remove a user from the system completely. Only able to be done if they - * don't have any related learning designs, etc. + * Remove a user from the system completely. Only able to be done if they don't have any related learning designs, + * etc. * * @param userId */ @@ -1112,6 +1106,21 @@ return list; } + public List searchUserSingleTerm(String term, Integer orgId, boolean includeChildOrgs) { + + String whereClause = ""; + if (includeChildOrgs) { + whereClause = " or uo.organisation.parentOrganisation.organisationId=" + orgId; + } + + String query = "select u from User u where" + " (u.login like '%" + term + "%'" + " or u.firstName like '%" + + term + "%'" + " or u.lastName like '%" + term + "%'" + " or u.email like '%" + term + "%')" + + " and u.disabledFlag=0" + " and u.userId in" + " (select uo.user.userId from UserOrganisation uo" + + " where uo.organisation.organisationId=" + orgId + whereClause + ")" + " order by u.login"; + List list = baseDAO.find(query); + return list; + } + public List getAllUsers() { String query = "from User u where u.disabledFlag=0 order by u.login"; return baseDAO.find(query);