Skip to content

Commit

Permalink
Merge pull request #316 from mayuradesh/MOSIP-17718
Browse files Browse the repository at this point in the history
added updatePreRegStatus error handling, fixed Prefetched status update issue in data sync
  • Loading branch information
mandeepdhiman123 authored Sep 22, 2021
2 parents d295436 + 99555a2 commit 6a1ad67
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import io.mosip.preregistration.core.common.dto.DeleteBookingDTO;
import io.mosip.preregistration.core.common.dto.DemographicResponseDTO;
import io.mosip.preregistration.core.common.dto.DocumentMultipartResponseDTO;
import io.mosip.preregistration.core.common.dto.ExceptionJSONInfoDTO;
import io.mosip.preregistration.core.common.dto.MainRequestDTO;
import io.mosip.preregistration.core.common.dto.MainResponseDTO;
import io.mosip.preregistration.core.common.dto.PreRegIdsByRegCenterIdDTO;
Expand Down Expand Up @@ -822,15 +823,24 @@ public MainResponseDTO<String> updatePreRegistrationStatus(String preRegId, Stri
if (validationUtil.requstParamValidator(requestParamMap)) {
DemographicEntity demographicEntity = demographicRepository.findBypreRegistrationId(preRegId);
statusCheck(demographicEntity, status, userId);
}
response.setResponse("STATUS_UPDATED_SUCESSFULLY");
}
} catch (RecordFailedToUpdateException | RecordNotFoundException ex) {
response.setResponse("STATUS_NOT_UPDATED_SUCESSFULLY");
log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex));
log.error("sessionId", "idType", "id",
"Error in updatePreRegistrationStatus method of pre-registration service- " + ex.getMessage());
// new DemographicExceptionCatcher().handle(ex, response);
ExceptionJSONInfoDTO errorDetails = new ExceptionJSONInfoDTO(ex.getErrorCode(), ex.getErrorText());
List<ExceptionJSONInfoDTO> errorList = new ArrayList<>();
errorList.add(errorDetails);
response.setErrors(errorList);
} catch (Exception ex) {
log.error("sessionId", "idType", "id", ExceptionUtils.getStackTrace(ex));
log.error("sessionId", "idType", "id",
"In updatePreRegistrationStatus method of pre-registration service- " + ex.getMessage());
"Error in updatePreRegistrationStatus method of pre-registration service- " + ex.getMessage());
new DemographicExceptionCatcher().handle(ex, response);
}
response.setResponse("STATUS_UPDATED_SUCESSFULLY");

return response;
}

Expand All @@ -846,14 +856,19 @@ public void statusCheck(DemographicEntity demographicEntity, String status, Stri
if (serviceUtil.isStatusValid(status)) {
demographicEntity.setStatusCode(StatusCodes.valueOf(status.toUpperCase()).getCode());
if (status.toLowerCase().equals(StatusCodes.PENDING_APPOINTMENT.getCode().toLowerCase())) {
if (isupdateStausToPendingAppointmentValid(demographicEntity)) {
String prid = demographicEntity.getPreRegistrationId();
serviceUtil.updateApplicationStatus(prid, status, userId);
log.info("Application booking status updated succesfully --> {}", status);
demographicRepository.update(demographicEntity);
log.info("demographic booking status updated succesfully --> {}", status);
try {
if (isupdateStausToPendingAppointmentValid(demographicEntity)) {
String prid = demographicEntity.getPreRegistrationId();
serviceUtil.updateApplicationStatus(prid, status, userId);
log.info("Application booking status updated succesfully --> {}", status);
demographicRepository.update(demographicEntity);
log.info("demographic booking status updated succesfully --> {}", status);

} else {
} else {
throw new RecordFailedToUpdateException(DemographicErrorCodes.PRG_PAM_APP_023.getCode(),
DemographicErrorMessages.FAILED_TO_UPDATE_STATUS_PENDING_APPOINTMENT.getMessage());
}
} catch(Exception e) {
throw new RecordFailedToUpdateException(DemographicErrorCodes.PRG_PAM_APP_023.getCode(),
DemographicErrorMessages.FAILED_TO_UPDATE_STATUS_PENDING_APPOINTMENT.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,17 @@ public MainResponseDTO<PreRegArchiveDTO> fetchPreRegistrationData(String preId,
responseDto.setResponsetime(serviceUtil.getCurrentResponseTime());
responseDto.setResponse(preRegArchiveDTO);
isRetrieveSuccess = true;
// insert the anonymous profile only if the appointment is being booked for the
// first time or being prefetched for the first time
if (preRegistrationDTO.getStatusCode().equals(StatusCodes.APPLICATION_INCOMPLETE.getCode())
|| preRegistrationDTO.getStatusCode().equals(StatusCodes.PENDING_APPOINTMENT.getCode())) {
// insert the anonymous profile only if the appointment is being prefetched for the first time
if (!preRegistrationDTO.getStatusCode().equals(StatusCodes.BOOKED.getCode())
&& !preRegistrationDTO.getStatusCode().equals(StatusCodes.PREFETCHED.getCode())
&& !preRegistrationDTO.getStatusCode().equals(StatusCodes.EXPIRED.getCode())
&& !preRegistrationDTO.getStatusCode().equals(StatusCodes.CANCELLED.getCode())) {
preRegistrationDTO.setStatusCode(StatusCodes.PREFETCHED.getCode());
anonymousProfileUtil.saveAnonymousProfile(preRegistrationDTO, documentsMetaData,
bookingRegistrationDTO, null);
anonymousProfileUtil.saveAnonymousProfile(preRegistrationDTO, documentsMetaData, bookingRegistrationDTO,
null);
// update status to prefetched
serviceUtil.updateApplicationStatusToPreFectched(preId);
}
// update status to prefetched
serviceUtil.updateApplicationStatusToPreFectched(preId);
} catch (AnonymousProfileException apex) {
log.debug("sessionId", "idType", "id" + ExceptionUtils.getStackTrace(apex));
log.error("Unable to save AnonymousProfile in getPreRegistrationData method of datasync service -" + apex.getMessage());
Expand Down

0 comments on commit 6a1ad67

Please sign in to comment.