Resolved conflicts
This commit is contained in:
@@ -290,5 +290,6 @@ public class GepafinConstant {
|
||||
public static final String REMINDER_EMAIL_SENT_SUCCESS_MSG = "reminder.email.sent.success.msg";
|
||||
public static final String ENCRYPT_INIT_VECTOR = "IG8*(*@&)*#biVVD";
|
||||
public static final String ENCRYPT_KEY = "U2VjdXJlRW5jcnlwdEtleQ==";
|
||||
public static final String DUPLICATE_BENEFICIARY_CALL = "beneficiary.call.duplicate";
|
||||
}
|
||||
|
||||
|
||||
@@ -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.Join;
|
||||
@@ -8,15 +9,15 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.*;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
@@ -25,10 +26,8 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -174,7 +173,8 @@ public class ApplicationAmendmentRequestDao {
|
||||
|
||||
try {
|
||||
List<Map<String, Object>> dataList = objectMapper.readValue(
|
||||
content, new TypeReference<List<Map<String, Object>>>() {});
|
||||
content, new TypeReference<List<Map<String, Object>>>() {
|
||||
});
|
||||
|
||||
for (Map<String, Object> data : dataList) {
|
||||
if (target.equals(data.get("name"))) {
|
||||
@@ -194,7 +194,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = createApplicationAmendmentRequestEntity(applicationAmendmentRequest, applicationEvaluationId);
|
||||
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = convertEntityToResponse(applicationAmendmentRequestEntity);
|
||||
log.info("Application submitted successfully for amendment", applicationAmendmentRequestResponse);
|
||||
if(Boolean.TRUE.equals(applicationAmendmentRequestResponse.isSendEmail())){
|
||||
if (Boolean.TRUE.equals(applicationAmendmentRequestResponse.getIsSendEmail())) {
|
||||
emailNotificationDao.sendMailToNotifyBeneficiaryRegardingNewAmendment(applicationAmendmentRequestEntity);
|
||||
}
|
||||
return applicationAmendmentRequestResponse;
|
||||
@@ -216,11 +216,17 @@ public class ApplicationAmendmentRequestDao {
|
||||
applicationAmendmentRequestEntity.setApplicationId(applicationId);
|
||||
|
||||
if (applicationAmendmentRequest.getFormFields() != null) {
|
||||
String fieldIdsString = applicationAmendmentRequest.getFormFields().stream()
|
||||
List<ApplicationFormFieldRequestBean> formFieldRequestBean = applicationAmendmentRequest.getFormFields().stream()
|
||||
.filter(AmendmentFormFieldResponse::isSelected)
|
||||
.map(AmendmentFormFieldResponse::getFieldId)
|
||||
.collect(Collectors.joining(","));
|
||||
applicationAmendmentRequestEntity.setFormFields(fieldIdsString);
|
||||
.map(amendmentFormFieldRequest -> {
|
||||
ApplicationFormFieldRequestBean formField = new ApplicationFormFieldRequestBean();
|
||||
formField.setFieldId(amendmentFormFieldRequest.getFieldId());
|
||||
formField.setFieldValue(null);
|
||||
return formField;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
String formFieldsJson = Utils.convertObjectToJson(formFieldRequestBean);
|
||||
applicationAmendmentRequestEntity.setFormFields(formFieldsJson);
|
||||
}
|
||||
UserEntity userEntity = userService.validateUser(applicationEvaluationEntity.getUserId());
|
||||
Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub());
|
||||
@@ -269,8 +275,8 @@ public class ApplicationAmendmentRequestDao {
|
||||
LocalDateTime expirationDate = startDate.plus(expirationDays, ChronoUnit.DAYS);
|
||||
applicationAmendmentRequestResponse.setExpirationDate(expirationDate);
|
||||
|
||||
applicationAmendmentRequestResponse.setSendEmail(applicationAmendmentRequestEntity.getIsEmail());
|
||||
applicationAmendmentRequestResponse.setSendNotification(applicationAmendmentRequestEntity.getIsNotification());
|
||||
applicationAmendmentRequestResponse.setIsSendEmail(applicationAmendmentRequestEntity.getIsEmail());
|
||||
applicationAmendmentRequestResponse.setIsSendNotification(applicationAmendmentRequestEntity.getIsNotification());
|
||||
String callName = application.getCall().getName();
|
||||
Long protocolNumber = (applicationAmendmentRequestEntity.getProtocol() != null && applicationAmendmentRequestEntity.getProtocol().getProtocolNumber() != null)
|
||||
? applicationAmendmentRequestEntity.getProtocol().getProtocolNumber()
|
||||
@@ -287,48 +293,64 @@ public class ApplicationAmendmentRequestDao {
|
||||
applicationAmendmentRequestResponse.setProtocolNumber(protocolNumber);
|
||||
applicationAmendmentRequestResponse.setBeneficiaryName(beneficiaryName);
|
||||
|
||||
String formFieldsString = applicationAmendmentRequestEntity.getFormFields();
|
||||
List<String> storedFieldIds = (formFieldsString != null) ? Arrays.asList(formFieldsString.split(",")) : Collections.emptyList();
|
||||
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(application.getId());
|
||||
List<AmendmentFormFieldResponse> formFields = new ArrayList<>();
|
||||
for (ApplicationFormEntity formEntity : applicationForms) {
|
||||
String content = formEntity.getForm().getContent();
|
||||
List<Map<String, Object>> result = filterByName(content, "fileupload");
|
||||
List<ApplicationFormEntity> forms = applicationFormRepository.findByApplicationId(applicationId);
|
||||
List<AmendmentFormFieldResponse> allFormFields = new ArrayList<>();
|
||||
|
||||
List<AmendmentFormFieldResponse> matchingFields = getIdAndLabelFromResult(result).stream()
|
||||
.filter(field -> storedFieldIds.contains(field.getFieldId()))
|
||||
.collect(Collectors.toList());
|
||||
formFields.addAll(matchingFields);
|
||||
for (ApplicationFormEntity form : forms) {
|
||||
String content = form.getForm().getContent();
|
||||
List<Map<String, Object>> result = filterByName(content, "fileupload");
|
||||
allFormFields.addAll(getIdAndLabelFromResult(result));
|
||||
}
|
||||
|
||||
Map<String, String> fieldIdToLabelMap = allFormFields.stream()
|
||||
.collect(Collectors.toMap(AmendmentFormFieldResponse::getFieldId, AmendmentFormFieldResponse::getLabel));
|
||||
|
||||
String formFieldsJson = applicationAmendmentRequestEntity.getFormFields();
|
||||
List<AmendmentFormFieldResponse> formFields = Utils.convertJsonToList(
|
||||
formFieldsJson, new TypeReference<List<AmendmentFormFieldResponse>>() {
|
||||
});
|
||||
|
||||
for (AmendmentFormFieldResponse formField : formFields) {
|
||||
String label = fieldIdToLabelMap.get(formField.getFieldId());
|
||||
formField.setLabel(label);
|
||||
formField.setSelected(true);
|
||||
}
|
||||
// Set the filtered formFields in the response
|
||||
applicationAmendmentRequestResponse.setFormFields(formFields);
|
||||
|
||||
List<AmendmentFormFieldResponse> formField = formFields.stream()
|
||||
.map(field -> {
|
||||
AmendmentFormFieldResponse responseField = new AmendmentFormFieldResponse();
|
||||
responseField.setFieldId(field.getFieldId());
|
||||
responseField.setLabel(field.getLabel());
|
||||
responseField.setSelected(true);
|
||||
return responseField;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
applicationAmendmentRequestResponse.setFormFields(formField);
|
||||
|
||||
List<ApplicationFormFieldEntity> formFieldEntities = applicationFormFieldRepository.findByApplicationFormIdIn(
|
||||
applicationForms.stream().map(ApplicationFormEntity::getId).collect(Collectors.toList())
|
||||
);
|
||||
String applicationFormFieldsJson = applicationAmendmentRequestEntity.getFormFields();
|
||||
List<ApplicationFormFieldResponseBean> applicationFormFields = Utils.convertJsonToList(
|
||||
formFieldsJson, new TypeReference<List<ApplicationFormFieldResponseBean>>() {
|
||||
});
|
||||
|
||||
List<ApplicationFormFieldResponseBean> fileDetailResponses = new ArrayList<>();
|
||||
for (AmendmentFormFieldResponse field : formFields) {
|
||||
for (ApplicationFormFieldEntity formFieldEntity : formFieldEntities) {
|
||||
if (formFieldEntity.getFieldId().equals(field.getFieldId()) && formFieldEntity.getFieldValue() != null) {
|
||||
for (ApplicationFormFieldResponseBean field : applicationFormFields) {
|
||||
ApplicationFormFieldResponseBean responseBean = new ApplicationFormFieldResponseBean();
|
||||
responseBean.setFieldId(formFieldEntity.getFieldId());
|
||||
responseBean.setFieldId(field.getFieldId());
|
||||
|
||||
String[] documentIds = formFieldEntity.getFieldValue().split(",");
|
||||
Optional<ApplicationFormFieldEntity> formFieldEntity = Optional.empty();
|
||||
for (ApplicationFormEntity form : forms) {
|
||||
formFieldEntity = applicationFormFieldRepository
|
||||
.findByApplicationFormIdAndFieldId(form.getId(), field.getFieldId());
|
||||
if (formFieldEntity.isPresent()) {
|
||||
// Set the applicationFormId from the matching form
|
||||
responseBean.setApplicationFormId(form.getId());
|
||||
responseBean.setId(formFieldEntity.get().getId());
|
||||
responseBean.setCreatedDate(formFieldEntity.get().getCreatedDate());
|
||||
responseBean.setUpdatedDate(formFieldEntity.get().getUpdatedDate());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if fieldValue is not null and is a String
|
||||
if (field.getFieldValue() instanceof String && field.getFieldValue() != null && !((String) field.getFieldValue()).isBlank()) {
|
||||
String fieldValueString = (String) field.getFieldValue();
|
||||
String[] documentIds = fieldValueString.split(",");
|
||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||
|
||||
// Process each document ID
|
||||
for (String docId : documentIds) {
|
||||
try {
|
||||
Long documentId = Long.valueOf(docId.trim());
|
||||
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||
DocumentResponseBean docBean = new DocumentResponseBean();
|
||||
@@ -342,13 +364,18 @@ public class ApplicationAmendmentRequestDao {
|
||||
docBean.setUpdatedDate(documentEntity.getUpdatedDate());
|
||||
documentResponseBeans.add(docBean);
|
||||
});
|
||||
} catch (NumberFormatException e) {
|
||||
// Handle the case where documentId is not a valid number
|
||||
// Log the error if necessary
|
||||
}
|
||||
}
|
||||
responseBean.setFieldValue(documentResponseBeans);
|
||||
} else {
|
||||
responseBean.setFieldValue(null);
|
||||
}
|
||||
|
||||
responseBean.setFieldValue(documentResponseBeans);
|
||||
fileDetailResponses.add(responseBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
applicationAmendmentRequestResponse.setApplicationFormFields(fileDetailResponses);
|
||||
|
||||
@@ -416,6 +443,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
setIfUpdated(existingApplicationAmendment::getNote, existingApplicationAmendment::setNote, updateRequest.getNote());
|
||||
if (updateRequest.getApplicationFormFields() != null) {
|
||||
updateApplicationFormFields(existingApplicationAmendment, updateRequest.getApplicationFormFields());
|
||||
updateFormFieldsJson(existingApplicationAmendment, updateRequest.getApplicationFormFields());
|
||||
}
|
||||
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
|
||||
@@ -479,23 +507,71 @@ public class ApplicationAmendmentRequestDao {
|
||||
|
||||
boolean fieldUpdated = false;
|
||||
|
||||
// Parse the formFields JSON string to get amendment field values
|
||||
String amendmentFieldValue = null;
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
List<ApplicationFormFieldRequestBean> amendmentFields = mapper.readValue(
|
||||
applicationAmendment.getFormFields(),
|
||||
mapper.getTypeFactory().constructCollectionType(List.class, ApplicationFormFieldRequestBean.class)
|
||||
);
|
||||
|
||||
// Find the matching field value and convert to string if found
|
||||
Optional<Object> amendmentFieldObj = amendmentFields.stream()
|
||||
.filter(field -> updatedFormField.getFieldId().equals(field.getFieldId()))
|
||||
.map(ApplicationFormFieldRequestBean::getFieldValue)
|
||||
.findFirst();
|
||||
|
||||
if (amendmentFieldObj.isPresent() && amendmentFieldObj.get() instanceof String) {
|
||||
amendmentFieldValue = (String) amendmentFieldObj.get();
|
||||
}
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing formFields JSON: {}", e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (amendmentFieldValue == null) {
|
||||
log.warn("No matching field found in amendment for field ID {}", updatedFormField.getFieldId());
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> amendmentDocumentIds = Arrays.asList(amendmentFieldValue.split(","));
|
||||
|
||||
for (ApplicationFormEntity applicationForm : applicationForms) {
|
||||
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||
.findByApplicationFormIdAndFieldId(applicationForm.getId(), updatedFormField.getFieldId());
|
||||
|
||||
if (formFieldEntityOptional.isPresent()) {
|
||||
ApplicationFormFieldEntity formEntity = formFieldEntityOptional.get();
|
||||
formEntity.setFieldValue(String.join(",", validDocumentIds));
|
||||
|
||||
// Retrieve existing document IDs in ApplicationFormFieldTable
|
||||
String existingFieldValue = formEntity.getFieldValue();
|
||||
Set<String> existingDocumentIds = existingFieldValue != null
|
||||
? new HashSet<>(Arrays.asList(existingFieldValue.split(",")))
|
||||
: new HashSet<>();
|
||||
|
||||
// Remove amendment documents from existing document IDs
|
||||
existingDocumentIds.removeAll(amendmentDocumentIds);
|
||||
|
||||
// Add valid new document IDs from the request
|
||||
existingDocumentIds.addAll(validDocumentIds);
|
||||
|
||||
// Set the combined document IDs back as the field value
|
||||
formEntity.setFieldValue(String.join(",", existingDocumentIds));
|
||||
applicationFormFieldRepository.save(formEntity);
|
||||
|
||||
log.info("Updated field value for application ID {} and field ID {} with document IDs {}",
|
||||
applicationAmendment.getApplicationId(), updatedFormField.getFieldId(), String.join(",", validDocumentIds));
|
||||
applicationAmendment.getApplicationId(), updatedFormField.getFieldId(), String.join(",", existingDocumentIds));
|
||||
fieldUpdated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fieldUpdated) {
|
||||
throw new CustomValidationException(Status.NOT_FOUND,"No ApplicationFormField found for application ID {} and field ID {}. Skipping update.");
|
||||
throw new CustomValidationException(Status.NOT_FOUND,
|
||||
String.format("No ApplicationFormField found for application ID %s and field ID %s. Skipping update.",
|
||||
applicationAmendment.getApplicationId(), updatedFormField.getFieldId()));
|
||||
}
|
||||
} else {
|
||||
log.warn("No valid document IDs found for update. Skipping field ID {}", updatedFormField.getFieldId());
|
||||
@@ -503,6 +579,54 @@ public class ApplicationAmendmentRequestDao {
|
||||
}
|
||||
|
||||
|
||||
private void updateFormFieldsJson(ApplicationAmendmentRequestEntity applicationAmendment, ApplicationFormFieldRequestBean updatedFormField) {
|
||||
if (updatedFormField != null) {
|
||||
try {
|
||||
// Step 1: Fetch the existing form fields JSON
|
||||
String existingFormFieldsJson = applicationAmendment.getFormFields();
|
||||
List<ApplicationFormFieldRequestBean> formFieldsList;
|
||||
|
||||
if (existingFormFieldsJson == null || existingFormFieldsJson.isEmpty()) {
|
||||
formFieldsList = new ArrayList<>(); // If no existing data, start with an empty list
|
||||
} else {
|
||||
// Step 2: Deserialize the existing JSON into a list of objects
|
||||
formFieldsList = new ObjectMapper().readValue(existingFormFieldsJson, new TypeReference<List<ApplicationFormFieldRequestBean>>() {
|
||||
});
|
||||
}
|
||||
|
||||
// Step 3: Check if the field ID already exists in the list and update it
|
||||
boolean fieldUpdated = false;
|
||||
for (ApplicationFormFieldRequestBean field : formFieldsList) {
|
||||
if (field.getFieldId().equals(updatedFormField.getFieldId())) {
|
||||
field.setFieldValue(updatedFormField.getFieldValue()); // Update field value
|
||||
fieldUpdated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If field wasn't updated, log a warning message instead of adding a new field
|
||||
if (!fieldUpdated) {
|
||||
log.warn("Field ID {} does not exist in the form fields for application amendment ID {}", updatedFormField.getFieldId(), applicationAmendment.getId());
|
||||
throw new CustomValidationException(Status.NOT_FOUND, "Field ID {} does not exist in the form fields for application amendment ID {}");
|
||||
|
||||
}
|
||||
|
||||
// Step 4: Serialize the updated list back to JSON if the update was successful
|
||||
String updatedFormFieldsJson = new ObjectMapper().writeValueAsString(formFieldsList);
|
||||
applicationAmendment.setFormFields(updatedFormFieldsJson); // Update the form fields with the modified list
|
||||
|
||||
log.info("Updated form fields JSON for application amendment ID {}: {}", applicationAmendment.getId(), updatedFormFieldsJson);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error processing JSON for form fields for application amendment ID {}: {}", applicationAmendment.getId(), e.getMessage());
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, "Error processing JSON for form fields");
|
||||
}
|
||||
} else {
|
||||
log.warn("No form field data to update for application amendment ID {}", applicationAmendment.getId());
|
||||
throw new CustomValidationException(Status.NOT_FOUND, "No form field data to update for application amendment ID {}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(Long beneficiaryId) {
|
||||
UserEntity userEntity = userService.validateUser(beneficiaryId);
|
||||
@@ -523,6 +647,16 @@ public class ApplicationAmendmentRequestDao {
|
||||
|
||||
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment);
|
||||
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment);
|
||||
|
||||
List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(existingApplicationAmendment.getApplicationEvaluationEntity().getId());
|
||||
boolean allClosed = amendmentRequests.stream()
|
||||
.allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()));
|
||||
|
||||
if (allClosed) {
|
||||
existingApplicationAmendment.getApplicationEvaluationEntity().setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
||||
applicationEvaluationRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity());
|
||||
log.info("All amendments are closed. Application Evaluation status set to OPEN.");
|
||||
}
|
||||
log.info("Application Amendment closed successfully: {}", response);
|
||||
return response;
|
||||
}
|
||||
@@ -547,7 +681,8 @@ public class ApplicationAmendmentRequestDao {
|
||||
if (statuses != null && !statuses.isEmpty()) {
|
||||
List<String> statusStrings = statuses.stream().map(Enum::name).collect(Collectors.toList());
|
||||
applicationAmendmentRequestEntity = applicationAmendmentRequestRepository.findByApplicationIdAndStatusInAndIsDeletedFalse(application.getId(), statusStrings);
|
||||
} if(!applicationAmendmentRequestEntity.isEmpty()) {
|
||||
}
|
||||
if (!applicationAmendmentRequestEntity.isEmpty()) {
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequest = applicationAmendmentRequestEntity.get(0);
|
||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationAmendmentRequest.getApplicationEvaluationEntity().getId());
|
||||
if (entityOptional.isPresent()) {
|
||||
@@ -556,7 +691,8 @@ public class ApplicationAmendmentRequestDao {
|
||||
} else {
|
||||
validator.validateUserId(request, entityOptional.get().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
List<ApplicationAmendmentRequestResponse> response = new ArrayList<>();
|
||||
if (applicationAmendmentRequestEntity != null) {
|
||||
response = applicationAmendmentRequestEntity.stream()
|
||||
@@ -565,6 +701,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(
|
||||
Long id, ApplicationAmendmentRequestEnum statusTypeEnum) {
|
||||
|
||||
@@ -579,6 +716,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
log.info("Amendment status updated successfully: {}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public void sendReminderEmail(Long amendmentId) {
|
||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(amendmentId)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
|
||||
@@ -93,9 +93,6 @@ public class ApplicationDao {
|
||||
@Value("${default_System_Receiver_Email}")
|
||||
private String defaultSystemReceiverEmail;
|
||||
|
||||
@Value("${gepafin_email}")
|
||||
private String gepafinEmail;
|
||||
|
||||
@Value("${rinaldo_email}")
|
||||
private String rinaldoEmail;
|
||||
|
||||
|
||||
@@ -1307,14 +1307,17 @@ public class ApplicationEvaluationDao {
|
||||
entity = applicationEvaluationRepository.save(existingEntity);
|
||||
assignedApplicationsRepository.save(assignedApplicationsEntity);
|
||||
|
||||
ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestRepository.findByApplicationEvaluationIdAndIsDeletedFalse(entity.getId());
|
||||
if(amendmentRequest!=null){
|
||||
List<ApplicationAmendmentRequestEntity> amendmentRequest = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(entity.getId());
|
||||
for (ApplicationAmendmentRequestEntity request : amendmentRequest) {
|
||||
request.setStatus(ApplicationAmendmentRequestEnum.CLOSE.getValue());
|
||||
}
|
||||
applicationAmendmentRequestRepository.saveAll(amendmentRequest);
|
||||
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.APPROVED.getValue())))) {
|
||||
emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(amendmentRequest);
|
||||
emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(application);
|
||||
}
|
||||
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.REJECTED.getValue())))) {
|
||||
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(amendmentRequest);
|
||||
}}
|
||||
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(application,existingEntity);
|
||||
}
|
||||
return convertToResponse(entity);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.slf4j.Logger;
|
||||
@@ -20,6 +21,7 @@ import org.springframework.stereotype.Component;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -38,6 +40,15 @@ public class BeneficiaryPreferredCallDao {
|
||||
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest httpServletRequest, BeneficiaryPreferredCallReq request, UserEntity user) {
|
||||
log.info("Creating new beneficiary preferred call with details: {}", request);
|
||||
validator.validateUserWithCompany(httpServletRequest, request.getCompanyId());
|
||||
|
||||
Optional<BeneficiaryPreferredCallEntity> existingCall = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(user.getId(), request.getCallId(), request.getCompanyId());
|
||||
|
||||
if (existingCall.isPresent()) {
|
||||
log.warn("Duplicate beneficiary preferred call detected: {}", existingCall.get());
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.DUPLICATE_BENEFICIARY_CALL));
|
||||
}
|
||||
|
||||
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request, user);
|
||||
entity = beneficiaryPreferredCallRepository.save(entity);
|
||||
log.info("Beneficiary preferred call created with ID: {}", entity.getId());
|
||||
@@ -53,6 +64,7 @@ public class BeneficiaryPreferredCallDao {
|
||||
entity.setCallId(request.getCallId());
|
||||
entity.setUserId(userEntity.getId());
|
||||
entity.setCompanyId(request.getCompanyId());
|
||||
entity.setIsDeleted( false);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -77,17 +89,18 @@ public class BeneficiaryPreferredCallDao {
|
||||
// }
|
||||
|
||||
public void deleteBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
|
||||
log.info("Deleting beneficiary preferred call with ID: {}", id);
|
||||
log.info("Soft deleting beneficiary preferred call with ID: {}", id);
|
||||
BeneficiaryPreferredCallEntity entity = validateBeneficiaryPreferredCall(id);
|
||||
validator.validateUserId(request, entity.getUserId());
|
||||
beneficiaryPreferredCallRepository.deleteById(id);
|
||||
log.info("Beneficiary preferred call deleted with ID: {}", id);
|
||||
entity.setIsDeleted(true);
|
||||
beneficiaryPreferredCallRepository.save(entity);
|
||||
log.info("Beneficiary preferred call soft deleted with ID: {}", id);
|
||||
}
|
||||
|
||||
public List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls(HttpServletRequest request) {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
log.info("Fetching all beneficiary preferred calls");
|
||||
List<BeneficiaryPreferredCallResponseBean> calls = beneficiaryPreferredCallRepository.findByUserId(userEntity.getId())
|
||||
List<BeneficiaryPreferredCallResponseBean> calls = beneficiaryPreferredCallRepository.findByUserIdAndIsDeletedFalse(userEntity.getId())
|
||||
.stream()
|
||||
.map(this::convertEntityToResponse)
|
||||
.collect(Collectors.toList());
|
||||
@@ -97,7 +110,7 @@ public class BeneficiaryPreferredCallDao {
|
||||
|
||||
private BeneficiaryPreferredCallEntity validateBeneficiaryPreferredCall(Long id) {
|
||||
log.info("Validating beneficiary preferred call with ID: {}", id);
|
||||
return beneficiaryPreferredCallRepository.findById(id)
|
||||
return beneficiaryPreferredCallRepository.findByIdAndIsDeletedFalse(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.BENEFICIARY_CALL_NOT_FOUND)));
|
||||
}
|
||||
|
||||
@@ -123,7 +136,7 @@ public class BeneficiaryPreferredCallDao {
|
||||
}
|
||||
public List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(UserEntity userEntity, Long companyId) {
|
||||
|
||||
List<BeneficiaryPreferredCallEntity> calls = beneficiaryPreferredCallRepository.findByUserIdAndCompanyId(userEntity.getId(), companyId);
|
||||
List<BeneficiaryPreferredCallEntity> calls = beneficiaryPreferredCallRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), companyId);
|
||||
return calls.stream()
|
||||
.map(this::convertEntityToResponse)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -10,12 +10,15 @@ import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.*;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
@@ -26,16 +29,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||
import net.gepafin.tendermanagement.entities.CallTargetAudienceChecklistEntity;
|
||||
import net.gepafin.tendermanagement.entities.CriteriaFormFieldEntity;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.EvaluationCriteriaEntity;
|
||||
import net.gepafin.tendermanagement.entities.FaqEntity;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||
import net.gepafin.tendermanagement.entities.RegionEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
||||
@@ -45,13 +39,6 @@ import net.gepafin.tendermanagement.model.request.EvaluationCriteriaReq;
|
||||
import net.gepafin.tendermanagement.model.request.FaqReq;
|
||||
import net.gepafin.tendermanagement.model.request.LookUpDataReq;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||
import net.gepafin.tendermanagement.repositories.CallTargetAudienceChecklistRepository;
|
||||
import net.gepafin.tendermanagement.repositories.CriteriaFormFieldRepository;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.EvaluationCriteriaRepository;
|
||||
import net.gepafin.tendermanagement.repositories.FaqRepository;
|
||||
import net.gepafin.tendermanagement.repositories.RegionRepository;
|
||||
import net.gepafin.tendermanagement.service.impl.CallValidatorServiceImpl;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
@@ -104,6 +91,9 @@ public class CallDao {
|
||||
|
||||
@Autowired
|
||||
private S3PathConfig s3PathConfig;
|
||||
@Autowired
|
||||
private BeneficiaryPreferredCallRepository beneficiaryPreferredCallRepository;
|
||||
|
||||
|
||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
|
||||
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
||||
@@ -435,12 +425,24 @@ public class CallDao {
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
}
|
||||
|
||||
public CallResponse getCallById(CallEntity callEntity) {
|
||||
return getCallResponseBean(callEntity);
|
||||
public CallResponse getCallById(UserEntity user, CallEntity callEntity) {
|
||||
Long userId = user.getId();
|
||||
Long callId = callEntity.getId();
|
||||
|
||||
BeneficiaryPreferredCallEntity preferredCall = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdInAndIsDeletedFalse(userId, List.of(callId))
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
CallResponse callResponse = getCallResponseBean(callEntity);
|
||||
callResponse.setPreferredCallId(preferredCall != null ? preferredCall.getId() : null);
|
||||
|
||||
return callResponse;
|
||||
}
|
||||
|
||||
|
||||
public CallResponse createCallStep2(CallEntity callEntity, CreateCallRequestStep2 createCallRequest, UserEntity user) {
|
||||
validateUpdate(callEntity);
|
||||
// validateUpdate(callEntity);
|
||||
setIfUpdated(callEntity::getThreshold, callEntity::setThreshold, createCallRequest.getThreshold());
|
||||
callRepository.save(callEntity);
|
||||
convertToEvaluationCriteriaEntities(createCallRequest.getCriteria(), callEntity, LookUpDataTypeEnum.EVALUATION_CRITERIA);
|
||||
@@ -500,13 +502,6 @@ public class CallDao {
|
||||
}
|
||||
|
||||
public CallResponse updateCallStep1(CallEntity callEntity, UpdateCallRequestStep1 updateCallRequest, UserEntity userEntity) {
|
||||
if(Boolean.TRUE.equals(callEntity.getStatus().equals(CallStatusEnum.PUBLISH.getValue()))) {
|
||||
try {
|
||||
Utils.retainOnlySpecificFields(updateCallRequest, Collections.singletonList("faq"));
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.FAILED_RETAIN_FIELD));
|
||||
}
|
||||
}
|
||||
isValidDateRange(updateCallRequest, callEntity);
|
||||
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
||||
setIfUpdated(callEntity::getDescriptionShort, callEntity::setDescriptionShort,
|
||||
@@ -654,15 +649,42 @@ public class CallDao {
|
||||
public List<CallDetailsResponseBean> getAllCalls(UserEntity user) {
|
||||
String type = user.getRoleEntity().getRoleType();
|
||||
List<String> callStatusList = CallStatusEnum.getStatusValues();
|
||||
|
||||
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
|
||||
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue());
|
||||
}
|
||||
|
||||
List<CallEntity> calls = callRepository.findByStatusInAndHubId(callStatusList, user.getHub().getId());
|
||||
List<Long> callIds = calls.stream().map(CallEntity::getId).collect(Collectors.toList());
|
||||
|
||||
Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap = getBeneficiaryPreferredCallsForUser(user, callIds);
|
||||
|
||||
return calls.stream()
|
||||
.map(this::convertToCallDetailsResponseBean)
|
||||
.map(call -> {
|
||||
CallDetailsResponseBean responseBean = convertToCallDetailsResponseBean(call);
|
||||
String key = user.getId() + "_" + call.getId();
|
||||
|
||||
BeneficiaryPreferredCallEntity preferredCall = preferredCallsMap.get(key);
|
||||
Long preferredId = (preferredCall != null && !preferredCall.getIsDeleted()) ? preferredCall.getId() : null;
|
||||
responseBean.setPreferredCallId(preferredId);
|
||||
|
||||
return responseBean;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Map<String, BeneficiaryPreferredCallEntity> getBeneficiaryPreferredCallsForUser(UserEntity user, List<Long> callIds) {
|
||||
List<BeneficiaryPreferredCallEntity> beneficiaryPreferredCalls = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdInAndIsDeletedFalse(user.getId(), callIds);
|
||||
|
||||
return beneficiaryPreferredCalls.stream()
|
||||
.collect(Collectors.toMap(
|
||||
call -> user.getId() + "_" + call.getCallId(),
|
||||
call -> call
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public CallResponse validateCallData(CallEntity callEntity) {
|
||||
validateUpdate(callEntity);
|
||||
CallResponse callResponseBean = getCallResponseBean(callEntity);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class DocumentDao {
|
||||
private Long resolveSourceId(Long sourceId, DocumentSourceTypeEnum sourceType) {
|
||||
if (sourceType == DocumentSourceTypeEnum.CALL) {
|
||||
CallEntity callEntity = callService.validateCall(sourceId);
|
||||
callDao.validateUpdate(callEntity);
|
||||
// callDao.validateUpdate(callEntity);
|
||||
return callEntity.getId();
|
||||
}
|
||||
// else if (sourceType == SourceTypeEnum.APPLICATION) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.EmailEntityTypeEnum;
|
||||
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.EmailLogRequest;
|
||||
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
||||
@@ -59,10 +60,9 @@ public class EmailNotificationDao {
|
||||
private EmailLogRepository emailLogRepository;
|
||||
|
||||
|
||||
private void sendEmail(ApplicationAmendmentRequestEntity amendmentRequest, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType,
|
||||
private void sendEmail(ApplicationEntity applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType,
|
||||
Map<String, String> bodyPlaceholders, List<String> additionalRecipients) {
|
||||
|
||||
ApplicationEntity applicationEntity = applicationService.validateApplication(amendmentRequest.getApplicationId());
|
||||
HubEntity hubEntity = hubService.valdateHub(applicationEntity.getHubId());
|
||||
String service = determineService(applicationEntity.getHubId());
|
||||
String legalMail = service.equals("Gepafin S.p.a.") ? "bandi.gepafin@legalmail.it" : "bandi.sviluppumbria@legalmail.it";
|
||||
@@ -77,7 +77,7 @@ public class EmailNotificationDao {
|
||||
|
||||
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
||||
List<String> recipientEmails = getRecipientEmails(applicationEntity, userEntity, additionalRecipients);
|
||||
EmailLogRequest emailLogRequest=emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.BENEFICIARY,userEntity.getBeneficiary().getId(),subject,body, StatusTypeEnum.SUCCESS.getValue(), null, amendmentRequest.getId(), EmailEntityTypeEnum.AMENDMENT,Utils.listToCommaSeparatedString(recipientEmails),userEntity.getId());
|
||||
EmailLogRequest emailLogRequest=emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.BENEFICIARY,userEntity.getBeneficiary().getId(),subject,body, StatusTypeEnum.SUCCESS.getValue(), null, applicationEntity.getId(), EmailEntityTypeEnum.AMENDMENT,Utils.listToCommaSeparatedString(recipientEmails),userEntity.getId());
|
||||
|
||||
sendMail(applicationEntity.getHubId(), subject, body, recipientEmails,emailLogRequest);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class EmailNotificationDao {
|
||||
log.error("Failed to parse form fields JSON: ", e);
|
||||
}
|
||||
bodyPlaceholders.put("{{note}}", applicationAmendmentRequest.getNote());
|
||||
sendEmail(applicationAmendmentRequest, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, bodyPlaceholders, null);
|
||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, bodyPlaceholders, null);
|
||||
}
|
||||
|
||||
public void sendApplicationFailureNotificationEmail(ApplicationAmendmentRequestEntity amendmentRequest) {
|
||||
@@ -155,32 +155,28 @@ public class EmailNotificationDao {
|
||||
}
|
||||
bodyPlaceholders.put("{{date_time_emailSend}}", DateTimeUtil.formatLocalDateTime(lastReminderDateTime, GepafinConstant.DD_MM_YYYY));
|
||||
|
||||
sendEmail(amendmentRequest, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, bodyPlaceholders, null);
|
||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, bodyPlaceholders, null);
|
||||
}
|
||||
|
||||
public void sendAdmissibilityNotificationEmailForApprovedApplication(ApplicationAmendmentRequestEntity amendmentRequest) {
|
||||
|
||||
ApplicationEntity applicationEntity = applicationService.validateApplication(amendmentRequest.getApplicationId());
|
||||
public void sendAdmissibilityNotificationEmailForApprovedApplication(ApplicationEntity applicationEntity) {
|
||||
Map<String, String> bodyPlaceholders = new HashMap<>();
|
||||
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
||||
bodyPlaceholders.put("{{protocol_number}}", amendmentRequest.getProtocol().getProtocolNumber().toString());
|
||||
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatCreatedDate(amendmentRequest.getProtocol().getCreatedDate()));
|
||||
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(amendmentRequest.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
||||
bodyPlaceholders.put("{{protocol_number}}", applicationEntity.getProtocol().getProtocolNumber().toString());
|
||||
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatCreatedDate(applicationEntity.getProtocol().getCreatedDate()));
|
||||
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
||||
|
||||
sendEmail(amendmentRequest, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.ADMISSIBILITY_NOTIFICATION, bodyPlaceholders, null);
|
||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.ADMISSIBILITY_NOTIFICATION, bodyPlaceholders, null);
|
||||
}
|
||||
|
||||
public void sendInadmissibilityEmailForRejectedApplication(ApplicationAmendmentRequestEntity amendmentRequest) {
|
||||
|
||||
ApplicationEntity applicationEntity = applicationService.validateApplication(amendmentRequest.getApplicationId());
|
||||
public void sendInadmissibilityEmailForRejectedApplication(ApplicationEntity applicationEntity,ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||
Map<String, String> bodyPlaceholders = new HashMap<>();
|
||||
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
||||
bodyPlaceholders.put("{{protocol_number}}", amendmentRequest.getProtocol().getProtocolNumber().toString());
|
||||
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatCreatedDate(amendmentRequest.getProtocol().getCreatedDate()));
|
||||
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(amendmentRequest.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
||||
bodyPlaceholders.put("{{form_text}}", amendmentRequest.getNote());
|
||||
bodyPlaceholders.put("{{protocol_number}}", applicationEntity.getProtocol().getProtocolNumber().toString());
|
||||
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatCreatedDate(applicationEntity.getProtocol().getCreatedDate()));
|
||||
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
||||
bodyPlaceholders.put("{{form_text}}", applicationEvaluationEntity.getNote());
|
||||
|
||||
sendEmail(amendmentRequest, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE, bodyPlaceholders, null);
|
||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE, bodyPlaceholders, null);
|
||||
}
|
||||
|
||||
public void sendMail(Long hubId, String subject, String body, List<String> recipientEmails, EmailLogRequest emailLogRequest) {
|
||||
|
||||
@@ -72,7 +72,7 @@ public class FlowDao {
|
||||
}
|
||||
|
||||
public void checkIfFlowExits(CallEntity call) {
|
||||
callDao.validateUpdate(call);
|
||||
// callDao.validateUpdate(call);
|
||||
List<FlowDataEntity> flowDataEntities = flowDataRepository.findByCallId(call.getId());
|
||||
List<FlowEdgesEntity> flowEdgesEntities = flowEdgesRepository.findByCallId(call.getId());
|
||||
if (Boolean.FALSE.equals(flowDataEntities.isEmpty()) || Boolean.FALSE.equals(flowEdgesEntities.isEmpty())) {
|
||||
|
||||
@@ -173,7 +173,7 @@ public class FormDao {
|
||||
String choosenField=null;
|
||||
FormEntity formEntity = validateForm(formId);
|
||||
validator.validateUserWithCall(user, formEntity.getCall().getId());
|
||||
callDao.validateUpdate(formEntity.getCall());
|
||||
// callDao.validateUpdate(formEntity.getCall());
|
||||
List<ContentRequestBean> contentRequestBean = Utils.convertJsonStringToList(formEntity.getContent(), ContentRequestBean.class);
|
||||
for (ContentRequestBean contentRequestBean1 : contentRequestBean) {
|
||||
FlowDataEntity flowDataEntity = flowDataRepository.findByFormIdAndChoosenField(formEntity.getId(), contentRequestBean1.getId());
|
||||
|
||||
@@ -34,4 +34,6 @@ public class BeneficiaryPreferredCallEntity extends BaseEntity{
|
||||
|
||||
@Column(name = "STATUS", length = 255)
|
||||
private String status;
|
||||
@Column(name="IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class AmendmentFormFieldResponse {
|
||||
private String fieldId;
|
||||
private String label;
|
||||
|
||||
@@ -14,8 +14,8 @@ public class ApplicationAmendmentRequestResponse {
|
||||
private String note;
|
||||
private Long responseDays;
|
||||
private LocalDateTime startDate;
|
||||
private boolean isSendNotification;
|
||||
private boolean isSendEmail;
|
||||
private Boolean isSendNotification;
|
||||
private Boolean isSendEmail;
|
||||
private Long protocolNumber;
|
||||
private String callName;
|
||||
private String beneficiaryName;
|
||||
|
||||
@@ -54,4 +54,5 @@ public class CallDetailsResponseBean {
|
||||
|
||||
private LocalDateTime updatedDate;
|
||||
|
||||
private Long preferredCallId;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public class CallResponse {
|
||||
|
||||
private String currentStep;
|
||||
|
||||
private Long preferredCallId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository<App
|
||||
@Query(value = "SELECT amr FROM ApplicationAmendmentRequestEntity amr " + "WHERE amr.applicationEvaluationEntity.id = :id " + "AND amr.applicationEvaluationEntity.isDeleted = false")
|
||||
ApplicationAmendmentRequestEntity findByApplicationEvaluationIdAndIsDeletedFalse(Long id);
|
||||
|
||||
@Query(value = "SELECT amr FROM ApplicationAmendmentRequestEntity amr " +
|
||||
"WHERE amr.applicationEvaluationEntity.id = :id " +
|
||||
"AND amr.applicationEvaluationEntity.isDeleted = false")
|
||||
List<ApplicationAmendmentRequestEntity> findAllByApplicationEvaluationIdAndIsDeletedFalse(Long id);
|
||||
|
||||
// ApplicationAmendmentRequestEntity findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||
|
||||
List<ApplicationAmendmentRequestEntity> findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||
|
||||
@@ -6,13 +6,19 @@ import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface BeneficiaryPreferredCallRepository extends JpaRepository<BeneficiaryPreferredCallEntity, Long> {
|
||||
List<BeneficiaryPreferredCallEntity> findByBeneficiaryId(Long beneficiaryId);
|
||||
List<BeneficiaryPreferredCallEntity> findByUserId(Long userId);
|
||||
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndIsDeletedFalse(Long beneficiaryId);
|
||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndIsDeletedFalse(Long userId);
|
||||
|
||||
@Query("SELECT preferredCall FROM BeneficiaryPreferredCallEntity preferredCall where preferredCall.userId=:userId AND (:companyId is null OR preferredCall.companyId=:companyId)")
|
||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndCompanyId(@Param("userId") Long userId, @Param("companyId") Long companyId);
|
||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(@Param("userId") Long userId, @Param("companyId") Long companyId);
|
||||
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndCompanyId(Long beneficiaryId,Long companyId);
|
||||
public List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List<Long> callIds);
|
||||
|
||||
Optional<BeneficiaryPreferredCallEntity> findByIdAndIsDeletedFalse(Long id);
|
||||
Optional<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(Long userId, Long callId, Long companyId);
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class CallServiceImpl implements CallService {
|
||||
public CallResponse getCallById(HttpServletRequest request, Long callId) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
CallEntity call = validator.validateUserWithCall(user, callId);
|
||||
return callDao.getCallById(call);
|
||||
return callDao.getCallById(user,call);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
package net.gepafin.tendermanagement.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.mailgun.api.v3.MailgunMessagesApi;
|
||||
import com.mailgun.client.MailgunClient;
|
||||
|
||||
@Component
|
||||
public class MailUtil {
|
||||
|
||||
@Value("${apiKey}")
|
||||
private String apiKeyValue;
|
||||
|
||||
@Value("${mailGun_user}")
|
||||
private String mailGunUser;
|
||||
|
||||
@Value("${mailGun_apiKey}")
|
||||
private String mailGunApiKey;
|
||||
|
||||
@Value("${mailGun_domainName}")
|
||||
private String mailGunDomainName;
|
||||
|
||||
@Value("${mailGun_base_url}")
|
||||
private String mailGunBaseUrl;
|
||||
|
||||
@Value("${isMailSendingEnabled}")
|
||||
private String isEmailSendingEnabled;
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
public Boolean isTestProfileActivated() {
|
||||
String[] activeProfiles = environment.getActiveProfiles();
|
||||
return Arrays.stream(activeProfiles).anyMatch("test"::equals);
|
||||
}
|
||||
|
||||
public void sendMailByMailGunAPI(List<String> recipents, List<String> CC, List<String> BCC, String subject,
|
||||
String body, String replyTo) {
|
||||
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||
return;
|
||||
}
|
||||
|
||||
MailgunMessagesApi mailgunMessagesApi = MailgunClient.config(mailGunBaseUrl, mailGunApiKey)
|
||||
.createApi(MailgunMessagesApi.class);
|
||||
|
||||
String mailFrom = mailGunUser;
|
||||
|
||||
com.mailgun.model.message.Message.MessageBuilder temp = com.mailgun.model.message.Message.builder()
|
||||
.replyTo(replyTo).from(mailFrom).to(recipents).subject(subject).html(body);
|
||||
|
||||
if (Boolean.FALSE.equals(CollectionUtils.isEmpty(CC))) {
|
||||
temp.cc(CC);
|
||||
}
|
||||
|
||||
if (Boolean.FALSE.equals(CollectionUtils.isEmpty(BCC))) {
|
||||
temp.bcc(BCC);
|
||||
}
|
||||
|
||||
if (Boolean.FALSE.equals(isTestProfileActivated())) {
|
||||
com.mailgun.model.message.Message message = temp.build();
|
||||
mailgunMessagesApi.sendMessage(mailGunDomainName, message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendByMailGun(String subject, String body, List<String> receiverEmails, String replyTo) {
|
||||
sendMailByMailGunAPI(receiverEmails, null, null, subject, body, replyTo);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,13 +53,10 @@ vatCheckNewToken: 66026bd891a51044e90e08c4
|
||||
spid.ipd.base.url=https://federatest.umbriadigitale.it
|
||||
active.profile.folder=dev
|
||||
|
||||
# MailGun API Key
|
||||
mailGun_apiKey= 398e3dea1911fe941af261906ec99362-07e2c238-8094421f
|
||||
mailGun_user=comunicazione@paghiamoci.ai
|
||||
mailGun_domainName=paghiamoci.ai
|
||||
# MailGun API
|
||||
mailGun_base_url=https://api.eu.mailgun.net/
|
||||
# SendinBlue API key
|
||||
apiKey=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
|
||||
|
||||
|
||||
api.pecUrl=https://ws.pecmassiva.com
|
||||
#senderEmail=mailer@bflows.net
|
||||
|
||||
|
||||
@@ -1760,4 +1760,16 @@
|
||||
</changeSet>
|
||||
|
||||
|
||||
|
||||
<changeSet id="13-11-2024_1" author="Rajesh Khore">
|
||||
<dropNotNullConstraint tableName="application_amendment_request" columnName="is_email"/>
|
||||
<dropNotNullConstraint tableName="application_amendment_request" columnName="is_notification"/>
|
||||
</changeSet>
|
||||
<changeSet id="13-11-2024_2" author="Harish Bagora">
|
||||
<addColumn tableName="beneficiary_preferred_call">
|
||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
|
||||
@@ -306,3 +306,4 @@ comment.not.associate.with.amendment = Comment Not Associated with Amendment Req
|
||||
amendment.found.success = Amendment Request Found Successfully.
|
||||
invalid.amendment.for.comment = Invalid Amendment Request for the Given Comment.
|
||||
DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm
|
||||
beneficiary.call.duplicate = A preferred call with this call ID and company ID already exists for this user.
|
||||
@@ -301,3 +301,4 @@ DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm
|
||||
create.application.data.amendment.msg =Emendamento alla domanda inviato con successo
|
||||
beneficiary.email.not.found.msg=L'indirizzo email per il beneficiario non è stato trovato. Si prega di assicurarsi che il beneficiario abbia un indirizzo email valido.
|
||||
reminder.email.sent.success.msg=Email di promemoria inviata con successo!
|
||||
beneficiary.call.duplicate = Una chiamata preferita con questo ID di chiamata e ID azienda esiste già per questo utente.
|
||||
Reference in New Issue
Block a user