Skip to content

Commit

Permalink
Merge pull request #642 from bcgov/feature/GRAD2-2525
Browse files Browse the repository at this point in the history
GRAD2-2525: task is complete.
  • Loading branch information
infstar authored Mar 8, 2024
2 parents 2277a65 + 794ed83 commit 555fd9d
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@
public class GradProgram implements Serializable {
private Code code = new Code();

private String expiryDate = "";

public Code getCode() {
return code;
}

public void setCode(Code value) {
this.code = value;
}

public String getExpiryDate() {
return expiryDate;
}

public void setExpiryDate(String value) {
this.expiryDate = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public GradProgram getGradProgram(ReportData reportData) {
assert program != null;
return new GradProgramImpl(GraduationProgramCode.valueFrom(
program.getCode().getCode(),
program.getCode().getDescription()));
program.getCode().getDescription()), program.getExpiryDate());
}

public List<School> getSchools(ReportData reportData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ public final class GradProgramImpl extends AbstractDomainEntity
private GraduationProgramCode code;
private String programCode;
private String programName;
private String expiryDate;

public GradProgramImpl() {

}

public GradProgramImpl(GraduationProgramCode code) {
public GradProgramImpl(GraduationProgramCode code, String expiryDate) {
setCode(code);
setExpiryDate(expiryDate);
}

@Override
Expand Down Expand Up @@ -69,4 +71,14 @@ public void setProgramCode(String programCode) {
public void setProgramName(String programName) {
this.programName = programName;
}

@Override
public String getExpiryDate() {
return expiryDate;
}

@Override
public void setExpiryDate(String value) {
this.expiryDate = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ public interface GradProgram extends DomainEntity {
* @param code The new graduation program code.
*/
void setCode(GraduationProgramCode code);

public String getExpiryDate();

public void setExpiryDate(String value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private GradProgram createGradProgram(String code) {

return new GradProgramImpl(GraduationProgramCode.valueFrom(
code,
reportData.getGradProgram().getCode().getDescription()));
reportData.getGradProgram().getCode().getDescription()),"");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ public Transcript getTranscript(
LOG.entering(CLASSNAME, methodName);

final Transcript transcriptInfo = getTranscriptInformation(pen);
final List<TranscriptCourse> transcriptCourses = getTranscriptCourseList(pen, transcriptInfo.getInterim());
final StudentInfo studentInfo = getStudentInfo(pen);
final TranscriptTypeCode transcriptTypeCode = transcriptInfo.getTranscriptTypeCode();
final GradProgram program = createGradProgram(studentInfo.getGradReqYear());
final List<TranscriptCourse> transcriptCourses = getTranscriptCourseList(pen, transcriptInfo.getInterim(), StringUtils.isBlank(program.getExpiryDate()));
final Date reportDate = transcriptInfo.getIssueDate();

final Transcript transcript = adapt(
Expand Down Expand Up @@ -274,7 +274,7 @@ private StudentTranscriptReport createTranscriptReport(
* @return
*/
private List<TranscriptCourse> getTranscriptCourseList(
final String pen, final boolean interim)
final String pen, final boolean interim, final boolean openGradProgram)
throws DomainServiceException {
final String methodName = "getTranscriptCourseList(String, boolean)";
LOG.entering(CLASSNAME, methodName);
Expand All @@ -283,7 +283,7 @@ private List<TranscriptCourse> getTranscriptCourseList(

ReportData reportData = getReportData(methodName);
if(interim) {
results = filterCourses(gradDataConvertionBean.getTranscriptCourses(reportData));
results = filterCourses(gradDataConvertionBean.getTranscriptCourses(reportData), openGradProgram);
} else {
results = gradDataConvertionBean.getTranscriptCourses(reportData);
}
Expand Down Expand Up @@ -683,14 +683,14 @@ private GraduationData adaptGraduationData(
* @param results Courses for PEN user which might have duplicated courses
* @return
*/
private List<TranscriptCourse> filterCourses(final List<TranscriptCourse> results) {
private List<TranscriptCourse> filterCourses(final List<TranscriptCourse> results, boolean openGradProgram) {

final List<TranscriptCourse> resultOfCourses = new ArrayList<>();
for (final TranscriptCourse course : results) {

if (!resultOfCourses.contains(course)) {
final TranscriptCourse interimCourse
= getInterimCourse(course, results);
= getInterimCourse(course, results, openGradProgram);

if (!(resultOfCourses.contains(interimCourse))) {
resultOfCourses.add(interimCourse);
Expand All @@ -712,21 +712,27 @@ private List<TranscriptCourse> filterCourses(final List<TranscriptCourse> result
*/
private TranscriptCourse getInterimCourse(
TranscriptCourse course,
final List<TranscriptCourse> results) {
final List<TranscriptCourse> results, boolean openGradProgram) {
//Check for duplicate courses
for (final TranscriptCourse compareCourse : results) {
//Check and compare two courses for duplication and if required
//replace course based on requirement.
if (course.courseEquals(compareCourse)
&& !course.isCompletedCourseUsedForGrad()
&& course.compareCourse(compareCourse) ) {
if (isInterimCourse(course, compareCourse, openGradProgram)) {
course = compareCourse;
}
}
return course;

}

private boolean isInterimCourse(TranscriptCourse source, TranscriptCourse target, boolean openGradProgram) {
if (openGradProgram) { // GRAD-2525
return source.courseEquals(target) && source.compareCourse(target);
} else { // GRAD2-2222
return source.courseEquals(target) && !source.isCompletedCourseUsedForGrad() && source.compareCourse(target);
}
}

/**
* @param results
* @param code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void createTranscriptReport(String methodName, String jsonPath, GraduationProgra

if(graduationProgramCode != null) {
mockGradProgramEntity(graduationProgramCode.getCode(), reportRequest.getData().getTranscript().getTranscriptTypeCode().getCode());
GradProgramImpl gradProgram = new GradProgramImpl(graduationProgramCode);
GradProgramImpl gradProgram = new GradProgramImpl(graduationProgramCode, "");
gradProgram.setProgramCode(graduationProgramCode.getCode());
gradProgram.setProgramName(graduationProgramCode.getDescription());
mockGradProgram(gradProgram);
Expand Down

0 comments on commit 555fd9d

Please sign in to comment.