|
|
|
@@ -1,23 +1,16 @@
|
|
|
|
package net.gepafin.tendermanagement.dao;
|
|
|
|
package net.gepafin.tendermanagement.dao;
|
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
|
|
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
|
|
|
import net.gepafin.tendermanagement.entities.*;
|
|
|
|
import net.gepafin.tendermanagement.entities.*;
|
|
|
|
import net.gepafin.tendermanagement.enums.EmailEntityTypeEnum;
|
|
|
|
|
|
|
|
import net.gepafin.tendermanagement.enums.RecipientTypeEnum;
|
|
|
|
import net.gepafin.tendermanagement.enums.RecipientTypeEnum;
|
|
|
|
import net.gepafin.tendermanagement.enums.StatusTypeEnum;
|
|
|
|
|
|
|
|
import net.gepafin.tendermanagement.entities.*;
|
|
|
|
|
|
|
|
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
|
|
|
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
|
|
|
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
|
|
|
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
|
|
|
|
|
|
|
import net.gepafin.tendermanagement.model.response.AmendmentFormFieldResponse;
|
|
|
|
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
|
|
|
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
|
|
|
import net.gepafin.tendermanagement.repositories.EmailLogRepository;
|
|
|
|
import net.gepafin.tendermanagement.repositories.*;
|
|
|
|
import net.gepafin.tendermanagement.repositories.HubRepository;
|
|
|
|
import net.gepafin.tendermanagement.service.*;
|
|
|
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
|
|
|
|
|
|
|
import net.gepafin.tendermanagement.service.HubService;
|
|
|
|
|
|
|
|
import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
|
|
|
|
|
|
|
|
import net.gepafin.tendermanagement.service.UserService;
|
|
|
|
|
|
|
|
import net.gepafin.tendermanagement.service.impl.EmailService;
|
|
|
|
import net.gepafin.tendermanagement.service.impl.EmailService;
|
|
|
|
import net.gepafin.tendermanagement.service.impl.EmailServiceFactory;
|
|
|
|
import net.gepafin.tendermanagement.service.impl.EmailServiceFactory;
|
|
|
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
|
|
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
|
|
|
@@ -25,11 +18,14 @@ import net.gepafin.tendermanagement.util.Utils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static net.gepafin.tendermanagement.dao.ApplicationAmendmentRequestDao.filterByName;
|
|
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
|
public class EmailNotificationDao {
|
|
|
|
public class EmailNotificationDao {
|
|
|
|
|
|
|
|
|
|
|
|
@@ -59,85 +55,164 @@ public class EmailNotificationDao {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private EmailLogRepository emailLogRepository;
|
|
|
|
private EmailLogRepository emailLogRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private CompanyService companyService;
|
|
|
|
|
|
|
|
|
|
|
|
private void sendEmail(ApplicationEntity applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType,
|
|
|
|
@Autowired
|
|
|
|
Map<String, String> bodyPlaceholders, List<String> additionalRecipients,Long amendmentId) {
|
|
|
|
private ApplicationFormRepository applicationFormRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ApplicationFormFieldRepository applicationFormFieldRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${rinaldo_email}")
|
|
|
|
|
|
|
|
private String rinaldoEmail;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void sendEmail(ApplicationEntity applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType, Map<String, String> bodyPlaceholders,
|
|
|
|
|
|
|
|
List<String> additionalRecipients, Long amendmentId) {
|
|
|
|
|
|
|
|
|
|
|
|
HubEntity hubEntity = hubService.valdateHub(applicationEntity.getHubId());
|
|
|
|
HubEntity hubEntity = hubService.valdateHub(applicationEntity.getHubId());
|
|
|
|
String service = determineService(applicationEntity.getHubId());
|
|
|
|
// String service = determineService(applicationEntity.getHubId());
|
|
|
|
String legalMail = service.equals("Gepafin S.p.a.") ? "bandi.gepafin@legalmail.it" : "bandi.sviluppumbria@legalmail.it";
|
|
|
|
// String legalMail = service.equals("Gepafin S.p.a.") ? "bandi.gepafin@legalmail.it" : "bandi.sviluppumbria@legalmail.it";
|
|
|
|
|
|
|
|
|
|
|
|
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(templateType, hubEntity, null);
|
|
|
|
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(templateType, hubEntity, null);
|
|
|
|
Map<String, String> subjectPlaceholders = new HashMap<>();
|
|
|
|
Map<String, String> subjectPlaceholders = new HashMap<>();
|
|
|
|
|
|
|
|
CompanyEntity company = companyService.validateCompany(applicationEntity.getCompany().getId());
|
|
|
|
subjectPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
|
|
|
subjectPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
|
|
|
subjectPlaceholders.put("{{company_name}}", applicationEntity.getCompany().getCompanyName());
|
|
|
|
subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
|
|
|
|
bodyPlaceholders.put("{{legal_mail}}", legalMail);
|
|
|
|
// bodyPlaceholders.put("{{legal_mail}}", legalMail);
|
|
|
|
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
|
|
|
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
|
|
|
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
|
|
|
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
|
|
|
|
|
|
|
|
|
|
|
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
|
|
|
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
|
|
|
List<String> recipientEmails = getRecipientEmails(applicationEntity, userEntity, additionalRecipients);
|
|
|
|
sendEmails(applicationEntity, userEntity, additionalRecipients,amendmentId,systemEmailTemplateResponse,subject,body);
|
|
|
|
EmailLogRequest emailLogRequest=emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.BENEFICIARY,userEntity.getBeneficiary().getId(),Utils.listToCommaSeparatedString(recipientEmails),userEntity.getId(),applicationEntity.getId(),amendmentId ,applicationEntity.getCall().getId());
|
|
|
|
|
|
|
|
sendMail(applicationEntity.getHubId(), subject, body, recipientEmails,emailLogRequest);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private List<String> getRecipientEmails(ApplicationEntity applicationEntity, UserEntity userEntity, List<String> additionalRecipients) {
|
|
|
|
private void sendEmails(ApplicationEntity applicationEntity, UserEntity userEntity, List<String> additionalRecipients,Long amendmentId,SystemEmailTemplateResponse systemEmailTemplateResponse,String subject,String body) {
|
|
|
|
List<String> recipientEmails = new ArrayList<>();
|
|
|
|
|
|
|
|
String companyEmail = applicationEntity.getCompany().getEmail();
|
|
|
|
|
|
|
|
String contactEmail = applicationEntity.getCompany().getContactEmail();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (companyEmail != null && !companyEmail.isEmpty()) {
|
|
|
|
Optional<ApplicationEvaluationEntity> applicationEvaluationEntity = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationEntity.getId());
|
|
|
|
recipientEmails.add(companyEmail);
|
|
|
|
CompanyEntity company = companyService.validateCompany(applicationEntity.getCompany().getId());
|
|
|
|
}
|
|
|
|
String companyEmail = company.getEmail();
|
|
|
|
if (contactEmail != null && !contactEmail.isEmpty() && !contactEmail.equals(companyEmail)) {
|
|
|
|
String contactEmail = company.getContactEmail();
|
|
|
|
recipientEmails.add(contactEmail);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (userEntity.getBeneficiary().getEmail() != null) {
|
|
|
|
if (companyEmail != null && !companyEmail.isEmpty()) {
|
|
|
|
recipientEmails.add(userEntity.getBeneficiary().getEmail());
|
|
|
|
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.COMPANY,company.getId() ,
|
|
|
|
}
|
|
|
|
companyEmail, userEntity.getId(), applicationEntity.getId(), amendmentId, applicationEntity.getCall().getId());
|
|
|
|
if (additionalRecipients != null) {
|
|
|
|
sendMail(applicationEntity.getHubId(), subject, body, List.of(companyEmail), emailLogRequest);
|
|
|
|
recipientEmails.addAll(additionalRecipients);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (contactEmail != null && !contactEmail.isEmpty() && !contactEmail.equals(companyEmail)) {
|
|
|
|
|
|
|
|
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.COMPANY,company.getId(),
|
|
|
|
|
|
|
|
contactEmail, userEntity.getId(), applicationEntity.getId(), amendmentId, applicationEntity.getCall().getId());
|
|
|
|
|
|
|
|
sendMail(applicationEntity.getHubId(), subject, body, List.of(contactEmail), emailLogRequest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return recipientEmails;
|
|
|
|
if (userEntity.getBeneficiary().getEmail() != null) {
|
|
|
|
|
|
|
|
String beneficiaryEmail = userEntity.getBeneficiary().getEmail();
|
|
|
|
|
|
|
|
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.BENEFICIARY,userEntity.getBeneficiary().getId() ,
|
|
|
|
|
|
|
|
beneficiaryEmail, userEntity.getId(), applicationEntity.getId(), amendmentId, applicationEntity.getCall().getId());
|
|
|
|
|
|
|
|
sendMail(applicationEntity.getHubId(), subject, body, List.of(beneficiaryEmail), emailLogRequest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(userEntity.getHub().getEmail() != null){
|
|
|
|
|
|
|
|
String hubEmails = userEntity.getHub().getEmail();
|
|
|
|
|
|
|
|
String[] hubEmailArray = hubEmails.split(",");
|
|
|
|
|
|
|
|
for (String hubEmail : hubEmailArray) {
|
|
|
|
|
|
|
|
hubEmail = hubEmail.trim();
|
|
|
|
|
|
|
|
if (!hubEmail.isEmpty()) {
|
|
|
|
|
|
|
|
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.PROPERTIES,null,
|
|
|
|
|
|
|
|
hubEmail, userEntity.getId(), applicationEntity.getId(), amendmentId, applicationEntity.getCall().getId());
|
|
|
|
|
|
|
|
sendMail(applicationEntity.getHubId(), subject, body, List.of(hubEmail), emailLogRequest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rinaldoEmail != null) {
|
|
|
|
|
|
|
|
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.PROPERTIES,null ,
|
|
|
|
|
|
|
|
rinaldoEmail, userEntity.getId(), applicationEntity.getId(), amendmentId, applicationEntity.getCall().getId());
|
|
|
|
|
|
|
|
sendMail(applicationEntity.getHubId(), subject, body, List.of(rinaldoEmail), emailLogRequest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (applicationEvaluationEntity.isPresent()) {
|
|
|
|
|
|
|
|
Long preInstructorId = applicationEvaluationEntity.get().getUserId(); // Assuming UserEntity has an email field
|
|
|
|
|
|
|
|
UserEntity instructorUser = userService.validateUser(preInstructorId);
|
|
|
|
|
|
|
|
String preInstructorEmail = instructorUser.getEmail();
|
|
|
|
|
|
|
|
if (preInstructorEmail != null && !preInstructorEmail.isEmpty()) {
|
|
|
|
|
|
|
|
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.INSTRUCTOR, instructorUser.getId(),
|
|
|
|
|
|
|
|
preInstructorEmail, userEntity.getId(), applicationEntity.getId(), amendmentId, applicationEntity.getCall().getId());
|
|
|
|
|
|
|
|
sendMail(applicationEntity.getHubId(), subject, body, List.of(preInstructorEmail), emailLogRequest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// private String determineService(Long hubId) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// HubEntity hub = hubRepository.findById(hubId).orElseThrow(() -> new IllegalArgumentException("Invalid Hub ID: " + hubId));
|
|
|
|
|
|
|
|
// return hub.getEmailServiceType().equalsIgnoreCase("MAILGUN_SERVICE") ? "Sviluppumbria" : "Gepafin S.p.a.";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void sendMailToNotifyBeneficiaryRegardingNewAmendment(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity) {
|
|
|
|
|
|
|
|
|
|
|
|
private String determineService(Long hubId) {
|
|
|
|
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationAmendmentRequestEntity.getApplicationId());
|
|
|
|
|
|
|
|
|
|
|
|
HubEntity hub = hubRepository.findById(hubId).orElseThrow(() -> new IllegalArgumentException("Invalid Hub ID: " + hubId));
|
|
|
|
|
|
|
|
return hub.getEmailServiceType().equalsIgnoreCase("MAILGUN_SERVICE") ? "Gepafin S.p.a." : "Sviluppumbria";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void sendMailToNotifyBeneficiaryRegardingNewAmendment(ApplicationAmendmentRequestEntity applicationAmendmentRequest) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationAmendmentRequest.getApplicationId());
|
|
|
|
|
|
|
|
Map<String, String> bodyPlaceholders = new HashMap<>();
|
|
|
|
Map<String, String> bodyPlaceholders = new HashMap<>();
|
|
|
|
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
|
|
|
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
|
|
|
bodyPlaceholders.put("{{protocol_number}}", applicationAmendmentRequest.getProtocol().getProtocolNumber().toString());
|
|
|
|
bodyPlaceholders.put("{{protocol_number}}", applicationAmendmentRequestEntity.getProtocol().getProtocolNumber().toString());
|
|
|
|
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatLocalDateTime(applicationAmendmentRequest.getProtocol().getCreatedDate(), GepafinConstant.DD_MM_YYYY));
|
|
|
|
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatLocalDateTime(applicationAmendmentRequestEntity.getProtocol().getCreatedDate(), GepafinConstant.DD_MM_YYYY));
|
|
|
|
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationAmendmentRequest.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
|
|
|
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationAmendmentRequestEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
|
|
|
String formFieldsJson = applicationAmendmentRequest.getFormFields();
|
|
|
|
bodyPlaceholders.put("{{response_days}}", applicationAmendmentRequestEntity.getResponseDays().toString());
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<Map<String, Object>> formFields = objectMapper.readValue(formFieldsJson, new TypeReference<List<Map<String, Object>>>() {
|
|
|
|
// Retrieve forms and initialize required collections
|
|
|
|
});
|
|
|
|
List<ApplicationFormEntity> forms = applicationFormRepository.findByApplicationId(applicationEntity.getId());
|
|
|
|
//•
|
|
|
|
List<AmendmentFormFieldResponse> allFormFields = new ArrayList<>();
|
|
|
|
StringBuilder bulletPoints = new StringBuilder();
|
|
|
|
StringBuilder bulletPoints = new StringBuilder();
|
|
|
|
for (Map<String, Object> field : formFields) {
|
|
|
|
|
|
|
|
String label = (String) field.get("label");
|
|
|
|
// Extract data from forms
|
|
|
|
boolean selected = (boolean) field.get("selected");
|
|
|
|
for (ApplicationFormEntity form : forms) {
|
|
|
|
if (!selected) {
|
|
|
|
String content = form.getForm().getContent();
|
|
|
|
bulletPoints.append("• ").append(label).append("\n");
|
|
|
|
List<Map<String, Object>> result = filterByName(content, "fileupload");
|
|
|
|
}
|
|
|
|
allFormFields.addAll(getIdAndLabelFromResult(result));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Process allFormFields and generate bullet points
|
|
|
|
|
|
|
|
for (AmendmentFormFieldResponse field : allFormFields) {
|
|
|
|
|
|
|
|
// Build bullet points
|
|
|
|
|
|
|
|
// bulletPoints.append(field.getLabel());
|
|
|
|
|
|
|
|
bulletPoints.append("<li>").append(field.getLabel()).append("</li>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the generated bullet points to placeholders
|
|
|
|
bodyPlaceholders.put("{{form_dataInput}}", bulletPoints.toString());
|
|
|
|
bodyPlaceholders.put("{{form_dataInput}}", bulletPoints.toString());
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("Failed to parse form fields JSON: ", e);
|
|
|
|
log.error("Failed to process form fields: ", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bodyPlaceholders.put("{{note}}", applicationAmendmentRequest.getNote());
|
|
|
|
|
|
|
|
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, bodyPlaceholders, null,applicationAmendmentRequest.getId());
|
|
|
|
|
|
|
|
|
|
|
|
bodyPlaceholders.put("{{note}}", applicationAmendmentRequestEntity.getNote());
|
|
|
|
|
|
|
|
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, bodyPlaceholders, null,
|
|
|
|
|
|
|
|
applicationAmendmentRequestEntity.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<AmendmentFormFieldResponse> getIdAndLabelFromResult(List<Map<String, Object>> result) {
|
|
|
|
|
|
|
|
List<AmendmentFormFieldResponse> formFieldResponses = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Map<String, Object> item : result) {
|
|
|
|
|
|
|
|
AmendmentFormFieldResponse formFieldResponse = new AmendmentFormFieldResponse();
|
|
|
|
|
|
|
|
formFieldResponse.setFieldId((String) item.get("id"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Extract "label" value from the "settings" array
|
|
|
|
|
|
|
|
List<Map<String, Object>> settings = (List<Map<String, Object>>) item.get("settings");
|
|
|
|
|
|
|
|
String label = settings.stream()
|
|
|
|
|
|
|
|
.filter(setting -> "label".equals(setting.get("name")))
|
|
|
|
|
|
|
|
.map(setting -> (String) setting.get("value"))
|
|
|
|
|
|
|
|
.findFirst()
|
|
|
|
|
|
|
|
.orElse(""); // Default to empty string if not found
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (label == null || label.trim().isEmpty()) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formFieldResponse.setLabel(label); // Set the label as fieldValue
|
|
|
|
|
|
|
|
formFieldResponses.add(formFieldResponse);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return formFieldResponses;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void sendApplicationFailureNotificationEmail(ApplicationAmendmentRequestEntity amendmentRequest) {
|
|
|
|
public void sendApplicationFailureNotificationEmail(ApplicationAmendmentRequestEntity amendmentRequest) {
|
|
|
|
|