Merge pull request #363 from Kitzanos/feature/GEPAFINBE-6145
GEPAFINBE-6145 (Fixed Special Amendment Document Deletion issue)
This commit is contained in:
@@ -17,6 +17,7 @@ import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -251,7 +252,12 @@ public class DocumentDao {
|
||||
} else if (DocumentSourceTypeEnum.APPLICATION.getValue().equalsIgnoreCase(documentEntity.getSource())) {
|
||||
applicationId = documentEntity.getSourceId();
|
||||
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
||||
|
||||
String rejectedDocument=applicationEntity.getRejectedDocument();
|
||||
if(applicationEntity.getRejectedDocument()!=null) {
|
||||
String updatedValue = removeDocumentIdFromFieldValue(rejectedDocument, documentId);
|
||||
applicationEntity.setRejectedDocument(updatedValue);
|
||||
applicationRepository.save(applicationEntity);
|
||||
}
|
||||
List<ApplicationFormEntity> applicationFormEntity=applicationFormRepository.findByApplicationId(applicationId);
|
||||
for (ApplicationFormEntity applicationForm:applicationFormEntity){
|
||||
FormEntity formEntity=applicationForm.getForm();
|
||||
@@ -276,13 +282,17 @@ public class DocumentDao {
|
||||
amendmentId = documentEntity.getSourceId();
|
||||
ApplicationEntity applicationEntity = applicationAmendmentRequestRepository.findApplicationByAmendmentId(amendmentId);
|
||||
Optional<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntity=applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(amendmentId);
|
||||
Map<String, AmendmentFormField> amendmentFormFieldMap = Utils
|
||||
Map<String, AmendmentFormField> amendmentFormFieldMap =null;
|
||||
if(Boolean.FALSE.equals(StringUtils.isEmpty(applicationAmendmentRequestEntity.get().getFormFields()))){
|
||||
amendmentFormFieldMap = Utils
|
||||
.convertJsonStringToList(applicationAmendmentRequestEntity.get().getFormFields(), AmendmentFormField.class)
|
||||
.stream().collect(Collectors.toMap(AmendmentFormField::getFieldId, Function.identity()));
|
||||
for (Map.Entry<String, AmendmentFormField> entry : amendmentFormFieldMap.entrySet()) {
|
||||
AmendmentFormField amendmentFormField=entry.getValue();
|
||||
String updatedValue = removeDocumentIdFromFieldValue(amendmentFormField.getFieldValue(), documentId);
|
||||
amendmentFormField.setFieldValue(updatedValue);
|
||||
}
|
||||
applicationAmendmentRequestEntity.get().setFormFields(Utils.convertListToJsonString(amendmentFormFieldMap.values().stream().toList()));
|
||||
}
|
||||
String amendmentDocs=applicationAmendmentRequestEntity.get().getAmendmentDocument();
|
||||
Map<String,Object> amendmentDocument=Utils.convertIntoJson(amendmentDocs);
|
||||
@@ -297,7 +307,6 @@ public class DocumentDao {
|
||||
// Step 5: Set it back to entity
|
||||
applicationAmendmentRequestEntity.get().setAmendmentDocument(updatedAmendmentDocs);
|
||||
}
|
||||
applicationAmendmentRequestEntity.get().setFormFields(Utils.convertListToJsonString(amendmentFormFieldMap.values().stream().toList()));
|
||||
applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity.get());
|
||||
|
||||
applicationId = applicationEntity.getId();
|
||||
@@ -321,6 +330,18 @@ public class DocumentDao {
|
||||
callId = applicationEntity.getCall().getId();
|
||||
log.info("Processing document of type EVALUATION. Resolved evaluationId={}, applicationId={}, callId={}", evaluationId, applicationId, callId);
|
||||
}
|
||||
else if(DocumentSourceTypeEnum.COMMUNICATION.getValue().equalsIgnoreCase(documentEntity.getSource())) {
|
||||
communicationId = documentEntity.getSourceId();
|
||||
Optional<CommunicationEntity> communicationEntity=communicationRepository.findByIdAndIsDeletedFalse(communicationId);
|
||||
CommunicationEntity communicationEntity1=communicationEntity.get();
|
||||
String communicationDocuments=communicationEntity1.getDocuments();
|
||||
if(communicationEntity1.getDocuments()!=null) {
|
||||
String updatedValue = removeDocumentIdFromFieldValue(communicationDocuments, documentId);
|
||||
communicationEntity1.setDocuments(updatedValue);
|
||||
communicationRepository.save(communicationEntity1);
|
||||
}
|
||||
|
||||
}
|
||||
deleteFileFromS3(documentEntity, callId, applicationId,amendmentId,communicationId);
|
||||
log.info("Successfully deleted file from S3 for documentId={}", documentId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user