Resolved conflicts
This commit is contained in:
@@ -634,8 +634,8 @@ public class GepafinConstant {
|
|||||||
public static final String MAIL_SENT_SUCCESSFULLY="mail.send.successfully";
|
public static final String MAIL_SENT_SUCCESSFULLY="mail.send.successfully";
|
||||||
public static final String EMAIL_LOG_FETCHED="email.log.fetched";
|
public static final String EMAIL_LOG_FETCHED="email.log.fetched";
|
||||||
public static final String APPLICATION_AMENDMENT_APPROPIATE_STATUS="amendment.appropiate.status";
|
public static final String APPLICATION_AMENDMENT_APPROPIATE_STATUS="amendment.appropiate.status";
|
||||||
|
public static final String UPLOAD_COMPANY_DOCUMENT_TO_APPLICATION_MSG="upload.company.document.to.application";
|
||||||
|
public static final String COMPANY_DOCUMENT_NOT_FOUND_WITH_IDS="company.document.not.found.with.ids";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,15 @@ public class ApplicationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationContractRepository applicationContractRepository;
|
private ApplicationContractRepository applicationContractRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CompanyDocumentRepository companyDocumentRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AppointmentDao appointmentDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DocumentDao documentDao;
|
||||||
|
|
||||||
public final Random random = new Random();
|
public final Random random = new Random();
|
||||||
|
|
||||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
||||||
@@ -2630,4 +2639,56 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
public void uploadCompanyDocumentsToApplication( Long applicationId,List<Long> companyDocumentIds,UserEntity user) {
|
||||||
|
ApplicationEntity applicationEntity=validateApplication(applicationId);
|
||||||
|
ApplicationEntity oldApplication = Utils.getClonedEntityForData(applicationEntity);
|
||||||
|
List<CompanyDocumentEntity> companyDocumentEntities=validateCompanyDocuments(companyDocumentIds);
|
||||||
|
List<MultipartFile> multipartFiles=new ArrayList<>();
|
||||||
|
for(CompanyDocumentEntity companyDocumentEntity:companyDocumentEntities) {
|
||||||
|
try {
|
||||||
|
File localFile = appointmentDao.downloadFileFromS3(companyDocumentEntity.getFilePath());
|
||||||
|
MultipartFile multipartFile = appointmentDao.convertFileToMultipartFile(localFile);
|
||||||
|
multipartFiles.add(multipartFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
List<DocumentResponseBean> documentResponseBeans=documentDao.uploadFiles(user.getId(),multipartFiles,applicationId,DocumentSourceTypeEnum.APPLICATION,DocumentTypeEnum.DOCUMENT);
|
||||||
|
List<Long> initialDocumentIds = documentResponseBeans.stream()
|
||||||
|
.map(DocumentResponseBean::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
String initialDocumentId = initialDocumentIds.stream()
|
||||||
|
.map(String::valueOf)
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
applicationEntity.setCompanyDocument(initialDocumentId);
|
||||||
|
applicationRepository.save(applicationEntity);
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplication).newData(applicationEntity).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CompanyDocumentEntity> validateCompanyDocuments(List<Long> ids) {
|
||||||
|
|
||||||
|
List<CompanyDocumentEntity> documents =
|
||||||
|
companyDocumentRepository.findByIdInAndIsDeletedFalseAndStatus(ids,CompanyDocumentStatusEnum.VALID.getValue());
|
||||||
|
|
||||||
|
Set<Long> foundIds = documents.stream()
|
||||||
|
.map(CompanyDocumentEntity::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
List<Long> missingIds = ids.stream()
|
||||||
|
.filter(id -> !foundIds.contains(id))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (!missingIds.isEmpty()) {
|
||||||
|
log.warn("Company Document(s) not found with IDs {}", missingIds);
|
||||||
|
throw new ResourceNotFoundException(
|
||||||
|
Status.NOT_FOUND,
|
||||||
|
MessageFormat.format(
|
||||||
|
Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_NOT_FOUND_WITH_IDS),
|
||||||
|
missingIds
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return documents;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -630,6 +630,16 @@ public class ApplicationEvaluationDao {
|
|||||||
|
|
||||||
processedFieldIds.add(fieldResponse.getId());
|
processedFieldIds.add(fieldResponse.getId());
|
||||||
});
|
});
|
||||||
|
List<DocumentResponseBean> companyDocuments=applicationAmendmentRequestDao.getDocumentResponseBean(applicationFormEntities.get(0).getApplication().getCompanyDocument());
|
||||||
|
|
||||||
|
for(DocumentResponseBean documentResponseBean:companyDocuments) {
|
||||||
|
FieldResponse companyFieldResponse = new FieldResponse();
|
||||||
|
companyFieldResponse.setId("COMPANY");
|
||||||
|
companyFieldResponse.setValid(Boolean.TRUE);
|
||||||
|
companyFieldResponse.setLabel(documentResponseBean.getName());
|
||||||
|
companyFieldResponse.setFileDetail(List.of(documentResponseBean));
|
||||||
|
validFieldResponses.add(companyFieldResponse);
|
||||||
|
}
|
||||||
response.setFiles(validFieldResponses);
|
response.setFiles(validFieldResponses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1355,13 +1355,13 @@ public class AppointmentDao {
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MultipartFile convertFileToMultipartFile(File file) throws IOException {
|
public MultipartFile convertFileToMultipartFile(File file) throws IOException {
|
||||||
|
|
||||||
FileInputStream input = new FileInputStream(file);
|
FileInputStream input = new FileInputStream(file);
|
||||||
return new MockMultipartFile(file.getName(), file.getName(), MediaType.APPLICATION_OCTET_STREAM_VALUE, input);
|
return new MockMultipartFile(file.getName(), file.getName(), MediaType.APPLICATION_OCTET_STREAM_VALUE, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File downloadFileFromS3(String fileUrl) throws Exception {
|
public File downloadFileFromS3(String fileUrl) throws Exception {
|
||||||
String key = amazonS3Service.extractS3KeyFromUrl(fileUrl);
|
String key = amazonS3Service.extractS3KeyFromUrl(fileUrl);
|
||||||
String fileName = extractFileName(key);
|
String fileName = extractFileName(key);
|
||||||
String folderPath = key.substring(0, key.lastIndexOf("/"));
|
String folderPath = key.substring(0, key.lastIndexOf("/"));
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ public class CompanyDocumentDao {
|
|||||||
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
||||||
);
|
);
|
||||||
predicate = builder.and(predicate, builder.or(companyPredicate, personalPredicate));
|
predicate = builder.and(predicate, builder.or(companyPredicate, personalPredicate));
|
||||||
|
predicate = builder.equal(root.get("status"), CompanyDocumentStatusEnum.VALID.getValue());
|
||||||
return predicate;
|
return predicate;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,4 +87,7 @@ public class ApplicationEntity extends BaseEntity {
|
|||||||
|
|
||||||
@Column(name = "REJECTED_DOCUMENT")
|
@Column(name = "REJECTED_DOCUMENT")
|
||||||
private String rejectedDocument;
|
private String rejectedDocument;
|
||||||
|
|
||||||
|
@Column(name = "COMPANY_DOCUMENT")
|
||||||
|
private String companyDocument;
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,8 @@ public enum UserActionContextEnum {
|
|||||||
FETCH_APPLICATION_CONTRACT_BY_BENEFICIARY_USER_ID("FETCH_APPLICATION_CONTRACT_BY_BENEFICIARY_USER_ID"),
|
FETCH_APPLICATION_CONTRACT_BY_BENEFICIARY_USER_ID("FETCH_APPLICATION_CONTRACT_BY_BENEFICIARY_USER_ID"),
|
||||||
SEND_PEC_MAIL("SEND_PEC_MAIL"),
|
SEND_PEC_MAIL("SEND_PEC_MAIL"),
|
||||||
FETCH_EMAIL_LOG("FETCH_EMAIL_LOG"),
|
FETCH_EMAIL_LOG("FETCH_EMAIL_LOG"),
|
||||||
FETCH_ALL_EMAIL_LOG("FETCH_ALL_EMAIL_LOG");
|
FETCH_ALL_EMAIL_LOG("FETCH_ALL_EMAIL_LOG"),
|
||||||
|
UPLOAD_COMPANY_DOCUMENT_TO_APPLICATION("UPLOAD_COMPANY_DOCUMENT_TO_APPLICATION");
|
||||||
|
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public interface CompanyDocumentRepository extends JpaRepository<CompanyDocument
|
|||||||
|
|
||||||
List<CompanyDocumentEntity> findByCategoryEntityId(Long categoryId);
|
List<CompanyDocumentEntity> findByCategoryEntityId(Long categoryId);
|
||||||
|
|
||||||
|
List<CompanyDocumentEntity> findByIdInAndIsDeletedFalseAndStatus(List<Long> ids,String status);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,5 +54,5 @@ public interface ApplicationService {
|
|||||||
|
|
||||||
public byte[] downloadRankingCsv(HttpServletRequest request, Long callId);
|
public byte[] downloadRankingCsv(HttpServletRequest request, Long callId);
|
||||||
|
|
||||||
|
public void uploadCompanyDocumentsToApplication(HttpServletRequest request, Long applicationId, List<Long> companyDocumentIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,4 +182,10 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
UserEntity userEntity = validator.validateUser(request);
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
return applicationDao.downloadRankingCsv(callId,userEntity);
|
return applicationDao.downloadRankingCsv(callId,userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadCompanyDocumentsToApplication(HttpServletRequest request, Long applicationId, List<Long> companyDocumentIds) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
applicationDao.uploadCompanyDocumentsToApplication(applicationId,companyDocumentIds,userEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,6 +267,19 @@ public interface ApplicationApi {
|
|||||||
public ResponseEntity<byte[]> downloadRankingCsv(
|
public ResponseEntity<byte[]> downloadRankingCsv(
|
||||||
HttpServletRequest request, @Parameter(description = "The call id", required = true) @PathVariable(value = "callId", required = true) Long callId);
|
HttpServletRequest request, @Parameter(description = "The call id", required = true) @PathVariable(value = "callId", required = true) Long callId);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to upload company documents in application",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "OK"),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||||
|
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||||
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))
|
||||||
|
})
|
||||||
|
@GetMapping(value = "/{applicationId}/companyDocuments")
|
||||||
|
public ResponseEntity<Response<Void>> uploadCompanyDocumentsToApplication(
|
||||||
|
HttpServletRequest request,@Parameter(description = "The application id", required = true) @PathVariable(value = "applicationId", required = true) Long applicationId, @Parameter(description = "The company document id", required = true) @RequestParam("companyDocumentIds") List<Long> companyDocumentIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,4 +275,15 @@ public class ApplicationApiController implements ApplicationApi {
|
|||||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
.body(csvBytes);
|
.body(csvBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Void>> uploadCompanyDocumentsToApplication(HttpServletRequest request, Long applicationId,List<Long> companyDocumentIds) {
|
||||||
|
loggingUtil.logUserAction(
|
||||||
|
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.UPLOAD_COMPANY_DOCUMENT_TO_APPLICATION).build());
|
||||||
|
|
||||||
|
applicationService.uploadCompanyDocumentsToApplication(request, applicationId,companyDocumentIds);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.UPLOAD_COMPANY_DOCUMENT_TO_APPLICATION_MSG)));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3167,4 +3167,10 @@
|
|||||||
<column name="attachments" type="TEXT"></column>
|
<column name="attachments" type="TEXT"></column>
|
||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="18-11-2025_RK_132242" author="Rajesh Khore">
|
||||||
|
<addColumn tableName="application">
|
||||||
|
<column name="company_document" type="VARCHAR(255)"></column>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
@@ -427,5 +427,8 @@ subject.body.required=Subject and body is required to create contract.
|
|||||||
mail.send.successfully=Mail sent succesfully.
|
mail.send.successfully=Mail sent succesfully.
|
||||||
email.log.fetched=Email log fetched successfully.
|
email.log.fetched=Email log fetched successfully.
|
||||||
amendment.appropiate.status=Application amendment is not in appropiate status for this operation.
|
amendment.appropiate.status=Application amendment is not in appropiate status for this operation.
|
||||||
|
upload.company.document.to.application=Uploaded company document to application successfully.
|
||||||
|
company.document.not.found.with.ids=Company document not found. Missing IDs: {0}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -418,3 +418,5 @@ subject.body.required=Per creare un contratto sono necessari oggetto e corpo.
|
|||||||
mail.send.successfully=Email inviata con successo.
|
mail.send.successfully=Email inviata con successo.
|
||||||
email.log.fetched=Registro email recuperato correttamente.
|
email.log.fetched=Registro email recuperato correttamente.
|
||||||
amendment.appropiate.status=L'emendamento dell'applicazione non <20> in stato appropriato per questa operazione.
|
amendment.appropiate.status=L'emendamento dell'applicazione non <20> in stato appropriato per questa operazione.
|
||||||
|
upload.company.document.to.application=Documento aziendale caricato correttamente nell'applicazione.
|
||||||
|
company.document.not.found.with.ids=Documento aziendale non trovato. ID mancanti: {0}
|
||||||
|
|||||||
Reference in New Issue
Block a user