public ActionForward prepare( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixFilterException, FenixServiceException { IUserView userView = UserView.getUser(); InfoExecutionYear executionYear = ReadCurrentExecutionYear.run(); Object[] argsDCPs = {executionYear.getIdInternal()}; List degreeCurricularPlans = (List) ServiceUtils.executeService("ReadActiveDegreeCurricularPlansByExecutionYear", argsDCPs); final ComparatorChain comparatorChain = new ComparatorChain(); comparatorChain.addComparator(new BeanComparator("infoDegree.tipoCurso")); comparatorChain.addComparator(new BeanComparator("infoDegree.nome")); Collections.sort(degreeCurricularPlans, comparatorChain); request.setAttribute("degreeCurricularPlans", degreeCurricularPlans); DynaActionForm dynaActionForm = (DynaActionForm) form; Integer[] defaultLimits = {0, 10, 35, 65, 90, 100}; dynaActionForm.set("entryGradeLimits", defaultLimits); dynaActionForm.set("approvationRatioLimits", defaultLimits); dynaActionForm.set("arithmeticMeanLimits", defaultLimits); return mapping.findForward("chooseDegreeCurricularPlan"); }
public ActionForward createClassifications( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixFilterException, FenixServiceException, IOException { IUserView userView = UserView.getUser(); DynaActionForm dynaActionForm = (DynaActionForm) form; Integer degreeCurricularPlanID = (Integer) dynaActionForm.get("degreeCurricularPlanID"); Integer[] entryGradeLimits = (Integer[]) dynaActionForm.get("entryGradeLimits"); Integer[] approvationRatioLimits = (Integer[]) dynaActionForm.get("approvationRatioLimits"); Integer[] arithmeticMeanLimits = (Integer[]) dynaActionForm.get("arithmeticMeanLimits"); Object[] args = { entryGradeLimits, approvationRatioLimits, arithmeticMeanLimits, degreeCurricularPlanID }; ByteArrayOutputStream resultStream = (ByteArrayOutputStream) ServiceUtils.executeService("CreateClassificationsForStudents", args); String currentDate = new SimpleDateFormat("dd-MMM-yy.HH-mm").format(new Date()); response.setHeader( "Content-disposition", "attachment;filename=" + degreeCurricularPlanID + "_" + currentDate + ".zip"); response.setContentType("application/zip"); DataOutputStream dos = new DataOutputStream(response.getOutputStream()); dos.write(resultStream.toByteArray()); dos.close(); return null; }
@Override public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException { IUserView userView = UserView.getUser(); String degreeID = request.getParameter("degreeId"); String degreeCurricularPlanID = request.getParameter("degreeCurricularPlanId"); try { Map result = ReadPrecedencesFromDegreeCurricularPlan.run(degreeCurricularPlanID); request.setAttribute("precedences", result); } catch (FenixServiceException e) { throw new FenixActionException(e); } request.setAttribute("degreeId", degreeID); request.setAttribute("degreeCurricularPlanId", degreeCurricularPlanID); return mapping.findForward("showPrecedences"); }
@Override protected void redirectToCAS( final CasConfig casConfig, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { if (UserView.getUser() == null) { String pendingRequest = request.getParameter("pendingRequest"); if (pendingRequest == null) { pendingRequest = (String) request.getAttribute("pendingRequest"); } final String barraAsAuthBroker = PropertiesManager.getProperty("barra.as.authentication.broker"); final boolean useBarraAsAuthenticationBroker = barraAsAuthBroker != null && barraAsAuthBroker.equals("true"); final String serviceString = encodeUrl(RequestUtils.generateRedirectLink(casConfig.getServiceUrl(), pendingRequest)); String casLoginUrl = ""; if (useBarraAsAuthenticationBroker) { final String barraLoginUrl = PropertiesManager.getProperty("barra.loginUrl"); casLoginUrl += barraLoginUrl; casLoginUrl += "?next="; } casLoginUrl += casConfig.getCasLoginUrl(); final String casLoginString = casLoginUrl + "?service=" + serviceString; response.sendRedirect(casLoginString); } else { response.sendRedirect(request.getContextPath() + "/home.do"); } }
public ActionForward insert( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException { IUserView userView = UserView.getUser(); DynaActionForm dynaForm = (DynaValidatorForm) form; String code = (String) dynaForm.get("code"); String name = (String) dynaForm.get("name"); String nameEn = (String) dynaForm.get("nameEn"); String degreeTypeInt = (String) dynaForm.get("degreeType"); String gradeTypeString = (String) dynaForm.get("gradeType"); DegreeType degreeType = DegreeType.valueOf(degreeTypeInt); GradeScale gradeScale = null; if (gradeTypeString != null && gradeTypeString.length() > 0) { gradeScale = GradeScale.valueOf(gradeTypeString); } try { InsertDegree.run(code, name, nameEn, degreeType, gradeScale); } catch (ExistingServiceException ex) { throw new ExistingActionException( "message.already.existing.degree", mapping.findForward("readDegrees")); } catch (FenixServiceException e) { throw new FenixActionException(e.getMessage()); } return mapping.findForward("readDegrees"); }
public ActionForward sort( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm roomSearchForm = (DynaValidatorForm) form; IUserView userView = UserView.getUser(); String[] availableRoomsId = (String[]) roomSearchForm.get("availableRoomsId"); String sortParameter = request.getParameter("sortParameter"); List<InfoRoom> availableRooms = new ArrayList<InfoRoom>(); for (String element : availableRoomsId) { InfoRoom infoRoom = ReadRoomByOID.run(new Integer(element)); availableRooms.add(infoRoom); } if ((sortParameter != null) && (sortParameter.length() != 0)) { if (sortParameter.equals("name")) { Collections.sort(availableRooms, new BeanComparator("nome")); } else if (sortParameter.equals("type")) { Collections.sort(availableRooms, new BeanComparator("tipo")); } else if (sortParameter.equals("building")) { Collections.sort(availableRooms, new BeanComparator("edificio")); } else if (sortParameter.equals("floor")) { Collections.sort(availableRooms, new BeanComparator("piso")); } else if (sortParameter.equals("normal")) { Collections.sort( availableRooms, new ReverseComparator(new BeanComparator("capacidadeNormal"))); } else if (sortParameter.equals("exam")) { Collections.sort( availableRooms, new ReverseComparator(new BeanComparator("capacidadeExame"))); } } else { Collections.sort(availableRooms, new BeanComparator("nome")); } String sdate = roomSearchForm.get("day") + "/" + roomSearchForm.get("month") + "/" + roomSearchForm.get("year"); String startTime = roomSearchForm.get("beginningHour") + ":" + roomSearchForm.get("beginningMinute"); String endTime = roomSearchForm.get("endHour") + ":" + roomSearchForm.get("endMinute"); request.setAttribute(PresentationConstants.DATE, sdate); request.setAttribute(PresentationConstants.START_TIME, startTime); request.setAttribute(PresentationConstants.END_TIME, endTime); request.setAttribute(PresentationConstants.AVAILABLE_ROOMS, availableRooms); request.setAttribute(PresentationConstants.AVAILABLE_ROOMS_ID, availableRoomsId); return mapping.findForward("showRooms"); }
public ActionForward welcome( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { /*//Pick up user so that you can find out which //agreement greeting is supposed to be shown. //(for single agreement supervisors only) final IUserView userView = UserView.getUser(); Person supervisor = userView.getPerson(); //If action is being called after Protocol Selection, it means //this supervisor is responsible for several agreements. //In that case the agreement greeting supposed to be shown //is attainable through the request. final String registrationProtocolId = request.getParameter("registrationProtocolId"); RegistrationProtocol registrationProtocol = FenixFramework.getDomainObject(registrationProtocolId); RegistrationAgreement registrationAgreement; //If coming from selectProtocol, read agreement from request. Else read from user. Plain simple. if(registrationProtocol != null){ registrationAgreement = registrationProtocol.getRegistrationAgreement(); } else { registrationAgreement = supervisor.getRegistrationProtocols().iterator().next().getRegistrationAgreement(); }*/ final IUserView userView = UserView.getUser(); Person supervisor = userView.getPerson(); RegistrationProtocol registrationProtocol = supervisor.getOnlyRegistrationProtocol(); if (registrationProtocol == null) { return mapping.findForward("welcome"); } switch (registrationProtocol.getRegistrationAgreement()) { case AFA: return mapping.findForward("welcome_AFA"); case MA: return mapping.findForward("welcome_MA"); default: return mapping.findForward("welcome"); } }
public ActionForward print( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException, FenixFilterException { IUserView userView = UserView.getUser(); Integer reimbursementGuideId = new Integer(this.getFromRequest("id", request)); InfoReimbursementGuide infoReimbursementGuide = null; List infoStudents = null; InfoStudent infoStudent = null; try { infoReimbursementGuide = ViewReimbursementGuide.run(reimbursementGuideId); Object args2[] = {infoReimbursementGuide.getInfoGuide().getInfoPerson()}; infoStudents = (List) ServiceUtils.executeService("ReadStudentsByPerson", args2); Iterator it = infoStudents.iterator(); while (it.hasNext()) { infoStudent = (InfoStudent) it.next(); if (infoStudent.getDegreeType().equals(DegreeType.MASTER_DEGREE)) { break; } } } catch (FenixServiceException e) { throw new FenixActionException(e.getMessage(), mapping.findForward("error")); } Locale locale = this.getLocale(request); Date date = null; InfoReimbursementGuideSituation infoReimbursementGuideSituation = null; List infoReimbursementGuideSituations = infoReimbursementGuide.getInfoReimbursementGuideSituations(); Iterator it = infoReimbursementGuideSituations.iterator(); while (it.hasNext()) { infoReimbursementGuideSituation = (InfoReimbursementGuideSituation) it.next(); if (infoReimbursementGuideSituation .getReimbursementGuideState() .equals(ReimbursementGuideState.ISSUED)) { date = infoReimbursementGuideSituation.getOfficialDate().getTime(); } } String formatedDate = DateFormat.getDateInstance(DateFormat.LONG, locale).format(date); request.setAttribute(PresentationConstants.DATE, formatedDate); request.setAttribute(PresentationConstants.REIMBURSEMENT_GUIDE, infoReimbursementGuide); if (infoStudent != null) { request.setAttribute(PresentationConstants.STUDENT, infoStudent); } return mapping.findForward("start"); }
private Teacher getLoggedTeacher(HttpServletRequest request) { IUserView userView = UserView.getUser(); return userView.getPerson().getTeacher(); }
public ActionForward findPerson( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { IUserView userView = UserView.getUser(); FindPersonBean bean = getRenderedObject(); boolean fromRequest = true; String name = request.getParameter("name"); String roleType = null; String departmentId = null; String degreeId = null; String degreeType = null; if (bean != null && name == null) { fromRequest = false; name = bean.getName(); roleType = bean.getRoleType() == null ? null : bean.getRoleType().toString(); departmentId = bean.getDepartmentExternalId(); degreeId = bean.getDegreeExternalId(); degreeType = bean.getDegreeType() == null ? null : bean.getDegreeType().toString(); } else { roleType = request.getParameter("roleType"); departmentId = request.getParameter("departmentId"); degreeId = request.getParameter("degreeId"); degreeType = request.getParameter("degreeType"); } if (name == null) { // error } SearchParameters searchParameters = new SearchPerson.SearchParameters( name, null, null, null, null, roleType, degreeType, degreeId, departmentId, Boolean.TRUE, null, Boolean.FALSE, (String) null); SearchPersonPredicate predicate = new SearchPerson.SearchPersonPredicate(searchParameters); CollectionPager result = SearchPerson.runSearchPerson(searchParameters, predicate); if (result == null) { addErrorMessage(request, "impossibleFindPerson", "error.manager.implossible.findPerson"); return preparePerson(mapping, actionForm, request, response); } if (result.getCollection().isEmpty()) { addErrorMessage(request, "impossibleFindPerson", "error.manager.implossible.findPerson"); return preparePerson(mapping, actionForm, request, response); } final String pageNumberString = request.getParameter("pageNumber"); final Integer pageNumber = !StringUtils.isEmpty(pageNumberString) ? Integer.valueOf(pageNumberString) : Integer.valueOf(1); request.setAttribute("pageNumber", pageNumber); request.setAttribute("numberOfPages", Integer.valueOf(result.getNumberOfPages())); request.setAttribute("personListFinded", result.getPage(pageNumber.intValue())); request.setAttribute("totalFindedPersons", result.getCollection().size()); request.setAttribute("name", name); request.setAttribute("roleType", roleType == null ? "" : roleType); request.setAttribute("degreeId", degreeId == null ? "" : degreeId.toString()); request.setAttribute("degreeType", degreeType == null ? "" : degreeType.toString()); request.setAttribute("departmentId", departmentId == null ? "" : departmentId.toString()); if (isEmployeeOrTeacher(userView)) { request.setAttribute("show", Boolean.TRUE); } else { request.setAttribute("show", Boolean.FALSE); } Boolean viewPhoto = null; if (request.getParameter("viewPhoto") != null && request.getParameter("viewPhoto").length() > 0) { viewPhoto = getCheckBoxValue(request.getParameter("viewPhoto")); } else if (bean.getViewPhoto() != null) { viewPhoto = bean.getViewPhoto(); } request.setAttribute("viewPhoto", viewPhoto); if (fromRequest) { bean = new FindPersonBean(); bean.setName(name); bean.setViewPhoto(viewPhoto); if (!StringUtils.isEmpty(roleType)) { bean.setRoleType(RoleType.valueOf(roleType)); } if (!StringUtils.isEmpty(degreeId)) { bean.setDegree(FenixFramework.<Degree>getDomainObject(degreeId)); } if (!StringUtils.isEmpty(degreeType)) { bean.setDegreeType(DegreeType.valueOf(degreeType)); } if (!StringUtils.isEmpty(departmentId)) { bean.setDepartment(FenixFramework.<Department>getDomainObject(departmentId)); } } RenderUtils.invalidateViewState(); request.setAttribute("bean", bean); return mapping.findForward("findPerson"); }
public ActionForward search( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { IUserView userView = UserView.getUser(); DynaValidatorForm roomSearchForm = (DynaValidatorForm) form; // date Calendar searchDate = Calendar.getInstance(); Integer day = new Integer((String) roomSearchForm.get("day")); Integer month = new Integer((String) roomSearchForm.get("month")); Integer year = new Integer((String) roomSearchForm.get("year")); request.setAttribute("day", day.toString()); request.setAttribute("month", month.toString()); request.setAttribute("year", year.toString()); searchDate.set(Calendar.YEAR, year.intValue()); searchDate.set(Calendar.MONTH, month.intValue() - 1); searchDate.set(Calendar.DAY_OF_MONTH, day.intValue()); if (searchDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { ActionError actionError = new ActionError("error.sunday"); ActionErrors actionErrors = new ActionErrors(); actionErrors.add("error.sunday", actionError); saveErrors(request, actionErrors); return prepare(mapping, form, request, response); } // exam start time Calendar searchStartTime = Calendar.getInstance(); Integer startHour = new Integer((String) roomSearchForm.get("beginningHour")); Integer startMinute = new Integer((String) roomSearchForm.get("beginningMinute")); request.setAttribute("beginningHour", startHour.toString()); request.setAttribute("beginningMinute", startMinute.toString()); searchStartTime.set(Calendar.HOUR_OF_DAY, startHour.intValue()); searchStartTime.set(Calendar.MINUTE, startMinute.intValue()); searchStartTime.set(Calendar.SECOND, 0); // exam end time Calendar searchEndTime = Calendar.getInstance(); Integer endHour = new Integer((String) roomSearchForm.get("endHour")); Integer endMinute = new Integer((String) roomSearchForm.get("endMinute")); request.setAttribute("endHour", endHour.toString()); request.setAttribute("endMinute", endMinute.toString()); searchEndTime.set(Calendar.HOUR_OF_DAY, endHour.intValue()); searchEndTime.set(Calendar.MINUTE, endMinute.intValue()); searchEndTime.set(Calendar.SECOND, 0); if (searchStartTime.after(searchEndTime)) { ActionError actionError = new ActionError("error.timeSwitched"); ActionErrors actionErrors = new ActionErrors(); actionErrors.add("error.timeSwitched", actionError); saveErrors(request, actionErrors); return prepare(mapping, form, request, response); } int dayOfWeekInt = searchDate.get(Calendar.DAY_OF_WEEK); DiaSemana dayOfWeek = new DiaSemana(dayOfWeekInt); List<InfoRoom> availableInfoRoom = null; availableInfoRoom = ReadAvailableRoomsForExam.run( YearMonthDay.fromCalendarFields(searchDate), YearMonthDay.fromCalendarFields(searchDate), HourMinuteSecond.fromCalendarFields(searchStartTime), HourMinuteSecond.fromCalendarFields(searchEndTime), dayOfWeek, null, null, Boolean.FALSE); String sdate = roomSearchForm.get("day") + "/" + roomSearchForm.get("month") + "/" + roomSearchForm.get("year"); String startTime = roomSearchForm.get("beginningHour") + ":" + roomSearchForm.get("beginningMinute"); String endTime = roomSearchForm.get("endHour") + ":" + roomSearchForm.get("endMinute"); request.setAttribute(PresentationConstants.DATE, sdate); request.setAttribute(PresentationConstants.START_TIME, startTime); request.setAttribute(PresentationConstants.END_TIME, endTime); Integer exam = null; Integer normal = null; List<InfoRoom> newAvailableInfoRoom = new ArrayList<InfoRoom>(); if (availableInfoRoom != null && !availableInfoRoom.isEmpty()) { try { exam = new Integer((String) roomSearchForm.get("exam")); } catch (NumberFormatException ex) { // the user didn't speciefy a exam minimum capacity } try { normal = new Integer((String) roomSearchForm.get("normal")); } catch (NumberFormatException ex) { // the user didn't speciefy a normal minimum capacity } if (normal != null || exam != null) { Iterator<InfoRoom> iter = availableInfoRoom.iterator(); while (iter.hasNext()) { InfoRoom elem = iter.next(); if (!((normal != null && elem.getCapacidadeNormal().intValue() < normal.intValue()) || (exam != null && elem.getCapacidadeExame().intValue() < exam.intValue()))) { newAvailableInfoRoom.add(elem); } } } else { newAvailableInfoRoom = availableInfoRoom; } } if (newAvailableInfoRoom != null && !newAvailableInfoRoom.isEmpty()) { Collections.sort(newAvailableInfoRoom, new BeanComparator("nome")); String[] availableRoomId = new String[newAvailableInfoRoom.size()]; Iterator<InfoRoom> iter = newAvailableInfoRoom.iterator(); int i = 0; while (iter.hasNext()) { InfoRoom elem = iter.next(); availableRoomId[i] = elem.getIdInternal().toString(); } request.setAttribute(PresentationConstants.AVAILABLE_ROOMS_ID, availableRoomId); } request.setAttribute(PresentationConstants.AVAILABLE_ROOMS, newAvailableInfoRoom); return mapping.findForward("showRooms"); }