Package org.fenixedu.academic.domain

Examples of org.fenixedu.academic.domain.Grouping


    @Atomic
    public Grouping createOrEditGrouping(ProjectGroupBean bean, ExecutionCourse executionCourse) {
        EnrolmentGroupPolicyType enrolmentPolicyType =
                bean.getAtomicEnrolmentPolicy() != null && bean.getAtomicEnrolmentPolicy() ? new EnrolmentGroupPolicyType(1) : new EnrolmentGroupPolicyType(
                        2);
        Grouping grouping;
        ShiftType shiftType =
                bean.getShiftType() == null || bean.getShiftType().isEmpty() ? null : ShiftType.valueOf(bean.getShiftType());
        if (executionCourse.getGroupingByName(bean.getName()) == null) {
            grouping =
                    Grouping.create(bean.getName(), bean.getEnrolmentBeginDay().toDate(), bean.getEnrolmentEndDay().toDate(),
                            enrolmentPolicyType, bean.getMaxGroupNumber(), bean.getIdealGroupCapacity(),
                            bean.getMaximumGroupCapacity(), bean.getMinimumGroupCapacity(), bean.getProjectDescription(),
                            shiftType, bean.getAutomaticEnrolment(), bean.getDifferentiatedCapacity(), executionCourse,
                            bean.getDifferentiatedCapacityShifts());

        } else {
            grouping = executionCourse.getGroupingByName(bean.getName());
            grouping.edit(bean.getName(), bean.getEnrolmentBeginDay().toDate(), bean.getEnrolmentEndDay().toDate(),
                    enrolmentPolicyType, bean.getMaxGroupNumber(), bean.getIdealGroupCapacity(), bean.getMaximumGroupCapacity(),
                    bean.getMinimumGroupCapacity(), bean.getProjectDescription(), shiftType, bean.getAutomaticEnrolment(),
                    bean.getDifferentiatedCapacity(), bean.getDifferentiatedCapacityShifts());
        }
View Full Code Here


        if (!errors.isEmpty()) {
            model.addAttribute("errors", errors);
            return new TeacherView("insertGroupProperties");
        }

        Grouping grouping = studentGroupService.createOrEditGrouping(projectGroup, executionCourse);
        return new RedirectView("/teacher/" + executionCourse.getExternalId() + "/student-groups/view/"
                + grouping.getExternalId(), true);
    }
View Full Code Here

        final Project project = (Project) FenixFramework.getDomainObject(projectID);
        if (project == null) {
            throw new FenixServiceException("error.noEvaluation");
        }

        final Grouping grouping = (groupingID != null) ? FenixFramework.<Grouping> getDomainObject(groupingID) : null;

        project.edit(name, begin, end, description, onlineSubmissionsAllowed, maxSubmissionsToKeep, grouping, gradeScale,
                departments);
    }
View Full Code Here

        final ExecutionCourse executionCourse = FenixFramework.getDomainObject(executionCourseID);
        if (executionCourse == null) {
            throw new FenixServiceException("error.noExecutionCourse");
        }

        final Grouping grouping = (groupingID != null) ? FenixFramework.<Grouping> getDomainObject(groupingID) : null;

        final Project project =
                new Project(name, begin, end, description, onlineSubmissionsAllowed, maxSubmissionsToKeep, grouping,
                        executionCourse, gradeScale);
        project.getDeparmentsSet().addAll(departments);
View Full Code Here

    public ActionForward sendGroupingEmail(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        String executionCourseCode = request.getParameter("executionCourseID");
        String groupingCode = request.getParameter("groupingCode");
        ExecutionCourse executionCourse = FenixFramework.getDomainObject(executionCourseCode);
        Grouping grouping = FenixFramework.getDomainObject(groupingCode);
        Group groupToSend = GroupingGroup.get(grouping);
        Sender sender = ExecutionCourseSender.newInstance(executionCourse);
        final String label =
                getResources(request, "APPLICATION_RESOURCES").getMessage("label.students.grouping.send.email",
                        grouping.getName());
        Recipient recipient = Recipient.newInstance(label, groupToSend);
        return EmailsDA.sendEmail(request, sender, recipient);
    }
View Full Code Here

    private InfoSiteShiftsAndGroups readShiftAndGroups(String groupPropertiesCode, String shiftCode) throws ExcepcaoInexistente,
            FenixServiceException {

        InfoSiteShiftsAndGroups infoSiteShiftsAndGroups = new InfoSiteShiftsAndGroups();

        Grouping grouping = FenixFramework.getDomainObject(groupPropertiesCode);
        if (grouping == null) {
            return null;
        }

        Shift shift = FenixFramework.getDomainObject(shiftCode);

        List<InfoSiteGroupsByShift> infoSiteGroupsByShiftList = new ArrayList<InfoSiteGroupsByShift>();
        InfoSiteShift infoSiteShift = new InfoSiteShift();
        infoSiteShift.setInfoShift(InfoShift.newInfoFromDomain(shift));

        List allStudentGroups = grouping.readAllStudentGroupsBy(shift);

        if (grouping.getDifferentiatedCapacity()) {
            Integer vagas = shift.getShiftGroupingProperties().getCapacity();
            infoSiteShift.setNrOfGroups(vagas);
        } else {
            if (grouping.getGroupMaximumNumber() != null) {
                int vagas = grouping.getGroupMaximumNumber().intValue() - allStudentGroups.size();
                infoSiteShift.setNrOfGroups(Integer.valueOf(vagas));
            } else {
                infoSiteShift.setNrOfGroups("Sem limite");
            }
        }
View Full Code Here

            FenixServiceException {

        List<InfoSiteStudentsAndShiftByStudentGroup> infoSiteStudentsAndShiftByStudentGroupList =
                new ArrayList<InfoSiteStudentsAndShiftByStudentGroup>();

        Grouping groupProperties = FenixFramework.getDomainObject(groupPropertiesCode);
        if (groupProperties == null) {
            return null;
        }

        Shift shift = FenixFramework.getDomainObject(shiftCode);

        List<StudentGroup> aux = new ArrayList<StudentGroup>();
        List studentGroupsWithShift = groupProperties.getStudentGroupsWithShift();
        Iterator iterStudentGroupsWithShift = studentGroupsWithShift.iterator();
        while (iterStudentGroupsWithShift.hasNext()) {
            StudentGroup studentGroup = (StudentGroup) iterStudentGroupsWithShift.next();
            if (studentGroup.getShift().equals(shift)) {
                aux.add(studentGroup);
            }
        }
        List<StudentGroup> allStudentGroups = new ArrayList<StudentGroup>();
        allStudentGroups.addAll(groupProperties.getStudentGroupsSet());

        Iterator iterAux = aux.iterator();
        while (iterAux.hasNext()) {
            StudentGroup studentGroup = (StudentGroup) iterAux.next();
            allStudentGroups.remove(studentGroup);
View Full Code Here

    public InfoSiteShifts getInfoSiteShifts(InfoSiteShifts component, String groupPropertiesCode, String studentGroupCode)
            throws FenixServiceException {
        List<InfoShift> infoShifts = new ArrayList<InfoShift>();
        ExecutionCourse executionCourse = null;

        Grouping groupProperties = FenixFramework.getDomainObject(groupPropertiesCode);
        if (groupProperties == null) {
            return null;
        }
        if (studentGroupCode != null) {
            StudentGroup studentGroup = FenixFramework.getDomainObject(studentGroupCode);
            if (studentGroup == null) {
                component.setShifts(null);
                return component;
            }

            component.setOldShift(InfoShift.newInfoFromDomain(studentGroup.getShift()));
        }

        IGroupEnrolmentStrategyFactory enrolmentGroupPolicyStrategyFactory = GroupEnrolmentStrategyFactory.getInstance();
        IGroupEnrolmentStrategy strategy = enrolmentGroupPolicyStrategyFactory.getGroupEnrolmentStrategyInstance(groupProperties);

        if (strategy.checkHasShift(groupProperties)) {

            List executionCourses = new ArrayList();
            executionCourses = groupProperties.getExecutionCourses();

            Iterator iterExecutionCourses = executionCourses.iterator();
            List<Shift> shifts = new ArrayList<Shift>();
            while (iterExecutionCourses.hasNext()) {
                ExecutionCourse executionCourse2 = (ExecutionCourse) iterExecutionCourses.next();
View Full Code Here

    }

    public static Boolean enrole(String groupingID, String shiftID, Integer groupNumber, List<String> studentUsernames,
            String studentUsername) throws FenixServiceException {
        final Bennu rootDomainObject = Bennu.getInstance();
        final Grouping grouping = FenixFramework.getDomainObject(groupingID);
        if (grouping == null) {
            throw new NonExistingServiceException();
        }

        final Registration userStudent = Registration.readByUsername(studentUsername);

        final IGroupEnrolmentStrategyFactory enrolmentGroupPolicyStrategyFactory = GroupEnrolmentStrategyFactory.getInstance();
        final IGroupEnrolmentStrategy strategy = enrolmentGroupPolicyStrategyFactory.getGroupEnrolmentStrategyInstance(grouping);

        if (grouping.getStudentAttend(studentUsername) == null) {
            throw new NoChangeMadeServiceException();
        }
        Shift shift = null;
        if (shiftID != null) {
            shift = FenixFramework.getDomainObject(shiftID);
        }
        Set<String> allStudentsUsernames = new HashSet<String>(studentUsernames);
        allStudentsUsernames.add(studentUsername);
        Integer result = strategy.enrolmentPolicyNewGroup(grouping, allStudentsUsernames.size(), shift);

        if (result.equals(Integer.valueOf(-1))) {
            throw new InvalidArgumentsServiceException();
        }
        if (result.equals(Integer.valueOf(-2))) {
            throw new NonValidChangeServiceException();
        }
        if (result.equals(Integer.valueOf(-3))) {
            throw new NotAuthorizedException();
        }

        final Attends userAttend = grouping.getStudentAttend(userStudent);
        if (userAttend == null) {
            throw new InvalidStudentNumberServiceException();
        }
        if (strategy.checkAlreadyEnroled(grouping, studentUsername)) {
            throw new InvalidSituationServiceException();
        }

        StudentGroup newStudentGroup = grouping.readStudentGroupBy(groupNumber);
        if (newStudentGroup != null) {
            throw new FenixServiceException();
        }

        if (!strategy.checkStudentsUserNamesInGrouping(studentUsernames, grouping)) {
            throw new InvalidStudentNumberServiceException();
        }
        checkStudentUsernamesAlreadyEnroledInStudentGroup(strategy, studentUsernames, grouping);

        newStudentGroup = new StudentGroup(groupNumber, grouping, shift);
        for (final String studentUsernameIter : studentUsernames) {
            Attends attend = grouping.getStudentAttend(studentUsernameIter);
            attend.addStudentGroups(newStudentGroup);
        }
        userAttend.addStudentGroups(newStudentGroup);
        grouping.addStudentGroups(newStudentGroup);

        return true;
    }
View Full Code Here

        this.endProjectHour = endProjectHour;
    }

    public String getGroupingID() {
        if (this.groupingID == null && this.getProject() != null) {
            Grouping grouping = this.getProject().getGrouping();

            this.groupingID = (grouping != null) ? grouping.getExternalId() : null;
        }
        return groupingID;
    }
View Full Code Here

TOP

Related Classes of org.fenixedu.academic.domain.Grouping

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.