Enhanced PEC error response saving
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
@@ -308,6 +309,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
emailNotificationDao.sendMailToNotifyBeneficiaryRegardingNewAmendment(applicationAmendmentRequestEntity);
|
||||
EmailSendResponse emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
applicationAmendmentRequestResponse.setEmailSendResponse(emailSendResponse);
|
||||
saveEmailSendResponse(emailSendResponse, applicationAmendmentRequestEntity);
|
||||
}
|
||||
return applicationAmendmentRequestResponse;
|
||||
}
|
||||
@@ -1197,6 +1199,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email), emailLogRequest);
|
||||
EmailSendResponse emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
emailReminderResponse.setEmailSendResponse(emailSendResponse);
|
||||
saveEmailSendResponse(emailSendResponse, amendment);
|
||||
} else {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.BENEFICIARY_EMAIL_NOT_FOUND_MSG));
|
||||
}
|
||||
@@ -1551,8 +1554,14 @@ public class ApplicationAmendmentRequestDao {
|
||||
applicationAmendmentRequestViewResponse.setExpirationDate(applicationAmendmentRequestView.getExpirationDate());
|
||||
applicationAmendmentRequestViewResponse.setAssigendUserName(applicationAmendmentRequestView.getAssigendUserName());
|
||||
applicationAmendmentRequestViewResponse.setStatus(applicationAmendmentRequestView.getStatus());
|
||||
applicationAmendmentRequestViewResponse.setEmailSendResponse(applicationAmendmentRequestView.getEmailSendResponse());
|
||||
return applicationAmendmentRequestViewResponse;
|
||||
}
|
||||
|
||||
private void saveEmailSendResponse(EmailSendResponse newResponses, ApplicationAmendmentRequestEntity amendment) {
|
||||
List<EmailSendResponse> mergedResponses = Utils.mergeEmailSendResponses(amendment.getEmailSendResponse(), newResponses);
|
||||
|
||||
amendment.setEmailSendResponse(mergedResponses);
|
||||
applicationAmendmentRequestRepository.save(amendment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1892,7 +1892,7 @@ public class ApplicationEvaluationDao {
|
||||
log.info("Status updated to ADMISSIBLE for applicationId: " + application.getId());
|
||||
emailNotificationDao.sendAdmissibilityNotificationEmailForAdmissibleApplication(application);
|
||||
emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
|
||||
saveEmailSendResponseToEvaluation(emailSendResponse,existingEntity);
|
||||
}
|
||||
|
||||
if(newStatus.equals(ApplicationStatusForEvaluation.TECHNICAL_EVALUATION) && Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.ADMISSIBLE.getValue()))){
|
||||
@@ -1950,6 +1950,7 @@ public class ApplicationEvaluationDao {
|
||||
application = applicationRepository.save(application);
|
||||
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(application,existingEntity);
|
||||
emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
saveEmailSendResponseToEvaluation(emailSendResponse,existingEntity);
|
||||
}
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_RESULT);
|
||||
@@ -1963,6 +1964,14 @@ public class ApplicationEvaluationDao {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void saveEmailSendResponseToEvaluation(EmailSendResponse newResponse, ApplicationEvaluationEntity evaluationEntity) {
|
||||
List<EmailSendResponse> mergedResponses = Utils.mergeEmailSendResponses(
|
||||
evaluationEntity.getEmailSendResponse(), newResponse
|
||||
);
|
||||
evaluationEntity.setEmailSendResponse(mergedResponses);
|
||||
applicationEvaluationRepository.save(evaluationEntity);
|
||||
}
|
||||
|
||||
public ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId) {
|
||||
return applicationEvaluationRepository
|
||||
.findByApplicationIdAndIsDeletedFalse(applicationId)
|
||||
|
||||
@@ -470,6 +470,7 @@ public class AssignedApplicationsDao {
|
||||
response.setCompanyName(view.getCompanyName());
|
||||
response.setCreatedDate(view.getCreatedDate());
|
||||
response.setUpdatedDate(view.getUpdatedDate());
|
||||
response.setEmailSendResponse(view.getEmailSendResponse());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Log4j2
|
||||
@@ -36,21 +35,25 @@ public class EmailDao {
|
||||
@Autowired
|
||||
private CallService callService;
|
||||
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
|
||||
public EmailResendResponseBean resendEmail(HttpServletRequest request , Long userActionId){
|
||||
List<EmailLogEntity> emailLogs = emailLogRepository.findByUserActionIdAndEmailServiceType(userActionId,EmailServiceTypeEnum.PEC_SERVICE.getValue());
|
||||
List<EmailLogEntity> emailLogs = emailLogRepository.findByUserActionIdAndEmailServiceTypeAndSendStatus(userActionId,EmailServiceTypeEnum.PEC_SERVICE.getValue(),StatusTypeEnum.FAILED.getValue());
|
||||
if (emailLogs.isEmpty()) {
|
||||
log.info("No emails found for given userActionId.");
|
||||
}
|
||||
EmailResendResponseBean emailResendResponseBean = new EmailResendResponseBean();
|
||||
for (EmailLogEntity log : emailLogs){
|
||||
EmailLogRequest emailLogRequest = new EmailLogRequest();
|
||||
emailLogRequest.setEmailType(EmailScenarioTypeEnum.valueOf(log.getEmailType()));
|
||||
emailLogRequest.setRecipientType(RecipientTypeEnum.valueOf(log.getRecipientType()));
|
||||
emailLogRequest.setRecipientId(log.getRecipientId());
|
||||
emailLogRequest.setUserId(log.getUserId());
|
||||
emailLogRequest.setApplicatioId(log.getApplicationId());
|
||||
emailLogRequest.setCallId(log.getCallId());
|
||||
emailLogRequest.setAmendmentId(log.getAmendmentId());
|
||||
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(EmailScenarioTypeEnum.valueOf(log.getEmailType()),
|
||||
RecipientTypeEnum.valueOf(log.getRecipientType()),
|
||||
log.getRecipientId(),
|
||||
log.getRecipientEmails(),
|
||||
log.getUserId(),
|
||||
log.getApplicationId(),
|
||||
log.getAmendmentId(),
|
||||
log.getCallId()
|
||||
);
|
||||
|
||||
List<String> recipients = Utils.commaSeparatedStringToList(log.getRecipientEmails());
|
||||
CallEntity call = callService.validateCall(log.getCallId());
|
||||
@@ -69,23 +72,37 @@ public class EmailDao {
|
||||
|
||||
public EmailSendResponse buildEmailSendResponseFromRequest(HttpServletRequest request) {
|
||||
Long userActionId = (Long) request.getAttribute(GepafinConstant.USER_ACTION_ID);
|
||||
boolean isEmailSendSuccess = isEmailSentSuccessfully(userActionId);
|
||||
EmailSendResponse emailSendResponse = new EmailSendResponse();
|
||||
emailSendResponse.setIsEmailSend(isEmailSendSuccess);
|
||||
emailSendResponse.setUserActionId(userActionId);
|
||||
return emailSendResponse;
|
||||
}
|
||||
|
||||
public boolean isEmailSentSuccessfully(Long userActionId) {
|
||||
List<EmailLogEntity> emailLogs = emailLogRepository.findByUserActionId(userActionId);
|
||||
|
||||
boolean allSuccess = true;
|
||||
String emailScenario = null;
|
||||
|
||||
for (EmailLogEntity log : emailLogs) {
|
||||
if (EmailServiceTypeEnum.PEC_SERVICE.getValue().equals(log.getEmailServiceType()) &&
|
||||
StatusTypeEnum.SUCCESS.getValue().equals(log.getSendStatus())) {
|
||||
return true;
|
||||
if (emailScenario == null) {
|
||||
emailScenario = log.getEmailType();
|
||||
}
|
||||
boolean isSuccess = EmailServiceTypeEnum.PEC_SERVICE.getValue().equals(log.getEmailServiceType()) &&
|
||||
StatusTypeEnum.SUCCESS.getValue().equals(log.getSendStatus());
|
||||
if (!isSuccess) {
|
||||
allSuccess = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return buildResponse(userActionId, allSuccess, emailScenario);
|
||||
}
|
||||
|
||||
private EmailSendResponse buildResponse(Long userActionId, boolean allSuccess, String emailScenario) {
|
||||
EmailSendResponse response = new EmailSendResponse();
|
||||
response.setUserActionId(userActionId);
|
||||
response.setIsEmailSend(allSuccess);
|
||||
response.setEmailScenario(emailScenario != null ? EmailScenarioTypeEnum.valueOf(emailScenario) : null);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.springframework.stereotype.Component;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
@@ -155,6 +156,8 @@ public class UserDao {
|
||||
emailSendResponse.setIsEmailSend(isEmailSendSuccess);
|
||||
Long userActionId =(Long)request.getAttribute(GepafinConstant.USER_ACTION_ID);
|
||||
emailSendResponse.setUserActionId(userActionId);
|
||||
emailSendResponse.setEmailScenario(EmailScenarioTypeEnum.USER_CREATION);
|
||||
saveEmailSendResponseToUser(emailSendResponse,userEntity);
|
||||
}
|
||||
JWTToken token = authService.getJWTTokenBean(userEntity, Boolean.TRUE, loginAttemptEntity.getId(),emailSendResponse);
|
||||
return token;
|
||||
@@ -406,6 +409,7 @@ public class UserDao {
|
||||
RoleResponseBean roleResponseBean = roleDao.convertRoleEntityToRoleResponse(userEntity.getRoleEntity());
|
||||
userResponseBean.setRole(roleResponseBean);
|
||||
userResponseBean.setLastLogin(userEntity.getLastLogin());
|
||||
userResponseBean.setEmailSendResponse(userEntity.getEmailSendResponse());
|
||||
List<CompanyResponse> companyResponseBeans = companyDao.getCompanyByUserId(userEntity.getId());
|
||||
userResponseBean.setCompanies(companyResponseBeans);
|
||||
if (userEntity.getBeneficiary() == null) {
|
||||
@@ -506,8 +510,18 @@ public class UserDao {
|
||||
InitiatePasswordResetResponse initiatePasswordResetResponse = new InitiatePasswordResetResponse();
|
||||
EmailSendResponse emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
initiatePasswordResetResponse.setEmailSendResponse(emailSendResponse);
|
||||
saveEmailSendResponseToUser(emailSendResponse,user);
|
||||
return initiatePasswordResetResponse;
|
||||
}
|
||||
|
||||
private void saveEmailSendResponseToUser(EmailSendResponse newResponse, UserEntity user) {
|
||||
List<EmailSendResponse> mergedResponses = Utils.mergeEmailSendResponses(
|
||||
user.getEmailSendResponse(), newResponse
|
||||
);
|
||||
user.setEmailSendResponse(mergedResponses);
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
||||
public void sendResetPasswordTokenEmail(UserEntity user, String token) {
|
||||
|
||||
SystemEmailTemplateResponse emailTemplate = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(
|
||||
|
||||
@@ -2,7 +2,10 @@ package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name="application_amendment_request")
|
||||
@@ -53,7 +56,10 @@ public class ApplicationAmendmentRequestEntity extends BaseEntity {
|
||||
@Column(name = "amendment_document")
|
||||
private String amendmentDocument;
|
||||
|
||||
|
||||
@Column(name = "CLOSING_DATE")
|
||||
private LocalDateTime closingDate;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package net.gepafin.tendermanagement.entities;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Immutable
|
||||
@@ -13,12 +16,12 @@ import java.time.LocalDateTime;
|
||||
@Getter
|
||||
@Setter
|
||||
@IdClass(ApplicationAmendmentRequestViewId.class)
|
||||
public class ApplicationAmendmentRequestView {
|
||||
public class ApplicationAmendmentRequestView extends BaseEntity {
|
||||
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
private Long id;
|
||||
// @Id
|
||||
// @Column(name = "ID")
|
||||
// private Long id;
|
||||
|
||||
@Column(name = "APPLICATION_ID")
|
||||
private Long applicationId;
|
||||
@@ -56,12 +59,17 @@ public class ApplicationAmendmentRequestView {
|
||||
@Column(name = "APPLICATION_USER_ID")
|
||||
private Long applicationUserId;
|
||||
|
||||
@Column(name = "CREATED_DATE")
|
||||
private String createdDate;
|
||||
|
||||
@Column(name = "UPDATED_DATE")
|
||||
private String updatedDate;
|
||||
// @Column(name = "CREATED_DATE")
|
||||
// private String createdDate;
|
||||
//
|
||||
// @Column(name = "UPDATED_DATE")
|
||||
// private String updatedDate;
|
||||
|
||||
@Column(name = "IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@@ -71,4 +73,7 @@ public class ApplicationEvaluationEntity extends BaseEntity{
|
||||
@Column(name = "evaluationVersion")
|
||||
private String evaluationVersion;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Immutable
|
||||
@@ -58,4 +60,8 @@ public class AssignedApplicationsView{
|
||||
|
||||
@Column(name = "IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.persistence.AttributeConverter;
|
||||
import jakarta.persistence.Converter;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Converter
|
||||
public class EmailSendResponseConverter implements AttributeConverter<List<EmailSendResponse>, String> {
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String convertToDatabaseColumn(List<EmailSendResponse> attribute) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(attribute);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new IllegalArgumentException("Error converting list to JSON", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmailSendResponse> convertToEntityAttribute(String dbData) {
|
||||
if (dbData == null || dbData.isBlank()) {
|
||||
return List.of(); // or null if you prefer
|
||||
}
|
||||
try {
|
||||
return objectMapper.readValue(dbData, new TypeReference<List<EmailSendResponse>>() {});
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Error reading JSON from database", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "GEPAFIN_USER")
|
||||
@@ -69,4 +71,9 @@ public class UserEntity extends BaseEntity {
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "HUB_ID")
|
||||
private HubEntity hub;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.model.response;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApplicationAmendmentRequestViewResponse {
|
||||
@@ -24,4 +25,6 @@ public class ApplicationAmendmentRequestViewResponse {
|
||||
private String assigendUserName;
|
||||
|
||||
private String status;
|
||||
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AssignedApplicationViewResponse extends BaseBean {
|
||||
@@ -20,5 +21,7 @@ public class AssignedApplicationViewResponse extends BaseBean {
|
||||
private Long protocolNumber;
|
||||
private String callName;
|
||||
private String companyName;
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||
|
||||
@Data
|
||||
public class EmailSendResponse {
|
||||
private Boolean isEmailSend;
|
||||
private Long userActionId;
|
||||
private EmailScenarioTypeEnum emailScenario;
|
||||
}
|
||||
|
||||
@@ -48,4 +48,5 @@ public class UserResponseBean extends BaseBean {
|
||||
private Boolean thirdParty;
|
||||
|
||||
private String emailPec;
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ public interface EmailLogRepository extends JpaRepository<EmailLogEntity,Long> {
|
||||
|
||||
List<EmailLogEntity> findByUserIdAndAmendmentIdAndIsDeletedFalse(Long userId,Long amendmentId);
|
||||
List<EmailLogEntity> findByUserActionId(Long userActionId);
|
||||
List<EmailLogEntity> findByUserActionIdAndEmailServiceType(Long userActionId, String emailServiceType);
|
||||
|
||||
List<EmailLogEntity> findByUserActionIdAndEmailServiceTypeAndSendStatus(
|
||||
Long userActionId, String emailServiceType, String sendStatus);
|
||||
Optional<EmailLogEntity> findTopByUserIdAndEmailTypeAndIsDeletedFalseOrderByCreatedDateDesc(Long userId, String emailType);
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -36,9 +37,11 @@ import jakarta.persistence.criteria.Root;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.MatchModeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.FilterCriteria;
|
||||
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.*;
|
||||
import net.objecthunter.exp4j.Expression;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
@@ -1021,5 +1024,21 @@ public class Utils {
|
||||
}
|
||||
|
||||
|
||||
public static List<EmailSendResponse> mergeEmailSendResponses(List<EmailSendResponse> existingResponses, EmailSendResponse newResponse) {
|
||||
Map<EmailScenarioTypeEnum, EmailSendResponse> responseMap = Optional.ofNullable(existingResponses)
|
||||
.orElse(new ArrayList<>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
EmailSendResponse::getEmailScenario,
|
||||
Function.identity(),
|
||||
(oldVal, newVal) -> newVal,
|
||||
LinkedHashMap::new
|
||||
));
|
||||
|
||||
responseMap.put(newResponse.getEmailScenario(), newResponse);
|
||||
|
||||
return new ArrayList<>(responseMap.values());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user