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");
}
}
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;
}
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;
}
Aggregations