Search in sources :

Example 1 with AreaClassificationMajor

use of org.cpsolver.studentsct.model.AreaClassificationMajor 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 AreaClassificationMajor

use of org.cpsolver.studentsct.model.AreaClassificationMajor 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

AcademicAreaCode (org.cpsolver.studentsct.model.AcademicAreaCode)2 AreaClassificationMajor (org.cpsolver.studentsct.model.AreaClassificationMajor)2 Unavailability (org.cpsolver.studentsct.model.Unavailability)2 Element (org.dom4j.Element)2 Offering (org.cpsolver.studentsct.model.Offering)1 Section (org.cpsolver.studentsct.model.Section)1 Student (org.cpsolver.studentsct.model.Student)1