Skip to content

Commit

Permalink
Merge pull request #480 from bcgov/feature/GRAD2-2570
Browse files Browse the repository at this point in the history
GRAD2-2570: the issues have been resolved to support null distributio…
  • Loading branch information
arybakov-cgi authored Apr 22, 2024
2 parents 9c6b7a3 + 9a8cf43 commit ba68fb5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public WebClient webClient() {
return WebClient.builder().exchangeStrategies(ExchangeStrategies.builder()
.codecs(configurer -> configurer
.defaultCodecs()
.maxInMemorySize(300 * 1024 * 1024)) // 100 MB
.maxInMemorySize(300 * 1024 * 1024)) // 300 MB
.build()).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.Instant;
import java.time.LocalDateTime;

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,18 @@ public class RegenerateCertificatePartitioner extends BasePartitioner {

@Override
public Map<String, ExecutionContext> partition(int gridSize) {
ResponseObj res = restUtils.getTokenResponseObject();
String accessToken = null;
if (res != null) {
accessToken = res.getAccess_token();
}
List<StudentCredentialDistribution> credentialList = new ArrayList<>();
JobParameters jobParameters = context.getJobParameters();
String searchRequest = jobParameters.getString(SEARCH_REQUEST);
CertificateRegenerationRequest certificateRegenerationRequest = (CertificateRegenerationRequest)jsonTransformer.unmarshall(searchRequest, CertificateRegenerationRequest.class);
if (certificateRegenerationRequest.runForAll()) {
if (certificateRegenerationRequest == null || certificateRegenerationRequest.runForAll()) {
Mono<DistributionDataParallelDTO> parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData();
DistributionDataParallelDTO parallelDTO = parallelDTOMono.block();
if(parallelDTO != null) {
credentialList.addAll(parallelDTO.certificateList());
}
} else {
credentialList.addAll(getStudentsForUserReqRun(certificateRegenerationRequest, accessToken));
credentialList.addAll(getStudentsForUserReqRun(certificateRegenerationRequest));
}

Set<UUID> studentSet = new HashSet<>();
Expand Down Expand Up @@ -85,9 +80,9 @@ public Map<String, ExecutionContext> partition(int gridSize) {
}

// retrieve students based on the search criteria requested by user
private List<StudentCredentialDistribution> getStudentsForUserReqRun(CertificateRegenerationRequest certificateRegenerationRequest, String accessToken) {
private List<StudentCredentialDistribution> getStudentsForUserReqRun(CertificateRegenerationRequest certificateRegenerationRequest) {
if(certificateRegenerationRequest != null && "Y".equalsIgnoreCase(certificateRegenerationRequest.getRunMode())) {
return restUtils.getStudentsForUserReqDisRun("OC", certificateRegenerationRequest);
return restUtils.getStudentsForUserReqDisRunWithNullDistributionDate("OC", certificateRegenerationRequest);
} else {
return new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,20 @@ public List<StudentCredentialDistribution> getStudentsForUserReqDisRun(String cr
.block();
}

public List<StudentCredentialDistribution> getStudentsForUserReqDisRunWithNullDistributionDate(String credentialType, StudentSearchRequest req) {
UUID correlationID = UUID.randomUUID();
String accessToken = getAccessToken();
final ParameterizedTypeReference<List<StudentCredentialDistribution>> responseType = new ParameterizedTypeReference<>() {
};
return this.webClient.post()
.uri(String.format(constants.getStudentDataForUserReqDisRunWithNullDistributionDate(),credentialType))
.headers(h -> { h.setBearerAuth(accessToken); h.set(EducGradBatchGraduationApiConstants.CORRELATION_ID, correlationID.toString()); })
.body(BodyInserters.fromValue(req))
.retrieve()
.bodyToMono(responseType)
.block();
}

public void updateStudentGradRecord(UUID studentID, Long batchId,String activityCode) {
//Grad2-1931 not updating the school record if student id does not exist.
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public class EducGradBatchGraduationApiConstants {
@Value("${endpoint.grad-graduation-report-api.user-req-dis-run.url}")
private String studentDataForUserReqDisRun;

@Value("${endpoint.grad-graduation-report-api.user-req-dis-run-for-not-yet-distributed.url}")
private String studentDataForUserReqDisRunWithNullDistributionDate;

@Value("${endpoint.grad-graduation-api.schoolreport.url}")
private String createAndStoreSchoolReports;

Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ endpoint:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/studentcredential?studentID=%s&credentialTypeCode=%s&paperType=%s&documentStatusCode=%s&activityCode=%s
user-req-dis-run:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/userrequest/%s
user-req-dis-run-for-not-yet-distributed:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/userrequest/notyetdistributed/%s
get-district-data-yearly:
url: ${GRAD_GRADUATION_REPORT_API}api/v1/graduationreports/districtdataearly
get-certificate-types:
Expand Down
2 changes: 2 additions & 0 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ endpoint:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studentcredential?studentID=%s&credentialTypeCode=%s&paperType=%s&documentStatusCode=%s&activityCode=%s
user-req-dis-run:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/userrequest/%s
user-req-dis-run-for-not-yet-distributed:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/userrequest/notyetdistributed/%s
get-district-data-yearly:
url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/districtdataearly
get-certificate-types:
Expand Down

0 comments on commit ba68fb5

Please sign in to comment.