Resolved conflicts of PR GEPAFINBE-6139 (Reviewed Evaluation Process)
This commit is contained in:
@@ -34,6 +34,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -149,6 +150,9 @@ public class ApplicationAmendmentRequestDao {
|
||||
@Autowired
|
||||
private EmailDao emailDao;
|
||||
|
||||
@Autowired
|
||||
private DocumentDao documentDao;
|
||||
|
||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
||||
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||
@@ -302,10 +306,10 @@ public class ApplicationAmendmentRequestDao {
|
||||
return filteredList;
|
||||
}
|
||||
|
||||
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(Long applicationEvaluationId, ApplicationAmendmentRequest applicationAmendmentRequest) {
|
||||
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(Long applicationEvaluationId, List<MultipartFile> files, ApplicationAmendmentRequest applicationAmendmentRequest,Long userId) {
|
||||
log.info("Submiting application data for amendment Process with details: {}", applicationEvaluationId);
|
||||
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = createApplicationAmendmentRequestEntity(applicationAmendmentRequest, applicationEvaluationId);
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = createApplicationAmendmentRequestEntity(applicationAmendmentRequest, applicationEvaluationId,files, userId);
|
||||
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = convertEntityToResponse(applicationAmendmentRequestEntity,false);
|
||||
log.info("Application submitted successfully for amendment", applicationAmendmentRequestResponse);
|
||||
if (Boolean.TRUE.equals(applicationAmendmentRequestResponse.getIsSendEmail())) {
|
||||
@@ -323,7 +327,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
return applicationAmendmentRequestResponse;
|
||||
}
|
||||
|
||||
public ApplicationAmendmentRequestEntity createApplicationAmendmentRequestEntity(ApplicationAmendmentRequest applicationAmendmentRequest,Long applicationEvaluationId) {
|
||||
public ApplicationAmendmentRequestEntity createApplicationAmendmentRequestEntity(ApplicationAmendmentRequest applicationAmendmentRequest,Long applicationEvaluationId,List<MultipartFile> files,Long userId) {
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = new ApplicationAmendmentRequestEntity();
|
||||
applicationAmendmentRequestEntity.setNote(applicationAmendmentRequest.getNote());
|
||||
applicationAmendmentRequestEntity.setResponseDays(applicationAmendmentRequest.getResponseDays());
|
||||
@@ -389,7 +393,15 @@ public class ApplicationAmendmentRequestDao {
|
||||
applicationAmendmentRequestEntity.setProtocol(protocolEntity);
|
||||
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT);
|
||||
log.info("Amendment request saved with ID={}", applicationAmendment.getId());
|
||||
|
||||
List<DocumentResponseBean> documentResponseBeans= uploadInitialDocument(userId,files,applicationAmendment);
|
||||
List<Long> initialDocumentIds = documentResponseBeans.stream()
|
||||
.map(DocumentResponseBean::getId)
|
||||
.collect(Collectors.toList());
|
||||
String initialDocumentId = initialDocumentIds.stream()
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(","));
|
||||
applicationAmendment.setAmendmentInitialDocument(initialDocumentId);
|
||||
applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendment, null, VersionActionTypeEnum.UPDATE);
|
||||
String evaluationStatusType = applicationEvaluationEntity.getStatus();
|
||||
if (Boolean.FALSE.equals(evaluationStatusType.equals((ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue())))){
|
||||
// applicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||
@@ -473,45 +485,65 @@ public class ApplicationAmendmentRequestDao {
|
||||
// List<AmendmentDetailsResponseBean> amendmentDetailsList =
|
||||
// Utils.convertJsonStringToList(applicationAmendmentRequestEntity.getAmendmentDocument(),
|
||||
// AmendmentDetailsResponseBean.class);
|
||||
AmendmentDetailsResponseBean amendmentDetails = Utils.convertStringToObject(applicationAmendmentRequestEntity.getAmendmentDocument() ,AmendmentDetailsResponseBean.class);
|
||||
if(amendmentDetails!=null) {
|
||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||
if (amendmentDetails.getAmendmentDocuments() != null) {
|
||||
// Extract the comma-separated document IDs as a string
|
||||
String documentIdsString = amendmentDetails.getAmendmentDocuments();
|
||||
AmendmentDetailsResponseBean amendmentDetails = Utils.convertStringToObject(applicationAmendmentRequestEntity.getAmendmentDocument(), AmendmentDetailsResponseBean.class);
|
||||
if (amendmentDetails != null) {
|
||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||
if (amendmentDetails.getAmendmentDocuments() != null) {
|
||||
// Extract the comma-separated document IDs as a string
|
||||
String documentIdsString = amendmentDetails.getAmendmentDocuments();
|
||||
|
||||
if (documentIdsString != null && !documentIdsString.trim().isEmpty()) {
|
||||
// Split the comma-separated values and process them
|
||||
List<String> documentIds = Arrays.stream(documentIdsString.split(","))
|
||||
.map(String::trim)
|
||||
.filter(id -> !id.isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
if (documentIdsString != null && !documentIdsString.trim().isEmpty()) {
|
||||
// Split the comma-separated values and process them
|
||||
List<String> documentIds = Arrays.stream(documentIdsString.split(","))
|
||||
.map(String::trim)
|
||||
.filter(id -> !id.isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
documentResponseBeans.addAll(
|
||||
documentIds.stream()
|
||||
.map(id -> {
|
||||
try {
|
||||
return createDocumentResponseBean(id); // Convert to Long
|
||||
} catch (NumberFormatException e) {
|
||||
// Handle invalid document IDs gracefully
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull) // Skip null responses
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
response.setAmendmentNotes(amendmentDetails.getAmendmentNotes());
|
||||
response.setValid(amendmentDetails.getValid());
|
||||
}
|
||||
documentResponseBeans.addAll(
|
||||
documentIds.stream()
|
||||
.map(id -> {
|
||||
try {
|
||||
return createDocumentResponseBean(id); // Convert to Long
|
||||
} catch (NumberFormatException e) {
|
||||
// Handle invalid document IDs gracefully
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull) // Skip null responses
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
response.setAmendmentNotes(amendmentDetails.getAmendmentNotes());
|
||||
response.setValid(amendmentDetails.getValid());
|
||||
}
|
||||
response.setAmendmentDocuments(documentResponseBeans);
|
||||
}
|
||||
|
||||
|
||||
|
||||
response.setAmendmentDocuments(documentResponseBeans);
|
||||
}
|
||||
}
|
||||
List<DocumentResponseBean> initialDocumentBeans = new ArrayList<>();
|
||||
String initialDocuments = applicationAmendmentRequestEntity.getAmendmentInitialDocument();
|
||||
|
||||
if (initialDocuments != null && !initialDocuments.trim().isEmpty()) {
|
||||
// Split the comma-separated values and process them
|
||||
List<String> documentIds = Arrays.stream(initialDocuments.split(","))
|
||||
.map(String::trim)
|
||||
.filter(id -> !id.isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
initialDocumentBeans.addAll(
|
||||
documentIds.stream()
|
||||
.map(id -> {
|
||||
try {
|
||||
return createDocumentResponseBean(id); // Convert to Long
|
||||
} catch (NumberFormatException e) {
|
||||
// Handle invalid document IDs gracefully
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull) // Skip null responses
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
response.setAmendmentInitialDocuments(initialDocumentBeans);
|
||||
processFormFields(amendmentFormFields, fieldIdToLabelMap, formFieldEntityMap, response);
|
||||
|
||||
return response;
|
||||
@@ -609,23 +641,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
createFormField(formFields, fieldIdToLabelMap, amendmentFormField);
|
||||
|
||||
// Create document responses
|
||||
List<Long> documentIds = extractIds(amendmentFormField.getFieldValue());
|
||||
List<DocumentResponseBean> documentResponseBeans = documentIds.stream()
|
||||
.map(id -> {
|
||||
DocumentEntity documentEntity = documentService.validateDocument(id);
|
||||
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||
responseBean.setId(documentEntity.getId());
|
||||
responseBean.setName(documentEntity.getFileName());
|
||||
responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType()));
|
||||
responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource()));
|
||||
responseBean.setSourceId(documentEntity.getSourceId());
|
||||
responseBean.setFilePath(documentEntity.getFilePath());
|
||||
responseBean.setCreatedDate(documentEntity.getCreatedDate());
|
||||
responseBean.setUpdatedDate(documentEntity.getUpdatedDate());
|
||||
responseBean.setDocumentAttachmentId(documentEntity.getDocumentAttachmentId());
|
||||
return responseBean;
|
||||
})
|
||||
.toList();
|
||||
List<DocumentResponseBean> documentResponseBeans = getDocumentResponseBean(amendmentFormField.getFieldValue());
|
||||
|
||||
// Map to application form field response bean
|
||||
ApplicationFormFieldEntity formFieldEntity = formFieldEntityMap.get(amendmentFormField.getFieldId());
|
||||
@@ -644,6 +660,27 @@ public class ApplicationAmendmentRequestDao {
|
||||
response.setApplicationFormFields(fileDetails);
|
||||
}
|
||||
|
||||
private List<DocumentResponseBean> getDocumentResponseBean(String documentId) {
|
||||
List<Long> documentIds = extractIds(documentId);
|
||||
List<DocumentResponseBean> documentResponseBeans = documentIds.stream()
|
||||
.map(id -> {
|
||||
DocumentEntity documentEntity = documentService.validateDocument(id);
|
||||
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||
responseBean.setId(documentEntity.getId());
|
||||
responseBean.setName(documentEntity.getFileName());
|
||||
responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType()));
|
||||
responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource()));
|
||||
responseBean.setSourceId(documentEntity.getSourceId());
|
||||
responseBean.setFilePath(documentEntity.getFilePath());
|
||||
responseBean.setCreatedDate(documentEntity.getCreatedDate());
|
||||
responseBean.setUpdatedDate(documentEntity.getUpdatedDate());
|
||||
responseBean.setDocumentAttachmentId(documentEntity.getDocumentAttachmentId());
|
||||
return responseBean;
|
||||
})
|
||||
.toList();
|
||||
return documentResponseBeans;
|
||||
}
|
||||
|
||||
private String buildBeneficiaryName(UserEntity userEntity) {
|
||||
if (userEntity.getBeneficiary() == null) {
|
||||
return "";
|
||||
@@ -1878,5 +1915,10 @@ public class ApplicationAmendmentRequestDao {
|
||||
log.info("Application submitted successfully for amendment", applicationAmendmentRequestResponse);
|
||||
return applicationAmendmentRequestResponse;
|
||||
}
|
||||
|
||||
public List<DocumentResponseBean> uploadInitialDocument(Long userId,List<MultipartFile> files,ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity){
|
||||
if(files!=null) {
|
||||
return documentDao.uploadFiles(userId, files, applicationAmendmentRequestEntity.getId(), DocumentSourceTypeEnum.AMENDMENT, DocumentTypeEnum.DOCUMENT);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user