Skip to content

Commit

Permalink
GRAD2-2393: removed the code smells complained by sonar code quality.
Browse files Browse the repository at this point in the history
GRAD2-2393: removed the code smells complained by sonar code quality.
  • Loading branch information
infstar committed Nov 2, 2023
1 parent 96ddea6 commit b41f860
Showing 1 changed file with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private void createCourseListForTranscript(List<StudentCourse> studentCourseList
int diff = EducGraduationApiUtils.getDifferenceInMonths(sDate, today);
boolean notCompletedCourse = xml && diff <= 0;
if (!sc.isDuplicate() && !sc.isFailed() && !sc.isNotCompleted() && ((notCompletedCourse) || !sc.isProjected()) && !sc.isValidationCourse()) {
if (sc.isCutOffCourse() && !isValidCutOffCourse(studentCourseList, sc, xml)) {
if (sc.isCutOffCourse() && !isValidCutOffCourse(studentCourseList, sc)) {
continue;
}
TranscriptResult result = new TranscriptResult();
Expand Down Expand Up @@ -345,17 +345,14 @@ private void createCourseListForTranscript(List<StudentCourse> studentCourseList
* @param cutOffCourse
* @return
*/
private boolean isValidCutOffCourse(List<StudentCourse> studentCourseList, StudentCourse cutOffCourse, boolean xml) {
xml = false;
if (!xml) {
List<StudentCourse> dups = studentCourseList.stream().filter(sc ->
StringUtils.equalsIgnoreCase(sc.getCourseCode(), cutOffCourse.getCourseCode()) && StringUtils.equalsIgnoreCase(sc.getCourseLevel(), cutOffCourse.getCourseLevel())
).sorted(Comparator.comparing(StudentCourse::getCompletedCoursePercentage, Comparator.nullsLast(Double::compareTo)).reversed()).collect(Collectors.toList());

if (!dups.isEmpty()) {
StudentCourse topMarkCourse = dups.get(0);
return StringUtils.equalsIgnoreCase(topMarkCourse.getSessionDate(), cutOffCourse.getSessionDate());
}
private boolean isValidCutOffCourse(List<StudentCourse> studentCourseList, StudentCourse cutOffCourse) {
List<StudentCourse> dups = studentCourseList.stream().filter(sc ->
StringUtils.equalsIgnoreCase(sc.getCourseCode(), cutOffCourse.getCourseCode()) && StringUtils.equalsIgnoreCase(sc.getCourseLevel(), cutOffCourse.getCourseLevel())
).sorted(Comparator.comparing(StudentCourse::getCompletedCoursePercentage, Comparator.nullsLast(Double::compareTo)).reversed()).toList();

if (!dups.isEmpty()) {
StudentCourse topMarkCourse = dups.get(0);
return StringUtils.equalsIgnoreCase(topMarkCourse.getSessionDate(), cutOffCourse.getSessionDate());
}
return false;
}
Expand Down Expand Up @@ -514,7 +511,7 @@ public List<StudentAssessment> removeDuplicatedAssessmentsForTranscript(List<Stu
.map((StudentAssessment studentAssessment) -> new StudentAssessmentDuplicatesWrapper(studentAssessment, xml))
.distinct()
.map(StudentAssessmentDuplicatesWrapper::getStudentAssessment)
.collect(Collectors.toList());
.toList();
}

private List<TranscriptResult> getTranscriptResults(ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, boolean xml, String accessToken) {
Expand All @@ -523,13 +520,13 @@ private List<TranscriptResult> getTranscriptResults(ca.bc.gov.educ.api.graduatio
List<StudentCourse> studentCourseList = graduationDataStatus.getStudentCourses().getStudentCourseList();
if (!studentCourseList.isEmpty()) {
if (program.contains("1950") || program.contains("1986")) {
List<StudentCourse> provinciallyExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("Y") == 0).collect(Collectors.toList());
List<StudentCourse> provinciallyExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("Y") == 0).toList();
if (!provinciallyExaminable.isEmpty()) {
sortOnCourseCode(provinciallyExaminable);
createCourseListForTranscript(provinciallyExaminable, graduationDataStatus, tList, "provincially", xml);
}

List<StudentCourse> nonExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("N") == 0).collect(Collectors.toList());
List<StudentCourse> nonExaminable = studentCourseList.stream().filter(sc -> sc.getProvExamCourse().compareTo("N") == 0).toList();
if (!nonExaminable.isEmpty()) {
sortOnCourseCode(nonExaminable);
createCourseListForTranscript(nonExaminable, graduationDataStatus, tList, "non-examinable", xml);
Expand Down Expand Up @@ -830,11 +827,11 @@ private void getStudentCoursesAssessmentsNExams(ReportData data, ca.bc.gov.educ.
List<StudentCourse> studentExamList = sCList
.stream()
.filter(sc -> "Y".compareTo(sc.getProvExamCourse()) == 0)
.collect(Collectors.toList());
.toList();
List<StudentCourse> studentCourseList = sCList
.stream()
.filter(sc -> "N".compareTo(sc.getProvExamCourse()) == 0)
.collect(Collectors.toList());
.toList();
List<StudentAssessment> studentAssessmentList = graduationDataStatus.getStudentAssessments().getStudentAssessmentList();
List<AchievementCourse> sCourseList = new ArrayList<>();
List<Exam> sExamList = new ArrayList<>();
Expand Down Expand Up @@ -1050,12 +1047,10 @@ public ReportData prepareCertificateData(GraduationStudentRecord gradResponse,
data.setUpdateDate(EducGraduationApiUtils.formatDateForReportJasper(gradResponse.getUpdateDate().toString()));
data.setCertificate(getCertificateData(gradResponse, certType));
data.getStudent().setGraduationData(graduationData);
switch (certType.getCertificateTypeCode()) {
case "F", "SCF", "S":
data.getStudent().setFrenchCert(certType.getCertificateTypeCode());
break;
default:
data.getStudent().setEnglishCert(certType.getCertificateTypeCode());
if (certType.getCertificateTypeCode().equals("F") || certType.getCertificateTypeCode().equals("SCF") || certType.getCertificateTypeCode().equals("S")) {
data.getStudent().setFrenchCert(certType.getCertificateTypeCode());
} else {
data.getStudent().setEnglishCert(certType.getCertificateTypeCode());
}
return data;
}
Expand Down Expand Up @@ -1207,7 +1202,7 @@ private List<GradRequirement> getRequirementsMetAchvReport(List<ca.bc.gov.educ.a
List<StudentCourse> scList = optionalStudentCourses.getStudentCourseList()
.stream()
.filter(sc -> gr.getTranscriptRule() != null && sc.getGradReqMet().contains(gr.getTranscriptRule()))
.collect(Collectors.toList());
.toList();
List<AchievementCourse> cdList = new ArrayList<>();
scList.forEach(sc -> {
AchievementCourse cD = new AchievementCourse();
Expand Down

0 comments on commit b41f860

Please sign in to comment.