Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageAction.java,v diff -u -r1.22.12.2 -r1.22.12.3 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageAction.java 28 Aug 2015 05:44:09 -0000 1.22.12.2 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageAction.java 5 Oct 2015 18:02:59 -0000 1.22.12.3 @@ -22,19 +22,20 @@ */ package org.lamsfoundation.lams.admin.web; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; +import java.io.IOException; import java.util.List; +import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.beanutils.BeanUtils; -import org.apache.struts.action.Action; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.apache.tomcat.util.json.JSONArray; +import org.apache.tomcat.util.json.JSONException; +import org.apache.tomcat.util.json.JSONObject; import org.lamsfoundation.lams.admin.service.AdminServiceProxy; import org.lamsfoundation.lams.admin.web.form.OrgManageForm; import org.lamsfoundation.lams.security.ISecurityService; @@ -44,36 +45,36 @@ import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.usermanagement.service.UserManagementService; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; /** - * @version - * *

* View Source *

* * @author Fei Yang - * - * Created at 20:29:13 on 2006-6-5 - */ - -/** - * struts doclets * - * @struts:action path="/orgmanage" name="OrgManageForm" input=".orglist" scope="request" validate="false" + * @struts:action path="/orgmanage" parameter="dispatch" name="OrgManageForm" input=".orglist" scope="request" validate="false" * * @struts:action-forward name="orglist" path=".orglist" */ -public class OrgManageAction extends Action { +public class OrgManageAction extends LamsDispatchAction { + + private static IUserManagementService userManagementService; @SuppressWarnings("unchecked") @Override - public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + initServices(); + // Get organisation whose child organisations we will populate the OrgManageForm with Integer orgId = WebUtil.readIntParam(request, "org", true); if (orgId == null) { @@ -87,7 +88,6 @@ // get logged in user's id Integer userId = ((UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER)).getUserID(); ISecurityService securityService = AdminServiceProxy.getSecurityService(getServlet().getServletContext()); - IUserManagementService userManagementService = AdminServiceProxy.getService(getServlet().getServletContext()); Organisation org = null; boolean isRootOrganisation = false; @@ -142,32 +142,6 @@ request.setAttribute("parentGroupName", pOrg.getName()); request.setAttribute("parentGroupId", pOrg.getOrganisationId()); } else { - List orgManageBeans = new ArrayList(); - // the organisation type of the children - Integer typeId = (orgManageForm.getType().equals(OrganisationType.ROOT_TYPE) ? OrganisationType.COURSE_TYPE - : OrganisationType.CLASS_TYPE); - - HashMap properties = new HashMap(); - properties.put("organisationType.organisationTypeId", typeId); - properties.put("organisationState.organisationStateId", orgManageForm.getStateId()); - List organisations = userManagementService.findByProperties(Organisation.class, properties); - - for (Organisation organisation : organisations) { - Organisation parentOrg = (typeId.equals(OrganisationType.CLASS_TYPE)) - ? organisation.getParentOrganisation() : organisation; - // do not list this org if it is not a child of the requested parent - if (typeId.equals(OrganisationType.CLASS_TYPE) && !parentOrg.getOrganisationId().equals(orgId)) { - continue; - } - - OrgManageBean orgManageBean = new OrgManageBean(); - BeanUtils.copyProperties(orgManageBean, organisation); - orgManageBean.setStatus(organisation.getOrganisationState().getDescription()); - orgManageBean.setEditable(true); - orgManageBeans.add(orgManageBean); - } - Collections.sort(orgManageBeans); - orgManageForm.setOrgManageBeans(orgManageBeans); request.setAttribute("OrgManageForm", orgManageForm); // display org info @@ -181,4 +155,81 @@ request.setAttribute("manageGlobalRoles", request.isUserInRole(Role.SYSADMIN)); return mapping.findForward("orglist"); } + + /** + * Returns list of organisations for . + */ + public ActionForward getOrgs(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse res) throws IOException, ServletException, JSONException { + initServices(); + + Integer parentOrgId = WebUtil.readIntParam(request, "parentOrgId"); + Integer stateId = WebUtil.readIntParam(request, "stateId"); + Integer typeIdParam = WebUtil.readIntParam(request, "type"); + // the organisation type of the children + Integer typeId = (typeIdParam.equals(OrganisationType.ROOT_TYPE) ? OrganisationType.COURSE_TYPE + : OrganisationType.CLASS_TYPE); + String searchString = WebUtil.readStrParam(request, "fcol[1]", true); + + // paging parameters of tablesorter + int size = WebUtil.readIntParam(request, "size"); + int page = WebUtil.readIntParam(request, "page"); + Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true); + Integer isSort2 = WebUtil.readIntParam(request, "column[1]", true); + Integer isSort3 = WebUtil.readIntParam(request, "column[2]", true); + Integer isSort4 = WebUtil.readIntParam(request, "column[3]", true); + + String sortBy = ""; + String sortOrder = ""; + if (isSort1 != null) { + sortBy = "id"; + sortOrder = isSort1.equals(0) ? "ASC" : "DESC"; + + } else if (isSort2 != null) { + sortBy = "name"; + sortOrder = isSort2.equals(0) ? "ASC" : "DESC"; + + } else if (isSort3 != null) { + sortBy = "code"; + sortOrder = isSort3.equals(0) ? "ASC" : "DESC"; + + } else if (isSort4 != null) { + sortBy = "description"; + sortOrder = isSort4.equals(0) ? "ASC" : "DESC"; + + } + + List organisations = userManagementService.getPagedCourses(parentOrgId, typeId, stateId, page, + size, sortBy, sortOrder, searchString); + + JSONObject responcedata = new JSONObject(); + responcedata.put("total_rows", userManagementService.getCountCoursesByParentCourseAndTypeAndState(parentOrgId, + typeId, stateId, searchString)); + + JSONArray rows = new JSONArray(); + for (Organisation organisation : organisations) { + + JSONObject responseRow = new JSONObject(); + responseRow.put("id", organisation.getOrganisationId()); + String orgName = organisation.getName() == null ? "" : organisation.getName(); + responseRow.put("name", StringEscapeUtils.escapeHtml(orgName)); + String orgCode = organisation.getCode() == null ? "" : organisation.getCode(); + responseRow.put("code", StringEscapeUtils.escapeHtml(orgCode)); + String orgDescription = organisation.getDescription() == null ? "" : organisation.getDescription(); + responseRow.put("description", StringEscapeUtils.escapeHtml(orgDescription)); + + rows.put(responseRow); + } + responcedata.put("rows", rows); + res.setContentType("application/json;charset=utf-8"); + res.getWriter().print(new String(responcedata.toString())); + return null; + } + + private void initServices() { + if (userManagementService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServlet().getServletContext()); + userManagementService = (UserManagementService) ctx.getBean("userManagementService"); + } + } } \ No newline at end of file Index: lams_admin/web/usersearchlist.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_admin/web/usersearchlist.jsp,v diff -u -r1.27.2.1 -r1.27.2.2 --- lams_admin/web/usersearchlist.jsp 14 Jul 2015 14:28:50 -0000 1.27.2.1 +++ lams_admin/web/usersearchlist.jsp 5 Oct 2015 18:02:59 -0000 1.27.2.2 @@ -104,7 +104,6 @@ " /> - + + - : + + : @@ -134,11 +218,13 @@ " /> - + + - : + + : @@ -180,9 +266,9 @@

- - " onclick=javascript:document.location='organisation.do?method=edit&orgId=' /> - + + " onclick=javascript:document.location='organisation.do?method=edit&orgId=' /> +

@@ -191,62 +277,55 @@

<% if (request.isUserInRole(Role.SYSADMIN)) { %> -
- " onclick="javascript:document.location='clone.do?groupId=';"> -
-

 

+
+ " onclick="javascript:document.location='clone.do?groupId=';"> +
+

 

<% } %> - -
- - - - - - - - - - - - - - - - - - - -
Id
- - - - - -
-
+ -
-
- - - - - - -
-
+ + + + + + + + + + + + +
+ Id + + + + + + +
+ + +
+
+ + + + + + +
+
- - Index: lams_build/lib/lams/lams.jar =================================================================== RCS file: /usr/local/cvsroot/lams_build/lib/lams/lams.jar,v diff -u -r1.420.2.32 -r1.420.2.33 Binary files differ Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/dao/IOrganisationDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/dao/IOrganisationDAO.java,v diff -u -r1.10 -r1.10.14.1 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/dao/IOrganisationDAO.java 19 Oct 2007 02:32:39 -0000 1.10 +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/dao/IOrganisationDAO.java 5 Oct 2015 18:03:00 -0000 1.10.14.1 @@ -18,36 +18,65 @@ * * http://www.gnu.org/licenses/gpl.txt * **************************************************************** - */ - -/* $Id$ */ -package org.lamsfoundation.lams.usermanagement.dao; + */ +/* $Id$ */ +package org.lamsfoundation.lams.usermanagement.dao; + import java.util.List; import org.lamsfoundation.lams.dao.IBaseDAO; - +import org.lamsfoundation.lams.usermanagement.Organisation; + /** * @author jliew - * */ public interface IOrganisationDAO extends IBaseDAO { - - /** - * Get list of orgIds of active groups. - * @param userId - * @param isSysadmin - * @return list of orgIds - */ - public List getActiveCourseIdsByUser(Integer userId, boolean isSysadmin); - - /** - * Get list of orgIds of archived groups. - * @param userId - * @param isSysadmin - * @return list of orgIds - */ - public List getArchivedCourseIdsByUser(Integer userId, boolean isSysadmin); + /** + * Get list of orgIds of active groups. + * + * @param userId + * @param isSysadmin + * @return list of orgIds + */ + List getActiveCourseIdsByUser(Integer userId, boolean isSysadmin); + + /** + * Get list of orgIds of archived groups. + * + * @param userId + * @param isSysadmin + * @return list of orgIds + */ + List getArchivedCourseIdsByUser(Integer userId, boolean isSysadmin); + + /** + * Returns courses with specified type, state and parent course. + * + * @param parentOrgId + * @param typeId + * @param stateId + * @param page + * @param size + * @param sortBy + * @param sortOrder + * @param searchString filters results by course name. It can be null and then doesn't affect results + * @return + */ + List getPagedCourses(final Integer parentOrgId, final Integer typeId, final Integer stateId, + int page, int size, String sortBy, String sortOrder, String searchString); + + /** + * Counts courses with specified type, state and parent course. + * + * @param parentOrgId + * @param typeId + * @param stateId + * @param searchString filters results by course name. It can be null and then doesn't affect results + * @return + */ + int getCountCoursesByParentCourseAndTypeAndState(final Integer parentOrgId, final Integer typeId, + final Integer stateId, String searchString); + } - \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/OrganisationDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/OrganisationDAO.java,v diff -u -r1.13.14.3 -r1.13.14.4 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/OrganisationDAO.java 8 Dec 2014 21:50:14 -0000 1.13.14.3 +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/OrganisationDAO.java 5 Oct 2015 18:03:00 -0000 1.13.14.4 @@ -18,76 +18,133 @@ * * http://www.gnu.org/licenses/gpl.txt * **************************************************************** - */ - -/* $Id$ */ -package org.lamsfoundation.lams.usermanagement.dao.hibernate; + */ +/* $Id$ */ +package org.lamsfoundation.lams.usermanagement.dao.hibernate; + import java.util.List; +import org.hibernate.Query; import org.lamsfoundation.lams.dao.hibernate.LAMSBaseDAO; +import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationState; import org.lamsfoundation.lams.usermanagement.OrganisationType; import org.lamsfoundation.lams.usermanagement.dao.IOrganisationDAO; -import org.springframework.stereotype.Repository; - + /** * @author jliew - * */ @Repository public class OrganisationDAO extends LAMSBaseDAO implements IOrganisationDAO { - - private static final String GET_ALL_ACTIVE_COURSE_IDS = "select o.organisationId from Organisation o" - + " where o.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE - + " and o.organisationState.organisationStateId = " + OrganisationState.ACTIVE - + " order by name"; - - private static final String GET_ACTIVE_COURSE_IDS_BY_USER = "select uo.organisation.organisationId, uoc.collapsed" - + " from Organisation o, UserOrganisation uo left join uo.userOrganisationCollapsed uoc" - + " where uo.organisation.organisationId = o.organisationId" - + " and o.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE - + " and o.organisationState.organisationStateId = " + OrganisationState.ACTIVE - + " and uo.user.userId = :userId" - + " order by name"; - - private static final String GET_ALL_ARCHIVED_COURSE_IDS = "select distinct o1.organisationId" - + " from Organisation o1, Organisation o2 " - + " where (o1.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE - + " and o1.organisationState.organisationStateId = " + OrganisationState.ACTIVE - + " and o2.organisationType.organisationTypeId = " + OrganisationType.CLASS_TYPE - + " and o2.organisationState.organisationStateId = " + OrganisationState.ARCHIVED - + " and o1.organisationId = o2.parentOrganisation.organisationId)" - + " or (o1.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE - + " and o1.organisationState.organisationStateId = " + OrganisationState.ARCHIVED + ")" - + " order by o1.name"; - - private static final String GET_ARCHIVED_COURSE_IDS_BY_USER = "select distinct o1.organisationId, uoc.collapsed" - + " from UserOrganisation uo1, Organisation o1, Organisation o2 left join uo1.userOrganisationCollapsed uoc" - + " where (uo1.user.userId = :userId" - + " and uo1.organisation.organisationId = o1.organisationId" - + " and o1.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE - + " and o1.organisationState.organisationStateId = " + OrganisationState.ACTIVE - + " and o2.organisationType.organisationTypeId = " + OrganisationType.CLASS_TYPE - + " and o2.organisationState.organisationStateId = " + OrganisationState.ARCHIVED - + " and o1.organisationId = o2.parentOrganisation.organisationId)" - + " or (uo1.organisation.organisationId = o1.organisationId" - + " and o1.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE - + " and o1.organisationState.organisationStateId = " + OrganisationState.ARCHIVED - + " and uo1.user.userId = :userId)" - + " order by o1.name"; - - public List getActiveCourseIdsByUser(final Integer userId, final boolean isSysadmin) { - return (List) (isSysadmin ? getSession().createQuery(GET_ALL_ACTIVE_COURSE_IDS).list() : getSession() - .createQuery(GET_ACTIVE_COURSE_IDS_BY_USER).setInteger("userId", userId).list()); + private static final String GET_ALL_ACTIVE_COURSE_IDS = "select o.organisationId from Organisation o" + + " where o.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE + + " and o.organisationState.organisationStateId = " + OrganisationState.ACTIVE + " order by name"; + + private static final String GET_ACTIVE_COURSE_IDS_BY_USER = "select uo.organisation.organisationId, uoc.collapsed" + + " from Organisation o, UserOrganisation uo left join uo.userOrganisationCollapsed uoc" + + " where uo.organisation.organisationId = o.organisationId" + + " and o.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE + + " and o.organisationState.organisationStateId = " + OrganisationState.ACTIVE + + " and uo.user.userId = :userId" + " order by name"; + + private static final String GET_ALL_ARCHIVED_COURSE_IDS = "select distinct o1.organisationId" + + " from Organisation o1, Organisation o2 " + " where (o1.organisationType.organisationTypeId = " + + OrganisationType.COURSE_TYPE + " and o1.organisationState.organisationStateId = " + + OrganisationState.ACTIVE + " and o2.organisationType.organisationTypeId = " + OrganisationType.CLASS_TYPE + + " and o2.organisationState.organisationStateId = " + OrganisationState.ARCHIVED + + " and o1.organisationId = o2.parentOrganisation.organisationId)" + + " or (o1.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE + + " and o1.organisationState.organisationStateId = " + OrganisationState.ARCHIVED + ")" + + " order by o1.name"; + + private static final String GET_ARCHIVED_COURSE_IDS_BY_USER = "select distinct o1.organisationId, uoc.collapsed" + + " from UserOrganisation uo1, Organisation o1, Organisation o2 left join uo1.userOrganisationCollapsed uoc" + + " where (uo1.user.userId = :userId" + " and uo1.organisation.organisationId = o1.organisationId" + + " and o1.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE + + " and o1.organisationState.organisationStateId = " + OrganisationState.ACTIVE + + " and o2.organisationType.organisationTypeId = " + OrganisationType.CLASS_TYPE + + " and o2.organisationState.organisationStateId = " + OrganisationState.ARCHIVED + + " and o1.organisationId = o2.parentOrganisation.organisationId)" + + " or (uo1.organisation.organisationId = o1.organisationId" + + " and o1.organisationType.organisationTypeId = " + OrganisationType.COURSE_TYPE + + " and o1.organisationState.organisationStateId = " + OrganisationState.ARCHIVED + + " and uo1.user.userId = :userId)" + " order by o1.name"; + + public List getActiveCourseIdsByUser(final Integer userId, final boolean isSysadmin) { + + return (List) (isSysadmin ? getSession().createQuery(GET_ALL_ACTIVE_COURSE_IDS).list() : getSession() + .createQuery(GET_ACTIVE_COURSE_IDS_BY_USER).setInteger("userId", userId).list()); + } + + public List getArchivedCourseIdsByUser(final Integer userId, final boolean isSysadmin) { + + return (List) (isSysadmin ? getSession().createQuery(GET_ALL_ARCHIVED_COURSE_IDS).list() : getSession() + .createQuery(GET_ARCHIVED_COURSE_IDS_BY_USER).setInteger("userId", userId).list()); + } + @Override + public List getPagedCourses(final Integer parentOrgId, final Integer typeId, final Integer stateId, + int page, int size, String sortBy, String sortOrder, String searchString) { + String GET_ORGS = "SELECT o FROM " + Organisation.class.getName() + " o " + + " WHERE o.organisationType.organisationTypeId =:typeId " + + " AND o.organisationState.organisationStateId =:stateId " + + " AND o.parentOrganisation.organisationId =:parentOrgId" + + " AND (o.name LIKE CONCAT('%', :searchString, '%')) " + + " ORDER BY "; + + String sortByParam = "o.name"; + if (sortBy == null) { + sortByParam = "o.name"; + + } else if (sortBy.equals("id")) { + sortByParam = "o.organisationId"; + + } else if (sortBy.equals("name")) { + sortByParam = "o.name"; + + } else if (sortBy.equals("code")) { + sortByParam = "o.code"; + + } else if (sortBy.equals("description")) { + sortByParam = "o.description"; } - public List getArchivedCourseIdsByUser(final Integer userId, final boolean isSysadmin) { + Query query = getSession().createQuery(GET_ORGS + sortByParam + " " +sortOrder); + query.setInteger("typeId", typeId); + query.setInteger("stateId", stateId); + query.setInteger("parentOrgId", parentOrgId); + // support for custom search from a toolbar + searchString = searchString == null ? "" : searchString; + query.setString("searchString", searchString); + query.setFirstResult(page * size); + query.setMaxResults(size); + return query.list(); + } + + @Override + public int getCountCoursesByParentCourseAndTypeAndState(final Integer parentOrgId, final Integer typeId, + final Integer stateId, String searchString) { + final String GET_ORGS = "SELECT count(*) FROM Organisation o " + + " WHERE o.parentOrganisation.organisationId =:parentOrgId " + + " AND o.organisationType.organisationTypeId =:typeId " + + " AND o.organisationState.organisationStateId =:stateId " + + " AND (o.name LIKE CONCAT('%', :searchString, '%')) "; - return (List) (isSysadmin ? getSession().createQuery(GET_ALL_ARCHIVED_COURSE_IDS).list() : getSession() - .createQuery(GET_ARCHIVED_COURSE_IDS_BY_USER).setInteger("userId", userId).list()); + Query query = getSession().createQuery(GET_ORGS); + query.setInteger("parentOrgId", parentOrgId); + query.setInteger("typeId", typeId); + query.setInteger("stateId", stateId); + // support for custom search from a toolbar + searchString = searchString == null ? "" : searchString; + query.setString("searchString", searchString); + + List list = query.list(); + if (list == null || list.size() == 0) { + return 0; + } else { + return ((Number) list.get(0)).intValue(); } + } } - \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java,v diff -u -r1.65.2.1 -r1.65.2.2 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java 30 Sep 2014 13:11:31 -0000 1.65.2.1 +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java 5 Oct 2015 18:03:00 -0000 1.65.2.2 @@ -44,489 +44,557 @@ import org.lamsfoundation.lams.usermanagement.dto.UserManageBean; /** - * @version - * *

* View Source *

- * + * * @author Fei Yang - * - * Created at 11:53:53 on 2006-6-2 */ public interface IUserManagementService { + /** + * save(insert or update) + * + * @param object + * The object to be inserted + */ + void save(Object object); - /** - * save(insert or update) - * @param object The object to be inserted - */ - public void save(Object object); + /** + * @param objects + * @return void + */ + void saveAll(Collection objects); - /** - * @param objects - * @return void - */ - public void saveAll(Collection objects); + /** + * Remove an object from the database. + * + * @param object + * The object to be deleted + */ + void delete(Object object); - /** - * Remove an object from the database. - * @param object The object to be deleted - */ - public void delete(Object object); - - - /** - * Be careful to use this method. It will clean up the whole table for the Class - * @param clazz - * @return void - */ - public void deleteAll(Class clazz); - - /** - * @param objects to delete - * @return void - */ - public void deleteAll(Collection objects); - - /** - * @param clazz java Class - * @param id identifier - * @return void - */ - public void deleteById(Class clazz, Serializable id); - - /** - * @param clazz - * @param name - * @param value - * @return void - */ - public void deleteByProperty(Class clazz, String name, Object value); - - /** - * @param properties a map of property names and values - * @return void - */ - public void deleteByProperties(Class clazz, Map properties); - - /** - * Delete any object which has the same non-null property values as the object - * @param object - * @return void - */ - public void deleteAnythingLike(Object object); - - /** - * Find an object. If the object is not found - * then it will return null - * @param clazz - * @param id - */ - public Object findById(Class clazz, Serializable id); - - /** - * @param clazz - * @return all of rows in the table for the Class as objects - */ - public List findAll(Class clazz); - - /** - * @param clazz - * @param name - * @param value - * @return a list of objects which have the same propery value - */ - public List findByProperty(Class clazz, String name, Object value); - - /** - * @param properties a map of property names and values - * @return a list of objects which have the same property values - */ - public List findByProperties(Class clazz, Map properties); - - /** - * Find any object which has the same non-null property values as the object - * @param object - * @return a list of objects which has the same non-null property values as the object - */ - public List findAnythingLike(Object object); - - /** - * @param clazz - * @param properties - * @return a list of objects which have similar property values - */ - public List searchByStringProperties(Class clazz, Map properties); - /** - * Retrieves a tree of organisations for a user. The top of the tree is a "dummy" root - * organisation, just so that we have a real tree. This makes life easier for Flash. + * Be careful to use this method. It will clean up the whole table for the Class * - * If restrictToRoleNames contains any role names (ie not null and size > 0 ) - * then it will restrict the organisations to those in which the user has one of the - * given roles. If restrictToRoleNames is null/empty then till return all organisations - * to which the user belongs. + * @param clazz + * @return void + */ + void deleteAll(Class clazz); + + /** + * @param objects + * to delete + * @return void + */ + void deleteAll(Collection objects); + + /** + * @param clazz + * java Class + * @param id + * identifier + * @return void + */ + void deleteById(Class clazz, Serializable id); + + /** + * @param clazz + * @param name + * @param value + * @return void + */ + void deleteByProperty(Class clazz, String name, Object value); + + /** + * @param properties + * a map of property names and values + * @return void + */ + void deleteByProperties(Class clazz, Map properties); + + /** + * Delete any object which has the same non-null property values as the object * - * @param user mandatory - * @param restrictToRoleNames role names to which to restrict the user + * @param object + * @return void + */ + void deleteAnythingLike(Object object); + + /** + * Find an object. If the object is not found then it will return null + * + * @param clazz + * @param id + */ + Object findById(Class clazz, Serializable id); + + /** + * @param clazz + * @return all of rows in the table for the Class as objects + */ + List findAll(Class clazz); + + /** + * @param clazz + * @param name + * @param value + * @return a list of objects which have the same propery value + */ + List findByProperty(Class clazz, String name, Object value); + + /** + * @param properties + * a map of property names and values + * @return a list of objects which have the same property values + */ + List findByProperties(Class clazz, Map properties); + + /** + * Find any object which has the same non-null property values as the object + * + * @param object + * @return a list of objects which has the same non-null property values as the object + */ + List findAnythingLike(Object object); + + /** + * @param clazz + * @param properties + * @return a list of objects which have similar property values + */ + List searchByStringProperties(Class clazz, Map properties); + + /** + * Retrieves a tree of organisations for a user. The top of the tree is a "dummy" root organisation, just so that we + * have a real tree. This makes life easier for Flash. + * + * If restrictToRoleNames contains any role names (ie not null and size > 0 ) then it will restrict the + * organisations to those in which the user has one of the given roles. If restrictToRoleNames is null/empty then + * till return all organisations to which the user belongs. + * + * @param user + * mandatory + * @param restrictToRoleNames + * role names to which to restrict the user * @return List of organisationDTOs */ - public OrganisationDTO getOrganisationsForUserByRole(User user, List restrictToRoleNames); - - /** - * Retrieves a tree of child of organisations in which the user has the specified role. - * If courseID only is set, then return course organisationDTO and its children as its nodes - * If courseID && restrictToClassIds are set, then course organisationDTO and its the nominated class - * organisationDTOs - most cases will have only single classID - * - * If restrictToRoleNames contains any role names (ie not null and size > 0 ) - * then it will restrict the organisations to those in which the user has one of the - * given roles. + OrganisationDTO getOrganisationsForUserByRole(User user, List restrictToRoleNames); + + /** + * Retrieves a tree of child of organisations in which the user has the specified role. If courseID only is set, + * then return course organisationDTO and its children as its nodes If courseID && restrictToClassIds are set, then + * course organisationDTO and its the nominated class organisationDTOs - most cases will have only single classID * - * @param user mandatory - * @param roles optional - * @param courseID mandatory - * @param restrictToClassIds optional - * @return organisationDTO hierarchy, in WDDX format. - */ - public OrganisationDTO getOrganisationsForUserByRole(User user, List restrictToRoleNames, Integer courseId, List restrictToClassIds); + * If restrictToRoleNames contains any role names (ie not null and size > 0 ) then it will restrict the + * organisations to those in which the user has one of the given roles. + * + * @param user + * mandatory + * @param roles + * optional + * @param courseID + * mandatory + * @param restrictToClassIds + * optional + * @return organisationDTO hierarchy, in WDDX format. + */ + OrganisationDTO getOrganisationsForUserByRole(User user, List restrictToRoleNames, Integer courseId, + List restrictToClassIds); - /** - * Gets an organisation for a user, with the user's roles. Doesn't not return a tree of organisations - */ - public OrganisationDTO getOrganisationForUserWithRole(User user, Integer organisationId); + /** + * Gets an organisation for a user, with the user's roles. Doesn't not return a tree of organisations + */ + OrganisationDTO getOrganisationForUserWithRole(User user, Integer organisationId); - /** - * Retrieves roles in which the user - * has the specified role + /** + * Retrieves roles in which the user has the specified role * - * @param user the user - * @param orgId organisation's id + * @param user + * the user + * @param orgId + * organisation's id * @return List of roles */ - public List getRolesForUserByOrganisation(User user, Integer orgId); + List getRolesForUserByOrganisation(User user, Integer orgId); - /** + /** * Retrieves users from the specified organisation * - * @param orgId organisation's id + * @param orgId + * organisation's id * @return List of users */ - public List getUsersFromOrganisation(Integer orgId); - - /** - * This method returns the users in the Organisation with - * given organisationID and roleName - * - * @param organisationID - * @param roleName - * @param isFlashCall - * @param getUser - * @return UserFlashDTO objects (in a Vector to suit WDDX) - */ - public Vector getUsersFromOrganisationByRole(Integer organisationID, String roleName, boolean isFlashCall, boolean getUser); + List getUsersFromOrganisation(Integer orgId); - public Organisation getRootOrganisation(); - - /** - * @param userId - * @param orgId - * @param roleName - * @return true or false - */ - public boolean isUserInRole(Integer userId,Integer orgId, String roleName); - - /** - * @param typeId - * @param stateId - * @return a list of organisations - */ - public List getOrganisationsByTypeAndStatus(Integer typeId, Integer stateId); - - /** - * @param orgId - * @param login user's login - * @return a list of UserOrganisationRoles - */ - public List getUserOrganisationRoles(Integer orgId, String login); - - /** - * @param login - * @param typeId - * @param stateId - * @return a list of UserOrganisations - */ - public List getUserOrganisationsForUserByTypeAndStatus(String login, Integer typeId, Integer stateId); + /** + * This method returns the users in the Organisation with given organisationID and + * roleName + * + * @param organisationID + * @param roleName + * @param isFlashCall + * @param getUser + * @return UserFlashDTO objects (in a Vector to suit WDDX) + */ + Vector getUsersFromOrganisationByRole(Integer organisationID, String roleName, boolean isFlashCall, + boolean getUser); - /** - * - * @param login - * @param typeId - * @param stateId - * @param parentOrgId - * @return a list of UserOrganisations - */ - public List getUserOrganisationsForUserByTypeAndStatusAndParent(String login, Integer typeId, Integer stateId, Integer parentOrgId); - - /** - * @param login - * @return the User - */ - public User getUserByLogin(String login); - - - /** - * @param login user's login - * @param password new password - * @return void - */ - public void updatePassword(String login, String password); - - /** - * @param userId - * @param orgId - * @return UserOrganisation - */ - public UserOrganisation getUserOrganisation(Integer userId, Integer orgId); - - /** - * Save an organisation. If it is a new course organisation then it will create a workspace and - * its workspace folders. - * - * @param organisation - * @param userID - * @return - */ - public Organisation saveOrganisation( Organisation organisation, Integer userID ); - + Organisation getRootOrganisation(); + /** - * Update and organisation's name, used for integrations. - * It also updates the workspace name and workspace folders + * @param userId + * @param orgId + * @param roleName + * @return true or false + */ + boolean isUserInRole(Integer userId, Integer orgId, String roleName); + + /** + * @param typeId + * @param stateId + * @return a list of organisations + */ + List getOrganisationsByTypeAndStatus(Integer typeId, Integer stateId); + + /** + * Returns courses with specified type, state and parent course. + * + * @param parentOrgId + * @param typeId + * @param stateId + * @param page + * @param size + * @param sortBy + * @param sortOrder + * @param searchString + * filters results by course name. It can be null and then doesn't affect results + * @return + */ + List getPagedCourses(final Integer parentOrgId, final Integer typeId, final Integer stateId, + int page, int size, String sortBy, String sortOrder, String searchString); + + /** + * Counts courses with specified type, state and parent course. + * + * @param parentOrgId + * @param typeId + * @param stateId + * @param searchString + * filters results by course name. It can be null and then doesn't affect results + * @return + */ + int getCountCoursesByParentCourseAndTypeAndState(final Integer parentOrgId, final Integer typeId, + final Integer stateId, String searchString); + + /** + * @param orgId + * @param login + * user's login + * @return a list of UserOrganisationRoles + */ + List getUserOrganisationRoles(Integer orgId, String login); + + /** + * @param login + * @param typeId + * @param stateId + * @return a list of UserOrganisations + */ + List getUserOrganisationsForUserByTypeAndStatus(String login, Integer typeId, Integer stateId); + + /** + * + * @param login + * @param typeId + * @param stateId + * @param parentOrgId + * @return a list of UserOrganisations + */ + List getUserOrganisationsForUserByTypeAndStatusAndParent(String login, Integer typeId, Integer stateId, + Integer parentOrgId); + + /** + * @param login + * @return the User + */ + User getUserByLogin(String login); + + /** + * @param login + * user's login + * @param password + * new password + * @return void + */ + void updatePassword(String login, String password); + + /** + * @param userId + * @param orgId + * @return UserOrganisation + */ + UserOrganisation getUserOrganisation(Integer userId, Integer orgId); + + /** + * Save an organisation. If it is a new course organisation then it will create a workspace and its workspace + * folders. + * * @param organisation + * @param userID + * @return */ - public void updateOrganisationandWorkspaceNames(Organisation organisation); - - public List getUserManageBeans(Integer orgId); - - /** Remove a user from the system completely. Only able to be done if they don't have any - * related learning designs, etc. - * @param userId - */ - public void removeUser(Integer userId) throws Exception; - - /** - * Determines whether a user has associated learning designs, progress data, etc. - * @param user - * @return Boolean - */ - public Boolean userHasData(User user); - - /** - * Sets user's disabled flag to true, and removes their organisation memberships. - * @param userId - */ - public void disableUser(Integer userId); + Organisation saveOrganisation(Organisation organisation, Integer userID); - /** - * Set the roles for the specified user and organisation using the roleIds in rolesList. - * If userOrganisation exists, will also remove roles that are not in rolesList. - * @param user - * @param orgId - * @param rolesList - */ - public void setRolesForUserOrganisation(User user, Integer organisationId, List rolesList); - - /** - * Returns list of roles suitable for the given orgType. - * @param rolelist - * @param isSysadmin - * @param orgType - * @return - */ - public List filterRoles(List rolelist, Boolean isSysadmin, OrganisationType orgType); - + /** + * Update and organisation's name, used for integrations. It also updates the workspace name and workspace folders + * + * @param organisation + */ + void updateOrganisationandWorkspaceNames(Organisation organisation); - public boolean hasRoleInOrganisation(User user, Integer roleId); - - /** - * Returns true if user has the role in the given organisation. Otherwise false. - * @param user - * @param roleId - * @param organisation - * @return - */ - public boolean hasRoleInOrganisation(User user, Integer roleId, Organisation organisation); - - /** - * Given a user and a group, removes user from subgroups. - * @param user - * @param org - */ - public void deleteChildUserOrganisations(User user, Organisation org); - - /** - * Removes user from this group and its subgroups. - * @param user - * @param org - */ - public void deleteUserOrganisation(User user, Organisation org); - - /** - * Return true if user is a global group admin. - * @return - */ - public boolean isUserGlobalGroupAdmin(); - - /** - * Return true if user has sysadmin role in root organisation. - * @return - */ - public boolean isUserSysAdmin(); - - /** - * Count the number of unique (distinct) users with a particular role in the system. - * @param roleId Role ID - * @return - */ - public Integer getCountRoleForSystem(Integer roleId); - - /** - * Count then umber of users with a particular role in a given org. - * @param orgId - * @param roleId - * @return - */ - public Integer getCountRoleForOrg(Integer orgId, Integer roleId); - - /** - * Get default flash theme of server. - * @return default flash theme object - */ - public Theme getDefaultFlashTheme(); - - /** - * Get default html theme of server. - * @return default html theme object - */ - public Theme getDefaultHtmlTheme(); - - public void auditPasswordChanged(User user, String moduleName); - - public void auditUserCreated(User user, String moduleName); - - public Integer getCountUsers(); - - public Integer getCountUsers(Integer authenticationMethodId); - - public List getActiveCourseIdsByUser(Integer userId, boolean isSysadmin); - - public List getArchivedCourseIdsByUser(Integer userId, boolean isSysadmin); - - /** - * Search users across login, first name, last name and email fields using the search term. - * Filters out disabled users. - * @param term - * @return list of Users - */ - public List searchUserSingleTerm(String term); - - /** - * Search users 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 - * @param filteredOrgId - * @return list of Users - */ - 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 - * @param orgId - * @param filteredOrgId - * @return list of Users - */ - public List searchUserSingleTerm(String term, Integer orgId, Integer filteredOrgId); - - /** - * Get all users, except for disabled users. - * @return list of Users - */ - public List getAllUsers(); - - /** - * Get all users, except for disabled users and users that are members of filteredOrg. - * @param optionalOrgId - * @return list of Users - */ - public List getAllUsers(Integer filteredOrgId); - - /** - * Get all users with the given Email. Email must not be empty - * Use a regex check to make sure the string is in correct xxx@xxx.xxx form, - * see lams-central/web/forgotPassword.jsp javascript methods - * * @param email a non empty email string - * @return list of Users - */ - public List getAllUsersWithEmail(String email); - - /** - * Get all users in orgId, except for users that are members of filteredOrg. - * @param orgId - * @param filteredOrgId - * @return list of Users - */ - public List getUsersFromOrganisation(Integer orgId, Integer filteredOrgId); - - /** - * Tests whether user can edit the given org's details. - * @param userId - * @param orgId - * @return boolean - */ - public boolean canEditGroup(Integer userId, Integer orgId); - - /** - * Gets a forgot password request from the db with the given key - * @param key - * @return - */ - public ForgotPasswordRequest getForgotPasswordRequest(String key); - - /** - * Remove given user from groups other than the specified one. Doesn't remove - * user from subgroups of the specified group if any. - * @param userId - * @param orgId - * @return number of deleted rows. - */ - public int removeUserFromOtherGroups(Integer userId, Integer orgId); - - - /** - * Returns the user dto for the given openidURL if one exists - * used for sif openid login - * - * @param openidURL - * @return - */ - public User getUserDTOByOpenidURL(String openidURL); - - /** - * Stores organisation (course) groups and removes the unnecessary ones. - */ - public void saveOrganisationGrouping(OrganisationGrouping grouping, Collection newGroups); + List getUserManageBeans(Integer orgId); + + /** + * Remove a user from the system completely. Only able to be done if they don't have any related learning designs, + * etc. + * + * @param userId + */ + void removeUser(Integer userId) throws Exception; + + /** + * Determines whether a user has associated learning designs, progress data, etc. + * + * @param user + * @return Boolean + */ + Boolean userHasData(User user); + + /** + * Sets user's disabled flag to true, and removes their organisation memberships. + * + * @param userId + */ + void disableUser(Integer userId); + + /** + * Set the roles for the specified user and organisation using the roleIds in rolesList. If userOrganisation exists, + * will also remove roles that are not in rolesList. + * + * @param user + * @param orgId + * @param rolesList + */ + void setRolesForUserOrganisation(User user, Integer organisationId, List rolesList); + + /** + * Returns list of roles suitable for the given orgType. + * + * @param rolelist + * @param isSysadmin + * @param orgType + * @return + */ + List filterRoles(List rolelist, Boolean isSysadmin, OrganisationType orgType); + + boolean hasRoleInOrganisation(User user, Integer roleId); + + /** + * Returns true if user has the role in the given organisation. Otherwise false. + * + * @param user + * @param roleId + * @param organisation + * @return + */ + boolean hasRoleInOrganisation(User user, Integer roleId, Organisation organisation); + + /** + * Given a user and a group, removes user from subgroups. + * + * @param user + * @param org + */ + void deleteChildUserOrganisations(User user, Organisation org); + + /** + * Removes user from this group and its subgroups. + * + * @param user + * @param org + */ + void deleteUserOrganisation(User user, Organisation org); + + /** + * Return true if user is a global group admin. + * + * @return + */ + boolean isUserGlobalGroupAdmin(); + + /** + * Return true if user has sysadmin role in root organisation. + * + * @return + */ + boolean isUserSysAdmin(); + + /** + * Count the number of unique (distinct) users with a particular role in the system. + * + * @param roleId + * Role ID + * @return + */ + Integer getCountRoleForSystem(Integer roleId); + + /** + * Count then umber of users with a particular role in a given org. + * + * @param orgId + * @param roleId + * @return + */ + Integer getCountRoleForOrg(Integer orgId, Integer roleId); + + /** + * Get default flash theme of server. + * + * @return default flash theme object + */ + Theme getDefaultFlashTheme(); + + /** + * Get default html theme of server. + * + * @return default html theme object + */ + Theme getDefaultHtmlTheme(); + + void auditPasswordChanged(User user, String moduleName); + + void auditUserCreated(User user, String moduleName); + + Integer getCountUsers(); + + Integer getCountUsers(Integer authenticationMethodId); + + List getActiveCourseIdsByUser(Integer userId, boolean isSysadmin); + + List getArchivedCourseIdsByUser(Integer userId, boolean isSysadmin); + + /** + * Search users across login, first name, last name and email fields using the search term. Filters out disabled + * users. + * + * @param term + * @return list of Users + */ + List searchUserSingleTerm(String term); + + /** + * Search users 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 + * @param filteredOrgId + * @return list of Users + */ + 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 + */ + 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 + * @param orgId + * @param filteredOrgId + * @return list of Users + */ + List searchUserSingleTerm(String term, Integer orgId, Integer filteredOrgId); + + /** + * Get all users, except for disabled users. + * + * @return list of Users + */ + List getAllUsers(); + + /** + * Get all users, except for disabled users and users that are members of filteredOrg. + * + * @param optionalOrgId + * @return list of Users + */ + List getAllUsers(Integer filteredOrgId); + + /** + * Get all users with the given Email. Email must not be empty Use a regex check to make sure the string is in + * correct xxx@xxx.xxx form, see lams-central/web/forgotPassword.jsp javascript methods * @param email a non empty + * email string + * + * @return list of Users + */ + List getAllUsersWithEmail(String email); + + /** + * Get all users in orgId, except for users that are members of filteredOrg. + * + * @param orgId + * @param filteredOrgId + * @return list of Users + */ + List getUsersFromOrganisation(Integer orgId, Integer filteredOrgId); + + /** + * Tests whether user can edit the given org's details. + * + * @param userId + * @param orgId + * @return boolean + */ + boolean canEditGroup(Integer userId, Integer orgId); + + /** + * Gets a forgot password request from the db with the given key + * + * @param key + * @return + */ + ForgotPasswordRequest getForgotPasswordRequest(String key); + + /** + * Remove given user from groups other than the specified one. Doesn't remove user from subgroups of the specified + * group if any. + * + * @param userId + * @param orgId + * @return number of deleted rows. + */ + int removeUserFromOtherGroups(Integer userId, Integer orgId); + + /** + * Returns the user dto for the given openidURL if one exists used for sif openid login + * + * @param openidURL + * @return + */ + User getUserDTOByOpenidURL(String openidURL); + + /** + * Stores organisation (course) groups and removes the unnecessary ones. + */ + void saveOrganisationGrouping(OrganisationGrouping grouping, Collection newGroups); } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java,v diff -u -r1.115.2.4 -r1.115.2.5 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java 25 Nov 2014 09:39:20 -0000 1.115.2.4 +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java 5 Oct 2015 18:03:00 -0000 1.115.2.5 @@ -305,10 +305,6 @@ return baseDAO.searchByStringProperties(clazz, properties); } - /** - * @see org.lamsfoundation.lams.usermanagement.service.IUserManagementService - * #getOrganisationRolesForUser(org.lamsfoundation.lams.usermanagement. User, java.util.List) - */ @Override public OrganisationDTO getOrganisationsForUserByRole(User user, List restrictToRoleNames) { List list = new ArrayList(); @@ -325,11 +321,6 @@ return OrganisationDTOFactory.createTree(list); } - /** - * @see org.lamsfoundation.lams.usermanagement.service.IUserManagementService - * #getOrganisationRolesForUser(org.lamsfoundation.lams.usermanagement. User, java.util.List, - * java.util.Integer) - */ @Override public OrganisationDTO getOrganisationsForUserByRole(User user, List restrictToRoleNames, Integer courseId, List restrictToClassIds) { @@ -398,10 +389,6 @@ return roleFound; } - /** - * 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. - */ @Override public OrganisationDTO getOrganisationForUserWithRole(User user, Integer organisationId) { if ((user != null) && (organisationId != null)) { @@ -417,10 +404,6 @@ return null; } - /** - * @see org.lamsfoundation.lams.usermanagement.service.IUserManagementService#getRolesForUserByOrganisation(org.lamsfoundation.lams.usermanagement.User, - * java.lang.Integer) - */ @Override public List getRolesForUserByOrganisation(User user, Integer orgId) { List list = new ArrayList(); @@ -439,20 +422,13 @@ return list; } - /** - * @see org.lamsfoundation.lams.usermanagement.service.IUserManagementService#getUsersFromOrganisation(int) - */ @Override public List getUsersFromOrganisation(Integer orgId) { String query = "select uo.user from UserOrganisation uo" + " where uo.organisation.organisationId=" + orgId + " order by uo.user.login"; return baseDAO.find(query); } - /** - * @see org.lamsfoundation.lams.usermanagement.service.IUserManagementService#getUsersFromOrganisationByRole(java.lang.Integer, - * java.lang.String) - */ @Override @SuppressWarnings("unchecked") public Vector getUsersFromOrganisationByRole(Integer organisationID, String roleName, boolean isFlashCall, @@ -469,8 +445,8 @@ // it's ugly to put query string here, but it is a convention of this class so let's stick to it for now String query = "SELECT uo.user FROM UserOrganisation uo INNER JOIN uo.userOrganisationRoles r WHERE uo.organisation.organisationId=" + organisationID + " AND r.role.name= '" + roleName + "'"; - List queryResult = baseDAO.find(query); - + List queryResult = (List) baseDAO.find(query); + for (User user : queryResult) { if (isFlashCall && !getUser) { users.add(user.getUserFlashDTO()); @@ -480,7 +456,7 @@ users.add(user.getUserDTO()); } } - + return users; } @@ -511,6 +487,19 @@ } @Override + public List getPagedCourses(final Integer parentOrgId, final Integer typeId, final Integer stateId, + int page, int size, String sortBy, String sortOrder, String searchString) { + return organisationDAO.getPagedCourses(parentOrgId, typeId, stateId, page, size, sortBy, sortOrder, + searchString); + } + + @Override + public int getCountCoursesByParentCourseAndTypeAndState(final Integer parentOrgId, final Integer typeId, + final Integer stateId, String searchString) { + return organisationDAO.getCountCoursesByParentCourseAndTypeAndState(parentOrgId, typeId, stateId, searchString); + } + + @Override public List getUserOrganisationRoles(Integer orgId, String login) { Map properties = new HashMap(); properties.put("userOrganisation.organisation.organisationId", orgId); @@ -577,7 +566,7 @@ } @SuppressWarnings("unchecked") - public Workspace createWorkspaceForOrganisation(String workspaceName, Integer userID, Date createDateTime) { + private Workspace createWorkspaceForOrganisation(String workspaceName, Integer userID, Date createDateTime) { // this method is public so it can be accessed from the junit test @@ -748,12 +737,6 @@ return userManageBeans; } - /** - * Remove a user from the system completely. Only able to be done if they don't have any related learning designs, - * etc. - * - * @param userId - */ @Override public void removeUser(Integer userId) throws Exception { @@ -850,12 +833,6 @@ save(user); } - /** - * (non-Javadoc) - * - * @see org.lamsfoundation.lams.usermanagement.service.IUserManagementService#setRolesForUserOrganisation(org.lamsfoundation.lams.usermanagement.User, - * java.lang.Integer, java.util.List) - */ @Override public void setRolesForUserOrganisation(User user, Integer organisationId, List rolesList) {