Search in sources :

Example 1 with Unavailability

use of org.cpsolver.studentsct.model.Unavailability in project cpsolver by UniTime.

the class StudentSectioningXMLSaver method saveStudent.

/**
     * Save student
     * @param studentEl student element to be populated
     * @param student student to be saved
     */
protected void saveStudent(Element studentEl, Student student) {
    studentEl.addAttribute("id", getId("student", student.getId()));
    if (iShowNames) {
        if (student.getExternalId() != null && !student.getExternalId().isEmpty())
            studentEl.addAttribute("externalId", student.getExternalId());
        if (student.getName() != null && !student.getName().isEmpty())
            studentEl.addAttribute("name", student.getName());
        if (student.getStatus() != null && !student.getStatus().isEmpty())
            studentEl.addAttribute("status", student.getStatus());
    }
    if (student.isDummy())
        studentEl.addAttribute("dummy", "true");
    if (iSaveStudentInfo) {
        for (AcademicAreaCode aac : student.getAcademicAreaClasiffications()) {
            Element aacEl = studentEl.addElement("classification");
            if (aac.getArea() != null)
                aacEl.addAttribute("area", aac.getArea());
            if (aac.getCode() != null)
                aacEl.addAttribute("code", aac.getCode());
        }
        for (AcademicAreaCode aac : student.getMajors()) {
            Element aacEl = studentEl.addElement("major");
            if (aac.getArea() != null)
                aacEl.addAttribute("area", aac.getArea());
            if (aac.getCode() != null)
                aacEl.addAttribute("code", aac.getCode());
        }
        for (AcademicAreaCode aac : student.getMinors()) {
            Element aacEl = studentEl.addElement("minor");
            if (aac.getArea() != null)
                aacEl.addAttribute("area", aac.getArea());
            if (aac.getCode() != null)
                aacEl.addAttribute("code", aac.getCode());
        }
        for (AreaClassificationMajor acm : student.getAreaClassificationMajors()) {
            Element acmEl = studentEl.addElement("acm");
            if (acm.getArea() != null)
                acmEl.addAttribute("area", acm.getArea());
            if (acm.getArea() != null)
                acmEl.addAttribute("classification", acm.getClassification());
            if (acm.getArea() != null)
                acmEl.addAttribute("major", acm.getMajor());
        }
    }
    for (Unavailability unavailability : student.getUnavailabilities()) {
        Element unavEl = studentEl.addElement("unavailability");
        unavEl.addAttribute("offering", getId("offering", unavailability.getSection().getSubpart().getConfig().getOffering().getId()));
        unavEl.addAttribute("section", getId("section", unavailability.getSection().getId()));
        if (unavailability.isAllowOverlap())
            unavEl.addAttribute("allowOverlap", "true");
    }
}
Also used : AreaClassificationMajor(org.cpsolver.studentsct.model.AreaClassificationMajor) Unavailability(org.cpsolver.studentsct.model.Unavailability) Element(org.dom4j.Element) AcademicAreaCode(org.cpsolver.studentsct.model.AcademicAreaCode)

Example 2 with Unavailability

use of org.cpsolver.studentsct.model.Unavailability in project cpsolver by UniTime.

the class TimeOverlapsCounter method allConflicts.

/**
     * The set of all conflicts ({@link Conflict} objects) of the given
     * enrollment and other enrollments that are assigned to the same student.
     * @param assignment current assignment
     * @param enrollment given enrollment
     * @return all conflicts of the given enrollment
     */
public Set<Conflict> allConflicts(Assignment<Request, Enrollment> assignment, Enrollment enrollment) {
    Set<Conflict> ret = new HashSet<Conflict>();
    if (enrollment.getRequest() instanceof FreeTimeRequest)
        return ret;
    for (Request request : enrollment.getStudent().getRequests()) {
        if (request.equals(enrollment.getRequest()))
            continue;
        Enrollment other = assignment.getValue(request);
        if (request instanceof FreeTimeRequest) {
            FreeTimeRequest ft = (FreeTimeRequest) request;
            ret.addAll(conflicts(enrollment, ft.createEnrollment()));
            continue;
        } else if (other != null) {
            ret.addAll(conflicts(enrollment, other));
        }
    }
    for (Unavailability unavailability : enrollment.getStudent().getUnavailabilities()) for (SctAssignment section : enrollment.getAssignments()) if (inConflict(section, unavailability))
        ret.add(new Conflict(enrollment.getStudent(), share(section, unavailability), enrollment, section, unavailability.createEnrollment(), unavailability));
    return ret;
}
Also used : FreeTimeRequest(org.cpsolver.studentsct.model.FreeTimeRequest) Unavailability(org.cpsolver.studentsct.model.Unavailability) FreeTimeRequest(org.cpsolver.studentsct.model.FreeTimeRequest) Request(org.cpsolver.studentsct.model.Request) Enrollment(org.cpsolver.studentsct.model.Enrollment) SctAssignment(org.cpsolver.studentsct.model.SctAssignment) HashSet(java.util.HashSet)

Example 3 with Unavailability

use of org.cpsolver.studentsct.model.Unavailability in project cpsolver by UniTime.

the class StudentSectioningXMLLoader method loadStudent.

/**
     * Load student
     * @param studentEl student element
     * @param offeringTable offering table
     * @return loaded student
     */
protected Student loadStudent(Element studentEl, Map<Long, Offering> offeringTable) {
    Student student = new Student(Long.parseLong(studentEl.attributeValue("id")), "true".equals(studentEl.attributeValue("dummy")));
    student.setExternalId(studentEl.attributeValue("externalId"));
    student.setName(studentEl.attributeValue("name"));
    student.setStatus(studentEl.attributeValue("status"));
    for (Iterator<?> j = studentEl.elementIterator(); j.hasNext(); ) {
        Element requestEl = (Element) j.next();
        if ("classification".equals(requestEl.getName())) {
            student.getAcademicAreaClasiffications().add(new AcademicAreaCode(requestEl.attributeValue("area"), requestEl.attributeValue("code")));
        } else if ("major".equals(requestEl.getName())) {
            student.getMajors().add(new AcademicAreaCode(requestEl.attributeValue("area"), requestEl.attributeValue("code")));
        } else if ("minor".equals(requestEl.getName())) {
            student.getMinors().add(new AcademicAreaCode(requestEl.attributeValue("area"), requestEl.attributeValue("code")));
        } else if ("unavailability".equals(requestEl.getName())) {
            Offering offering = offeringTable.get(Long.parseLong(requestEl.attributeValue("offering")));
            Section section = (offering == null ? null : offering.getSection(Long.parseLong(requestEl.attributeValue("section"))));
            if (section != null)
                new Unavailability(student, section, "true".equals(requestEl.attributeValue("allowOverlap")));
        } else if ("acm".equals(requestEl.getName())) {
            student.getAreaClassificationMajors().add(new AreaClassificationMajor(requestEl.attributeValue("area"), requestEl.attributeValue("classification"), requestEl.attributeValue("major")));
        }
    }
    return student;
}
Also used : AreaClassificationMajor(org.cpsolver.studentsct.model.AreaClassificationMajor) Unavailability(org.cpsolver.studentsct.model.Unavailability) Element(org.dom4j.Element) AcademicAreaCode(org.cpsolver.studentsct.model.AcademicAreaCode) Student(org.cpsolver.studentsct.model.Student) Offering(org.cpsolver.studentsct.model.Offering) Section(org.cpsolver.studentsct.model.Section)

Aggregations

Unavailability (org.cpsolver.studentsct.model.Unavailability)3 AcademicAreaCode (org.cpsolver.studentsct.model.AcademicAreaCode)2 AreaClassificationMajor (org.cpsolver.studentsct.model.AreaClassificationMajor)2 Element (org.dom4j.Element)2 HashSet (java.util.HashSet)1 Enrollment (org.cpsolver.studentsct.model.Enrollment)1 FreeTimeRequest (org.cpsolver.studentsct.model.FreeTimeRequest)1 Offering (org.cpsolver.studentsct.model.Offering)1 Request (org.cpsolver.studentsct.model.Request)1 SctAssignment (org.cpsolver.studentsct.model.SctAssignment)1 Section (org.cpsolver.studentsct.model.Section)1 Student (org.cpsolver.studentsct.model.Student)1