Skip to content

Commit

Permalink
Merge pull request #282 from bcgov/hotfix/GRAD2-2172
Browse files Browse the repository at this point in the history
GRAD2-2172: bug fix on NPE when retrieving student optional programs.
  • Loading branch information
kamal-mohammed authored Jul 6, 2023
2 parents a30d030 + 88324ca commit 90a7fff
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1135,23 +1135,25 @@ public void saveGraduationStudent(StudentGradDTO gradStudent, String accessToken
}

private void removeAndReCreateOptionalPrograms(StudentGradDTO gradStudent, String accessToken) {
List<String> optionalProgramCodes = new ArrayList<>();

// Remove all optional programs
List<StudentOptionalProgram> studentOptionalPrograms = restUtils.getStudentOptionalPrograms(gradStudent.getStudentID().toString(), accessToken);
studentOptionalPrograms.forEach(op -> {
log.info(" => [{}] optional program will be removed if exist.", op.getOptionalProgramCode());
removeStudentOptionalProgram(op.getOptionalProgramID(), gradStudent, accessToken);
if (isOptionalProgramRecreationRequired(op.getOptionalProgramCode())) {
optionalProgramCodes.add(op.getOptionalProgramCode());
}
});
if (studentOptionalPrograms != null && !studentOptionalPrograms.isEmpty()) {
List<String> optionalProgramCodes = new ArrayList<>();

// Recreate nonFI & nonDD optional programs
optionalProgramCodes.forEach(opc -> {
log.info(" => [{}] optional program will be re-created.", opc);
addStudentOptionalProgram(opc, gradStudent, true, accessToken);
});
studentOptionalPrograms.forEach(op -> {
log.info(" => [{}] optional program will be removed if exist.", op.getOptionalProgramCode());
removeStudentOptionalProgram(op.getOptionalProgramID(), gradStudent, accessToken);
if (isOptionalProgramRecreationRequired(op.getOptionalProgramCode())) {
optionalProgramCodes.add(op.getOptionalProgramCode());
}
});

// Recreate nonFI & nonDD optional programs
optionalProgramCodes.forEach(opc -> {
log.info(" => [{}] optional program will be re-created.", opc);
addStudentOptionalProgram(opc, gradStudent, true, accessToken);
});
}
}

private void handleFIorDDOptionalProgram(StudentGradDTO gradStudent, String accessToken) {
Expand Down

0 comments on commit 90a7fff

Please sign in to comment.