Package org.fenixedu.academic.dto

Examples of org.fenixedu.academic.dto.InfoSiteStudentsWithoutGroup


        } catch (FenixServiceException e) {
            throw new FenixActionException(e);

        }

        InfoSiteStudentsWithoutGroup studentsNotEnroled = null;

        try {
            studentsNotEnroled = ReadStudentsWithoutGroup.run(groupPropertiesCodeString, userView.getUsername());

        } catch (ExistingServiceException e) {
            ActionErrors actionErrors1 = new ActionErrors();
            ActionError error1 = null;
            error1 = new ActionError("error.noProject");
            actionErrors1.add("error.noProject", error1);
            saveErrors(request, actionErrors1);
            return mapping.findForward("viewExecutionCourseProjects");
        } catch (NewStudentGroupAlreadyExists e) {
            ActionErrors actionErrors1 = new ActionErrors();
            ActionError error1 = null;
            error1 = new ActionError("error.existingGroup");
            actionErrors1.add("error.existingGroup", error1);
            saveErrors(request, actionErrors1);
            return prepareEnrolment(mapping, form, request, response);
        } catch (FenixServiceException e) {
            throw new FenixActionException(e);
        }

        List infoStudentList = studentsNotEnroled.getInfoStudentList();
        if (infoStudentList != null) {
            Collections.sort(infoStudentList, new BeanComparator("number"));
            request.setAttribute("infoStudents", infoStudentList);
        }
        request.setAttribute("groupNumber", studentsNotEnroled.getGroupNumber());
        request.setAttribute("groupPropertiesCode", groupPropertiesCodeString);
        request.setAttribute("shiftCode", shiftCodeString);
        request.setAttribute("infoUserStudent", studentsNotEnroled.getInfoUserStudent());
        request.setAttribute("infoGrouping", studentsNotEnroled.getInfoGrouping());

        List<InfoExportGrouping> infoExportGroupings = ReadExportGroupingsByGrouping.run(groupPropertiesCodeString);
        request.setAttribute("infoExportGroupings", infoExportGroupings);

        return mapping.findForward("sucess");
View Full Code Here


    @Atomic
    public static InfoSiteStudentsWithoutGroup run(final String groupPropertiesCode, final String username)
            throws FenixServiceException {
        check(RolePredicates.STUDENT_PREDICATE);

        final InfoSiteStudentsWithoutGroup infoSiteStudentsWithoutGroup = new InfoSiteStudentsWithoutGroup();
        final Grouping grouping = FenixFramework.getDomainObject(groupPropertiesCode);
        if (grouping == null) {
            throw new ExistingServiceException();
        }

        final Collection allStudentsGroups = grouping.getStudentGroupsSet();

        final Integer groupNumber = grouping.findMaxGroupNumber() + 1;

        infoSiteStudentsWithoutGroup.setGroupNumber(groupNumber);
        infoSiteStudentsWithoutGroup.setInfoGrouping(InfoGrouping.newInfoFromDomain(grouping));

        final Collection<Attends> attends = grouping.getAttendsSet();

        Registration userStudent = null;
        for (Object element : attends) {
            final Attends attend = (Attends) element;
            final Registration registration = attend.getRegistration();
            final Person person = registration.getPerson();
            if (person.getUser().getUsername().equals(username)) {
                userStudent = registration;
                break;
            }
        }
        final InfoStudent infoStudent = getInfoStudentFromStudent(userStudent);
        infoSiteStudentsWithoutGroup.setInfoUserStudent(infoStudent);

        if (grouping.getEnrolmentPolicy().equals(new EnrolmentGroupPolicyType(2))) {
            return infoSiteStudentsWithoutGroup;
        }

        final Set<Attends> attendsWithOutGroupsSet = new HashSet<Attends>(attends);
        for (final Iterator iterator = allStudentsGroups.iterator(); iterator.hasNext();) {
            final StudentGroup studentGroup = (StudentGroup) iterator.next();

            final Collection allStudentGroupsAttends = studentGroup.getAttendsSet();

            for (final Iterator iterator2 = allStudentGroupsAttends.iterator(); iterator2.hasNext();) {
                final Attends studentGroupAttend = (Attends) iterator2.next();
                attendsWithOutGroupsSet.remove(studentGroupAttend);
            }
        }

        final List<InfoStudent> infoStudentList = new ArrayList<InfoStudent>(attendsWithOutGroupsSet.size());
        for (Object element : attendsWithOutGroupsSet) {
            final Attends attend = (Attends) element;
            final Registration registration = attend.getRegistration();

            if (!registration.equals(userStudent)) {
                final InfoStudent infoStudent2 = getInfoStudentFromStudent(registration);
                infoStudentList.add(infoStudent2);
            }

        }
        infoSiteStudentsWithoutGroup.setInfoStudentList(infoStudentList);

        return infoSiteStudentsWithoutGroup;
    }
View Full Code Here

TOP

Related Classes of org.fenixedu.academic.dto.InfoSiteStudentsWithoutGroup

Copyright © 2018 www.massapicom. 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.