|
|
|
|
@@ -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,6 +9,7 @@ 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.ApplicationAmendmentRequest;
|
|
|
|
|
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
|
|
|
|
@@ -17,9 +19,8 @@ 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;
|
|
|
|
|
@@ -28,10 +29,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);
|
|
|
|
|
@@ -547,7 +671,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 +681,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 +691,7 @@ public class ApplicationAmendmentRequestDao {
|
|
|
|
|
}
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(
|
|
|
|
|
Long id, ApplicationAmendmentRequestEnum statusTypeEnum) {
|
|
|
|
|
|
|
|
|
|
@@ -579,6 +706,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,
|
|
|
|
|
|