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) {
course.addParticipant(student);
student.assignToCourse(course);
this.courseRepository.save(course);
this.studentRepository.save(student);
this.courseRepository.save(course); // This cascades to save the student as well.
}
}

View File

@ -50,7 +50,7 @@ public class StudentTeamService {
StudentTeam newTeam = new StudentTeam(course);
course.addStudentTeam(newTeam);
this.courseRepository.save(course);
logger.info("Created new team: " + newTeam.getId());
logger.info("Created new team.");
return newTeam;
}
@ -185,13 +185,19 @@ public class StudentTeamService {
s.removeFromAssignedTeam(team);
team.removeMember(s);
this.studentRepository.save(s);
logger.debug("Removed student " + s.getFullName() + " from team " + team.getId());
}
// Remove the TA team assignment.
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);
this.teachingAssistantTeamRepository.save(teachingAssistantTeam);
// Remove the repository from the course and delete it.
course.removeStudentTeam(team);