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-3182: task is completed. #558

Merged
merged 4 commits into from
Jan 23, 2025
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 @@ -75,14 +75,13 @@ public Map<String, ExecutionContext> partition(int gridSize) {
}
} else {
List<UUID> studentGuidsBySearch = restUtils.getStudentIDsBySearchCriteriaOrAll(searchRequest, distributionSummaryDTO);
List<String> studentGuidsBySearchString = studentGuidsBySearch.stream().map(UUID::toString).toList();
if(!studentGuidsBySearch.isEmpty()) {
for (String reportType : searchRequest.getReportTypes()) {
Long studentReportsCount = restUtils.getTotalReportsForProcessing(studentGuidsBySearch, reportType, distributionSummaryDTO);
Integer guidsRowCount = Integer.min(studentReportsCount.intValue(), DEFAULT_ROW_COUNT);
totalStudentReportsCount += guidsRowCount;
updateBatchJobHistory(algorithmJobHistory, totalStudentReportsCount);
List<UUID> reportTypeGuids = restUtils.getReportStudentIDsByStudentIDsAndReportType(studentGuidsBySearchString, reportType, guidsRowCount, distributionSummaryDTO);
List<UUID> reportTypeGuids = restUtils.getReportStudentIDsByStudentIDsAndReportType(studentGuidsBySearch, reportType, guidsRowCount, distributionSummaryDTO);
finalStudentGuids.addAll(reportTypeGuids);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Map<String, ExecutionContext> partition(int gridSize) {
// Clean up existing reports before running new one
logger.debug("Delete School Reports for Monthly Distribution");
long startTime = System.currentTimeMillis();
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL");
restUtils.deleteSchoolReportRecord("ADDRESS_LABEL_SCHL");
long endTime = System.currentTimeMillis();
long diff = (endTime - startTime)/1000;
logger.debug("Old School Reports deleted in {} sec", diff);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Map<String, ExecutionContext> partition(int gridSize) {
String transmissionType = jobParameters.getString("transmissionType");
PsiCredentialRequest req = (PsiCredentialRequest)jsonTransformer.unmarshall(searchRequest, PsiCredentialRequest.class);
String accessToken = restUtils.getAccessToken();
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_PSI");
restUtils.deleteSchoolReportRecord("ADDRESS_LABEL_PSI");

List<PsiCredentialDistribution> credentialList = getRecordsForPSIUserReqDisRun(req,transmissionType,accessToken);
if(!credentialList.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public Map<String, ExecutionContext> partition(int gridSize) {
logger.debug("Delete School Reports for Supplemental Distribution");
long startTime = System.currentTimeMillis();
// Clean up existing reports before running new one
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL");
restUtils.deleteSchoolReportRecord("", "DISTREP_SC");
restUtils.deleteSchoolReportRecord("ADDRESS_LABEL_SCHL");
restUtils.deleteSchoolReportRecord("DISTREP_SC");
long endTime = System.currentTimeMillis();
long diff = (endTime - startTime)/1000;
logger.debug("Old School Reports deleted in {} sec", diff);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public Map<String, ExecutionContext> partition(int gridSize) {
// Clean up existing reports before running new one
logger.debug("Delete School Reports for Yearly Distribution");
long startTime = System.currentTimeMillis();
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL");
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_YE");
restUtils.deleteSchoolReportRecord("", "NONGRADDISTREP_SC");
restUtils.deleteSchoolReportRecord("", "NONGRADDISTREP_SD");
restUtils.deleteSchoolReportRecord("ADDRESS_LABEL_SCHL");
restUtils.deleteDistrictReportRecord("ADDRESS_LABEL_YE");
restUtils.deleteSchoolReportRecord("NONGRADDISTREP_SC");
restUtils.deleteDistrictReportRecord("NONGRADDISTREP_SD");
long endTime = System.currentTimeMillis();
long diff = (endTime - startTime)/1000;
logger.debug("Old School Reports deleted in {} sec", diff);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class DistributionRunYearlyPartitioner extends BasePartitioner {

Expand All @@ -29,8 +30,8 @@ public Map<String, ExecutionContext> partition(int gridSize) {
// Clean up existing reports before running new one
logger.debug("Delete School Reports for Yearly Distribution");
long startTime = System.currentTimeMillis();
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL");
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_YE");
restUtils.deleteSchoolReportRecord("ADDRESS_LABEL_SCHL");
restUtils.deleteDistrictReportRecord("ADDRESS_LABEL_YE");
long endTime = System.currentTimeMillis();
long diff = (endTime - startTime)/1000;
logger.debug("Old School Reports deleted in {} sec", diff);
Expand All @@ -44,10 +45,13 @@ public Map<String, ExecutionContext> partition(int gridSize) {
filterByStudentSearchRequest(eligibleStudentSchoolDistricts);
if(!eligibleStudentSchoolDistricts.isEmpty()) {
updateBatchJobHistory(createBatchJobHistory(), (long) eligibleStudentSchoolDistricts.size());
List<String> schoolOfRecords = eligibleStudentSchoolDistricts.stream().map(StudentCredentialDistribution::getSchoolOfRecord).distinct().toList();
for(String mincode: schoolOfRecords) {
restUtils.deleteSchoolReportRecord(mincode, "DISTREP_YE_SC");
restUtils.deleteSchoolReportRecord(mincode, "DISTREP_YE_SD");
List<UUID> schoolIds = eligibleStudentSchoolDistricts.stream().map(StudentCredentialDistribution::getSchoolId).distinct().toList();
for(UUID schoolId: schoolIds) {
restUtils.deleteSchoolReportRecord(schoolId, "DISTREP_YE_SC");
}
List<UUID> districtIds = eligibleStudentSchoolDistricts.stream().map(StudentCredentialDistribution::getDistrictId).distinct().toList();
for(UUID districtId: districtIds) {
restUtils.deleteDistrictReportRecord(districtId, "DISTREP_YE_SD");
}
return getStringExecutionContextMap(gridSize, eligibleStudentSchoolDistricts, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public Map<String, ExecutionContext> partition(int gridSize) {
boolean processAllReports = "ALL".equalsIgnoreCase(searchRequest.getActivityCode());

List<UUID> schoolDistricts = gradSchoolOfRecordFilter.filterSchoolsByStudentSearch(searchRequest);
// List<UUID> schoolDistricts = eligibleStudentSchoolDistricts.stream().sorted().toList();
if(log.isDebugEnabled()) {
log.debug("Final list of eligible District / School codes {}", String.join(", ", schoolDistricts.toString()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,24 @@ public void updateStudentCredentialRecord(UUID studentID, String credentialTypeC
restService.get(url, Boolean.class, accessToken);
}

public void updateSchoolReportRecord(String schoolOfRecord, String reportTypeCode, String accessToken) {
public void deleteSchoolReportRecord(UUID schoolId, String reportTypeCode) {
ThreadLocalStateUtil.setCorrelationID(UUID.randomUUID().toString());
restService.get(String.format(constants.getUpdateSchoolReport(),schoolOfRecord,reportTypeCode), Boolean.class, accessToken);
restService.delete(String.format(constants.getDeleteSchoolReportsBySchoolIdAndReportType(),schoolId, reportTypeCode), Boolean.class);
}

public void deleteSchoolReportRecord(String schoolOfRecord, String reportTypeCode) {
public void deleteSchoolReportRecord(String reportTypeCode) {
ThreadLocalStateUtil.setCorrelationID(UUID.randomUUID().toString());
restService.delete(String.format(constants.getUpdateSchoolReport(),schoolOfRecord,reportTypeCode), Boolean.class);
restService.delete(String.format(constants.getDeleteSchoolReportsByReportType(),reportTypeCode), Boolean.class);
}

public void deleteDistrictReportRecord(UUID districtId, String reportTypeCode) {
ThreadLocalStateUtil.setCorrelationID(UUID.randomUUID().toString());
restService.delete(String.format(constants.getDeleteDistrictReportsByDistrictIdAndReportType(),districtId, reportTypeCode), Boolean.class);
}

public void deleteDistrictReportRecord(String reportTypeCode) {
ThreadLocalStateUtil.setCorrelationID(UUID.randomUUID().toString());
restService.delete(String.format(constants.getDeleteDistrictReportsByReportType(),reportTypeCode), Boolean.class);
}

public List<StudentCredentialDistribution> getStudentsForUserReqDisRun(String credentialType, StudentSearchRequest req) {
Expand Down Expand Up @@ -672,11 +682,11 @@ public List<SchoolReport> getSchoolReportsLiteByReportType(String reportType, Sc
return schoolReportsLite;
}

public List<UUID> getReportStudentIDsByStudentIDsAndReportType(List<String> finalSchoolDistricts, String reportType, Integer rowCount, DistributionSummaryDTO summaryDTO) {
public List<UUID> getReportStudentIDsByStudentIDsAndReportType(List<UUID> studentGuids, String reportType, Integer rowCount, DistributionSummaryDTO summaryDTO) {
List<UUID> result = new ArrayList<>();
ThreadLocalStateUtil.setCorrelationID(UUID.randomUUID().toString());
try {
var response = restService.post(String.format(constants.getGradStudentReportsGuidsUrl(), reportType, rowCount), finalSchoolDistricts, List.class);
var response = restService.post(String.format(constants.getGradStudentReportsGuidsUrl(), reportType, rowCount), studentGuids, List.class);
if (response != null) {
List<UUID> guids = jsonTransformer.convertValue(response, new TypeReference<>() {});
result.addAll(guids);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,17 @@ public class EducGradBatchGraduationApiConstants {
@Value("${endpoint.grad-student-api.read-grad-student-record-batch}")
private String readGradStudentRecordBatch;

@Value("${endpoint.grad-graduation-report-api.update-school-report.url}")
private String updateSchoolReport;
@Value("${endpoint.grad-graduation-report-api.delete-school-report-by-report-type-only.url}")
private String deleteSchoolReportsByReportType;

@Value("${endpoint.grad-graduation-report-api.delete-school-report.url}")
private String deleteSchoolReportsBySchoolIdAndReportType;

@Value("${endpoint.grad-graduation-report-api.delete-district-report-by-report-type-only.url}")
private String deleteDistrictReportsByReportType;

@Value("${endpoint.grad-graduation-report-api.delete-district-report.url}")
private String deleteDistrictReportsByDistrictIdAndReportType;

@Value("${endpoint.grad-graduation-report-api.update-student-report.url}")
private String updateStudentReport;
Expand Down
14 changes: 10 additions & 4 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ endpoint:
get-deceased-student-id-list: ${GRAD_STUDENT_API}api/v1/student/deceasedstudentid
grad-graduation-report-api:
get-school-reports-count:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/count?reportType=%s
url: ${GRAD_GRADUATION_REPORT_API}api/v2/graduationreports/count?reportType=%s
get-student-reports-guid:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/studentreportsbystudentid?reportType=%s&rowCount=%s
url: ${GRAD_GRADUATION_REPORT_API}api/v2/graduationreports/studentreportsbystudentid?reportType=%s&rowCount=%s
archive-school-reports:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/archive?batchId=%s&reportType=%s
get-transcript-list:
Expand All @@ -231,8 +231,14 @@ endpoint:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/certificatetype/%s
get-school-reports-lite-by-report-type:
url: ${GRAD_GRADUATION_REPORT_API}api/v2/graduationreports/schoolreport/search?reportTypeCode=%s&isLight=true
update-school-report:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/updateschoolreport?mincode=%s&reportTypeCode=%s
delete-school-report:
url: ${GRAD_GRADUATION_REPORT_API}api/v2/graduationreports/schoolreports/%s/%s
delete-school-report-by-report-type-only:
url: ${GRAD_GRADUATION_REPORT_API}api/v2/graduationreports/schoolreports?reportTypeCode=%s
delete-district-report:
url: ${GRAD_GRADUATION_REPORT_API}api/v2/graduationreports/district-report/%s/%s
delete-district-report-by-report-type-only:
url: ${GRAD_GRADUATION_REPORT_API}api/v2/graduationreports/district-report?reportTypeCode=%s
update-student-report:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/studentreports?reportTypeCode=%s
delete-student-report:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1303,33 +1303,48 @@ public void testUpdateStudentGradRecordHistory() {
}

@Test
public void testUpdateSchoolReportRecord() {
final String mincode = "123213123";
public void testDeleteSchoolReportRecordByReportType() {
String reportTypeCode = "E";

when(this.restService.get(String.format(constants.getUpdateSchoolReport(),mincode,reportTypeCode), Boolean.class)).thenReturn(true);
when(this.restService.delete(String.format(constants.getDeleteSchoolReportsByReportType(),reportTypeCode), Boolean.class)).thenReturn(true);

restUtils.deleteSchoolReportRecord(reportTypeCode);
assertThat(reportTypeCode).isEqualTo("E");
}

@Test
public void testDeleteSchoolReportRecord() {
final UUID schoolId = UUID.randomUUID();
String reportTypeCode = "E";

mockTokenResponseObject();

restUtils.updateSchoolReportRecord(mincode,reportTypeCode,null);
when(this.restService.delete(String.format(constants.getDeleteSchoolReportsBySchoolIdAndReportType(),schoolId,reportTypeCode), Boolean.class)).thenReturn(true);

this.restUtils.deleteSchoolReportRecord(schoolId,reportTypeCode);
assertThat(reportTypeCode).isEqualTo("E");
}

when(this.restService.delete(String.format(constants.getUpdateSchoolReport(),mincode,reportTypeCode), Boolean.class)).thenReturn(true);
@Test
public void testDeleteDistrictReportRecordByReportType() {
String reportTypeCode = "E";

restUtils.deleteSchoolReportRecord(mincode,reportTypeCode);
when(this.restService.delete(String.format(constants.getDeleteDistrictReportsByReportType(),reportTypeCode), Boolean.class)).thenReturn(true);

restUtils.deleteDistrictReportRecord(reportTypeCode);
assertThat(reportTypeCode).isEqualTo("E");
}

@Test
public void testDeleteSchoolReportRecord() {
final String mincode = "123213123";
public void testDeleteDistrictReportRecord() {
final UUID districtId = UUID.randomUUID();
String reportTypeCode = "E";

mockTokenResponseObject();

when(this.restService.delete(String.format(constants.getUpdateSchoolReport(),mincode,reportTypeCode), Boolean.class)).thenReturn(true);
when(this.restService.delete(String.format(constants.getDeleteDistrictReportsByDistrictIdAndReportType(),districtId,reportTypeCode), Boolean.class)).thenReturn(true);

this.restUtils.deleteSchoolReportRecord(mincode,reportTypeCode);
this.restUtils.deleteDistrictReportRecord(districtId,reportTypeCode);
assertThat(reportTypeCode).isEqualTo("E");
}

Expand Down Expand Up @@ -1526,7 +1541,7 @@ public void testGetTotalSchoolReportsRegeneration() {
@Test
public void testGetReportStudentIDsByStudentIDsAndReportType() {
UUID uuid = UUID.randomUUID();
List<String> studentIDsIn = Arrays.asList(uuid.toString());
List<UUID> studentIDsIn = Arrays.asList(uuid);
List<UUID> studentIDsOut = Arrays.asList(uuid);

mockTokenResponseObject();
Expand All @@ -1542,8 +1557,7 @@ public void testGetReportStudentIDsByStudentIDsAndReportType() {
@Test
public void testGetReportStudentIDsByStudentIDsAndReportTypeError() {
UUID uuid = UUID.randomUUID();
List<String> studentIDsIn = Arrays.asList(uuid.toString());
List<UUID> studentIDsOut = Arrays.asList(uuid);
List<UUID> studentIDsIn = Arrays.asList(uuid);

mockTokenResponseObject();

Expand Down
10 changes: 8 additions & 2 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,14 @@ endpoint:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/certificatetype/%s
get-school-reports-lite-by-report-type:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/schoolreport/search?reportTypeCode=%s&isLight=true
update-school-report:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/updateschoolreports?mincode=%s&reportTypeCode=%s
delete-school-report:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/graduationreports/schoolreports/%s/%s
delete-school-report-by-report-type-only:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/graduationreports/schoolreports?reportTypeCode=%s
delete-district-report:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/graduationreports/district-report/%s/%s
delete-district-report-by-report-type-only:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v2/graduationreports/district-report?reportTypeCode=%s
update-student-report:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studentreports?reportTypeCode=%s
delete-student-report:
Expand Down
Loading