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 851a24ac..ed676e89 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,7 +19,6 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Objects; import java.util.UUID; @CrossOrigin @@ -278,7 +277,10 @@ public ResponseEntity> getStudentCredentials @PathVariable String credentialType, @RequestBody StudentSearchRequest studentSearchRequest, @RequestHeader(name="Authorization") String accessToken) { logger.debug("getStudentCredentialsForUserRequestDisRun : "); - return response.GET(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,studentSearchRequest,false,accessToken.replace(BEARER, ""))); + boolean isPenNumberSearch = studentSearchRequest.getPens() != null && !studentSearchRequest.getPens().isEmpty() + && !studentSearchRequest.getPens().stream().filter(StringUtils::isNotBlank).toList().isEmpty(); + boolean onlyWithNullDistributionDate = !isPenNumberSearch && studentSearchRequest.getGradDateFrom() == null && studentSearchRequest.getGradDateTo() == null; + return response.GET(commonService.getStudentCredentialsForUserRequestDisRun(credentialType,studentSearchRequest,onlyWithNullDistributionDate,accessToken.replace(BEARER, ""))); } @PostMapping(EducGradReportApiConstants.USER_REQUEST_DIS_RUN_WITH_NULL_DISTRIBUTION_DATE)