From cd36de05ea7f9bac474ef7bb05f832e534748972 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 12 Apr 2024 09:56:28 -0600 Subject: [PATCH 01/16] GRAD2-2377 Add Transcripts to school reports only for CUR students --- .../api/grad/report/controller/CommonController.java | 4 ++-- .../gov/educ/api/grad/report/service/CommonService.java | 9 +++++++-- .../api/grad/report/controller/CommonControllerTest.java | 6 +++--- .../educ/api/grad/report/service/CommonServiceTest.java | 4 ++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java index 466ae874..bab9cdb6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java @@ -303,9 +303,9 @@ public ResponseEntity> saveSchoolReport(@Request @PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT_REPORTS) @Operation(summary = "Read All School Reports by Mincode", description = "Read All School Reports by Mincode", tags = { "Reports" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - public ResponseEntity> getAllSchoolReportsList(@PathVariable String mincode,@RequestHeader(name="Authorization") String accessToken) { + public ResponseEntity> getAllSchoolReportsList(@PathVariable String mincode) { logger.debug("getAllSchoolReportsList : "); - return response.GET(commonService.getAllSchoolReportListByMincode(mincode, accessToken.replace(BEARER,""))); + return response.GET(commonService.getAllSchoolReportListByMincode(mincode)); } @GetMapping(EducGradReportApiConstants.SCHOOL_REPORTS_BY_REPORT_TYPE) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index 948c12a6..030a6357 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -332,7 +332,7 @@ public List getAllStudentReportList(UUID studentID) { return reportList; } - public List getAllSchoolReportListByMincode(String mincode, String accessToken) { + public List getAllSchoolReportListByMincode(String mincode) { List reportList = new ArrayList<>(); if (StringUtils.isNotBlank(mincode)) { if (StringUtils.contains(mincode, "*")) { @@ -745,7 +745,12 @@ private synchronized List getNextPageStudentsFromGradStud } else { dataResult.setCertificateTypeCode(certificateTypeCode); } - result.add(dataResult); + if("YED4".equalsIgnoreCase(paperType) && "CUR".equalsIgnoreCase(s.getStudentStatus())) { + result.add(dataResult); + } + if (!"YED4".equalsIgnoreCase(paperType)) { + result.add(dataResult); + } } } return result; diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java index 010ec70a..c6bec997 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java @@ -413,9 +413,9 @@ public void testGetAllSchoolReportList() { studentCertificate2.setReportTypeCode(gradCertificateType.getCode()); gradStudentReportList.add(studentCertificate2); - Mockito.when(commonService.getAllSchoolReportListByMincode(mincode,"accessToken")).thenReturn(gradStudentReportList); - commonController.getAllSchoolReportsList(mincode,"accessToken"); - Mockito.verify(commonService).getAllSchoolReportListByMincode(mincode,"accessToken"); + Mockito.when(commonService.getAllSchoolReportListByMincode(mincode)).thenReturn(gradStudentReportList); + commonController.getAllSchoolReportsList(mincode); + Mockito.verify(commonService).getAllSchoolReportListByMincode(mincode); Mockito.when(commonService.getAllSchoolReportListByReportType(gradCertificateType.getCode(), mincode)).thenReturn(gradStudentReportList); commonController.getSchoolReportsListByReportType(gradCertificateType.getCode(), mincode, "accessToken"); diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java index 0ec1244a..0dc8e724 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java @@ -1187,7 +1187,7 @@ public void testGetAllSchoolReportList() { when(schoolReportsLightRepository.findByReportTypeCodeAndSchoolOfRecord(gradReportTypes.getCode(), "")).thenReturn(schoolReportsLightEntityList); when(gradReportTypesRepository.findById(gradReportTypes.getCode())).thenReturn(Optional.of(gradReportTypesEntity)); - var result = commonService.getAllSchoolReportListByMincode(mincode,"accessToken"); + var result = commonService.getAllSchoolReportListByMincode(mincode); assertThat(result).isNotNull().hasSize(2); assertThat(result.get(0).getSchoolOfRecord()).isEqualTo(mincode2); @@ -1262,7 +1262,7 @@ public void testGetAllSchoolReportList_withoutwildcard() { when(schoolReportsRepository.findBySchoolOfRecordOrderBySchoolOfRecord("12345631231")).thenReturn(schoolReportsEntityList); when(gradReportTypesRepository.findById(gradReportTypes.getCode())).thenReturn(Optional.of(gradReportTypesEntity)); - var result = commonService.getAllSchoolReportListByMincode(mincode,"accessToken"); + var result = commonService.getAllSchoolReportListByMincode(mincode); assertThat(result).isNotNull().hasSize(2); assertThat(result.get(0).getSchoolOfRecord()).isEqualTo(mincode2); From 66593b7744f0eb9e69c38261f18dfe8a4d208513 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 12 Apr 2024 10:08:31 -0600 Subject: [PATCH 02/16] Test coverage --- .../api/grad/report/controller/CommonControllerTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java index c6bec997..db53fd1c 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java @@ -453,6 +453,15 @@ public void testUpdateStudentCredential() { Mockito.verify(commonService).updateStudentCredential(studentID,credentialTypeCode,paperType,documentStatusCode, activityCode); } + @Test + public void testUpdateStudentCredentialPosting() { + final UUID studentID = new UUID(1,1); + final String credentialTypeCode = "TEST"; + Mockito.when(commonService.updateStudentCredentialPosting(studentID,credentialTypeCode)).thenReturn(true); + commonController.updateStudentCredentialPosting(studentID.toString(),credentialTypeCode); + Mockito.verify(commonService).updateStudentCredentialPosting(studentID,credentialTypeCode); + } + @Test public void testUpdateStudentCredential_YED2() { final UUID studentID = new UUID(1,1); From 9bb7305eb1bdf694eea7e4729c94d5ff5e1263ed Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 12 Apr 2024 10:14:11 -0600 Subject: [PATCH 03/16] Test coverage --- .../api/grad/report/controller/CommonControllerTest.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java index db53fd1c..c6bec997 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java @@ -453,15 +453,6 @@ public void testUpdateStudentCredential() { Mockito.verify(commonService).updateStudentCredential(studentID,credentialTypeCode,paperType,documentStatusCode, activityCode); } - @Test - public void testUpdateStudentCredentialPosting() { - final UUID studentID = new UUID(1,1); - final String credentialTypeCode = "TEST"; - Mockito.when(commonService.updateStudentCredentialPosting(studentID,credentialTypeCode)).thenReturn(true); - commonController.updateStudentCredentialPosting(studentID.toString(),credentialTypeCode); - Mockito.verify(commonService).updateStudentCredentialPosting(studentID,credentialTypeCode); - } - @Test public void testUpdateStudentCredential_YED2() { final UUID studentID = new UUID(1,1); From 96f298d1569f62ac11bda4419c03b9d556e69c2b Mon Sep 17 00:00:00 2001 From: Alexander Rybakov <83988488+arybakov-cgi@users.noreply.github.com> Date: Fri, 12 Apr 2024 10:24:36 -0600 Subject: [PATCH 04/16] GRAD2-2377 (#252) * GRAD2-2377 Add Transcripts to school reports only for CUR students * Test coverage * Test coverage --- .../api/grad/report/controller/CommonController.java | 4 ++-- .../gov/educ/api/grad/report/service/CommonService.java | 9 +++++++-- .../api/grad/report/controller/CommonControllerTest.java | 6 +++--- .../educ/api/grad/report/service/CommonServiceTest.java | 4 ++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java index 466ae874..bab9cdb6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java @@ -303,9 +303,9 @@ public ResponseEntity> saveSchoolReport(@Request @PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT_REPORTS) @Operation(summary = "Read All School Reports by Mincode", description = "Read All School Reports by Mincode", tags = { "Reports" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) - public ResponseEntity> getAllSchoolReportsList(@PathVariable String mincode,@RequestHeader(name="Authorization") String accessToken) { + public ResponseEntity> getAllSchoolReportsList(@PathVariable String mincode) { logger.debug("getAllSchoolReportsList : "); - return response.GET(commonService.getAllSchoolReportListByMincode(mincode, accessToken.replace(BEARER,""))); + return response.GET(commonService.getAllSchoolReportListByMincode(mincode)); } @GetMapping(EducGradReportApiConstants.SCHOOL_REPORTS_BY_REPORT_TYPE) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index 948c12a6..030a6357 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -332,7 +332,7 @@ public List getAllStudentReportList(UUID studentID) { return reportList; } - public List getAllSchoolReportListByMincode(String mincode, String accessToken) { + public List getAllSchoolReportListByMincode(String mincode) { List reportList = new ArrayList<>(); if (StringUtils.isNotBlank(mincode)) { if (StringUtils.contains(mincode, "*")) { @@ -745,7 +745,12 @@ private synchronized List getNextPageStudentsFromGradStud } else { dataResult.setCertificateTypeCode(certificateTypeCode); } - result.add(dataResult); + if("YED4".equalsIgnoreCase(paperType) && "CUR".equalsIgnoreCase(s.getStudentStatus())) { + result.add(dataResult); + } + if (!"YED4".equalsIgnoreCase(paperType)) { + result.add(dataResult); + } } } return result; diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java index 010ec70a..c6bec997 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java @@ -413,9 +413,9 @@ public void testGetAllSchoolReportList() { studentCertificate2.setReportTypeCode(gradCertificateType.getCode()); gradStudentReportList.add(studentCertificate2); - Mockito.when(commonService.getAllSchoolReportListByMincode(mincode,"accessToken")).thenReturn(gradStudentReportList); - commonController.getAllSchoolReportsList(mincode,"accessToken"); - Mockito.verify(commonService).getAllSchoolReportListByMincode(mincode,"accessToken"); + Mockito.when(commonService.getAllSchoolReportListByMincode(mincode)).thenReturn(gradStudentReportList); + commonController.getAllSchoolReportsList(mincode); + Mockito.verify(commonService).getAllSchoolReportListByMincode(mincode); Mockito.when(commonService.getAllSchoolReportListByReportType(gradCertificateType.getCode(), mincode)).thenReturn(gradStudentReportList); commonController.getSchoolReportsListByReportType(gradCertificateType.getCode(), mincode, "accessToken"); diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java index 0ec1244a..0dc8e724 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java @@ -1187,7 +1187,7 @@ public void testGetAllSchoolReportList() { when(schoolReportsLightRepository.findByReportTypeCodeAndSchoolOfRecord(gradReportTypes.getCode(), "")).thenReturn(schoolReportsLightEntityList); when(gradReportTypesRepository.findById(gradReportTypes.getCode())).thenReturn(Optional.of(gradReportTypesEntity)); - var result = commonService.getAllSchoolReportListByMincode(mincode,"accessToken"); + var result = commonService.getAllSchoolReportListByMincode(mincode); assertThat(result).isNotNull().hasSize(2); assertThat(result.get(0).getSchoolOfRecord()).isEqualTo(mincode2); @@ -1262,7 +1262,7 @@ public void testGetAllSchoolReportList_withoutwildcard() { when(schoolReportsRepository.findBySchoolOfRecordOrderBySchoolOfRecord("12345631231")).thenReturn(schoolReportsEntityList); when(gradReportTypesRepository.findById(gradReportTypes.getCode())).thenReturn(Optional.of(gradReportTypesEntity)); - var result = commonService.getAllSchoolReportListByMincode(mincode,"accessToken"); + var result = commonService.getAllSchoolReportListByMincode(mincode); assertThat(result).isNotNull().hasSize(2); assertThat(result.get(0).getSchoolOfRecord()).isEqualTo(mincode2); From 0320bead7a819fe46353a45c7594b7c2d1346e51 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 16 Apr 2024 10:23:15 -0600 Subject: [PATCH 05/16] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../bc/gov/educ/api/grad/report/service/CommonService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index 030a6357..8c72f0e6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -726,11 +726,13 @@ private synchronized List getNextPageStudentsFromGradStud if(studentsInBatch != null && !schools.isEmpty()) { boolean isDistrictSchool = schools.get(0).length() == 3; if(isDistrictSchool) { - studentsInBatch.removeIf(st -> (!schools.contains(StringUtils.substring(st.getMincode(), 0, 3)))); + studentsInBatch.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3)))); + studentsInBatch.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincodeAtGrad(), 0, 3)))); } boolean isSchoolSchool = schools.get(0).length() > 3; if(isSchoolSchool) { - studentsInBatch.removeIf(st -> (!schools.contains(StringUtils.trimToEmpty(st.getMincode())))); + studentsInBatch.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincode())))); + studentsInBatch.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincodeAtGrad())))); } } for(SchoolReportEntity e: students.getContent()) { From 74ff96f50e421efc634950495c117cb66089c2aa Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 16 Apr 2024 11:35:11 -0600 Subject: [PATCH 06/16] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../bc/gov/educ/api/grad/report/service/CommonServiceTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java index 0dc8e724..db6e36b8 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java @@ -1469,6 +1469,7 @@ public void testGetSchoolReportGradStudentData() { ReportGradStudentData reportGradStudentData = new ReportGradStudentData(); reportGradStudentData.setGraduationStudentRecordId(studentId); reportGradStudentData.setTranscriptTypeCode("BC2018-IND"); + reportGradStudentData.setMincode("12345678"); GradCertificateTypes certificateTypes = new GradCertificateTypes(); certificateTypes.setCode("E"); @@ -1485,6 +1486,8 @@ public void testGetSchoolReportGradStudentData() { reportGradStudentData = new ReportGradStudentData(); reportGradStudentData.setGraduationStudentRecordId(studentId); reportGradStudentData.setTranscriptTypeCode("BC2004-IND"); + reportGradStudentData.setMincode("12345678"); + reportGradStudentData.setMincodeAtGrad("09876543"); reportGradStudentDataList.add(reportGradStudentData); From ac2913218b2380d6d88dafebcc8f7bb582464e95 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 16 Apr 2024 11:38:15 -0600 Subject: [PATCH 07/16] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../report/service/CommonServiceTest.java | 218 ++++++++++++++++++ 1 file changed, 218 insertions(+) diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java index db6e36b8..26a54240 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java @@ -1676,6 +1676,224 @@ public Page map(Function converter) { assertThat(result).isNotEmpty(); } + @Test + @SneakyThrows + public void testGetSchoolReportGradStudentDataForSchools() { + UUID studentId = UUID.randomUUID(); + + String mincode = "12345678"; + + List reportGradStudentDataList = new ArrayList<>(); + ReportGradStudentData reportGradStudentData = new ReportGradStudentData(); + reportGradStudentData.setGraduationStudentRecordId(studentId); + reportGradStudentData.setTranscriptTypeCode("BC2018-IND"); + reportGradStudentData.setMincode(mincode); + + GradCertificateTypes certificateTypes = new GradCertificateTypes(); + certificateTypes.setCode("E"); + certificateTypes.setDescription("Dogwood"); + reportGradStudentData.setCertificateTypes(List.of(certificateTypes)); + + reportGradStudentDataList.add(reportGradStudentData); + + reportGradStudentData = new ReportGradStudentData(); + reportGradStudentData.setGraduationStudentRecordId(studentId); + + reportGradStudentDataList.add(reportGradStudentData); + + reportGradStudentData = new ReportGradStudentData(); + reportGradStudentData.setGraduationStudentRecordId(studentId); + reportGradStudentData.setTranscriptTypeCode("BC2004-IND"); + reportGradStudentData.setMincode(mincode); + reportGradStudentData.setMincodeAtGrad("09876543"); + + reportGradStudentDataList.add(reportGradStudentData); + + SchoolReportEntity schoolReportEntity = new SchoolReportEntity(); + schoolReportEntity.setSchoolReportEntityId(new SchoolReportEntityId(studentId, "EBDR", "E")); + + when(schoolReportYearEndRepository.findStudentForSchoolYearEndReport(PageRequest.of(0, PAGE_SIZE))).thenReturn(new Page() { + + @Override + public Iterator iterator() { + return getContent().listIterator(); + } + + @Override + public int getNumber() { + return 1; + } + + @Override + public int getSize() { + return 1; + } + + @Override + public int getNumberOfElements() { + return 1; + } + + @Override + public List getContent() { + return List.of(schoolReportEntity); + } + + @Override + public boolean hasContent() { + return !getContent().isEmpty(); + } + + @Override + public Sort getSort() { + return null; + } + + @Override + public boolean isFirst() { + return false; + } + + @Override + public boolean isLast() { + return false; + } + + @Override + public boolean hasNext() { + return false; + } + + @Override + public boolean hasPrevious() { + return false; + } + + @Override + public Pageable nextPageable() { + return null; + } + + @Override + public Pageable previousPageable() { + return null; + } + + @Override + public int getTotalPages() { + return getContent().size(); + } + + @Override + public long getTotalElements() { + return getContent().size(); + } + + @Override + public Page map(Function converter) { + return null; + } + }); + + when(schoolReportMonthlyRepository.findStudentForSchoolReport(PageRequest.of(0, PAGE_SIZE))).thenReturn(new Page() { + + @Override + public Iterator iterator() { + return getContent().listIterator(); + } + + @Override + public int getNumber() { + return 1; + } + + @Override + public int getSize() { + return 1; + } + + @Override + public int getNumberOfElements() { + return 1; + } + + @Override + public List getContent() { + return List.of(schoolReportEntity); + } + + @Override + public boolean hasContent() { + return !getContent().isEmpty(); + } + + @Override + public Sort getSort() { + return null; + } + + @Override + public boolean isFirst() { + return false; + } + + @Override + public boolean isLast() { + return false; + } + + @Override + public boolean hasNext() { + return false; + } + + @Override + public boolean hasPrevious() { + return false; + } + + @Override + public Pageable nextPageable() { + return null; + } + + @Override + public Pageable previousPageable() { + return null; + } + + @Override + public int getTotalPages() { + return getContent().size(); + } + + @Override + public long getTotalElements() { + return getContent().size(); + } + + @Override + public Page map(Function converter) { + return null; + } + }); + + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(constants.getStudentsForSchoolDistribution())).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(new ParameterizedTypeReference>() {})).thenReturn(Mono.just(reportGradStudentDataList)); + + mockAccessToken(); + + var result = commonService.getSchoolYearEndReportGradStudentData(List.of(mincode)); + assertThat(result).isNotEmpty(); + + result = commonService.getSchoolReportGradStudentData(); + assertThat(result).isNotEmpty(); + } + private void mockAccessToken() { final TokenResponse tokenObject = new TokenResponse(); tokenObject.setAccess_token(MOCK_TOKEN); From 118aa1b782ebbb69e9d93a5fec5df93c5c2db60f Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 16 Apr 2024 11:44:55 -0600 Subject: [PATCH 08/16] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../gov/educ/api/grad/report/service/CommonService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index 8c72f0e6..ac384ec0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -623,7 +623,8 @@ private School getSchool(String minCode, String accessToken) { } } - private District getDistrict(String districtCode, String accessToken) { + @Transactional + public District getDistrict(String districtCode, String accessToken) { try { return webClient.get() .uri(String.format(constants.getDistrictByMincodeUrl(), districtCode)) @@ -696,7 +697,8 @@ public List getSchoolReportGradStudentData() { return processReportGradStudentDataList(students, new ArrayList<>()); } - private List processReportGradStudentDataList(Page students, List schools) { + @Transactional + public List processReportGradStudentDataList(Page students, List schools) { List result = new ArrayList<>(); long startTime = System.currentTimeMillis(); if(students.hasContent()) { @@ -719,7 +721,8 @@ private List processReportGradStudentDataList(Page getNextPageStudentsFromGradStudentApi(Page students, List schools) { + @Transactional + public synchronized List getNextPageStudentsFromGradStudentApi(Page students, List schools) { List result = new ArrayList<>(); List studentGuidsInBatch = students.getContent().stream().map(SchoolReportEntity::getGraduationStudentRecordId).distinct().toList(); List studentsInBatch = getReportGradStudentData(fetchAccessToken(), studentGuidsInBatch); From 2e8edec9fce5d664d4ec70ddd15108d68b3821c4 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 16 Apr 2024 11:53:00 -0600 Subject: [PATCH 09/16] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../api/grad/report/service/CommonService.java | 16 ++++++++++------ .../gov/educ/api/grad/report/util/Generated.java | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/grad/report/util/Generated.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index ac384ec0..81321294 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -6,6 +6,7 @@ import ca.bc.gov.educ.api.grad.report.model.transformer.*; import ca.bc.gov.educ.api.grad.report.repository.*; import ca.bc.gov.educ.api.grad.report.util.EducGradReportApiConstants; +import ca.bc.gov.educ.api.grad.report.util.Generated; import ca.bc.gov.educ.api.grad.report.util.ThreadLocalStateUtil; import jakarta.transaction.Transactional; import org.apache.commons.codec.binary.Base64; @@ -606,6 +607,7 @@ public boolean deleteSchoolReports(String minCode, String reportTypeCode) { return false; } + @Generated private School getSchool(String minCode, String accessToken) { try { return webClient.get() @@ -623,8 +625,8 @@ private School getSchool(String minCode, String accessToken) { } } - @Transactional - public District getDistrict(String districtCode, String accessToken) { + @Generated + private District getDistrict(String districtCode, String accessToken) { try { return webClient.get() .uri(String.format(constants.getDistrictByMincodeUrl(), districtCode)) @@ -697,8 +699,8 @@ public List getSchoolReportGradStudentData() { return processReportGradStudentDataList(students, new ArrayList<>()); } - @Transactional - public List processReportGradStudentDataList(Page students, List schools) { + @Generated + private List processReportGradStudentDataList(Page students, List schools) { List result = new ArrayList<>(); long startTime = System.currentTimeMillis(); if(students.hasContent()) { @@ -721,8 +723,8 @@ public List processReportGradStudentDataList(Page getNextPageStudentsFromGradStudentApi(Page students, List schools) { + @Generated + private synchronized List getNextPageStudentsFromGradStudentApi(Page students, List schools) { List result = new ArrayList<>(); List studentGuidsInBatch = students.getContent().stream().map(SchoolReportEntity::getGraduationStudentRecordId).distinct().toList(); List studentsInBatch = getReportGradStudentData(fetchAccessToken(), studentGuidsInBatch); @@ -761,6 +763,7 @@ public synchronized List getNextPageStudentsFromGradStude return result; } + @Generated private synchronized ReportGradStudentData getReportGradStudentDataByGraduationStudentRecordIdFromList(UUID id, List studentsInBatch) { for(ReportGradStudentData s: studentsInBatch) { if(s.getGraduationStudentRecordId().equals(id)) { @@ -770,6 +773,7 @@ private synchronized ReportGradStudentData getReportGradStudentDataByGraduationS return null; } + @Generated private synchronized List getReportGradStudentData(String accessToken, List studentGuids) { final ParameterizedTypeReference> responseType = new ParameterizedTypeReference<>() { }; diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/util/Generated.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/util/Generated.java new file mode 100644 index 00000000..0ab0eabe --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/util/Generated.java @@ -0,0 +1,14 @@ +package ca.bc.gov.educ.api.grad.report.util; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Documented +@Retention(RUNTIME) +@Target({TYPE, METHOD, CONSTRUCTOR}) +public @interface Generated { +} From 3a37811957cc3c280b1714742211ec1426296e95 Mon Sep 17 00:00:00 2001 From: arybakov Date: Tue, 16 Apr 2024 11:57:43 -0600 Subject: [PATCH 10/16] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../ca/bc/gov/educ/api/grad/report/service/CommonService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index 81321294..20a21005 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -358,6 +358,7 @@ public List getAllSchoolReportListByReportType(String reportType, return reportList; } + @Generated private void populateSchoolRepors(List reportList) { reportList.forEach(rep -> { String accessToken = fetchAccessToken(); From 0b873fa5a299a9743817f34bddae04348799ad00 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 18 Apr 2024 18:16:16 -0600 Subject: [PATCH 11/16] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../api/grad/report/service/CommonService.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index 20a21005..c7d87d13 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -732,20 +732,20 @@ private synchronized List getNextPageStudentsFromGradStud if(studentsInBatch != null && !schools.isEmpty()) { boolean isDistrictSchool = schools.get(0).length() == 3; if(isDistrictSchool) { - studentsInBatch.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3)))); - studentsInBatch.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincodeAtGrad(), 0, 3)))); + studentsInBatch.removeIf(st -> (schools != null && !schools.isEmpty() && (StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincode(), 0, 3)))); + studentsInBatch.removeIf(st -> (schools != null && !schools.isEmpty() && (StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.substring(st.getMincodeAtGrad(), 0, 3)))); } boolean isSchoolSchool = schools.get(0).length() > 3; if(isSchoolSchool) { - studentsInBatch.removeIf(st -> ((StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincode())))); - studentsInBatch.removeIf(st -> ((StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincodeAtGrad())))); + studentsInBatch.removeIf(st -> (schools != null && !schools.isEmpty() && (StringUtils.isBlank(st.getMincodeAtGrad()) || StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincode())))); + studentsInBatch.removeIf(st -> (schools != null && !schools.isEmpty() && (StringUtils.isNotBlank(st.getMincodeAtGrad()) && !StringUtils.equals(st.getMincode(), st.getMincodeAtGrad())) && !schools.contains(StringUtils.trimToEmpty(st.getMincodeAtGrad())))); } } for(SchoolReportEntity e: students.getContent()) { String paperType = e.getPaperType(); String certificateTypeCode = e.getCertificateTypeCode(); //either transcript or certificate codes ReportGradStudentData s = getReportGradStudentDataByGraduationStudentRecordIdFromList(e.getGraduationStudentRecordId(), studentsInBatch); - if(s != null) { + if(s != null && "CUR".equalsIgnoreCase(s.getStudentStatus())) { ReportGradStudentData dataResult = SerializationUtils.clone(s); dataResult.setPaperType(paperType); if ("YED4".equalsIgnoreCase(paperType)) { @@ -753,12 +753,7 @@ private synchronized List getNextPageStudentsFromGradStud } else { dataResult.setCertificateTypeCode(certificateTypeCode); } - if("YED4".equalsIgnoreCase(paperType) && "CUR".equalsIgnoreCase(s.getStudentStatus())) { - result.add(dataResult); - } - if (!"YED4".equalsIgnoreCase(paperType)) { - result.add(dataResult); - } + result.add(dataResult); } } return result; From 8be02c56d22dc408d175dd277b3beab10e70d1c3 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 18 Apr 2024 18:29:16 -0600 Subject: [PATCH 12/16] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../gov/educ/api/grad/report/service/CommonServiceTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java index 26a54240..6791bbc9 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java @@ -1470,6 +1470,7 @@ public void testGetSchoolReportGradStudentData() { reportGradStudentData.setGraduationStudentRecordId(studentId); reportGradStudentData.setTranscriptTypeCode("BC2018-IND"); reportGradStudentData.setMincode("12345678"); + reportGradStudentData.setStudentStatus("CUR"); GradCertificateTypes certificateTypes = new GradCertificateTypes(); certificateTypes.setCode("E"); @@ -1480,6 +1481,7 @@ public void testGetSchoolReportGradStudentData() { reportGradStudentData = new ReportGradStudentData(); reportGradStudentData.setGraduationStudentRecordId(studentId); + reportGradStudentData.setStudentStatus("CUR"); reportGradStudentDataList.add(reportGradStudentData); @@ -1488,6 +1490,7 @@ public void testGetSchoolReportGradStudentData() { reportGradStudentData.setTranscriptTypeCode("BC2004-IND"); reportGradStudentData.setMincode("12345678"); reportGradStudentData.setMincodeAtGrad("09876543"); + reportGradStudentData.setStudentStatus("CUR"); reportGradStudentDataList.add(reportGradStudentData); @@ -1688,6 +1691,7 @@ public void testGetSchoolReportGradStudentDataForSchools() { reportGradStudentData.setGraduationStudentRecordId(studentId); reportGradStudentData.setTranscriptTypeCode("BC2018-IND"); reportGradStudentData.setMincode(mincode); + reportGradStudentData.setStudentStatus("CUR"); GradCertificateTypes certificateTypes = new GradCertificateTypes(); certificateTypes.setCode("E"); @@ -1698,6 +1702,7 @@ public void testGetSchoolReportGradStudentDataForSchools() { reportGradStudentData = new ReportGradStudentData(); reportGradStudentData.setGraduationStudentRecordId(studentId); + reportGradStudentData.setStudentStatus("CUR"); reportGradStudentDataList.add(reportGradStudentData); @@ -1706,6 +1711,7 @@ public void testGetSchoolReportGradStudentDataForSchools() { reportGradStudentData.setTranscriptTypeCode("BC2004-IND"); reportGradStudentData.setMincode(mincode); reportGradStudentData.setMincodeAtGrad("09876543"); + reportGradStudentData.setStudentStatus("CUR"); reportGradStudentDataList.add(reportGradStudentData); From f2f4237be58787cf3f584826b8ae21be5355ae23 Mon Sep 17 00:00:00 2001 From: arybakov Date: Fri, 19 Apr 2024 17:27:26 -0600 Subject: [PATCH 13/16] GRAD2-2377 HD-22859 (GRAD) YE Distribution run should direct Certificates to School at Graduation, not School of Record --- .../gov/educ/api/grad/report/service/CommonService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index c7d87d13..8f95c688 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -745,7 +745,7 @@ private synchronized List getNextPageStudentsFromGradStud String paperType = e.getPaperType(); String certificateTypeCode = e.getCertificateTypeCode(); //either transcript or certificate codes ReportGradStudentData s = getReportGradStudentDataByGraduationStudentRecordIdFromList(e.getGraduationStudentRecordId(), studentsInBatch); - if(s != null && "CUR".equalsIgnoreCase(s.getStudentStatus())) { + if(s != null) { ReportGradStudentData dataResult = SerializationUtils.clone(s); dataResult.setPaperType(paperType); if ("YED4".equalsIgnoreCase(paperType)) { @@ -753,7 +753,12 @@ private synchronized List getNextPageStudentsFromGradStud } else { dataResult.setCertificateTypeCode(certificateTypeCode); } - result.add(dataResult); + if("YED4".equalsIgnoreCase(paperType) && "CUR".equalsIgnoreCase(s.getStudentStatus())) { + result.add(dataResult); + } + if (!"YED4".equalsIgnoreCase(paperType)) { + result.add(dataResult); + } } } return result; From af68b0da61489adc8857b50508cc46661f688a75 Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Mon, 22 Apr 2024 12:09:06 -0700 Subject: [PATCH 14/16] GRAD2-2570: user request distribution run supports for null distribution date only. GRAD2-2570: user request distribution supports for null distribution date. --- .../api/grad/report/config/RestWebClient.java | 2 +- .../report/controller/CommonController.java | 15 ++- .../GradStudentCertificatesRepository.java | 3 + .../GradStudentTranscriptsRepository.java | 6 + .../grad/report/service/CommonService.java | 22 ++-- .../util/EducGradReportApiConstants.java | 1 + .../controller/CommonControllerTest.java | 23 +++- .../report/service/CommonServiceTest.java | 119 +++++++++++++++++- 8 files changed, 175 insertions(+), 16 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/config/RestWebClient.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/config/RestWebClient.java index 1976c304..1181b393 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/config/RestWebClient.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/config/RestWebClient.java @@ -37,7 +37,7 @@ public WebClient webClient() { return WebClient.builder().uriBuilderFactory(defaultUriBuilderFactory).exchangeStrategies(ExchangeStrategies.builder() .codecs(configurer -> configurer .defaultCodecs() - .maxInMemorySize(300 * 1024 * 1024)) // 100 MB + .maxInMemorySize(300 * 1024 * 1024)) // 300 MB .build()) .build(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java index bab9cdb6..5f5180bb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java @@ -271,13 +271,24 @@ public ResponseEntity updateStudentCredentialPosting(@RequestParam Stri @PostMapping(EducGradReportApiConstants.USER_REQUEST_DIS_RUN) @PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT_CERTIFICATES) - @Operation(summary = "Read All Student Transcripts/Certificates for User Req Distribution", description = "Read All Student Transcripts for Distribution", tags = { "Certificates" }) + @Operation(summary = "Read All Student Transcripts/Certificates for User Req Distribution", description = "Read All Student Credentials for Distribution", tags = { "Certificates" }) @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) public ResponseEntity> getStudentCredentialsForUserRequestDisRun( @PathVariable String credentialType, @RequestBody StudentSearchRequest studentSearchRequest, @RequestHeader(name="Authorization") String accessToken) { logger.debug("getStudentCredentialsForUserRequestDisRun : "); - return response.GET(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,studentSearchRequest,accessToken.replace(BEARER, ""))); + return response.GET(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,studentSearchRequest,false,accessToken.replace(BEARER, ""))); + } + + @PostMapping(EducGradReportApiConstants.USER_REQUEST_DIS_RUN_WITH_NULL_DISTRIBUTION_DATE) + @PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT_CERTIFICATES) + @Operation(summary = "Read All Student Transcripts/Certificates with Null Distribution Date for User Req Distribution", description = "Read All Student Credentials with Null Distribution Date for Distribution", tags = { "Certificates" }) + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")}) + public ResponseEntity> getStudentCredentialsForUserRequestDisRunWithNullDistributionDate( + @PathVariable String credentialType, @RequestBody StudentSearchRequest studentSearchRequest, + @RequestHeader(name="Authorization") String accessToken) { + logger.debug("getStudentCredentialsForRegenCertRun : "); + return response.GET(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,studentSearchRequest,true,accessToken.replace(BEARER, ""))); } @DeleteMapping(EducGradReportApiConstants.ARCH_ACHIEVEMENTS_BY_STUDENTID) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/repository/GradStudentCertificatesRepository.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/repository/GradStudentCertificatesRepository.java index 9a4edaeb..84faae7a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/repository/GradStudentCertificatesRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/repository/GradStudentCertificatesRepository.java @@ -34,4 +34,7 @@ public interface GradStudentCertificatesRepository extends JpaRepository findRecordsForUserRequest(List subList); + @Query("select new ca.bc.gov.educ.api.grad.report.model.dto.StudentCredentialDistribution(c.id,c.gradCertificateTypeCode,c.studentID,cert.paperType,c.documentStatusCode,c.distributionDate) from GradStudentCertificatesEntity c inner join GradCertificateTypesEntity cert on cert.code = c.gradCertificateTypeCode where c.studentID in (:subList) and c.distributionDate is null") + List findRecordsWithNullDistributionDateForUserRequest(List subList); + } diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/repository/GradStudentTranscriptsRepository.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/repository/GradStudentTranscriptsRepository.java index cf3d543a..e4bfffc4 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/repository/GradStudentTranscriptsRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/repository/GradStudentTranscriptsRepository.java @@ -43,6 +43,12 @@ public interface GradStudentTranscriptsRepository extends JpaRepository findRecordsForUserRequestByStudentIdOnly(List subList); + @Query("select new ca.bc.gov.educ.api.grad.report.model.dto.StudentCredentialDistribution(c.id,c.transcriptTypeCode,c.studentID,tran.paperType,c.documentStatusCode,c.distributionDate) from GradStudentTranscriptsEntity c inner join TranscriptTypesEntity tran on tran.code = c.transcriptTypeCode where c.studentID in (:subList) and c.documentStatusCode='COMPL' and c.distributionDate is null") + List findRecordsWithNullDistributionDateForUserRequest(List subList); + + @Query("select new ca.bc.gov.educ.api.grad.report.model.dto.StudentCredentialDistribution(c.id,c.transcriptTypeCode,c.studentID,tran.paperType,c.documentStatusCode,c.distributionDate) from GradStudentTranscriptsEntity c inner join TranscriptTypesEntity tran on tran.code = c.transcriptTypeCode where c.studentID in (:subList) and c.distributionDate is null") + List findRecordsWithNullDistributionDateForUserRequestByStudentIdOnly(List subList); + @Query("select new ca.bc.gov.educ.api.grad.report.model.dto.SchoolStudentCredentialDistribution(c.id,c.transcriptTypeCode,c.studentID,c.documentStatusCode) from GradStudentTranscriptsEntity c where c.transcriptUpdateDate is null or c.transcriptUpdateDate < c.updateDate") List findByTranscriptUpdateDate(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index 8f95c688..fc40181b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -505,7 +505,7 @@ public boolean updateStudentCredentialPosting(UUID studentID, String credentialT return false; } - public List getStudentCredentialsForUserRequestDisRun(String credentialType, StudentSearchRequest studentSearchRequest, String accessToken) { + public List getStudentCredentialsForUserRequestDisRun(String credentialType, StudentSearchRequest studentSearchRequest, boolean onlyWithNullDistributionDate, String accessToken) { List scdList = new ArrayList<>(); List studentIDs = studentSearchRequest.getStudentIDs(); if(studentIDs == null || studentIDs.isEmpty()) { @@ -518,30 +518,36 @@ public List getStudentCredentialsForUserRequestDi partitions.add(studentIDs.subList(i, Math.min(i + partitionSize, studentIDs.size()))); } if (credentialType.equalsIgnoreCase("OC") || credentialType.equalsIgnoreCase("RC")) { - processCertificate(partitions, scdList); + processCertificate(partitions, scdList, onlyWithNullDistributionDate); } else if (credentialType.equalsIgnoreCase("OT") || credentialType.equalsIgnoreCase("RT")) { - processTranscript(partitions, studentSearchRequest, scdList); + processTranscript(partitions, studentSearchRequest, scdList, onlyWithNullDistributionDate); } } return scdList; } - private void processCertificate(List> partitions, List scdList) { + private void processCertificate(List> partitions, List scdList, boolean onlyWithNullDistributionDate) { for (List subList : partitions) { - List scdSubList = gradStudentCertificatesRepository.findRecordsForUserRequest(subList); + List scdSubList = onlyWithNullDistributionDate? + gradStudentCertificatesRepository.findRecordsWithNullDistributionDateForUserRequest(subList) : + gradStudentCertificatesRepository.findRecordsForUserRequest(subList); if (!scdSubList.isEmpty()) { scdList.addAll(scdSubList); } } } - private void processTranscript(List> partitions, StudentSearchRequest studentSearchRequest, List scdList) { + private void processTranscript(List> partitions, StudentSearchRequest studentSearchRequest, List scdList, boolean onlyWithNullDistributionDate) { for (List subList : partitions) { List scdSubList; if (!studentSearchRequest.getPens().isEmpty()) { - scdSubList = gradStudentTranscriptsRepository.findRecordsForUserRequestByStudentIdOnly(subList); + scdSubList = onlyWithNullDistributionDate? + gradStudentTranscriptsRepository.findRecordsWithNullDistributionDateForUserRequestByStudentIdOnly(subList) + : gradStudentTranscriptsRepository.findRecordsForUserRequestByStudentIdOnly(subList); } else { - scdSubList = gradStudentTranscriptsRepository.findRecordsForUserRequest(subList); + scdSubList = onlyWithNullDistributionDate? + gradStudentTranscriptsRepository.findRecordsWithNullDistributionDateForUserRequest(subList) + : gradStudentTranscriptsRepository.findRecordsForUserRequest(subList); } if (!scdSubList.isEmpty()) { scdList.addAll(scdSubList); diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/util/EducGradReportApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/util/EducGradReportApiConstants.java index 9d0d6e47..468d4237 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/util/EducGradReportApiConstants.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/util/EducGradReportApiConstants.java @@ -66,6 +66,7 @@ private EducGradReportApiConstants(){} public static final String STUDENT_TRANSCRIPT_BY_DIST_DATE_N_STATUS_YEARLY = "/gettranscriptsfordistributionyearly"; public static final String USER_REQUEST_DIS_RUN = "/userrequest/{credentialType}"; + public static final String USER_REQUEST_DIS_RUN_WITH_NULL_DISTRIBUTION_DATE = "/userrequest/notyetdistributed/{credentialType}"; public static final String GET_STUDENT_CERTIFICATE_BY_CERTIFICATE_CODE_MAPPING = "/certificate/{certificateTypeCode}"; public static final String GET_STUDENT_REPORT_BY_REPORT_CODE_MAPPING = "/report/{reportTypeCode}"; diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java index c6bec997..19217fa1 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java @@ -479,11 +479,30 @@ public void testGetAllStudentCredentialDistributionList() { final StudentCredentialDistribution cred = new StudentCredentialDistribution(UUID.randomUUID(),"BC2018-IND",studentID,"YED4","COMPL", new Date()); list.add(cred); - Mockito.when(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,req,"accessToken")).thenReturn(list); + Mockito.when(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,req,false,"accessToken")).thenReturn(list); commonController.getStudentCredentialsForUserRequestDisRun(credentialType,req,"accessToken"); - Mockito.verify(commonService).getStudentCredentialsForUserRequestDisRun(credentialType,req,"accessToken"); + Mockito.verify(commonService).getStudentCredentialsForUserRequestDisRun(credentialType,req,false,"accessToken"); } + @Test + public void testGetAllStudentCredentialDistributionListWithNullDistributionDate() { + // UUID + final UUID studentID = UUID.randomUUID(); + final String credentialType = "E"; + final StudentSearchRequest req = new StudentSearchRequest(); + req.setPens(List.of("2131231213")); + + // Student Certificate Types + final List list = new ArrayList<>(); + final StudentCredentialDistribution cred = new StudentCredentialDistribution(UUID.randomUUID(),"BC2018-IND",studentID,"YED4","COMPL", new Date()); + list.add(cred); + + Mockito.when(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,req,true,"accessToken")).thenReturn(list); + commonController.getStudentCredentialsForUserRequestDisRunWithNullDistributionDate(credentialType,req,"accessToken"); + Mockito.verify(commonService).getStudentCredentialsForUserRequestDisRun(credentialType,req,true,"accessToken"); + } + + @Test public void testGetAllStudentTranscriptDistributionYearlyList() { // Student Certificate Types diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java index 6791bbc9..467aedd1 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java @@ -904,7 +904,41 @@ public void testGetStudentCredentialsForUserRequestDisRun_OC() { Mockito.when(gradStudentCertificatesRepository.findRecordsForUserRequest(studentList)).thenReturn(scdSubList); - List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,new StudentSearchRequest(),null); + List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,new StudentSearchRequest(),false,null); + assertThat(result).isNotEmpty(); + + } + + @Test + public void testGetStudentCredentialsForUserRequestDisRun_OC_with_Null_DistributionDate() { + + String credentialType = "OC"; + GraduationStudentRecordSearchResult res = new GraduationStudentRecordSearchResult(); + + List studList= new ArrayList<>(); + GraduationStudentRecord rec = new GraduationStudentRecord(); + rec.setLegalFirstName("asda"); + rec.setStudentID(new UUID(1,1)); + studList.add(rec.getStudentID()); + res.setStudentIDs(studList); + + List scdSubList = new ArrayList<>(); + StudentCredentialDistribution scdSub = new StudentCredentialDistribution(new UUID(4,4),"E",new UUID(5,5),"YED4","COMPL", new Date()); + scdSubList.add(scdSub); + + List studentList = new ArrayList<>(); + studentList.add(new UUID(1,1)); + + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(constants.getGradStudentApiStudentForSpcGradListUrl())).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(Mono.just(res)); + + Mockito.when(gradStudentCertificatesRepository.findRecordsWithNullDistributionDateForUserRequest(studentList)).thenReturn(scdSubList); + + List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,new StudentSearchRequest(),true,null); assertThat(result).isNotEmpty(); } @@ -973,7 +1007,46 @@ public void testGetStudentCredentialsForUserRequestDisRun_OT() { Mockito.when(gradStudentTranscriptsRepository.findRecordsForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); - List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,req,null); + List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,req,false,null); + assertThat(result.size()).isEqualTo(1); + + } + + @Test + public void testGetStudentCredentialsWithNullDistributionDateForUserRequestDisRun_OT() { + + String credentialType = "OT"; + GraduationStudentRecordSearchResult res = new GraduationStudentRecordSearchResult(); + + List studList= new ArrayList<>(); + GraduationStudentRecord rec = new GraduationStudentRecord(); + rec.setLegalFirstName("asda"); + rec.setStudentID(new UUID(1,1)); + studList.add(rec.getStudentID()); + res.setStudentIDs(studList); + + List scdSubList = new ArrayList<>(); + StudentCredentialDistribution scdSub = new StudentCredentialDistribution(new UUID(4,4),"E",new UUID(5,5),"YED4","COMPL", new Date()); + scdSubList.add(scdSub); + + List studentList = new ArrayList<>(); + studentList.add(new UUID(1,1)); + + StudentSearchRequest req = new StudentSearchRequest(); + List penList = new ArrayList<>(); + penList.add("13123111"); + req.setPens(penList); + + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(constants.getGradStudentApiStudentForSpcGradListUrl())).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(Mono.just(res)); + + Mockito.when(gradStudentTranscriptsRepository.findRecordsWithNullDistributionDateForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); + + List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,req,true,null); assertThat(result.size()).isEqualTo(1); } @@ -1013,7 +1086,47 @@ public void testGetStudentCredentialsForUserRequestDisRun_OT_Prgm() { Mockito.when(gradStudentTranscriptsRepository.findRecordsForUserRequest(studentList)).thenReturn(scdSubList); - List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,req,null); + List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,req,false,null); + assertThat(result.size()).isEqualTo(1); + + } + + @Test + public void testGetStudentCredentialsWithNullDistributionDateForUserRequestDisRun_OT_Prgm() { + + String credentialType = "OT"; + GraduationStudentRecordSearchResult res = new GraduationStudentRecordSearchResult(); + + List studList= new ArrayList<>(); + GraduationStudentRecord rec = new GraduationStudentRecord(); + rec.setLegalFirstName("asda"); + rec.setStudentID(new UUID(1,1)); + studList.add(rec.getStudentID()); + res.setStudentIDs(studList); + + List scdSubList = new ArrayList<>(); + StudentCredentialDistribution scdSub = new StudentCredentialDistribution(new UUID(4,4),"E",new UUID(5,5),"YED4","COMPL", new Date()); + scdSubList.add(scdSub); + + List studentList = new ArrayList<>(); + studentList.add(new UUID(1,1)); + + StudentSearchRequest req = new StudentSearchRequest(); + List pgList = new ArrayList<>(); + pgList.add("2018-EN"); + req.setPrograms(pgList); + req.setPens(new ArrayList<>()); + + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(constants.getGradStudentApiStudentForSpcGradListUrl())).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(Mono.just(res)); + + Mockito.when(gradStudentTranscriptsRepository.findRecordsWithNullDistributionDateForUserRequest(studentList)).thenReturn(scdSubList); + + List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,req,true,null); assertThat(result.size()).isEqualTo(1); } From db062177be9f02f1a0e21c8d5dd6e2a7da1436ea Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Tue, 23 Apr 2024 09:13:05 -0700 Subject: [PATCH 15/16] GRAD2-2570: the issue with pen list search is fixed not to filter null distribution date out. GRAD2-2570: the issue with pen list search is fixed not to filter null distribution date out. --- .../educ/api/grad/report/controller/CommonController.java | 7 +++++-- .../api/grad/report/controller/CommonControllerTest.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java index 5f5180bb..851a24ac 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/controller/CommonController.java @@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Objects; import java.util.UUID; @CrossOrigin @@ -287,8 +288,10 @@ public ResponseEntity> getStudentCredentials public ResponseEntity> getStudentCredentialsForUserRequestDisRunWithNullDistributionDate( @PathVariable String credentialType, @RequestBody StudentSearchRequest studentSearchRequest, @RequestHeader(name="Authorization") String accessToken) { - logger.debug("getStudentCredentialsForRegenCertRun : "); - return response.GET(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,studentSearchRequest,true,accessToken.replace(BEARER, ""))); + logger.debug("getStudentCredentialsForUserRequestDisRunWithNullDistributionDate : "); + boolean isPenNumberSearch = studentSearchRequest.getPens()!= null && !studentSearchRequest.getPens().isEmpty() + && !studentSearchRequest.getPens().stream().filter(StringUtils::isNotBlank).toList().isEmpty(); + return response.GET(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,studentSearchRequest,!isPenNumberSearch,accessToken.replace(BEARER, ""))); } @DeleteMapping(EducGradReportApiConstants.ARCH_ACHIEVEMENTS_BY_STUDENTID) diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java index 19217fa1..c98cc1ea 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/controller/CommonControllerTest.java @@ -490,7 +490,7 @@ public void testGetAllStudentCredentialDistributionListWithNullDistributionDate( final UUID studentID = UUID.randomUUID(); final String credentialType = "E"; final StudentSearchRequest req = new StudentSearchRequest(); - req.setPens(List.of("2131231213")); + req.setDistricts(List.of("005")); // Student Certificate Types final List list = new ArrayList<>(); From fa717f9acf23f6ade569235b182cbcd0464da0ea Mon Sep 17 00:00:00 2001 From: githubmamatha <106563495+githubmamatha@users.noreply.github.com> Date: Wed, 24 Apr 2024 09:37:01 -0700 Subject: [PATCH 16/16] Update pom.xml --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index 6b20823a..5a9f2cd8 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ ca.bc.gov.educ educ-grad-graduation-report-api - 1.8.45 + 1.8.46 educ-grad-graduation-report-api Grad Graduation Report API for GRAD team