Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-2339 #232

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.time.LocalDate;
Expand Down Expand Up @@ -103,7 +104,9 @@ public String getCertificates() {
}

public void setCertificates(String certificates) {
this.certificates = certificates;
String nextSeparator = StringUtils.isNotBlank(this.certificates) ? "," : "";
String nextCertificate = StringUtils.isNotBlank(certificates) ? nextSeparator + certificates : "";
this.certificates = StringUtils.defaultIfBlank(this.certificates, "") + nextCertificate;
}

public String getGraduationMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import org.springframework.web.reactive.function.client.WebClient;

import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.*;

@Service
public class ReportService {
Expand Down Expand Up @@ -123,40 +120,52 @@ public ReportRequest prepareSchoolDistributionReportData(SchoolDistributionReque
ReportData data = new ReportData();

List<StudentCredentialDistribution> schoolReportList = schoolDistributionRequest.getStudentList();
List<Student> stdList = new ArrayList<>();
School schObj = new School();
schObj.setMincode(schoolDetails.getDistNo()+schoolDetails.getSchlNo());
schObj.setName(schoolDetails.getSchoolName());
Map<Pen, Student> students = new HashMap<>();
School school = new School();
school.setMincode(schoolDetails.getDistNo()+schoolDetails.getSchlNo());
school.setName(schoolDetails.getSchoolName());
for(StudentCredentialDistribution sc:schoolReportList) {
Student std = new Student();
std.setFirstName(sc.getLegalFirstName());
std.setLastName(sc.getLegalLastName());
std.setMiddleName(sc.getLegalMiddleNames());
std.setCitizenship(sc.getStudentCitizenship());

Pen pen = new Pen();
pen.setPen(sc.getPen());
pen.setEntityID("" + sc.getStudentID());
std.setPen(pen);
std.setGradProgram(sc.getProgram());
GraduationData gradData = new GraduationData();
gradData.setGraduationDate(sc.getProgramCompletionDate() != null ? EducDistributionApiUtils.asDate(sc.getProgramCompletionDate()) : null);
gradData.setHonorsFlag(sc.getHonoursStanding() != null && sc.getHonoursStanding().equalsIgnoreCase("Y"));
std.setGraduationData(gradData);

std.setGraduationStatus(GraduationStatus.builder()
.programCompletionDate(sc.getProgramCompletionDate())
.honours(sc.getHonoursStanding())
.programName(sc.getProgram())
.studentGrade(sc.getStudentGrade())
.schoolOfRecord(sc.getSchoolOfRecord())
.build());

stdList.add(std);
Student student = students.get(pen);

if (student == null) {

student = new Student();

student.setFirstName(sc.getLegalFirstName());
student.setLastName(sc.getLegalLastName());
student.setMiddleName(sc.getLegalMiddleNames());
student.setCitizenship(sc.getStudentCitizenship());

student.setPen(pen);
student.setGradProgram(sc.getProgram());
GraduationData gradData = new GraduationData();
gradData.setGraduationDate(sc.getProgramCompletionDate() != null ? EducDistributionApiUtils.asDate(sc.getProgramCompletionDate()) : null);
gradData.setHonorsFlag(sc.getHonoursStanding() != null && sc.getHonoursStanding().equalsIgnoreCase("Y"));
student.setGraduationData(gradData);

student.setGraduationStatus(GraduationStatus.builder()
.programCompletionDate(sc.getProgramCompletionDate())
.honours(sc.getHonoursStanding())
.programName(sc.getProgram())
.studentGrade(sc.getStudentGrade())
.schoolOfRecord(sc.getSchoolOfRecord())
.build());

students.put(pen, student);
}
//Add student certificate into the list of student certificate credentials
if(!"YED4".equalsIgnoreCase(sc.getPaperType())) {
student.getGraduationStatus().setCertificates(sc.getCredentialTypeCode());
}
}
//No dups for school report
List<Student> uniqueStudentList = new ArrayList<>(new LinkedHashSet<>(stdList));
schObj.setStudents(uniqueStudentList);
data.setSchool(schObj);
List<Student> uniqueStudentList = new ArrayList<>(students.values());
school.setStudents(uniqueStudentList);
data.setSchool(school);
data.setOrgCode(StringUtils.startsWith(data.getSchool().getMincode(), "098") ? "YU" : "BC");
data.setReportNumber(data.getOrgCode()+"-"+batchId);
req.setData(data);
Expand All @@ -165,7 +174,7 @@ public ReportRequest prepareSchoolDistributionReportData(SchoolDistributionReque
options.setConvertTo("pdf");
options.setCacheReport(false);
options.setOverwrite(false);
options.setReportFile(String.format("%s School distribution.%s", schObj.getMincode(), options.getConvertTo()));
options.setReportFile(String.format("%s School distribution.%s", school.getMincode(), options.getConvertTo()));
options.setReportName("SchoolDistribution");

req.setOptions(options);
Expand Down
Loading