Examples of SearchExecutionCourseAttendsBean


Examples of org.fenixedu.academic.dto.teacher.executionCourse.SearchExecutionCourseAttendsBean

    @Override
    public ActionForward execute(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request,
            final HttpServletResponse response) throws FenixActionException, FenixServiceException {

        final SearchExecutionCourseAttendsBean executionCourseAttendsBean = getRenderedObject("downloadViewState");
        executionCourseAttendsBean.getExecutionCourse().searchAttends(executionCourseAttendsBean);

        final List<Attends> attendsResult = new ArrayList<Attends>(executionCourseAttendsBean.getAttendsResult());
        Collections.sort(attendsResult, Attends.COMPARATOR_BY_STUDENT_NUMBER);

        String fileContents = new String();

        // building the table header
        fileContents += STUDENT_USERNAME + SEPARATOR;
        fileContents += STUDENT_NUMBER + SEPARATOR;
        fileContents += NUMBER_OF_ENROLLMENTS + SEPARATOR;
        fileContents += ATTENDACY_TYPE + SEPARATOR;
        fileContents += COURSE + SEPARATOR;
        fileContents += NAME + SEPARATOR;

        final List<Grouping> groupings = new ArrayList<Grouping>(executionCourseAttendsBean.getExecutionCourse().getGroupings());
        Collections.sort(groupings, Grouping.COMPARATOR_BY_ENROLMENT_BEGIN_DATE);

        if (!groupings.isEmpty()) {
            for (final Grouping grouping : groupings) {
                fileContents += GROUP + grouping.getName() + SEPARATOR;
            }
        }

        fileContents += EMAIL + SEPARATOR;

        final List<ShiftType> shiftTypes =
                new ArrayList<ShiftType>(executionCourseAttendsBean.getExecutionCourse().getShiftTypes());
        Collections.sort(shiftTypes);
        for (final ShiftType shiftType : shiftTypes) {
            fileContents += SHIFT + BundleUtil.getString(Bundle.ENUMERATION, shiftType.getName()) + SEPARATOR;
        }

        fileContents += NEWLINE;

        // building each line
        for (final Attends attends : attendsResult) {
            fileContents += attends.getRegistration().getStudent().getPerson().getUsername() + SEPARATOR;
            fileContents += attends.getRegistration().getStudent().getNumber() + SEPARATOR;
            if (attends.getEnrolment() == null) {
                fileContents += NULL + SEPARATOR;
            } else {
                fileContents +=
                        attends.getEnrolment()
                                .getNumberOfTotalEnrolmentsInThisCourse(attends.getEnrolment().getExecutionPeriod()) + SEPARATOR;
            }
            fileContents +=
                    BundleUtil.getString(Bundle.ENUMERATION, attends.getAttendsStateType().getQualifiedName()) + SEPARATOR;
            fileContents += attends.getStudentCurricularPlanFromAttends().getDegreeCurricularPlan().getName() + SEPARATOR;
            fileContents += attends.getRegistration().getStudent().getPerson().getName() + SEPARATOR;
            for (final Grouping grouping : groupings) {
                final StudentGroup studentGroup = attends.getStudentGroupByGrouping(grouping);
                if (studentGroup == null) {
                    fileContents += NOT_AVAILABLE + SEPARATOR;
                } else {
                    fileContents += studentGroup.getGroupNumber() + SEPARATOR;
                }
            }

            final String email = attends.getRegistration().getStudent().getPerson().getEmail();
            fileContents += (email != null ? email : "") + SEPARATOR;

            for (final ShiftType shiftType : shiftTypes) {
                final Shift shift =
                        attends.getRegistration().getShiftFor(executionCourseAttendsBean.getExecutionCourse(), shiftType);
                if (shift == null) {
                    fileContents += NOT_AVAILABLE + SEPARATOR;
                } else {
                    fileContents += shift.getNome() + SEPARATOR;
                }
            }
            fileContents += NEWLINE;
        }

        fileContents += NEWLINE;
        fileContents += SUMMARY + NEWLINE;

        fileContents += NUMBER_ENROLLMENTS + SEPARATOR + NUMBER_STUDENTS + NEWLINE;
        final SortedSet<Integer> keys = new TreeSet<Integer>(executionCourseAttendsBean.getEnrolmentsNumberMap().keySet());
        for (final Integer key : keys) {
            fileContents += key + SEPARATOR + executionCourseAttendsBean.getEnrolmentsNumberMap().get(key) + NEWLINE;
        }

        try {
            response.setContentType("plain/text");
            final ServletOutputStream writer = response.getOutputStream();
            // final PrintWriter printWriter = response.getWriter();
            final StringBuilder fileName = new StringBuilder();
            final YearMonthDay currentDate = new YearMonthDay();
            fileName.append("listaDeAlunos_");
            fileName.append(executionCourseAttendsBean.getExecutionCourse().getSigla()).append("_")
                    .append(currentDate.getDayOfMonth());
            fileName.append("-").append(currentDate.getMonthOfYear()).append("-").append(currentDate.getYear());
            fileName.append(".tsv");
            response.setHeader("Content-disposition", "attachment; filename=" + StringNormalizer.normalize(fileName.toString()));
            // printWriter.print(fileContents);
View Full Code Here

Examples of org.fenixedu.academic.dto.teacher.executionCourse.SearchExecutionCourseAttendsBean

        // Integer objectCode =
        // Integer.valueOf(request.getParameter("objectCode"));
        ExecutionCourse executionCourse = getExecutionCourse(request);
        // ExecutionCourse executionCourse =
        // FenixFramework.getDomainObject(objectCode);
        SearchExecutionCourseAttendsBean searchExecutionCourseAttendsBean = readSearchBean(request, executionCourse);

        executionCourse.searchAttends(searchExecutionCourseAttendsBean);
        request.setAttribute("searchBean", searchExecutionCourseAttendsBean);
        request.setAttribute("executionCourse", searchExecutionCourseAttendsBean.getExecutionCourse());

        prepareAttendsCollectionPages(request, searchExecutionCourseAttendsBean, executionCourse);

        return forward(request, "/teacher/viewAttendsSearch.jsp");
    }
View Full Code Here

Examples of org.fenixedu.academic.dto.teacher.executionCourse.SearchExecutionCourseAttendsBean

        return forward(request, "/teacher/viewAttendsSearch.jsp");
    }

    private SearchExecutionCourseAttendsBean readSearchBean(HttpServletRequest request, ExecutionCourse executionCourse) {
        String executionCourseID = request.getParameter("executionCourse");
        SearchExecutionCourseAttendsBean searchExecutionCourseAttendsBean;
        if (executionCourseID != null) {
            searchExecutionCourseAttendsBean =
                    new SearchExecutionCourseAttendsBean(FenixFramework.<ExecutionCourse> getDomainObject(executionCourseID));
        } else {
            searchExecutionCourseAttendsBean = new SearchExecutionCourseAttendsBean(executionCourse);
        }
        String viewPhoto = request.getParameter("viewPhoto");
        if (viewPhoto != null && viewPhoto.equalsIgnoreCase("true")) {
            searchExecutionCourseAttendsBean.setViewPhoto(true);
        } else {
            searchExecutionCourseAttendsBean.setViewPhoto(false);
        }

        String attendsStates = request.getParameter("attendsStates");
        if (attendsStates != null) {
            List<StudentAttendsStateType> list = new ArrayList<StudentAttendsStateType>();
            for (String attendsState : attendsStates.split(":")) {
                list.add(StudentAttendsStateType.valueOf(attendsState));
            }
            searchExecutionCourseAttendsBean.setAttendsStates(list);
        }

        String workingStudentTypes = request.getParameter("workingStudentTypes");
        if (workingStudentTypes != null) {
            List<WorkingStudentSelectionType> list = new ArrayList<WorkingStudentSelectionType>();
            for (String workingStudentType : workingStudentTypes.split(":")) {
                list.add(WorkingStudentSelectionType.valueOf(workingStudentType));
            }
            searchExecutionCourseAttendsBean.setWorkingStudentTypes(list);
        }

        String degreeCurricularPlans = request.getParameter("degreeCurricularPlans");
        if (degreeCurricularPlans != null) {
            List<DegreeCurricularPlan> list = new ArrayList<DegreeCurricularPlan>();
            for (String degreeCurricularPlan : degreeCurricularPlans.split(":")) {
                list.add(FenixFramework.<DegreeCurricularPlan> getDomainObject(degreeCurricularPlan));
            }
            searchExecutionCourseAttendsBean.setDegreeCurricularPlans(list);
        }

        String shifts = request.getParameter("shifts");
        if (shifts != null) {
            List<Shift> list = new ArrayList<Shift>();
            for (String shift : shifts.split(":")) {
                if (!StringUtils.isEmpty(shift)) {
                    list.add(FenixFramework.<Shift> getDomainObject(shift));
                }
            }
            searchExecutionCourseAttendsBean.setShifts(list);
        }

        return searchExecutionCourseAttendsBean;
    }
View Full Code Here

Examples of org.fenixedu.academic.dto.teacher.executionCourse.SearchExecutionCourseAttendsBean

        final String pageParameter = request.getParameter("pageNumber");
        final Integer page = StringUtils.isEmpty(pageParameter) ? Integer.valueOf(1) : Integer.valueOf(pageParameter);
        request.setAttribute("pageNumber", page);

        SearchExecutionCourseAttendsBean attendsPagesBean = new SearchExecutionCourseAttendsBean(executionCourse);

        executionCourse.searchAttends(attendsPagesBean);

        Map<Integer, Integer> enrolmentsNumberMap = new HashMap<Integer, Integer>();
        for (Attends attends : pager.getCollection()) {
            executionCourse.addAttendsToEnrolmentNumberMap(attends, enrolmentsNumberMap);
        }
        attendsPagesBean.setEnrolmentsNumberMap(enrolmentsNumberMap);
        attendsPagesBean.setAttendsResult(pager.getPage(page));
        if (searchExecutionCourseAttendsBean.getViewPhoto()) {
            attendsPagesBean.setViewPhoto(true);
        }
        request.setAttribute("attendsPagesBean", attendsPagesBean);
    }
View Full Code Here

Examples of org.fenixedu.academic.dto.teacher.executionCourse.SearchExecutionCourseAttendsBean

            HttpServletResponse response) {
        ExecutionCourse executionCourse;
        Group studentsGroup = null;
        String label;
        Sender sender;
        SearchExecutionCourseAttendsBean bean = getRenderedObject("mailViewState");
        if (bean != null) {
            executionCourse = bean.getExecutionCourse();
            studentsGroup = bean.getAttendsGroup();
            label = bean.getLabel();
            sender = ExecutionCourseSender.newInstance(executionCourse);
        } else {
            SearchDegreeStudentsGroup degreeStudentsGroup =
                    SearchDegreeStudentsGroup.parse((String) getFromRequestOrForm(request, (DynaActionForm) form, "searchGroup"));
            label = degreeStudentsGroup.getLabel();
View Full Code Here

Examples of org.fenixedu.academic.dto.teacher.executionCourse.SearchExecutionCourseAttendsBean

    public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {

        request.setAttribute("objectCode", request.getAttribute("objectCode"));

        SearchExecutionCourseAttendsBean bean = getRenderedObject();
        RenderUtils.invalidateViewState();
        bean.getExecutionCourse().searchAttends(bean);

        request.setAttribute("searchBean", bean);
        request.setAttribute("executionCourse", bean.getExecutionCourse());

        prepareAttendsCollectionPages(request, bean, bean.getExecutionCourse());

        return forward(request, "/teacher/viewAttendsSearch.jsp");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.