public ActionForward create( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm classForm = (DynaValidatorForm) form; String className = (String) classForm.get("className"); InfoCurricularYear infoCurricularYear = (InfoCurricularYear) request.getAttribute(PresentationConstants.CURRICULAR_YEAR); InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) request.getAttribute(PresentationConstants.EXECUTION_DEGREE); AcademicInterval academicInterval = AcademicInterval.getAcademicIntervalFromResumedString( (String) request.getAttribute(PresentationConstants.ACADEMIC_INTERVAL)); Integer curricularYear = infoCurricularYear.getYear(); try { CriarTurma.run(className, curricularYear, infoExecutionDegree, academicInterval); } catch (DomainException e) { throw new ExistingActionException("A SchoolClass", e); } return listClasses(mapping, form, request, response); }
public ActionForward listClasses( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { AcademicInterval academicInterval = AcademicInterval.getAcademicIntervalFromResumedString( (String) request.getAttribute(PresentationConstants.ACADEMIC_INTERVAL)); InfoCurricularYear infoCurricularYear = (InfoCurricularYear) request.getAttribute(PresentationConstants.CURRICULAR_YEAR); InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) request.getAttribute(PresentationConstants.EXECUTION_DEGREE); final ExecutionDegree executionDegree = FenixFramework.getDomainObject(infoExecutionDegree.getExternalId()); final Set<SchoolClass> classes; Integer curricularYear = infoCurricularYear.getYear(); if (curricularYear != null) { classes = executionDegree.findSchoolClassesByAcademicIntervalAndCurricularYear( academicInterval, curricularYear); } else { classes = executionDegree.findSchoolClassesByAcademicInterval(academicInterval); } final List<InfoClass> infoClassesList = new ArrayList<InfoClass>(); for (final SchoolClass schoolClass : classes) { InfoClass infoClass = InfoClass.newInfoFromDomain(schoolClass); infoClassesList.add(infoClass); } if (infoClassesList != null && !infoClassesList.isEmpty()) { BeanComparator nameComparator = new BeanComparator("nome"); Collections.sort(infoClassesList, nameComparator); request.setAttribute(PresentationConstants.CLASSES, infoClassesList); } request.setAttribute("executionDegreeD", executionDegree); return mapping.findForward("ShowClassList"); }