Skip to content

Commit

Permalink
Merge pull request #317 from mosip/develop
Browse files Browse the repository at this point in the history
MOSIP-17729, MOSIP-16711, MOSIP-17718 Fixes
  • Loading branch information
mandeepdhiman123 authored Sep 23, 2021
2 parents 3c0e666 + 6a1ad67 commit 277e49c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 27 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 @@ -115,18 +115,18 @@ public MainResponseDTO<NotificationResponseDTO> emailNotification(NotificationDT
for (KeyValuePairDto keyValuePair : acknowledgementDTO.getFullName()) {
if (acknowledgementDTO.getIsBatch()) {
fileText = templateUtil.getTemplate(keyValuePair.getKey(), cancelAppoinment);
fileText.concat(System.lineSeparator() + System.lineSeparator());
// fileText.concat(System.lineSeparator() + System.lineSeparator());
} else {
fileText = templateUtil.getTemplate(keyValuePair.getKey(), emailAcknowledgement);
fileText.concat(System.lineSeparator() + System.lineSeparator());
// fileText.concat(System.lineSeparator() + System.lineSeparator());
}

String languageWiseTemplate = templateUtil.templateMerge(fileText, acknowledgementDTO,
(String) keyValuePair.getKey());
if (mergeTemplate == null) {
mergeTemplate = languageWiseTemplate;
mergeTemplate = languageWiseTemplate + System.lineSeparator();
} else {
mergeTemplate += System.lineSeparator() + languageWiseTemplate;
mergeTemplate += System.lineSeparator() + languageWiseTemplate +System.lineSeparator();
}
}

Expand Down Expand Up @@ -166,13 +166,15 @@ public MainResponseDTO<NotificationResponseDTO> emailNotification(NotificationDT
*/
public String getEmailSubject(NotificationDTO acknowledgementDTO) throws IOException {
log.info("sessionId", "idType", "id", "In getEmailSubject method of NotificationUtil service");
String emailSubject = null;
String emailSubject = "";
int noOfLang = acknowledgementDTO.getFullName().size();
for (KeyValuePairDto keyValuePair : acknowledgementDTO.getFullName()) {
emailSubject = templateUtil.templateMerge(
emailSubject = emailSubject + templateUtil.templateMerge(
templateUtil.getTemplate(keyValuePair.getKey(), emailAcknowledgementSubject), acknowledgementDTO,
(String) keyValuePair.getKey());
if (acknowledgementDTO.getFullName().size() > 1) {
emailSubject.concat(" / ");
if (noOfLang > 1) {
noOfLang--;
emailSubject = emailSubject + " / ";
}
}
return emailSubject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public void setUp() throws Exception {
notificationDTO.setRegistrationCenterName(regCenterName);
notificationDTO.setAddress(regCenterAddress);
notificationDTO.setFullName(languageNamePairs);
notificationDTO.setRegistrationCenterName(languageNamePairs);
notificationDTO.setAddress(languageNamePairs);
responseDTO = new MainResponseDTO<>();
responseDTO.setResponse(notificationDTO);
// responseDTO.setStatus(Boolean.TRUE);
Expand Down Expand Up @@ -138,6 +140,7 @@ public void notifyEmailsuccessTest() throws IOException {
Mockito.when(restTemplate.exchange(Mockito.anyString(), Mockito.eq(HttpMethod.POST), Mockito.any(),
Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<NotificationResponseDTO>>() {
}))).thenReturn(resp);

MainResponseDTO<NotificationResponseDTO> response = notificationUtil.notify("email", notificationDTO, file);
assertEquals(notificationResponseDTO.getMessage(), response.getResponse().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 277e49c

Please sign in to comment.