Merge pull request #233 from Kitzanos/fixed-application-amendment-issue

Cherry-pick (Fixed application amendment issue)
This commit is contained in:
Rinaldo
2025-03-04 13:04:45 +01:00
committed by GitHub
2 changed files with 10 additions and 2 deletions

View File

@@ -1047,7 +1047,7 @@ public class ApplicationAmendmentRequestDao {
List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse( List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(
existingApplicationAmendment.getApplicationEvaluationEntity().getId()); existingApplicationAmendment.getApplicationEvaluationEntity().getId());
Boolean allClosed = amendmentRequests.stream().allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue())); Boolean allClosed = amendmentRequests.stream().allMatch(amendment -> (amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()) || amendment.getStatus().equals(ApplicationAmendmentRequestEnum.EXPIRED.getValue())));
ApplicationEntity application = applicationService.validateApplication(existingApplicationAmendment.getApplicationId()); ApplicationEntity application = applicationService.validateApplication(existingApplicationAmendment.getApplicationId());
ApplicationEntity oldApplicationEntityData = Utils.getClonedEntityForData(application); ApplicationEntity oldApplicationEntityData = Utils.getClonedEntityForData(application);
if (Boolean.TRUE.equals(allClosed)) { if (Boolean.TRUE.equals(allClosed)) {

View File

@@ -1,5 +1,6 @@
package net.gepafin.tendermanagement.dao; package net.gepafin.tendermanagement.dao;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.CopyObjectRequest; import com.amazonaws.services.s3.model.CopyObjectRequest;
import jakarta.persistence.criteria.Predicate; import jakarta.persistence.criteria.Predicate;
@@ -33,6 +34,7 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.net.URL;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -86,6 +88,9 @@ public class CompanyDocumentDao {
@Autowired @Autowired
private Validator validator; private Validator validator;
@Autowired
private AmazonS3 amazonS3;
public List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, Long userId, List<MultipartFile> files, Long companyId, Long documentCategoryId, CompanyDocumentTypeEnum companyDocumentSourceTypeEnum, LocalDateTime expirationDate,String name){ public List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, Long userId, List<MultipartFile> files, Long companyId, Long documentCategoryId, CompanyDocumentTypeEnum companyDocumentSourceTypeEnum, LocalDateTime expirationDate,String name){
DocumentCategoryEntity categoryEntity = categoryDao.validateCategory(documentCategoryId); DocumentCategoryEntity categoryEntity = categoryDao.validateCategory(documentCategoryId);
validator.validateUserWithCompany(request,companyId); validator.validateUserWithCompany(request,companyId);
@@ -271,8 +276,11 @@ public class CompanyDocumentDao {
s3Client.copyObject(copyRequest); s3Client.copyObject(copyRequest);
log.info("File copied successfully from {} to {}", oldS3Path, newS3Path); log.info("File copied successfully from {} to {}", oldS3Path, newS3Path);
URL amazonS3Url = amazonS3.getUrl(bucketName, newS3Path);
String fileUrl = amazonS3Url.toString();
DocumentEntity entity = new DocumentEntity(); DocumentEntity entity = new DocumentEntity();
entity.setFilePath(newS3Path); entity.setFilePath(fileUrl);
entity.setFileName(companyDocumentEntity.getFileName()); entity.setFileName(companyDocumentEntity.getFileName());
entity.setSource(DocumentSourceTypeEnum.APPLICATION.getValue()); entity.setSource(DocumentSourceTypeEnum.APPLICATION.getValue());
entity.setType(documentTypeEnum.getValue()); entity.setType(documentTypeEnum.getValue());