Resolved conflicts of PR GEPAFINBE-6139 (Reviewed Evaluation Process)
This commit is contained in:
@@ -94,6 +94,9 @@ public class EmailNotificationDao {
|
||||
@Autowired
|
||||
private ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationDao applicationDao;
|
||||
|
||||
public void sendEmail(ApplicationEntity applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType, Map<String, String> bodyPlaceholders,
|
||||
List<String> additionalRecipients, Long amendmentId) {
|
||||
|
||||
@@ -131,21 +134,35 @@ public class EmailNotificationDao {
|
||||
|
||||
Optional<ApplicationEvaluationEntity> applicationEvaluationEntity = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationEntity.getId());
|
||||
CompanyEntity company = companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequest=applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequest =null;
|
||||
if(amendmentId!=null) {
|
||||
applicationAmendmentRequest = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
|
||||
}
|
||||
List<AttachmentRequest> attachmentRequests =new ArrayList<>();
|
||||
S3DocxProcessor processor = new S3DocxProcessor(s3Client);
|
||||
List<String> urls=new ArrayList<>();
|
||||
Map<String, String> replacements=new HashMap<>();
|
||||
List<DocumentEntity> documentEntities=new ArrayList<>();
|
||||
if(systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED)) {
|
||||
S3DocxProcessor processor = new S3DocxProcessor(s3Client);
|
||||
List<String> urls=new ArrayList<>();
|
||||
Map<String, String> replacements = Map.of(
|
||||
replacements = Map.of(
|
||||
"{call_name}", applicationEntity.getCall().getName(),
|
||||
"{amount_accepted}", String.valueOf(applicationEntity.getAmountAccepted()),
|
||||
"{pec}", "bandi.gepafin@legalmail.it"
|
||||
);
|
||||
List<DocumentEntity> documentEntities=documentRepository.findBySourceInAndIsDeletedFalse(List.of(applicationAmendmentRequest.getAmendmentDocumentType(),"MODELLO_AUTOCERTIFICAZIONE","MODELLO_PRIVACY"));
|
||||
urls = documentEntities.stream()
|
||||
.map(DocumentEntity::getFilePath) // or getUrl()
|
||||
.collect(Collectors.toList());
|
||||
documentEntities=documentRepository.findBySourceInAndIsDeletedFalse(List.of(applicationAmendmentRequest.getAmendmentDocumentType(),"MODELLO_AUTOCERTIFICAZIONE","MODELLO_PRIVACY"));
|
||||
}
|
||||
if(Boolean.TRUE.equals(userEntity.getHub().getUniqueUuid().equals(defaultHubUuid)) && Boolean.TRUE.equals(systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.APPLICATION_AMENDMENT_REQUESTED))) {
|
||||
List<Long> documentIds=applicationDao.validateDocumentIds(applicationAmendmentRequest.getAmendmentInitialDocument());
|
||||
Set<Long> setOfDocumentIds = (documentIds == null)
|
||||
? Collections.emptySet()
|
||||
: new HashSet<>(documentIds);
|
||||
documentEntities=documentRepository.findAllByIdInAndIsDeletedFalse(setOfDocumentIds);
|
||||
}
|
||||
|
||||
urls = documentEntities.stream()
|
||||
.map(DocumentEntity::getFilePath) // or getUrl()
|
||||
.collect(Collectors.toList());
|
||||
if(Boolean.FALSE.equals(urls.isEmpty())) {
|
||||
Map<String, AttachmentRequest> processedFiles = null;
|
||||
try {
|
||||
processedFiles = processor.processFiles(urls, replacements);
|
||||
@@ -159,7 +176,6 @@ public class EmailNotificationDao {
|
||||
attachmentRequests.add(attachmentRequest);
|
||||
}
|
||||
}
|
||||
|
||||
UserWithCompanyEntity userWithCompany=companyService.getUserWithCompany(userEntity.getId(),company.getId());
|
||||
String companyEmail = userWithCompany.getEmail();
|
||||
String contactEmail = userWithCompany.getContactEmail();
|
||||
@@ -404,7 +420,7 @@ public class EmailNotificationDao {
|
||||
return emailConfig;
|
||||
}
|
||||
|
||||
private EmailConfig parseEmailConfig(String configJson) {
|
||||
private static EmailConfig parseEmailConfig(String configJson) {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
@@ -413,11 +429,27 @@ public class EmailNotificationDao {
|
||||
throw new IllegalArgumentException("Failed to parse email configuration JSON", e);
|
||||
}
|
||||
}
|
||||
public void sendMailForApplicationTechnicalEvaluationRejected(ApplicationEntity applicationEntity,HubEntity hub,ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||
public void sendMailForApplicationTechnicalEvaluationRejected(ApplicationEntity applicationEntity,HubEntity hub,ApplicationEvaluationEntity applicationEvaluationEntity,Map<String, Object> emailJson) {
|
||||
|
||||
HubEntity hubEntity = hubService.valdateHub(applicationEntity.getHubId());
|
||||
SystemEmailTemplateResponse systemEmailTemplateResponse=new SystemEmailTemplateResponse();
|
||||
systemEmailTemplateResponse.setSubject((String) emailJson.get("subject"));
|
||||
systemEmailTemplateResponse.setHtmlContent((String) emailJson.get("message"));
|
||||
Map<String, String> subjectPlaceholders = new HashMap<>();
|
||||
CompanyEntity company = companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
subjectPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
||||
subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
|
||||
Map<String, String> bodyPlaceholders = prepareEmailPlaceholdersForTechnicalEvaluationRejected(applicationEntity,hub,applicationEvaluationEntity);
|
||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_TECHNICAL_EVALUATION_FAILURE, bodyPlaceholders, null,
|
||||
null);
|
||||
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
||||
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||
SystemEmailTemplateResponse systemEmailTemplateResponse1=new SystemEmailTemplateResponse();
|
||||
systemEmailTemplateResponse1.setSubject(subject);
|
||||
systemEmailTemplateResponse1.setHtmlContent(body);
|
||||
systemEmailTemplateResponse1.setEmailScenario(EmailScenarioTypeEnum.APPLICATION_TECHNICAL_EVALUATION_REJECTED);
|
||||
EmailContentResponse emailContentResponse=new EmailContentResponse(subject,body,systemEmailTemplateResponse1);
|
||||
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
||||
sendEmails(applicationEntity, userEntity, null,null,emailContentResponse.getSystemEmailTemplateResponse(),emailContentResponse.getSubject(),emailContentResponse.getBody());
|
||||
|
||||
}
|
||||
public Map<String, String> prepareEmailPlaceholdersForTechnicalEvaluationRejected(ApplicationEntity applicationEntity,HubEntity hub,ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||
Map<String, String> bodyPlaceholders = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user