use of ca.bc.gov.educ.penreg.api.constants.PenRequestBatchStudentStatusCodes in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenReqBatchStudentOrchestrator method saveDemogValidationResults.
/**
* Save demog validation results.
*
* @param event the event
* @param sagaData the saga data
*/
protected void saveDemogValidationResults(final Event event, final PenRequestBatchStudentSagaData sagaData) {
if (event.getEventType() == VALIDATE_STUDENT_DEMOGRAPHICS && StringUtils.isNotBlank(event.getEventPayload()) && !StringUtils.equalsIgnoreCase(VALIDATION_SUCCESS_NO_ERROR_WARNING.toString(), event.getEventPayload())) {
final PenRequestBatchStudentStatusCodes statusCode;
if (event.getEventOutcome() == VALIDATION_SUCCESS_WITH_ERROR) {
statusCode = PenRequestBatchStudentStatusCodes.ERROR;
} else {
statusCode = PenRequestBatchStudentStatusCodes.FIXABLE;
}
try {
final TypeReference<List<PenRequestValidationIssue>> responseType = new TypeReference<>() {
};
final var validationResults = new ObjectMapper().readValue(event.getEventPayload(), responseType);
if (!validationResults.isEmpty()) {
final var mappedEntities = validationResults.stream().map(issueMapper::toModel).collect(Collectors.toList());
this.getPenRequestBatchStudentOrchestratorService().saveDemogValidationResultsAndUpdateStudentStatus(mappedEntities, statusCode, sagaData.getPenRequestBatchStudentID());
}
} catch (final JsonProcessingException ex) {
log.error("json exception for :: {} {}", event.getSagaId().toString(), ex);
}
}
}
use of ca.bc.gov.educ.penreg.api.constants.PenRequestBatchStudentStatusCodes in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchAPIControllerTest method testFindAllPenRequestIDs_HasMatchedResultsWithAllSearchCriteria_ShouldReturnStatusOk.
@Test
public void testFindAllPenRequestIDs_HasMatchedResultsWithAllSearchCriteria_ShouldReturnStatusOk() throws Exception {
final String batchIDs = this.createBatchStudentRecords(2);
final Map<String, String> searchCriteria = new HashMap<>();
searchCriteria.put("mincode", "66510518");
searchCriteria.put("localID", "1488645");
searchCriteria.put("submittedPen", "123456789");
searchCriteria.put("legalSurname", "JOHNSTON");
searchCriteria.put("legalGivenName", "ANGEL");
searchCriteria.put("legalMiddleNames", "MARIA LYNN");
searchCriteria.put("usualSurname", "JEB");
searchCriteria.put("usualGivenName", "JEB");
searchCriteria.put("usualMiddleNames", "JEB");
searchCriteria.put("dob", "20060628");
searchCriteria.put("gender", "F");
searchCriteria.put("grade", "02");
searchCriteria.put("postalCode", "Y1A4V1");
searchCriteria.put("bestMatchPEN", "123456789");
searchCriteria.put("submissionNumber", "T-428469");
final ObjectMapper objectMapper = new ObjectMapper();
final String criteriaJSON = objectMapper.writeValueAsString(searchCriteria);
this.mockMvc.perform(get("/api/v1/pen-request-batch/pen-request-batch-ids").with(jwt().jwt((jwt) -> jwt.claim("scope", "READ_PEN_REQUEST_BATCH"))).param("penRequestBatchIDs", batchIDs).param("penRequestBatchStudentStatusCodes", PenRequestBatchStudentStatusCodes.SYS_NEW_PEN.getCode() + "," + PenRequestBatchStudentStatusCodes.LOADED.getCode()).param("searchCriteria", criteriaJSON).contentType(APPLICATION_JSON)).andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$", hasSize(1)));
}
use of ca.bc.gov.educ.penreg.api.constants.PenRequestBatchStudentStatusCodes in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchAPIController method findAllPenRequestIDs.
/**
* Find all pen request i ds response entity.
*
* @param penRequestBatchIDs the pen request batch i ds
* @param penRequestBatchStudentStatusCodes the pen request batch student status codes
* @param searchCriteriaListJson the search criteria list json
* @return the response entity
* @throws JsonProcessingException the json processing exception
*/
@Override
public ResponseEntity<List<PenRequestIDs>> findAllPenRequestIDs(final List<UUID> penRequestBatchIDs, final List<String> penRequestBatchStudentStatusCodes, final String searchCriteriaListJson) throws JsonProcessingException {
val errorCode = penRequestBatchStudentStatusCodes.stream().filter(statusCode -> PenRequestBatchStudentStatusCodes.valueOfCode(statusCode) == null).findFirst();
if (errorCode.isPresent()) {
log.error("Invalid pen request batch student status code provided :: " + errorCode);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();
}
Map<String, String> searchCriteria = null;
if (StringUtils.isNotBlank(searchCriteriaListJson)) {
searchCriteria = JsonUtil.mapper.readValue(searchCriteriaListJson, new TypeReference<>() {
});
}
return ResponseEntity.ok(this.getService().findAllPenRequestIDs(penRequestBatchIDs, penRequestBatchStudentStatusCodes, searchCriteria));
}
Aggregations