List<Student> studentListToEdit = new ArrayList<Student>();
List<Student> studentListToCompareWith = new ArrayList<Student>();
List<EnrollmentReport> enrollmentReportList = new ArrayList<EnrollmentReport>();
for (Student s1 : studentList) {
Student s2 = getStudentWithEmail(courseID, s1.getEmail());
if (s2 != null) {
studentListToCompareWith.add(s1);
studentListToEdit.add(s2);
enrollmentReportList.add(new EnrollmentReport(s2.getName(), s2.getEmail(), EnrollmentStatus.REMAINED, false, false, false));
}
}
// Edit the acquired Student objects and update the corresponding
// EnrollmentReport objects
for (int x = 0; x < studentListToEdit.size(); x++) {
EnrollmentReport er = enrollmentReportList.get(x);
Student s = studentListToCompareWith.get(x);
Student se = studentListToEdit.get(x);
if (!s.getName().equals(se.getName())) {
se.setName(s.getName());
er.setNameEdited(true);
er.setStatus(EnrollmentStatus.EDITED);
}
if (!s.getTeamName().equals(se.getTeamName())) {
se.setTeamName(s.getTeamName());
er.setTeamNameEdited(true);
er.setStatus(EnrollmentStatus.EDITED);
}
if (!s.getComments().equals(se.getComments())) {
se.setComments(studentList.get(x).getComments());
er.setCommentsEdited(true);
er.setStatus(EnrollmentStatus.EDITED);
}
}