|
|
|
|
@@ -22,9 +22,11 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
@@ -157,9 +159,8 @@ public class ApplicationEvaluationDao {
|
|
|
|
|
amendmentDocumentResponseBean.setAmendmentId(applicationAmendmentRequestEntity.getId());
|
|
|
|
|
String amendmentDocument=applicationAmendmentRequestEntity.getAmendmentDocument();
|
|
|
|
|
String formField=applicationAmendmentRequestEntity.getFormFields();
|
|
|
|
|
List<AmendmentDetailsResponseBean> amendmentDetailsList = Utils.convertJsonStringToList(amendmentDocument, AmendmentDetailsResponseBean.class);
|
|
|
|
|
if (amendmentDetailsList != null && !amendmentDetailsList.isEmpty()) {
|
|
|
|
|
AmendmentDetailsResponseBean amendmentDetails = amendmentDetailsList.get(0);
|
|
|
|
|
AmendmentDetailsResponseBean amendmentDetails = Utils.convertStringToObject(amendmentDocument, AmendmentDetailsResponseBean.class);
|
|
|
|
|
if (amendmentDetails != null) {
|
|
|
|
|
if (amendmentDetails.getAmendmentDocuments() != null) {
|
|
|
|
|
List<DocumentResponseBean> documentResponseBeans = Arrays.stream(amendmentDetails.getAmendmentDocuments().split(","))
|
|
|
|
|
.map(String::trim)
|
|
|
|
|
@@ -168,33 +169,39 @@ public class ApplicationEvaluationDao {
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
amendmentDocumentResponseBean.setAmendmentDocuments(documentResponseBeans);
|
|
|
|
|
amendmentDocumentResponseBean.setFileDetail(documentResponseBeans);
|
|
|
|
|
}
|
|
|
|
|
amendmentDocumentResponseBean.setAmendmentNotes(amendmentDetails.getAmendmentNotes());
|
|
|
|
|
amendmentDocumentResponseBean.setLabel(amendmentDetails.getAmendmentNotes());
|
|
|
|
|
amendmentDocumentResponseBean.setValid(amendmentDetails.getValid());
|
|
|
|
|
}
|
|
|
|
|
List<AmendmentFormField> amendmentFormFields=Utils.convertJsonStringToList(formField,AmendmentFormField.class);
|
|
|
|
|
amendmentDocumentResponseBean.setFormFieldDocuments(setFormFieldDocuments(amendmentFormFields));
|
|
|
|
|
amendmentDocumentResponseBeans.add(amendmentDocumentResponseBean);
|
|
|
|
|
}
|
|
|
|
|
response.setAmendmentDetails(amendmentDocumentResponseBeans);
|
|
|
|
|
List<AmendmentFormField> amendmentFormFields = Utils.convertJsonStringToList(formField, AmendmentFormField.class);
|
|
|
|
|
if (amendmentFormFields != null) {
|
|
|
|
|
for (AmendmentFormField amendmentFormField : amendmentFormFields) {
|
|
|
|
|
// Skip fields with null or empty fieldValue
|
|
|
|
|
if (StringUtils.isEmpty(amendmentFormField.getFieldValue())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<FieldResponse> setFormFieldDocuments(List<AmendmentFormField> amendmentFormFields) {
|
|
|
|
|
List<FieldResponse> fieldResponses=new ArrayList<>();
|
|
|
|
|
for (AmendmentFormField amendmentFormField: amendmentFormFields){
|
|
|
|
|
FieldResponse fieldResponse=new FieldResponse();
|
|
|
|
|
fieldResponse.setId(amendmentFormField.getFieldId());
|
|
|
|
|
fieldResponse.setLabel(amendmentFormField.getLabel());
|
|
|
|
|
fieldResponse.setValid(amendmentFormField.getValid());
|
|
|
|
|
List<Long> fileIds=applicationAmendmentRequestDao.extractIds(amendmentFormField.getFieldValue());
|
|
|
|
|
AmendmentDocumentResponseBean formFieldResponseBean = new AmendmentDocumentResponseBean();
|
|
|
|
|
formFieldResponseBean.setAmendmentId(applicationAmendmentRequestEntity.getId());
|
|
|
|
|
formFieldResponseBean.setFieldId(amendmentFormField.getFieldId());
|
|
|
|
|
formFieldResponseBean.setLabel(amendmentFormField.getLabel());
|
|
|
|
|
formFieldResponseBean.setValid(amendmentFormField.getValid());
|
|
|
|
|
|
|
|
|
|
List<Long> fileIds = applicationAmendmentRequestDao.extractIds(amendmentFormField.getFieldValue());
|
|
|
|
|
List<DocumentResponseBean> documentResponseBeans = fileIds.stream()
|
|
|
|
|
.map(fileId -> createDocumentResponseBean(documentService.validateDocument(fileId))) // Create DocumentResponseBean for each fileId
|
|
|
|
|
.collect(Collectors.toList()); // Collect all into a List
|
|
|
|
|
fieldResponse.setFileDetail(documentResponseBeans);
|
|
|
|
|
fieldResponses.add(fieldResponse);
|
|
|
|
|
.map(fileId -> createDocumentResponseBean(documentService.validateDocument(fileId)))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
formFieldResponseBean.setFileDetail(documentResponseBeans);
|
|
|
|
|
amendmentDocumentResponseBeans.add(formFieldResponseBean);
|
|
|
|
|
}
|
|
|
|
|
return fieldResponses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
amendmentDocumentResponseBeans.add(amendmentDocumentResponseBean);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response.setAmendmentDetails(amendmentDocumentResponseBeans);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setEvaluationDocResponse(ApplicationEvaluationResponse response, List<EvaluationDocumentRequest> docRequest) {
|
|
|
|
|
@@ -623,117 +630,162 @@ public class ApplicationEvaluationDao {
|
|
|
|
|
|
|
|
|
|
private void updateAmendmentDocumentsAndFormFields(List<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntities, List<AmendmentDetailsRequest> amendmentFormFields) {
|
|
|
|
|
// Iterate through amendment request entities
|
|
|
|
|
for (ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity : applicationAmendmentRequestEntities) {
|
|
|
|
|
// Process form fields if present
|
|
|
|
|
if (applicationAmendmentRequestEntity.getFormFields() != null) {
|
|
|
|
|
// Parse existing form fields from JSON
|
|
|
|
|
List<AmendmentFormFieldRequest> existingFormFields =
|
|
|
|
|
Utils.convertJsonStringToList(applicationAmendmentRequestEntity.getFormFields(), AmendmentFormFieldRequest.class);
|
|
|
|
|
|
|
|
|
|
// Prepare a new list to hold updated form fields
|
|
|
|
|
List<AmendmentFormFieldRequest> updatedFormFields = new ArrayList<>();
|
|
|
|
|
//
|
|
|
|
|
Map<Long,List<AmendmentDetailsRequest>> amendmentFormFieldsMap = amendmentFormFields.stream().collect(Collectors.groupingBy(AmendmentDetailsRequest::getAmendmentId,HashMap::new,Collectors.toCollection(ArrayList::new)));
|
|
|
|
|
// amendmentFormFields.forEach(data->{
|
|
|
|
|
// ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestMap.get(data.getAmendmentId());
|
|
|
|
|
// if (data.getFieldId().contains("amend_")){
|
|
|
|
|
// updateAmendmentDocument(applicationAmendmentRequestEntity, data);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
applicationAmendmentRequestEntities.forEach(applicationAmendmentRequestEntity->{
|
|
|
|
|
updateAmendment(applicationAmendmentRequestEntity, amendmentFormFieldsMap.get(applicationAmendmentRequestEntity.getId()));
|
|
|
|
|
});
|
|
|
|
|
applicationAmendmentRequestRepository.saveAll(applicationAmendmentRequestEntities);
|
|
|
|
|
|
|
|
|
|
// Map amendment details for quick lookup by amendment ID
|
|
|
|
|
Map<Long, List<AmendmentFormFieldRequest>> amendmentDetailsMap = amendmentFormFields.stream()
|
|
|
|
|
.filter(details -> applicationAmendmentRequestEntity.getId().equals(details.getAmendmentId()))
|
|
|
|
|
.filter(details -> details.getFormFieldDocuments() != null) // Null check for getFormFieldDocuments
|
|
|
|
|
.collect(Collectors.toMap(
|
|
|
|
|
AmendmentDetailsRequest::getAmendmentId,
|
|
|
|
|
AmendmentDetailsRequest::getFormFieldDocuments
|
|
|
|
|
));
|
|
|
|
|
// Get corresponding amendment documents for the current entity
|
|
|
|
|
List<AmendmentFormFieldRequest> amendmentDocuments = amendmentDetailsMap.get(applicationAmendmentRequestEntity.getId());
|
|
|
|
|
if (amendmentDocuments != null) {
|
|
|
|
|
// Update existing form fields with new values
|
|
|
|
|
for (AmendmentFormFieldRequest existingField : existingFormFields) {
|
|
|
|
|
for (AmendmentFormFieldRequest newField : amendmentDocuments) {
|
|
|
|
|
if (existingField.getFieldId().equals(newField.getFieldId())) {
|
|
|
|
|
// Update fields if there are changes
|
|
|
|
|
Utils.setIfUpdated(existingField::getValid, existingField::setValid, newField.getValid());
|
|
|
|
|
Utils.setIfUpdated(existingField::getFieldValue, existingField::setFieldValue, newField.getFieldValue());
|
|
|
|
|
|
|
|
|
|
updatedFormFields.add(existingField);
|
|
|
|
|
break; // Move to the next existing field
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// for (ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity : applicationAmendmentRequestEntities) {
|
|
|
|
|
// // Process form fields if present
|
|
|
|
|
// if (applicationAmendmentRequestEntity.getFormFields() != null) {
|
|
|
|
|
// // Parse existing form fields from JSON
|
|
|
|
|
// List<AmendmentFormFieldRequest> existingFormFields =
|
|
|
|
|
// Utils.convertJsonStringToList(applicationAmendmentRequestEntity.getFormFields(), AmendmentFormFieldRequest.class);
|
|
|
|
|
//
|
|
|
|
|
// // Prepare a new list to hold updated form fields
|
|
|
|
|
// List<AmendmentFormFieldRequest> updatedFormFields = new ArrayList<>();
|
|
|
|
|
//
|
|
|
|
|
// // Map amendment details for quick lookup by amendment ID
|
|
|
|
|
// Map<Long, Object> amendmentDetailsMap = amendmentFormFields.stream()
|
|
|
|
|
// .filter(details -> applicationAmendmentRequestEntity.getId().equals(details.getAmendmentId()))
|
|
|
|
|
// .filter(details -> details.getFieldValue() != null) // Null check for getFormFieldDocuments
|
|
|
|
|
// .collect(Collectors.toMap(
|
|
|
|
|
// AmendmentDetailsRequest::getAmendmentId,
|
|
|
|
|
// AmendmentDetailsRequest::getFieldValue
|
|
|
|
|
// ));
|
|
|
|
|
// // Get corresponding amendment documents for the current entity
|
|
|
|
|
// List<AmendmentFormFieldRequest> amendmentDocuments = (List<AmendmentFormFieldRequest>) amendmentDetailsMap.get(applicationAmendmentRequestEntity.getId());
|
|
|
|
|
// if (amendmentDocuments != null) {
|
|
|
|
|
// // Update existing form fields with new values
|
|
|
|
|
// for (AmendmentFormFieldRequest existingField : existingFormFields) {
|
|
|
|
|
// for (AmendmentFormFieldRequest newField : amendmentDocuments) {
|
|
|
|
|
// if (existingField.getFieldId().equals(newField.getFieldId())) {
|
|
|
|
|
// // Update fields if there are changes
|
|
|
|
|
// Utils.setIfUpdated(existingField::getValid, existingField::setValid, newField.getValid());
|
|
|
|
|
// Utils.setIfUpdated(existingField::getFieldValue, existingField::setFieldValue, newField.getFieldValue());
|
|
|
|
|
//
|
|
|
|
|
// updatedFormFields.add(existingField);
|
|
|
|
|
// break; // Move to the next existing field
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // Convert updated form fields back to JSON and save to the database
|
|
|
|
|
// applicationAmendmentRequestEntity.setFormFields(Utils.convertListToJsonString(updatedFormFields));
|
|
|
|
|
// applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // Process amendment documents if present
|
|
|
|
|
// if (applicationAmendmentRequestEntity.getAmendmentDocument() != null) {
|
|
|
|
|
// String existingDocumentIds = applicationAmendmentRequestEntity.getAmendmentDocument();
|
|
|
|
|
//
|
|
|
|
|
// // Split comma-separated document IDs into a list
|
|
|
|
|
// List<String> existingDocumentIdList = Arrays.stream(existingDocumentIds.split(","))
|
|
|
|
|
// .map(String::trim)
|
|
|
|
|
// .filter(id -> !id.isEmpty())
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
//
|
|
|
|
|
// List<String> updatedDocumentIdList = new ArrayList<>();
|
|
|
|
|
// Map<Long, Object> amendmentDetailsMap = amendmentFormFields.stream()
|
|
|
|
|
// .filter(details -> applicationAmendmentRequestEntity.getId().equals(details.getAmendmentId()))
|
|
|
|
|
// .collect(Collectors.toMap(
|
|
|
|
|
// AmendmentDetailsRequest::getAmendmentId,
|
|
|
|
|
// AmendmentDetailsRequest::getFieldValue
|
|
|
|
|
// ));
|
|
|
|
|
//
|
|
|
|
|
// String amendmentDocumentIds = (String) amendmentDetailsMap.get(applicationAmendmentRequestEntity.getId());
|
|
|
|
|
// if (amendmentDocumentIds != null) {
|
|
|
|
|
// // Split and validate new document IDs
|
|
|
|
|
// List<String> newDocumentIdList = Arrays.stream(amendmentDocumentIds.split(","))
|
|
|
|
|
// .map(String::trim)
|
|
|
|
|
// .filter(id -> !id.isEmpty())
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
//
|
|
|
|
|
// for (String existingId : existingDocumentIdList) {
|
|
|
|
|
// for (String newId : newDocumentIdList) {
|
|
|
|
|
// if (existingId.equals(newId)) {
|
|
|
|
|
// Optional<DocumentEntity> documentEntity = documentRepository.findByIdAndNotDeleted(Long.valueOf(newId));
|
|
|
|
|
// if(documentEntity.isPresent()) {
|
|
|
|
|
// updatedDocumentIdList.add(newId);
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // Add any new IDs not in the existing list
|
|
|
|
|
// for (String newId : newDocumentIdList) {
|
|
|
|
|
// if (!existingDocumentIdList.contains(newId)) {
|
|
|
|
|
// Optional<DocumentEntity> documentEntity = documentRepository.findByIdAndNotDeleted(Long.valueOf(newId));
|
|
|
|
|
// if(documentEntity.isPresent()) {
|
|
|
|
|
// updatedDocumentIdList.add(newId);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// String updatedDocumentIds = String.join(",", updatedDocumentIdList);
|
|
|
|
|
//
|
|
|
|
|
// // Create the AmendmentDetailsResponseBean for structured data
|
|
|
|
|
// AmendmentDetailsResponseBean amendmentDetails = new AmendmentDetailsResponseBean();
|
|
|
|
|
// amendmentDetails.setAmendmentDocuments(updatedDocumentIds);
|
|
|
|
|
// AmendmentDetailsRequest amendmentDetailsRequest = amendmentFormFields.stream()
|
|
|
|
|
// .filter(details -> applicationAmendmentRequestEntity.getId().equals(details.getAmendmentId()))
|
|
|
|
|
// .findFirst()
|
|
|
|
|
// .orElse(null);
|
|
|
|
|
//
|
|
|
|
|
// if (amendmentDetailsRequest != null) {
|
|
|
|
|
// amendmentDetails.setValid(amendmentDetailsRequest.getValid());
|
|
|
|
|
// } else {
|
|
|
|
|
// amendmentDetails.setValid(false);
|
|
|
|
|
// }
|
|
|
|
|
// String amendmentDetailsJson = Utils.convertListToJsonString(Collections.singletonList(amendmentDetails));
|
|
|
|
|
// applicationAmendmentRequestEntity.setAmendmentDocument(amendmentDetailsJson);
|
|
|
|
|
// applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Convert updated form fields back to JSON and save to the database
|
|
|
|
|
applicationAmendmentRequestEntity.setFormFields(Utils.convertListToJsonString(updatedFormFields));
|
|
|
|
|
applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity);
|
|
|
|
|
private void updateAmendment(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity, List<AmendmentDetailsRequest> amendmentDetailsRequestList) {
|
|
|
|
|
if (CollectionUtils.isEmpty(amendmentDetailsRequestList)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Map<String, AmendmentFormField> formFieldsMap = null;
|
|
|
|
|
List<AmendmentFormField> formFieldList = Utils.convertJsonStringToList(applicationAmendmentRequestEntity.getFormFields(), AmendmentFormField.class);
|
|
|
|
|
if(Boolean.FALSE.equals(CollectionUtils.isEmpty(formFieldList))){
|
|
|
|
|
formFieldsMap = formFieldList.stream().collect(Collectors.toMap(AmendmentFormField::getFieldId, Function.identity()));
|
|
|
|
|
}
|
|
|
|
|
updateAmendmentData(applicationAmendmentRequestEntity, amendmentDetailsRequestList, formFieldsMap);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process amendment documents if present
|
|
|
|
|
if (applicationAmendmentRequestEntity.getAmendmentDocument() != null) {
|
|
|
|
|
String existingDocumentIds = applicationAmendmentRequestEntity.getAmendmentDocument();
|
|
|
|
|
|
|
|
|
|
// Split comma-separated document IDs into a list
|
|
|
|
|
List<String> existingDocumentIdList = Arrays.stream(existingDocumentIds.split(","))
|
|
|
|
|
.map(String::trim)
|
|
|
|
|
.filter(id -> !id.isEmpty())
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
List<String> updatedDocumentIdList = new ArrayList<>();
|
|
|
|
|
Map<Long, String> amendmentDetailsMap = amendmentFormFields.stream()
|
|
|
|
|
.filter(details -> applicationAmendmentRequestEntity.getId().equals(details.getAmendmentId()))
|
|
|
|
|
.collect(Collectors.toMap(
|
|
|
|
|
AmendmentDetailsRequest::getAmendmentId,
|
|
|
|
|
AmendmentDetailsRequest::getAmendmentDocuments
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
String amendmentDocumentIds = amendmentDetailsMap.get(applicationAmendmentRequestEntity.getId());
|
|
|
|
|
if (amendmentDocumentIds != null) {
|
|
|
|
|
// Split and validate new document IDs
|
|
|
|
|
List<String> newDocumentIdList = Arrays.stream(amendmentDocumentIds.split(","))
|
|
|
|
|
.map(String::trim)
|
|
|
|
|
.filter(id -> !id.isEmpty())
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
for (String existingId : existingDocumentIdList) {
|
|
|
|
|
for (String newId : newDocumentIdList) {
|
|
|
|
|
if (existingId.equals(newId)) {
|
|
|
|
|
Optional<DocumentEntity> documentEntity = documentRepository.findByIdAndNotDeleted(Long.valueOf(newId));
|
|
|
|
|
if(documentEntity.isPresent()) {
|
|
|
|
|
updatedDocumentIdList.add(newId);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add any new IDs not in the existing list
|
|
|
|
|
for (String newId : newDocumentIdList) {
|
|
|
|
|
if (!existingDocumentIdList.contains(newId)) {
|
|
|
|
|
Optional<DocumentEntity> documentEntity = documentRepository.findByIdAndNotDeleted(Long.valueOf(newId));
|
|
|
|
|
if(documentEntity.isPresent()) {
|
|
|
|
|
updatedDocumentIdList.add(newId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String updatedDocumentIds = String.join(",", updatedDocumentIdList);
|
|
|
|
|
|
|
|
|
|
// Create the AmendmentDetailsResponseBean for structured data
|
|
|
|
|
AmendmentDetailsResponseBean amendmentDetails = new AmendmentDetailsResponseBean();
|
|
|
|
|
amendmentDetails.setAmendmentDocuments(updatedDocumentIds);
|
|
|
|
|
AmendmentDetailsRequest amendmentDetailsRequest = amendmentFormFields.stream()
|
|
|
|
|
.filter(details -> applicationAmendmentRequestEntity.getId().equals(details.getAmendmentId()))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.orElse(null);
|
|
|
|
|
|
|
|
|
|
if (amendmentDetailsRequest != null) {
|
|
|
|
|
private static void updateAmendmentData(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity, List<AmendmentDetailsRequest> amendmentDetailsRequestList, Map<String, AmendmentFormField> formFieldsMap) {
|
|
|
|
|
amendmentDetailsRequestList.forEach(amendmentDetailsRequest -> {
|
|
|
|
|
if (amendmentDetailsRequest.getFieldId().contains("amend_")) {
|
|
|
|
|
AmendmentDetailsResponseBean amendmentDetails = Utils.convertStringToObject(applicationAmendmentRequestEntity.getAmendmentDocument(), AmendmentDetailsResponseBean.class);
|
|
|
|
|
if(amendmentDetails!=null) {
|
|
|
|
|
amendmentDetails.setValid(amendmentDetailsRequest.getValid());
|
|
|
|
|
} else {
|
|
|
|
|
amendmentDetails.setValid(false);
|
|
|
|
|
}
|
|
|
|
|
String amendmentDetailsJson = Utils.convertListToJsonString(Collections.singletonList(amendmentDetails));
|
|
|
|
|
applicationAmendmentRequestEntity.setAmendmentDocument(amendmentDetailsJson);
|
|
|
|
|
applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity);
|
|
|
|
|
}
|
|
|
|
|
applicationAmendmentRequestEntity.setAmendmentDocument(Utils.convertObjectToString(amendmentDetails));
|
|
|
|
|
}
|
|
|
|
|
} else if(Boolean.FALSE.equals(CollectionUtils.isEmpty(formFieldsMap))){
|
|
|
|
|
AmendmentFormField amendmentFormField = formFieldsMap.get(amendmentDetailsRequest.getFieldId());
|
|
|
|
|
amendmentFormField.setValid(amendmentDetailsRequest.getValid());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
applicationAmendmentRequestEntity.setFormFields(Utils.convertListToJsonString(formFieldsMap.values().stream().toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private void updateAmendmentDocuments(List<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntities, List<AmendmentDetailsRequest> amendmentFormFields) {
|
|
|
|
|
// for (ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity : applicationAmendmentRequestEntities) {
|
|
|
|
|
// // Skip if there are no amendment documents
|
|
|
|
|
|