Fixed Ndg visura api call.
This commit is contained in:
@@ -486,7 +486,7 @@ public class AppointmentDao {
|
|||||||
// Try retrieving NDG by VAT number
|
// Try retrieving NDG by VAT number
|
||||||
AppointmentLoginResponse ndgResponse = retrieveNdgByVatNumber(company.getVatNumber(), authorizationToken, hub, application);
|
AppointmentLoginResponse ndgResponse = retrieveNdgByVatNumber(company.getVatNumber(), authorizationToken, hub, application);
|
||||||
if (isNdgValid(ndgResponse.getNdg())) {
|
if (isNdgValid(ndgResponse.getNdg())) {
|
||||||
saveNdgAndIdVisura(application, company, ndgResponse.getNdg(), null);
|
saveNdgAndIdVisura(application, company, ndgResponse.getNdg());
|
||||||
log.info("NDG successfully generated for applicationId: {}", applicationId);
|
log.info("NDG successfully generated for applicationId: {}", applicationId);
|
||||||
} else {
|
} else {
|
||||||
// If NDG isn't immediately available, start polling
|
// If NDG isn't immediately available, start polling
|
||||||
@@ -511,8 +511,29 @@ public class AppointmentDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Fetch Ndg via creating visura
|
||||||
|
AppointmentLoginResponse visuraResponse = createVisura(company, authorizationToken, hub);
|
||||||
|
if (isNdgValid(visuraResponse.getNdg())) {
|
||||||
|
log.info("Valid NDG retrieved from create visura api response: {} | ApplicationId: {}", visuraResponse.getNdg(), application.getId());
|
||||||
|
company.setNdg(visuraResponse.getNdg());
|
||||||
|
application.setNdg(visuraResponse.getNdg());
|
||||||
|
application.setNdgStatus(GepafinConstant.NDG_GENERATED);
|
||||||
|
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
||||||
|
application.setIdVisura(visuraResponse.getIdVisura());
|
||||||
|
applicationRepository.save(application);
|
||||||
|
companyRepository.save(company);
|
||||||
|
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(
|
||||||
|
application.getApplicationEvaluationId());
|
||||||
|
Map<String, String> placeHolders = new HashMap<>();
|
||||||
|
placeHolders.put("{{call_name}}", application.getCall().getName());
|
||||||
|
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
||||||
|
notificationDao.sendNotificationToInstructor(placeHolders, applicationEvaluationEntity, NotificationTypeEnum.NDG_GENERATION);
|
||||||
|
notificationDao.sendNotificationToSuperUser(application, placeHolders, NotificationTypeEnum.NDG_GENERATION);
|
||||||
|
log.info("Got NDG and saved successfully for applicationId: {}", application.getId());
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
// Fetch Visura list and attempt to parse NDG
|
// Fetch Visura list and attempt to parse NDG
|
||||||
String visuraListJson = getVisuraList(application.getIdVisura(), authorizationToken, application, hub);
|
String visuraListJson = getVisuraList(visuraResponse.getIdVisura(), authorizationToken, application, hub);
|
||||||
log.debug("Parsing NDG from visura list response | ApplicationId: {}", application.getId());
|
log.debug("Parsing NDG from visura list response | ApplicationId: {}", application.getId());
|
||||||
String ndg = parseNdgFromVisuraListResponse(visuraListJson);
|
String ndg = parseNdgFromVisuraListResponse(visuraListJson);
|
||||||
if (isNdgValid(ndg)) {
|
if (isNdgValid(ndg)) {
|
||||||
@@ -524,11 +545,11 @@ public class AppointmentDao {
|
|||||||
application.setNdg(ndg);
|
application.setNdg(ndg);
|
||||||
application.setNdgStatus(GepafinConstant.NDG_GENERATED);
|
application.setNdgStatus(GepafinConstant.NDG_GENERATED);
|
||||||
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
||||||
|
application.setIdVisura(visuraResponse.getIdVisura());
|
||||||
applicationRepository.save(application);
|
applicationRepository.save(application);
|
||||||
companyRepository.save(company);
|
companyRepository.save(company);
|
||||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(application.getApplicationEvaluationId());
|
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(
|
||||||
// Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.NDG_GENERATION);
|
application.getApplicationEvaluationId());
|
||||||
|
|
||||||
Map<String, String> placeHolders = new HashMap<>();
|
Map<String, String> placeHolders = new HashMap<>();
|
||||||
placeHolders.put("{{call_name}}", application.getCall().getName());
|
placeHolders.put("{{call_name}}", application.getCall().getName());
|
||||||
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
||||||
@@ -537,7 +558,7 @@ public class AppointmentDao {
|
|||||||
log.info("NDG saved successfully for applicationId: {}", application.getId());
|
log.info("NDG saved successfully for applicationId: {}", application.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if polling has timed out
|
// Check if polling has timed out
|
||||||
if (System.currentTimeMillis() - startTime > TimeUnit.HOURS.toMillis(2)) {
|
if (System.currentTimeMillis() - startTime > TimeUnit.HOURS.toMillis(2)) {
|
||||||
log.warn("NDG polling timed out for applicationId: {}", application.getId());
|
log.warn("NDG polling timed out for applicationId: {}", application.getId());
|
||||||
@@ -571,10 +592,9 @@ public class AppointmentDao {
|
|||||||
return ndg != null && !ndg.isEmpty();
|
return ndg != null && !ndg.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveNdgAndIdVisura(ApplicationEntity application, CompanyEntity company, String ndg, String idVisura) {
|
private void saveNdgAndIdVisura(ApplicationEntity application, CompanyEntity company, String ndg) {
|
||||||
|
|
||||||
application.setNdg(ndg);
|
application.setNdg(ndg);
|
||||||
application.setIdVisura(idVisura);
|
|
||||||
application.setNdgStatus(GepafinConstant.NDG_GENERATED);
|
application.setNdgStatus(GepafinConstant.NDG_GENERATED);
|
||||||
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
||||||
company.setNdg(ndg);
|
company.setNdg(ndg);
|
||||||
|
|||||||
Reference in New Issue
Block a user