/** * Method execute * * @param mapping * @param form * @param request * @param response * @return ActionForward * @throws HibernateException */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BackTracker.markForBack(request, null, null, false, true); sessionContext.checkPermission(Right.Classes); sessionContext.setAttribute("callingPage", "classShowSearch"); Object sas = sessionContext.getAttribute(SessionAttribute.ClassesSubjectAreas); Object cn = sessionContext.getAttribute(SessionAttribute.ClassesCourseNumber); String subjectAreaIds = ""; String courseNbr = ""; if ((sas == null || sas.toString().trim().isEmpty()) && (cn == null || cn.toString().trim().isEmpty())) { // use session variables from io search sas = sessionContext.getAttribute(SessionAttribute.OfferingsSubjectArea); cn = sessionContext.getAttribute(SessionAttribute.OfferingsCourseNumber); } request.setAttribute( Department.EXTERNAL_DEPT_ATTR_NAME, Department.findAllExternal(sessionContext.getUser().getCurrentAcademicSessionId())); ClassListForm classListForm = (ClassListForm) form; ClassSearchAction.setupGeneralFormFilters(sessionContext, classListForm); ClassSearchAction.setupClassListSpecificFormFilters(sessionContext, classListForm); if (!sessionContext.hasPermission(Right.CourseTimetabling)) classListForm.setTimetable(null); if (!sessionContext.hasPermission(Right.Examinations)) classListForm.setExams(null); classListForm.setSubjectAreas(SubjectArea.getUserSubjectAreas(sessionContext.getUser())); if (sas == null && classListForm.getSubjectAreas().size() == 1) sas = ((SubjectArea) classListForm.getSubjectAreas().iterator().next()) .getUniqueId() .toString(); if (Constants.ALL_OPTION_VALUE.equals(sas)) sas = null; // Subject Areas are saved to the session - Perform automatic search if (sas != null && sas.toString().trim().length() > 0) { subjectAreaIds = sas.toString(); try { if (cn != null && cn.toString().trim().length() > 0) courseNbr = cn.toString(); Debug.debug("Subject Areas: " + subjectAreaIds); Debug.debug("Course Number: " + courseNbr); classListForm.setSubjectAreaIds(subjectAreaIds.split(",")); classListForm.setCourseNbr(courseNbr); StringBuffer ids = new StringBuffer(); StringBuffer names = new StringBuffer(); StringBuffer subjIds = new StringBuffer(); classListForm.setClasses( ClassSearchAction.getClasses( classListForm, WebSolver.getClassAssignmentProxy(request.getSession()))); Collection classes = classListForm.getClasses(); if (classes.isEmpty()) { ActionMessages errors = new ActionMessages(); errors.add( "searchResult", new ActionMessage( "errors.generic", "No records matching the search criteria were found.")); saveErrors(request, errors); return mapping.findForward("showClassSearch"); } else { for (int i = 0; i < classListForm.getSubjectAreaIds().length; i++) { if (i > 0) { names.append(","); subjIds.append(","); } ids.append("&subjectAreaIds=" + classListForm.getSubjectAreaIds()[i]); subjIds.append(classListForm.getSubjectAreaIds()[i]); names.append( ((new SubjectAreaDAO()).get(new Long(classListForm.getSubjectAreaIds()[i]))) .getSubjectAreaAbbreviation()); } BackTracker.markForBack( request, "classSearch.do?doit=Search&loadFilter=1&" + ids + "&courseNbr=" + classListForm.getCourseNbr(), "Classes (" + names + (classListForm.getCourseNbr() == null || classListForm.getCourseNbr().length() == 0 ? "" : " " + classListForm.getCourseNbr()) + ")", true, true); return mapping.findForward("showClassList"); } } catch (NumberFormatException nfe) { Debug.error("Subject Area Ids session attribute is corrupted. Resetting ... "); sessionContext.removeAttribute(SessionAttribute.ClassesSubjectAreas); sessionContext.removeAttribute(SessionAttribute.ClassesCourseNumber); } } return mapping.findForward("showClassSearch"); }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ExamReportForm myForm = (ExamReportForm) form; // Check Access sessionContext.checkPermission(Right.NotAssignedExaminations); String op = (myForm.getOp() != null ? myForm.getOp() : request.getParameter("op")); if ("Export CSV".equals(op) || "Export PDF".equals(op) || "Apply".equals(op)) { myForm.save(sessionContext); } else if ("Refresh".equals(op)) { myForm.reset(mapping, request); } myForm.load(sessionContext); Session session = SessionDAO.getInstance().get(sessionContext.getUser().getCurrentAcademicSessionId()); RoomAvailability.setAvailabilityWarning(request, session, myForm.getExamType(), true, false); ExamSolverProxy solver = WebSolver.getExamSolver(request.getSession()); Collection<ExamInfo> unassignedExams = null; if (myForm.getSubjectArea() != null && myForm.getSubjectArea() != 0 && myForm.getExamType() != null) { if (solver != null && solver.getExamTypeId().equals(myForm.getExamType())) unassignedExams = solver.getUnassignedExams(myForm.getSubjectArea()); else unassignedExams = Exam.findUnassignedExams( sessionContext.getUser().getCurrentAcademicSessionId(), myForm.getSubjectArea(), myForm.getExamType()); } WebTable.setOrder(sessionContext, "unassignedExams.ord", request.getParameter("ord"), 1); WebTable table = getTable(true, false, myForm, unassignedExams); if ("Export PDF".equals(op) && table != null) { ExportUtils.exportPDF( getTable(false, true, myForm, unassignedExams), WebTable.getOrder(sessionContext, "unassignedExams.ord"), response, "unassigned"); return null; } if ("Export CSV".equals(op) && table != null) { ExportUtils.exportCSV( getTable(false, false, myForm, unassignedExams), WebTable.getOrder(sessionContext, "unassignedExams.ord"), response, "unassigned"); return null; } if (table != null) myForm.setTable( table.printTable(WebTable.getOrder(sessionContext, "unassignedExams.ord")), 9, unassignedExams.size()); if (request.getParameter("backId") != null) request.setAttribute("hash", request.getParameter("backId")); LookupTables.setupExamTypes( request, sessionContext.getUser(), DepartmentStatusType.Status.ExamTimetable); return mapping.findForward("showReport"); }