Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java,v diff -u -r1.17.8.1 -r1.17.8.2 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 29 Oct 2009 01:54:56 -0000 1.17.8.1 +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 29 Oct 2009 01:59:21 -0000 1.17.8.2 @@ -82,73 +82,57 @@ private static ICoreLearnerService learnerService; - public ActionForward view(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) - throws Exception { + public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - User requestor = (User) getService().getUserByLogin( - request.getRemoteUser()); - String fullName = (requestor.getTitle() != null ? requestor.getTitle() - + " " : "") - + requestor.getFirstName() + " " + requestor.getLastName(); + User requestor = (User) getService().getUserByLogin(request.getRemoteUser()); + String fullName = (requestor.getTitle() != null ? requestor.getTitle() + " " : "") + requestor.getFirstName() + + " " + requestor.getLastName(); String email = requestor.getEmail(); request.setAttribute("fullName", fullName); request.setAttribute("email", (email != null ? email : "")); - request.setAttribute("portraitUuid", - (requestor.getPortraitUuid() == null ? 0 : requestor - .getPortraitUuid())); + request.setAttribute("portraitUuid", (requestor.getPortraitUuid() == null ? 0 : requestor.getPortraitUuid())); request.setAttribute("tab", "profile"); return mapping.findForward("view"); } - public ActionForward lessons(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) - throws Exception { + public ActionForward lessons(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { // list all active lessons for this learner (single sql query) - User requestor = (User) getService().getUserByLogin( - request.getRemoteUser()); - LessonDTO[] lessons = getLearnerService().getActiveLessonsFor( - requestor.getUserId()); + User requestor = (User) getService().getUserByLogin(request.getRemoteUser()); + LessonDTO[] lessons = getLearnerService().getActiveLessonsFor(requestor.getUserId()); // make org-sorted beans out of the lessons HashMap orgBeansMap = new HashMap(); for (LessonDTO lesson : lessons) { Integer orgId = lesson.getOrganisationID(); - Organisation org = (Organisation) getService().findById( - Organisation.class, orgId); - Integer orgTypeId = org.getOrganisationType() - .getOrganisationTypeId(); - IndexLessonBean lessonBean = new IndexLessonBean(lesson - .getLessonName(), "javascript:openLearner(" + Organisation org = (Organisation) getService().findById(Organisation.class, orgId); + Integer orgTypeId = org.getOrganisationType().getOrganisationTypeId(); + IndexLessonBean lessonBean = new IndexLessonBean(lesson.getLessonName(), "javascript:openLearner(" + lesson.getLessonID() + ")"); lessonBean.setId(lesson.getLessonID()); log.debug("Lesson: " + lesson.getLessonName()); // insert or update bean if it is a course if (orgTypeId.equals(OrganisationType.COURSE_TYPE)) { - IndexOrgBean orgBean = (!orgBeansMap.containsKey(orgId)) ? new IndexOrgBean( - org.getOrganisationId(), org.getName(), orgTypeId) - : orgBeansMap.get(orgId); + IndexOrgBean orgBean = (!orgBeansMap.containsKey(orgId)) ? new IndexOrgBean(org.getOrganisationId(), + org.getName(), orgTypeId) : orgBeansMap.get(orgId); orgBean.addLesson(lessonBean); orgBeansMap.put(orgId, orgBean); } else if (orgTypeId.equals(OrganisationType.CLASS_TYPE)) { // if it is a class, find existing or create new parent bean Organisation parentOrg = org.getParentOrganisation(); Integer parentOrgId = parentOrg.getOrganisationId(); - IndexOrgBean parentOrgBean = (!orgBeansMap - .containsKey(parentOrgId)) ? new IndexOrgBean(parentOrg - .getOrganisationId(), parentOrg.getName(), - OrganisationType.COURSE_TYPE) : orgBeansMap + IndexOrgBean parentOrgBean = (!orgBeansMap.containsKey(parentOrgId)) ? new IndexOrgBean(parentOrg + .getOrganisationId(), parentOrg.getName(), OrganisationType.COURSE_TYPE) : orgBeansMap .get(parentOrgId); // create new bean for class, or use existing bean - IndexOrgBean orgBean = new IndexOrgBean( - org.getOrganisationId(), org.getName(), orgTypeId); - List childOrgBeans = parentOrgBean - .getChildIndexOrgBeans(); + IndexOrgBean orgBean = new IndexOrgBean(org.getOrganisationId(), org.getName(), orgTypeId); + List childOrgBeans = parentOrgBean.getChildIndexOrgBeans(); if (childOrgBeans.contains(orgBean)) { // use existing org bean orgBean = getOrgBean(org.getName(), childOrgBeans); @@ -166,8 +150,7 @@ } // sort group and subgroup names - ArrayList beans = new ArrayList(orgBeansMap - .values()); + ArrayList beans = new ArrayList(orgBeansMap.values()); Collections.sort(beans); for (IndexOrgBean b : beans) { Collections.sort(b.getChildIndexOrgBeans()); @@ -176,17 +159,15 @@ // sort lessons inside each org bean for (Object o : beans) { IndexOrgBean bean = (IndexOrgBean) o; - Organisation org = (Organisation) service.findById( - Organisation.class, bean.getId()); + Organisation org = (Organisation) service.findById(Organisation.class, bean.getId()); // put lesson beans into id-indexed map HashMap map = new HashMap(); for (IndexLessonBean lbean : bean.getLessons()) { map.put(lbean.getId(), lbean); } - bean.setLessons(IndexUtils.sortLessonBeans(org - .getOrderedLessonIds(), map)); + bean.setLessons(IndexUtils.sortLessonBeans(org.getOrderedLessonIds(), map)); } request.setAttribute("beans", beans); @@ -204,12 +185,10 @@ return null; } - public ActionForward edit(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) - throws Exception { + public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - User requestor = (User) getService().getUserByLogin( - request.getRemoteUser()); + User requestor = (User) getService().getUserByLogin(request.getRemoteUser()); DynaActionForm userForm = (DynaActionForm) form; BeanUtils.copyProperties(userForm, requestor); SupportedLocale locale = requestor.getLocale(); @@ -228,11 +207,9 @@ private IUserManagementService getService() { if (service == null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet() - .getServletContext()); - service = (IUserManagementService) ctx - .getBean("userManagementService"); + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + service = (IUserManagementService) ctx.getBean("userManagementService"); locales = getService().findAll(SupportedLocale.class); Collections.sort(locales); } @@ -241,11 +218,9 @@ private ICoreLearnerService getLearnerService() { if (learnerService == null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet() - .getServletContext()); - learnerService = (ICoreLearnerService) ctx - .getBean("learnerService"); + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + learnerService = (ICoreLearnerService) ctx.getBean("learnerService"); } return learnerService; }