Search in sources :

Example 1 with StudentGroup

use of org.cpsolver.studentsct.model.StudentGroup 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 (student.getPriority().ordinal() < StudentPriority.Normal.ordinal())
        studentEl.addAttribute("priority", student.getPriority().name());
    if (student.isNeedShortDistances())
        studentEl.addAttribute("shortDistances", "true");
    if (student.isAllowDisabled())
        studentEl.addAttribute("allowDisabled", "true");
    if (student.hasMinCredit())
        studentEl.addAttribute("minCredit", String.valueOf(student.getMinCredit()));
    if (student.hasMaxCredit())
        studentEl.addAttribute("maxCredit", String.valueOf(student.getMaxCredit()));
    if (iSaveStudentInfo) {
        for (AreaClassificationMajor acm : student.getAreaClassificationMajors()) {
            Element acmEl = studentEl.addElement("acm");
            if (acm.getArea() != null)
                acmEl.addAttribute("area", acm.getArea());
            if (acm.getClassification() != null)
                acmEl.addAttribute("classification", acm.getClassification());
            if (acm.getMajor() != null)
                acmEl.addAttribute("major", acm.getMajor());
            if (acm.getConcentration() != null)
                acmEl.addAttribute("concentration", acm.getConcentration());
            if (acm.getDegree() != null)
                acmEl.addAttribute("degree", acm.getDegree());
            if (acm.getProgram() != null)
                acmEl.addAttribute("program", acm.getProgram());
            if (acm.getAreaName() != null && iShowNames)
                acmEl.addAttribute("areaName", acm.getAreaName());
            if (acm.getClassificationName() != null && iShowNames)
                acmEl.addAttribute("classificationName", acm.getClassificationName());
            if (acm.getMajorName() != null && iShowNames)
                acmEl.addAttribute("majorName", acm.getMajorName());
            if (acm.getConcentrationName() != null && iShowNames)
                acmEl.addAttribute("concentrationName", acm.getConcentrationName());
            if (acm.getDegreeName() != null && iShowNames)
                acmEl.addAttribute("degreeName", acm.getDegreeName());
            if (acm.getProgramName() != null && iShowNames)
                acmEl.addAttribute("programName", acm.getProgramName());
            if (acm.getWeight() != 1.0)
                acmEl.addAttribute("weight", String.valueOf(acm.getWeight()));
        }
        for (AreaClassificationMajor acm : student.getAreaClassificationMinors()) {
            Element acmEl = studentEl.addElement("acm");
            if (acm.getArea() != null)
                acmEl.addAttribute("area", acm.getArea());
            if (acm.getClassification() != null)
                acmEl.addAttribute("classification", acm.getClassification());
            if (acm.getMajor() != null)
                acmEl.addAttribute("minor", acm.getMajor());
            if (acm.getConcentration() != null)
                acmEl.addAttribute("concentration", acm.getConcentration());
            if (acm.getDegree() != null)
                acmEl.addAttribute("degree", acm.getDegree());
            if (acm.getProgram() != null)
                acmEl.addAttribute("program", acm.getProgram());
            if (acm.getAreaName() != null && iShowNames)
                acmEl.addAttribute("areaName", acm.getAreaName());
            if (acm.getClassificationName() != null && iShowNames)
                acmEl.addAttribute("classificationName", acm.getClassificationName());
            if (acm.getMajorName() != null && iShowNames)
                acmEl.addAttribute("minorName", acm.getMajorName());
            if (acm.getConcentrationName() != null && iShowNames)
                acmEl.addAttribute("concentrationName", acm.getConcentrationName());
            if (acm.getDegreeName() != null && iShowNames)
                acmEl.addAttribute("degreeName", acm.getDegreeName());
            if (acm.getProgramName() != null && iShowNames)
                acmEl.addAttribute("programName", acm.getProgramName());
            if (acm.getWeight() != 1.0)
                acmEl.addAttribute("weight", String.valueOf(acm.getWeight()));
        }
        for (StudentGroup g : student.getGroups()) {
            Element grEl = studentEl.addElement("group");
            if (g.getType() != null && !g.getType().isEmpty())
                grEl.addAttribute("type", g.getType());
            if (g.getReference() != null)
                grEl.addAttribute("reference", g.getReference());
            if (g.getName() != null)
                grEl.addAttribute("name", g.getName());
        }
        for (String acc : student.getAccommodations()) studentEl.addElement("accommodation").addAttribute("reference", acc);
    }
    if (iShowNames && iSaveStudentInfo) {
        for (Instructor adv : student.getAdvisors()) {
            Element advEl = studentEl.addElement("advisor");
            if (adv.getExternalId() != null)
                advEl.addAttribute("externalId", adv.getExternalId());
            if (adv.getName() != null)
                advEl.addAttribute("name", adv.getName());
            if (adv.getEmail() != null)
                advEl.addAttribute("email", adv.getEmail());
        }
    }
    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) Instructor(org.cpsolver.studentsct.model.Instructor) StudentGroup(org.cpsolver.studentsct.model.StudentGroup)

Example 2 with StudentGroup

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

the class AccommodationConflictsTable method group.

protected String group(Student student) {
    String group = "";
    Set<String> groups = new TreeSet<String>();
    for (StudentGroup g : student.getGroups()) groups.add(g.getReference());
    for (String g : groups) group += (group.isEmpty() ? "" : ", ") + g;
    return group;
}
Also used : TreeSet(java.util.TreeSet) StudentGroup(org.cpsolver.studentsct.model.StudentGroup)

Example 3 with StudentGroup

use of org.cpsolver.studentsct.model.StudentGroup 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")));
    if (studentEl.attributeValue("priority") != null)
        student.setPriority(StudentPriority.getPriority(studentEl.attributeValue("priority")));
    if ("true".equals(studentEl.attributeValue("shortDistances")))
        student.setNeedShortDistances(true);
    if ("true".equals(studentEl.attributeValue("allowDisabled")))
        student.setAllowDisabled(true);
    student.setExternalId(studentEl.attributeValue("externalId"));
    student.setName(studentEl.attributeValue("name"));
    student.setStatus(studentEl.attributeValue("status"));
    String minCredit = studentEl.attributeValue("minCredit");
    if (minCredit != null)
        student.setMinCredit(Float.parseFloat(minCredit));
    String maxCredit = studentEl.attributeValue("maxCredit");
    if (maxCredit != null)
        student.setMaxCredit(Float.parseFloat(maxCredit));
    List<String[]> clasf = new ArrayList<String[]>();
    List<String[]> major = new ArrayList<String[]>();
    for (Iterator<?> j = studentEl.elementIterator(); j.hasNext(); ) {
        Element requestEl = (Element) j.next();
        if ("classification".equals(requestEl.getName())) {
            clasf.add(new String[] { requestEl.attributeValue("area"), requestEl.attributeValue("code"), requestEl.attributeValue("label") });
        } else if ("major".equals(requestEl.getName())) {
            major.add(new String[] { requestEl.attributeValue("area"), requestEl.attributeValue("code"), requestEl.attributeValue("label") });
        } else if ("minor".equals(requestEl.getName())) {
            if ("A".equals(requestEl.attributeValue("area")))
                student.getAccommodations().add(requestEl.attributeValue("code"));
            else
                student.getGroups().add(new StudentGroup(requestEl.attributeValue("area"), requestEl.attributeValue("code"), requestEl.attributeValue("label")));
        } 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())) {
            if (requestEl.attributeValue("minor") != null)
                student.getAreaClassificationMinors().add(new AreaClassificationMajor(requestEl.attributeValue("area"), requestEl.attributeValue("areaName"), requestEl.attributeValue("classification"), requestEl.attributeValue("classificationName"), requestEl.attributeValue("minor"), requestEl.attributeValue("minorName"), requestEl.attributeValue("concentration"), requestEl.attributeValue("concentrationName"), requestEl.attributeValue("degree"), requestEl.attributeValue("degreeName"), requestEl.attributeValue("program"), requestEl.attributeValue("programName"), requestEl.attributeValue("weight") == null ? null : Double.valueOf(requestEl.attributeValue("weight"))));
            else
                student.getAreaClassificationMajors().add(new AreaClassificationMajor(requestEl.attributeValue("area"), requestEl.attributeValue("areaName"), requestEl.attributeValue("classification"), requestEl.attributeValue("classificationName"), requestEl.attributeValue("major"), requestEl.attributeValue("majorName"), requestEl.attributeValue("concentration"), requestEl.attributeValue("concentrationName"), requestEl.attributeValue("degree"), requestEl.attributeValue("degreeName"), requestEl.attributeValue("program"), requestEl.attributeValue("programName"), requestEl.attributeValue("weight") == null ? null : Double.valueOf(requestEl.attributeValue("weight"))));
        } else if ("group".equals(requestEl.getName())) {
            student.getGroups().add(new StudentGroup(requestEl.attributeValue("type"), requestEl.attributeValue("reference"), requestEl.attributeValue("name")));
        } else if ("accommodation".equals(requestEl.getName())) {
            student.getAccommodations().add(requestEl.attributeValue("reference"));
        } else if ("advisor".equals(requestEl.getName())) {
            student.getAdvisors().add(new Instructor(0l, requestEl.attributeValue("externalId"), requestEl.attributeValue("name"), requestEl.attributeValue("email")));
        }
    }
    for (int i = 0; i < Math.min(clasf.size(), major.size()); i++) {
        student.getAreaClassificationMajors().add(new AreaClassificationMajor(clasf.get(i)[0], clasf.get(i)[1], major.get(i)[1]));
    }
    return student;
}
Also used : AreaClassificationMajor(org.cpsolver.studentsct.model.AreaClassificationMajor) Element(org.dom4j.Element) Instructor(org.cpsolver.studentsct.model.Instructor) ArrayList(java.util.ArrayList) Student(org.cpsolver.studentsct.model.Student) Offering(org.cpsolver.studentsct.model.Offering) Section(org.cpsolver.studentsct.model.Section) Constraint(org.cpsolver.ifs.model.Constraint) Unavailability(org.cpsolver.studentsct.model.Unavailability) StudentGroup(org.cpsolver.studentsct.model.StudentGroup)

Aggregations

StudentGroup (org.cpsolver.studentsct.model.StudentGroup)3 AreaClassificationMajor (org.cpsolver.studentsct.model.AreaClassificationMajor)2 Instructor (org.cpsolver.studentsct.model.Instructor)2 Unavailability (org.cpsolver.studentsct.model.Unavailability)2 Element (org.dom4j.Element)2 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 Constraint (org.cpsolver.ifs.model.Constraint)1 Offering (org.cpsolver.studentsct.model.Offering)1 Section (org.cpsolver.studentsct.model.Section)1 Student (org.cpsolver.studentsct.model.Student)1