Do not add duplicate supervisors in Daisy #26

Merged
tozh4728 merged 3 commits from handle-supervisor-change-failure into develop 2024-12-02 11:28:38 +01:00
Showing only changes of commit 2858446668 - Show all commits

View File

@ -241,12 +241,12 @@ public class ProjectExporter extends AbstractWorker {
}
private void updateHeadSupervisor(Project project) throws ExternalExportException {
boolean add = true;
boolean toAdd = true;
Set<ProjectParticipant> contributors = daisyAPI.getContributors(project.getIdentifier());
for (ProjectParticipant contributor : contributors) {
if (contributor.getRole() == Role.SUPERVISOR) {
if (contributor.getPerson().getId().equals(project.getHeadSupervisor().getIdentifier())) {
add = false;
toAdd = false;
ansv7779 marked this conversation as resolved Outdated

I suggest, while we are still on it, rename the variable from "add" to "toAdd".

I suggest, while we are still on it, rename the variable from "add" to "toAdd".
} else {
Response response = daisyAPI.deleteThesisPerson(project.getIdentifier(), contributor.getPerson().getId());
if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
@ -260,12 +260,12 @@ public class ProjectExporter extends AbstractWorker {
// the project from having multiple supervisors.
// Hopefully Daisy API will soon have support for the function "change supervisor"
// rather than just INSERT and DELETE rows in a table.
add = false;
toAdd = false;
}
}
}
}
if (add) {
if (toAdd) {
externalExporter.addContributorToProject(project, project.getHeadSupervisor(), Role.SUPERVISOR);
}
}