Fixed duplicate error, added debug messages.

This commit is contained in:
Andrew Lalis 2019-05-13 11:50:37 +02:00 committed by andrewlalis
parent 06cbf34b54
commit 643124f242
2 changed files with 10 additions and 5 deletions

View File

@ -35,8 +35,7 @@ public class StudentService {
if (course != null) { if (course != null) {
course.addParticipant(student); course.addParticipant(student);
student.assignToCourse(course); student.assignToCourse(course);
this.courseRepository.save(course); this.courseRepository.save(course); // This cascades to save the student as well.
this.studentRepository.save(student);
} }
} }

View File

@ -50,7 +50,7 @@ public class StudentTeamService {
StudentTeam newTeam = new StudentTeam(course); StudentTeam newTeam = new StudentTeam(course);
course.addStudentTeam(newTeam); course.addStudentTeam(newTeam);
this.courseRepository.save(course); this.courseRepository.save(course);
logger.info("Created new team: " + newTeam.getId()); logger.info("Created new team.");
return newTeam; return newTeam;
} }
@ -185,13 +185,19 @@ public class StudentTeamService {
s.removeFromAssignedTeam(team); s.removeFromAssignedTeam(team);
team.removeMember(s); team.removeMember(s);
this.studentRepository.save(s); this.studentRepository.save(s);
logger.debug("Removed student " + s.getFullName() + " from team " + team.getId());
} }
// Remove the TA team assignment. // Remove the TA team assignment.
TeachingAssistantTeam teachingAssistantTeam = team.getAssignedTeachingAssistantTeam(); TeachingAssistantTeam teachingAssistantTeam = team.getAssignedTeachingAssistantTeam();
teachingAssistantTeam.removeAssignedStudentTeam(team); if (teachingAssistantTeam != null) {
teachingAssistantTeam.removeAssignedStudentTeam(team);
this.teachingAssistantTeamRepository.save(teachingAssistantTeam);
logger.debug("Removed team " + team.getId() + " from Teaching Assistant Team " + teachingAssistantTeam.getId() + " assigned teams list.");
}
team.setAssignedTeachingAssistantTeam(null); team.setAssignedTeachingAssistantTeam(null);
this.teachingAssistantTeamRepository.save(teachingAssistantTeam);
// Remove the repository from the course and delete it. // Remove the repository from the course and delete it.
course.removeStudentTeam(team); course.removeStudentTeam(team);