Merge branch 'develop' of https://github.com/Kitzanos/GEPAFIN-BE into develop

This commit is contained in:
nisha
2024-10-30 16:49:26 +05:30
12 changed files with 126 additions and 29 deletions

View File

@@ -20,6 +20,7 @@ import net.gepafin.tendermanagement.service.CallService;
import net.gepafin.tendermanagement.service.CompanyService;
import net.gepafin.tendermanagement.service.DocumentService;
import net.gepafin.tendermanagement.service.FormService;
import net.gepafin.tendermanagement.service.HubService;
import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.util.DateTimeUtil;
@@ -127,6 +128,9 @@ public class ApplicationDao {
@Autowired
private ProtocolDao protocolDao;
@Autowired
private HubService hubService;
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
FormEntity formEntity = formService.validateForm(formId);
@@ -699,9 +703,10 @@ public class ApplicationDao {
CallEntity call =applicationEntity.getCall();
CompanyEntity company = applicationEntity.getCompany();
ProtocolEntity protocol = applicationEntity.getProtocol();
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
.retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum.APPLICATION_SUBMISSION_TO_USER_AND_COMPANY,
call, null);
hub, null);
// Create the map for subject placeholders
Map<String, String> subjectPlaceholders = new HashMap<>();
@@ -732,9 +737,10 @@ public class ApplicationDao {
CallEntity call = applicationEntity.getCall();
CompanyEntity company = applicationEntity.getCompany();
ProtocolEntity protocol = applicationEntity.getProtocol();
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
.retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum.APPLICATION_SUBMISSION_TO_GEPAFIN,
call, null);
hub, null);
// Create the map for subject placeholders
Map<String, String> subjectPlaceholders = new HashMap<>();

View File

@@ -3,11 +3,12 @@ package net.gepafin.tendermanagement.dao;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
import net.gepafin.tendermanagement.entities.ApplicationEntity;
import net.gepafin.tendermanagement.entities.HubEntity;
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
import net.gepafin.tendermanagement.repositories.CallRepository;
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.util.DateTimeUtil;
@@ -36,14 +37,14 @@ public class EmailNotificationDao {
private UserService userService;
@Autowired
CallRepository callRepository;
private HubService hubService;
public void sendMailToNotifyBeneficiaryRegardingNewAmendment(ApplicationAmendmentRequestEntity applicationAmendmentRequest) {
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationAmendmentRequest.getApplicationId());
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, applicationEntity.getCall(), null);
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, hub, null);
// Create the map for subject placeholders
Map<String, String> subjectPlaceholders = new HashMap<>();
@@ -68,8 +69,9 @@ public class EmailNotificationDao {
public void sendApplicationFailureNotificationEmail(ApplicationAmendmentRequestEntity amendmentRequest) {
ApplicationEntity applicationEntity = applicationService.validateApplication(amendmentRequest.getApplicationId());
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, applicationEntity.getCall(), null);
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, hub, null);
// Create the map for subject placeholders
Map<String, String> subjectPlaceholders = new HashMap<>();
@@ -93,8 +95,9 @@ public class EmailNotificationDao {
public void sendAdmissibilityNotificationEmailForApprovedApplication(ApplicationAmendmentRequestEntity amendmentRequest) {
ApplicationEntity applicationEntity = applicationService.validateApplication(amendmentRequest.getApplicationId());
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.ADMISSIBILITY_NOTIFICATION, applicationEntity.getCall(), null);
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.ADMISSIBILITY_NOTIFICATION, hub, null);
// Create the map for subject placeholders
Map<String, String> subjectPlaceholders = new HashMap<>();
@@ -126,8 +129,9 @@ public class EmailNotificationDao {
public void sendInadmissibilityEmailForRejectedApplication(ApplicationAmendmentRequestEntity amendmentRequest) {
ApplicationEntity applicationEntity = applicationService.validateApplication(amendmentRequest.getApplicationId());
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE, applicationEntity.getCall(), null);
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE, hub, null);
// Create the map for subject placeholders
Map<String, String> subjectPlaceholders = new HashMap<>();

View File

@@ -49,7 +49,7 @@ public class HubDao {
hubRepository.save(hubEntity);
}
private HubEntity validateHub(Long hubId) {
public HubEntity validateHub(Long hubId) {
return hubRepository.findById(hubId)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.HUB_NOT_FOUND)));

View File

@@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import net.gepafin.tendermanagement.entities.CallEntity;
import net.gepafin.tendermanagement.entities.HubEntity;
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity;
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
@@ -25,24 +25,27 @@ public class SystemEmailTemplatesDao {
@Value("${fe.base.url}")
private String feBaseUrl;
@Value("${default.email.signature}")
private String defaultEmailSignature;
public SystemEmailTemplateResponse retrieveTemplate(SystemEmailTemplatesEntityTypeEnum type, CallEntity call, Locale language) {
public SystemEmailTemplateResponse retrieveTemplate(SystemEmailTemplatesEntityTypeEnum type, HubEntity hub, Locale language) {
SystemEmailTemplatesEntity dbSystemEmailTemplatesEntity = null;
if(call != null){
if(hub != null){
// dbSystemEmailTemplatesEntity = systemEmailTemplatesRespository
// .findByTypeAndCallId(type.getValue(), call.getId());
}
if(dbSystemEmailTemplatesEntity == null){
if(dbSystemEmailTemplatesEntity == null) {
dbSystemEmailTemplatesEntity = systemEmailTemplatesRespository
.findByType(type.getValue());
}
SystemEmailTemplateResponse systemEmailTemplateResponse = replaceHtmlContant(dbSystemEmailTemplatesEntity, call, language, Boolean.TRUE);
SystemEmailTemplateResponse systemEmailTemplateResponse = replaceHtmlContant(dbSystemEmailTemplatesEntity, hub, language, Boolean.TRUE);
return systemEmailTemplateResponse;
}
private SystemEmailTemplateResponse replaceHtmlContant(SystemEmailTemplatesEntity dbSystemEmailTemplatesEntity,
CallEntity call, Locale language1, Boolean isDefaultReplace) {
HubEntity hub, Locale language1, Boolean isDefaultReplace) {
String language = null;
String htmlContent = dbSystemEmailTemplatesEntity.getHtmlContent();
String subject = dbSystemEmailTemplatesEntity.getSubject();
@@ -69,7 +72,8 @@ public class SystemEmailTemplatesDao {
}
htmlContent = replacePlatformLinkPlaceholder(call, htmlContent, languageMap);
htmlContent = replacePlatformLinkPlaceholderAndEmailSignature(hub, htmlContent, languageMap);
subject = replacePlatformLinkPlaceholderAndEmailSignature(hub, subject, languageMap);
SystemEmailTemplateResponse systemEmailTemplateResponse = new SystemEmailTemplateResponse();
systemEmailTemplateResponse.setHtmlContent(htmlContent);
systemEmailTemplateResponse.setSubject(subject);
@@ -102,15 +106,28 @@ public class SystemEmailTemplatesDao {
}
return "";
}
private String replacePlatformLinkPlaceholder(CallEntity call, String htmlContent,
private String replacePlatformLinkPlaceholderAndEmailSignature(HubEntity hub, String htmlContent,
Map<String, String> languageMap) {
String platformLink = feBaseUrl;
htmlContent = replacePlatformLinkPlaceholder(hub, htmlContent, languageMap);
htmlContent = replaceEmailSignature(hub, htmlContent, languageMap);
// if(hubEntity != null && Boolean.FALSE.equals(isEmpty(hubEntity.getDomainName()))){
// platformLink = hubEntity.getDomainName();
// }
htmlContent = htmlContent.replace("{{platform_link}}", platformLink);
return htmlContent;
}
private String replaceEmailSignature(HubEntity hub, String htmlContent, Map<String, String> languageMap) {
String emailSignature = defaultEmailSignature;
if(hub != null && Boolean.FALSE.equals(StringUtils.isEmpty(hub.getEmailSignature()))){
emailSignature = hub.getEmailSignature();
}
return htmlContent.replace("{{email_signature}}", emailSignature);
}
private String replacePlatformLinkPlaceholder(HubEntity hub, String htmlContent, Map<String, String> languageMap) {
String platformLink = feBaseUrl;
if(hub != null && Boolean.FALSE.equals(StringUtils.isEmpty(hub.getDomainName()))){
platformLink = hub.getDomainName();
}
return htmlContent.replace("{{platform_link}}", platformLink);
}
}

View File

@@ -45,4 +45,8 @@ public class HubEntity extends BaseEntity{
@Column(name="PDF_BANNER")
private String pdfBanner;
@Column(name = "EMAIL_SIGNATURE")
private String emailSignature;
}

View File

@@ -15,4 +15,5 @@ public interface HubService {
void deleteHub(Long hubId);
HubEntity getHubByUuid(String hubUuid);
HubResponseBean getHubByHubUuid(String uuid);
HubEntity valdateHub(Long hubId);
}

View File

@@ -2,12 +2,12 @@ package net.gepafin.tendermanagement.service;
import java.util.Locale;
import net.gepafin.tendermanagement.entities.CallEntity;
import net.gepafin.tendermanagement.entities.HubEntity;
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
public interface SystemEmailTemplatesService {
SystemEmailTemplateResponse retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum type, CallEntity call, Locale language);
SystemEmailTemplateResponse retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum type, HubEntity hub, Locale language);
}

View File

@@ -56,4 +56,8 @@ public class HubServiceImpl implements HubService {
public HubResponseBean getHubByHubUuid(String uuid) {
return hubDao.getHubByHubUuid(uuid);
}
@Override
public HubEntity valdateHub(Long hubId) {
return hubDao.validateHub(hubId);
}
}

View File

@@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import net.gepafin.tendermanagement.dao.SystemEmailTemplatesDao;
import net.gepafin.tendermanagement.entities.CallEntity;
import net.gepafin.tendermanagement.entities.HubEntity;
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
@@ -19,8 +19,8 @@ public class SystemEmailTemplatesServiceImpl implements SystemEmailTemplatesServ
@Override
public SystemEmailTemplateResponse retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum type, CallEntity call, Locale language) {
return systemEmailTemplatesDao.retrieveTemplate(type, call, language);
public SystemEmailTemplateResponse retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum type, HubEntity hub, Locale language) {
return systemEmailTemplatesDao.retrieveTemplate(type, hub, language);
}

View File

@@ -61,6 +61,7 @@ apiKey=xkeysib-d15439fedd7ff36d86676ac248153fc2c496ed9b879ca9dc8cee9a27fa309087-
#senderEmail=mailer@bflows.net
application.amendment.expiration.days=30
default.email.signature=Gepafin S.p.a
default.hub.pdf.banner=https://mementoresources.s3.amazonaws.com/gepafin/staging/template/gepafin-logo.jpg

View File

@@ -1666,5 +1666,28 @@
</update>
</changeSet>
<changeSet id="31-10-2024_1" author="Rajesh Khore">
<addColumn tableName="hub">
<column name="EMAIL_SIGNATURE" type="TEXT"/>
</addColumn>
</changeSet>
<changeSet id="31-10-2024_2" author="Rajesh Khore">
<sqlFile dbms="postgresql"
path="db/dump/updated_system_email_template_for_application_submition_30-10-2024.sql"/>
</changeSet>
<changeSet id="31-10-2024_3" author="Rajesh Khore">
<update tableName="hub">
<column name="EMAIL_SIGNATURE" value="Gepafin S.p.a"/>
<where>UNIQUE_UUID = 'p4lk3bcx1RStqTaIVVbXs'</where>
</update>
<update tableName="hub">
<column name="EMAIL_SIGNATURE" value="Sviluppumbria S.p.a"/>
<where>UNIQUE_UUID = 't7jh5wfg9QXylNaTZkPoE'</where>
</update>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,37 @@
UPDATE gepafin_schema.system_email_template SET html_content='<html>
<body style="font-family: Arial, sans-serif; color: #333; line-height: 1.6;">
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;">
<p>Buongiorno,</p>
<p>
Si comunica che, in riferimento alla domanda di concessione di
Finanziamento agevolato a valere sul Fondo prestiti
<strong>{{call_name}}</strong> di cui all''oggetto, la stessa è stata
regolarmente acquisita ed è stata registrata con Protocollo n.
<strong>{{protocol_number}}</strong> del <strong>{{date}}</strong> alle
<strong>{{time}}</strong>.
</p>
<p>Distinti Saluti,</p>
<p>
<strong>{{email_signature}}</strong>
</p>
</div>
</body>
</html>' WHERE "type"='APPLICATION_SUBMISSION_TO_USER_AND_COMPANY' AND "system"=true ;
UPDATE gepafin_schema.system_email_template SET html_content='<html>
<body style="font-family: Arial, sans-serif; color: #333; line-height: 1.6;">
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;">
<p>
In riferimento alla domanda di concessione di Finanziamento agevolato a valere sul Fondo prestiti
<strong>{{call_name}}</strong> di cui alloggetto, la stessa è stata regolarmente acquisita ed è stata
registrata con Protocollo n. <strong>{{protocol_number}}</strong> del <strong>{{date}}</strong> alle <strong>{{time}}</strong>.
</p>
<p>Distinti Saluti,</p>
<p>
<strong>{{email_signature}}</strong>
</p>
</div>
</body>
</html>' WHERE "type"='APPLICATION_SUBMISSION_TO_GEPAFIN' AND "system"=true;