Merge pull request #357 from Kitzanos/feature/GEPAFINBE-6139-prod

Cherry-pick (GEPAFINBE-6139)
This commit is contained in:
Rinaldo
2025-10-17 16:23:59 +02:00
committed by GitHub
49 changed files with 791 additions and 221 deletions

View File

@@ -1,5 +1,8 @@
package net.gepafin.tendermanagement.constants;
import java.util.Arrays;
import java.util.List;
public class GepafinConstant {
public static final String USER_CREATED_SUCCESS_MSG = "user.created.success";
@@ -614,6 +617,12 @@ public class GepafinConstant {
" </div>\n" +
" </body>\n" +
"</html>";
public static final String UPDATE_APPLICATION_TECHNICAL_EVALUATION_REJECTED_MSG = "application.technical.evaluation.rejected.success";
public static final String SUBJECT = "subject";
public static final List<String> MANUAL_EMAIL_KEYS = Arrays.asList(SUBJECT, MESSAGE);
public static final String INVALID_EMAIL_JSON = "invalid.email.json";
public static final String MORE_FIELDS_REQUIRED_FOR_REJECTION="more.fields.required";
}

View File

@@ -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());
@@ -337,6 +341,7 @@ public class ApplicationAmendmentRequestDao {
applicationAmendmentRequestEntity.setIsNotification(applicationAmendmentRequest.getIsSendNotification());
applicationAmendmentRequestEntity.setStartDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
applicationAmendmentRequestEntity.setStatus(ApplicationAmendmentRequestEnum.AWAITING.getValue());
applicationAmendmentRequestEntity.setType(ApplicationAmendmentRequestTypeEnum.REGULAR.getValue());
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
//cloned for old data entity
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(applicationEvaluationEntity);
@@ -345,7 +350,8 @@ public class ApplicationAmendmentRequestDao {
Long applicationId = applicationEvaluationEntity.getApplicationId();
Long assignedApplicationId = applicationEvaluationEntity.getAssignedApplicationsEntity().getId();
applicationAmendmentRequestEntity.setApplicationId(applicationId);
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
if (applicationAmendmentRequest.getFormFields() != null) {
List<AmendmentFormField> formFieldRequestBean = applicationAmendmentRequest.getFormFields().stream()
.filter(AmendmentFormFieldResponse::isSelected)
@@ -362,18 +368,22 @@ public class ApplicationAmendmentRequestDao {
}
List<ApplicationAmendmentRequestEntity> amendmentRequest = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(applicationEvaluationEntity.getId());
// Ensure startDate and initialDays are not null to avoid NullPointerException
if (amendmentRequest !=null && amendmentRequest.isEmpty() && applicationEvaluationEntity.getStartDate() != null && applicationEvaluationEntity.getInitialDays() != null ) {
Long initialDays = applicationEvaluationEntity.getInitialDays();
LocalDateTime startDate = applicationEvaluationEntity.getStartDate();
LocalDateTime nowInUTC = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
// Calculate remaining days
Long remainingDays = initialDays - DAYS.between(startDate, nowInUTC);
// Set remaining days in the entity
applicationEvaluationEntity.setRemainingDays(remainingDays);
//Set stop date time in the entity becuase amendment has started
applicationEvaluationEntity.setStopDateTime(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
if (amendmentRequest !=null && amendmentRequest.isEmpty()) {
if (applicationEvaluationEntity.getStartDate() != null && applicationEvaluationEntity.getInitialDays() != null) {
Long initialDays = applicationEvaluationEntity.getInitialDays();
LocalDateTime startDate = applicationEvaluationEntity.getStartDate();
LocalDateTime nowInUTC = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
// Calculate remaining days
Long remainingDays = initialDays - DAYS.between(startDate, nowInUTC);
// Set remaining days in the entity
applicationEvaluationEntity.setRemainingDays(remainingDays);
//Set stop date time in the entity becuase amendment has started
applicationEvaluationEntity.setStopDateTime(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
}
applicationEntity.setPreviousStatus(oldApplicationEntity.getStatus());
}
UserEntity userEntity = userService.validateUser(applicationEvaluationEntity.getUserId());
Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub());
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(
@@ -383,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());
@@ -396,8 +414,7 @@ public class ApplicationAmendmentRequestDao {
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity).newData(applicationEvaluationEntity).build());
}
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
String applicationStatusType = applicationEntity.getStatus();
if (Boolean.FALSE.equals(applicationStatusType.equals((ApplicationStatusTypeEnum.SOCCORSO.getValue())))) {
applicationEntity.setStatus(ApplicationStatusTypeEnum.SOCCORSO.getValue());
@@ -468,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;
@@ -560,13 +597,15 @@ public class ApplicationAmendmentRequestDao {
Map<String, String> bodyPlaceholders = emailNotificationDao.prepareEmailPlaceholders(applicationEntity, entity);
EmailContentResponse emailContent =null;
if(entity.getType()!=null && entity.getType().equals(ApplicationAmendmentRequestTypeEnum.SPECIAL.getValue())){
emailContent=emailNotificationDao.prepareEmailContent(applicationEntity, SystemEmailTemplatesEntityTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED, hubEntity, bodyPlaceholders);
emailContent=emailNotificationDao.prepareEmailContent(applicationEntity, SystemEmailTemplatesEntityTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED, hubEntity, bodyPlaceholders,null);
}else {
emailContent = emailNotificationDao.prepareEmailContent(applicationEntity, SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, hubEntity, bodyPlaceholders);
emailContent = emailNotificationDao.prepareEmailContent(applicationEntity, SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, hubEntity, bodyPlaceholders,null);
}
String body = emailContent.getBody();
response.setEmailTemplate(body);
}
response.setAmendmentType(entity.getType());
response.setAmendmentDocumentType(entity.getAmendmentDocumentType());
return response;
}
@@ -604,23 +643,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());
@@ -639,6 +662,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 "";
@@ -1120,9 +1164,11 @@ public class ApplicationAmendmentRequestDao {
applicationEvaluationRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity());
log.info("Updated ApplicationEvaluation status to OPEN for ID: {}", existingApplicationEvaluationEntity.getId());
application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue());
if(Boolean.FALSE.equals(existingApplicationAmendment.getType().equals(ApplicationAmendmentRequestTypeEnum.SPECIAL.getValue()))){
application.setStatus(application.getPreviousStatus());
}
applicationRepository.save(application);
log.info("Updated Application status to EVALUATION for Application ID: {}", application.getId());
log.info("Updated Application status to previous state for Application ID: {}", application.getId());
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().setStatus(AssignedApplicationEnum.OPEN.getValue());
@@ -1871,5 +1917,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<>();
}
}

View File

@@ -1,5 +1,6 @@
package net.gepafin.tendermanagement.dao;
import com.amazonaws.services.dynamodbv2.xspec.L;
import com.amazonaws.services.dynamodbv2.xspec.S;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
@@ -131,6 +132,9 @@ public class ApplicationDao {
@Autowired
private AssignedApplicationsRepository assignedApplicationsRepository;
@Autowired
private CommunicationRepository communicationRepository;
// @Value("${default_System_Receiver_Email}")
// private String defaultSystemReceiverEmail;
@@ -1372,7 +1376,7 @@ public class ApplicationDao {
ApplicationSignedDocumentEntity oldApplicationSignedDocument = Utils.getClonedEntityForData(applicationSignedDocumentEntity);
String oldS3Path = applicationSignedDocumentEntity.getFilePath();
log.debug("Old S3 path: {} ", oldS3Path);
String newS3Path = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.DELETED_USER_SIGNED_DOCUMENT,applicationSignedDocumentEntity.getApplication().getCall().getId(),applicationSignedDocumentEntity.getApplication().getId(),0L);
String newS3Path = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.DELETED_USER_SIGNED_DOCUMENT,applicationSignedDocumentEntity.getApplication().getCall().getId(),applicationSignedDocumentEntity.getApplication().getId(),0L,0L);
log.debug("Generated new S3 path for deleted document: {}", newS3Path);
UploadFileOnAmazonS3Response response = amazonS3Service.moveFile(applicationSignedDocumentEntity.getFileName(), oldS3Path, newS3Path);
@@ -1407,7 +1411,7 @@ public class ApplicationDao {
}
private String generateS3PathForDelegation(Long callId, Long applicationId) {
try {
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, callId, applicationId,0L);
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, callId, applicationId,0L,0L);
} catch (IllegalArgumentException e) {
log.error("Failed to generate S3 path for delegation | callId: {}, applicationId: {}, error: {}", callId, applicationId, e.getMessage(), e);
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
@@ -1529,11 +1533,12 @@ public class ApplicationDao {
ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
List<DocumentEntity> amendmentDocuments = fetchAmendmentDocuments(applicationId);
List<DocumentEntity> evaluationDocuments = fetchEvaluationDocuments(applicationId);
List<DocumentEntity> communicationnDocuments = fetchCommunicationDocuments(applicationId);
if (documents.isEmpty() && signedDocument == null && amendmentDocuments.isEmpty() && evaluationDocuments.isEmpty()) {
log.warn("No documents found for applicationId: {}", applicationId);
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND));
}
return createZipWithDocuments(applicationEntity, documents, signedDocument, amendmentDocuments, evaluationDocuments, applicationId);
return createZipWithDocuments(applicationEntity, documents, signedDocument, amendmentDocuments, evaluationDocuments, applicationId,communicationnDocuments);
}
private void validateAssignedUser(HttpServletRequest request, Long applicationId) {
@@ -1582,6 +1587,28 @@ public class ApplicationDao {
}
return Collections.emptyList();
}
private List<DocumentEntity> fetchCommunicationDocuments(Long applicationId) {
log.info("Fetching communication documents for applicationId: {}", applicationId);
List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
List<Long> amendmentRequestIds = amendmentRequests.stream()
.map(ApplicationAmendmentRequestEntity::getId)
.collect(Collectors.toList());
List<CommunicationEntity> communicationEntities=communicationRepository.findByApplicationAmendmentRequestIdInAndIsDeletedFalse(amendmentRequestIds);
List<DocumentEntity> documentEntities=new ArrayList<>();
if (Boolean.FALSE.equals(communicationEntities.isEmpty())) {
for (CommunicationEntity communicationEntity : communicationEntities) {
{
Long communicationId = communicationEntity.getId();
log.debug("Found communication entity with id: {}", communicationId);
List<DocumentEntity> communicationDocuments= documentRepository.findBySourceIdInAndSourceAndIsDeletedFalse(Collections.singleton(communicationId), DocumentSourceTypeEnum.COMMUNICATION.getValue());
documentEntities.addAll(communicationDocuments);
}
}
return documentEntities;
}
return Collections.emptyList();
}
private String fetchProtocolNumberForAmendment(Long amendmentRequestId) {
ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(amendmentRequestId).orElse(null);
@@ -1603,12 +1630,12 @@ public class ApplicationDao {
}
}
private byte[] createZipWithDocuments(ApplicationEntity applicationEntity, List<DocumentEntity> documents, ApplicationSignedDocumentEntity signedDocument,
List<DocumentEntity> amendmentDocuments, List<DocumentEntity> evaluationDocuments, Long applicationId) {
List<DocumentEntity> amendmentDocuments, List<DocumentEntity> evaluationDocuments, Long applicationId,List<DocumentEntity> communicationDocuments) {
try (ByteArrayOutputStream zipOutputStream = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
Long callId = applicationEntity.getCall().getId();
// Add Application Documents
String appS3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION, callId, applicationId, 0L);
String appS3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION, callId, applicationId, 0L,0L);
for (DocumentEntity document : documents) {
String fileName = Utils.extractFileName(document.getFilePath());
addDocumentToZip(zos, appS3Folder, document.getFilePath(), fileName);
@@ -1616,7 +1643,7 @@ public class ApplicationDao {
// Add Signed Document
if (signedDocument != null) {
String signedFolder = "SIGNED_DOCUMENT/";
String signedDocS3Folder = s3PathConfig.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, callId, applicationId, 0L);
String signedDocS3Folder = s3PathConfig.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, callId, applicationId, 0L,0L);
String fileName = signedDocument.getFileName();
addDocumentToZip(zos, signedDocS3Folder, signedDocument.getFilePath(), signedFolder + fileName);
}
@@ -1624,17 +1651,24 @@ public class ApplicationDao {
for (DocumentEntity amendmentDocument : amendmentDocuments) {
String protocolNumber = fetchProtocolNumberForAmendment(amendmentDocument.getSourceId());
String amendmentFolder = "SOCCORSO_" + protocolNumber + "/";
String amendmentS3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.AMENDMENT, callId, applicationId, amendmentDocument.getSourceId());
String amendmentS3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.AMENDMENT, callId, applicationId, amendmentDocument.getSourceId(),0L);
String fileName = Utils.extractFileName(amendmentDocument.getFilePath());
addDocumentToZip(zos, amendmentS3Folder, amendmentDocument.getFilePath(), amendmentFolder + fileName);
}
// Add Evaluation Documents
for (DocumentEntity evaluationDocument : evaluationDocuments) {
String evaluationFolder = "EVALUATION/";
String evaluationS3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.EVALUATION, callId, applicationId, evaluationDocument.getSourceId());
String evaluationS3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.EVALUATION, callId, applicationId, evaluationDocument.getSourceId(),0L);
String fileName = Utils.extractFileName(evaluationDocument.getFilePath());
addDocumentToZip(zos, evaluationS3Folder, evaluationDocument.getFilePath(), evaluationFolder + fileName);
}
for (DocumentEntity communicationDocument : communicationDocuments) {
Optional<CommunicationEntity> communicationEntity=communicationRepository.findByIdAndIsDeletedFalse(communicationDocument.getSourceId());
String evaluationFolder = "COMMUNICATION/";
String evaluationS3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.COMMUNICATION, callId, applicationId, communicationEntity.get().getApplicationAmendmentRequest().getId(),communicationDocument.getSourceId());
String fileName = Utils.extractFileName(communicationDocument.getFilePath());
addDocumentToZip(zos, evaluationS3Folder, communicationDocument.getFilePath(), evaluationFolder + fileName);
}
zos.finish();
return zipOutputStream.toByteArray();
} catch (IOException e) {

View File

@@ -19,8 +19,10 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.text.MessageFormat;
@@ -146,6 +148,11 @@ public class ApplicationEvaluationDao {
@Autowired
private EmailDao emailDao;
@Autowired
private DocumentDao documentDao;
@Value("${default.hub.uuid}")
private String defaultHubUuid;
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
@@ -182,7 +189,7 @@ public class ApplicationEvaluationDao {
ApplicationEvaluationResponse response = new ApplicationEvaluationResponse();
populateBasicDetails(entity, response);
ApplicationEntity applicationEntity=entity.getAssignedApplicationsEntity().getApplication();
CallEntity call = callRepository.findCallEntityByApplicationId(entity.getApplicationId());
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository
.findByCallIdAndLookupDataTypeAndIsDeletedFalse(call.getId(), LookUpDataEntity.LookUpDataTypeEnum.EVALUATION_CRITERIA.getValue());
@@ -201,10 +208,39 @@ public class ApplicationEvaluationDao {
List<EvaluationDocumentRequest> allDocs = prepareEvaluationDocumentBeanList(entity);
setEvaluationDocResponse(response, allDocs);
setApplicationDetails(response, entity);
setRejectedDocuments(applicationEntity, response);
return response;
}
private void setRejectedDocuments(ApplicationEntity applicationEntity, ApplicationEvaluationResponse response) {
List<DocumentResponseBean> initialDocumentBeans = new ArrayList<>();
String initialDocuments = applicationEntity.getRejectedDocument();
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 applicationAmendmentRequestDao.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.setRejectedDocument(initialDocumentBeans);
}
private void setAmendmentDetails(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response) {
List<ApplicationAmendmentRequestEntity> amendmentRequests=applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(entity.getId());
List<AmendmentDocumentResponseBean> amendmentDocumentResponseBeans=new ArrayList<>();
@@ -653,7 +689,7 @@ public class ApplicationEvaluationDao {
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
UserEntity user,
ApplicationEvaluationRequest req,
Long assignedApplicationId) {
Long assignedApplicationId, List<MultipartFile> rejectedDocuments) {
log.info("Start createOrUpdateApplicationEvaluation: assignedApplicationId={}, userId={}", assignedApplicationId, user.getId());
Optional<ApplicationEvaluationEntity> existingEntityOptional =
@@ -741,7 +777,7 @@ public class ApplicationEvaluationDao {
if (status != null) {
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplications.get();
return updateApplicationEvaluationStatus(application, assignedApplicationsEntity, status);
return updateApplicationEvaluationStatus(application, assignedApplicationsEntity, status,rejectedDocuments,req);
} else {
return convertToResponse(entity);
}
@@ -1903,7 +1939,7 @@ public class ApplicationEvaluationDao {
}
public ApplicationEvaluationResponse updateApplicationEvaluationStatus(ApplicationEntity application, AssignedApplicationsEntity assignedApplicationsEntity,
ApplicationStatusForEvaluation newStatus) {
ApplicationStatusForEvaluation newStatus, List<MultipartFile> files,ApplicationEvaluationRequest applicationEvaluationRequest) {
log.info("Starting updateApplicationEvaluationStatus for applicationId: {}, assignedApplicationId: {}, newStatus: {}",
application.getId(), assignedApplicationsEntity.getId(), newStatus);
@@ -1997,10 +2033,30 @@ public class ApplicationEvaluationDao {
notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_RESULT);
}
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.REJECTED.getValue())))) {
String tipoInammissibilita =null;
String emailType=null;
if(Boolean.TRUE.equals(hub.getUniqueUuid().equals(defaultHubUuid))) {
if (applicationEvaluationRequest.getMotivation() == null || applicationEvaluationRequest.getRejectedReason() == null || applicationEvaluationRequest.getRejectedReasonSubject()==null) {
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.MORE_FIELDS_REQUIRED_FOR_REJECTION));
}
if (files != null) {
List<DocumentResponseBean> documentResponseBeans = uploadRejectedDocument(user.getId(), files, application);
List<Long> rejectedDocumentIds = documentResponseBeans.stream()
.map(DocumentResponseBean::getId)
.collect(Collectors.toList());
String rejectedDocumentId = rejectedDocumentIds.stream()
.map(String::valueOf)
.collect(Collectors.joining(","));
application.setRejectedDocument(rejectedDocumentId);
}
tipoInammissibilita=applicationEvaluationRequest.getRejectedReason();
emailType=applicationEvaluationRequest.getRejectedReasonSubject();
application.setRejectedReason(applicationEvaluationRequest.getRejectedReason());
}
application.setDateRejected(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
application.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
application = applicationRepository.save(application);
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(application,existingEntity);
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(application,existingEntity,tipoInammissibilita,emailType);
emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
responses = List.of(emailSendResponse);
if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())) {
@@ -2083,7 +2139,7 @@ public class ApplicationEvaluationDao {
return convertToResponse(savedEntity);
}
public ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long evaluationFormId, Long assignedApplicationId){
public ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, List<MultipartFile> files, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long evaluationFormId, Long assignedApplicationId){
log.info("Start createApplicationEvaluation - assignedApplicationId: {}, evaluationFormId: {}", assignedApplicationId, evaluationFormId);
UserEntity user = validator.validateUser(request);
@@ -2094,7 +2150,7 @@ public class ApplicationEvaluationDao {
ApplicationEvaluationRequest req = convertToApplicationEvaluationRequest(applicationEvaluationFormRequestBean);
// Call the existing method to create or update evaluation
ApplicationEvaluationResponse evaluationResponse = createOrUpdateApplicationEvaluation(user, req, assignedApplicationId);
ApplicationEvaluationResponse evaluationResponse = createOrUpdateApplicationEvaluation(user, req, assignedApplicationId,files);
ApplicationEvaluationEntity entity = applicationEvaluationService.validateApplicationEvaluation(evaluationResponse.getId());
@@ -2415,7 +2471,8 @@ public class ApplicationEvaluationDao {
request.setApplicationStatus(formRequestBean.getApplicationStatus());
request.setMotivation(formRequestBean.getMotivation());
request.setAmountAccepted(formRequestBean.getAmountAccepted());
request.setRejectedReason(formRequestBean.getRejectedReason());
request.setRejectedReasonSubject(formRequestBean.getRejectedReasonSubject());
request.setCriteria(null);
request.setChecklist(null);
@@ -2605,6 +2662,48 @@ public class ApplicationEvaluationDao {
return BigDecimal.ZERO;
}
}
public ApplicationEvaluationResponse updateApplicationToTechnicalEvaluationRejected(ApplicationTechnicalEvaluationRejectedRequest applicationRequest, Long assignedApplicationsId) {
Optional<ApplicationEvaluationEntity> existingEntityOptional =
applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationsId);
Utils.validateEmailJson(applicationRequest.getEmailJson());
Optional<AssignedApplicationsEntity> assignedApplications =
assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationsId);
ApplicationEntity application = applicationService.validateApplication(assignedApplications.get().getApplication().getId());
UserEntity user=userService.validateUser(application.getUserId());
HubEntity hub=user.getHub();
EmailSendResponse emailSendResponse = new EmailSendResponse();
if (existingEntityOptional.isPresent()) {
ApplicationEvaluationEntity existingEntity = existingEntityOptional.get();
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(application);
List<EmailSendResponse> responses = new ArrayList<>();
application.setStatus(ApplicationStatusForEvaluation.TECHNICAL_EVALUATION_REJECTED.getValue());
log.info("Application status updated to {} for applicationId: {}", ApplicationStatusForEvaluation.TECHNICAL_EVALUATION_REJECTED, application.getId());
emailNotificationDao.sendMailForApplicationTechnicalEvaluationRejected(application, hub, existingEntity);
application.setDateRejected(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
responses = List.of(emailSendResponse);
if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())) {
saveEmailSendResponseToEvaluation(emailSendResponse, existingEntity);
}
application = applicationRepository.save(application);
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEntity).newData(application).build());
ApplicationEvaluationResponse response = convertToResponse(existingEntity);
if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())) {
response.setEmailSendResponse(responses);
}
return response;
}
return null;
}
public List<DocumentResponseBean> uploadRejectedDocument(Long userId,List<MultipartFile> files,ApplicationEntity application){
if(files!=null) {
return documentDao.uploadFiles(userId, files, application.getId(), DocumentSourceTypeEnum.APPLICATION, DocumentTypeEnum.DOCUMENT);
}
return new ArrayList<>();
}
}

View File

@@ -1123,7 +1123,7 @@ public class AppointmentDao {
richiestaCliente.setImportoBreveTermine(createAppointmentRequest.getImportoBreveTermine());
richiestaClienteList.add(richiestaCliente);
}
input.setDataAppuntamento(createAppointmentRequest.getDataAppuntamento());
input.setRichiestaCliente(richiestaClienteList);
appointmentCreationRequest.setInput(input);
return appointmentCreationRequest;

View File

@@ -116,7 +116,7 @@ public class AssignedApplicationsDao {
UserEntity user = userService.validateUser(userId);
AssignedApplicationsEntity assignment = createAssignmentEntity(application, user.getId(), assignedByUser, assignedApplicationsRequest);
applicationEvaluationDao.createOrUpdateApplicationEvaluation(user, new ApplicationEvaluationRequest(), assignment.getId());
applicationEvaluationDao.createOrUpdateApplicationEvaluation(user, new ApplicationEvaluationRequest(), assignment.getId(),null);
AssignedApplicationsResponse assignApplicationToInstructorResponse = convertEntityToResponse(assignment);
log.info("Application assigned succesfully {}", assignApplicationToInstructorResponse);
return assignApplicationToInstructorResponse;

View File

@@ -155,7 +155,7 @@ public class CallDao {
for (DocumentEntity document : documents) {
log.info("Adding document to ZIP: documentId={}, fileName={}", document.getId(), document.getFileName());
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CALL, callId, 0L,0L);
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CALL, callId, 0L,0L,0L);
try (InputStream fileInputStream = amazonS3Service.getFile(s3Folder, document.getFilePath())) {
String fileName = Utils.extractFileName(document.getFilePath());
ZipEntry zipEntry = new ZipEntry(fileName);

View File

@@ -5,13 +5,18 @@ import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
import net.gepafin.tendermanagement.entities.CommunicationEntity;
import net.gepafin.tendermanagement.entities.DocumentEntity;
import net.gepafin.tendermanagement.enums.CommunicationInitiatorTypeEnum;
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
import net.gepafin.tendermanagement.repositories.CommunicationRepository;
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
import net.gepafin.tendermanagement.service.DocumentService;
import net.gepafin.tendermanagement.util.LoggingUtil;
import net.gepafin.tendermanagement.util.Utils;
import net.gepafin.tendermanagement.util.Validator;
@@ -22,9 +27,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class CommunicationDao {
@@ -45,17 +53,48 @@ public class CommunicationDao {
@Autowired
private HttpServletRequest request;
public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationReq, Long amendmentId) {
@Autowired
private DocumentDao documentDao;
@Autowired
private ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
@Autowired
private DocumentService documentService;
public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationReq, Long amendmentId, List<MultipartFile> files) {
log.info("Adding communication request...");
CommunicationEntity communicationEntity = convertToCommunicationCommentEntity(communicationReq, amendmentId);
communicationEntity = communicationRepository.save(communicationEntity);
List<DocumentResponseBean> communicationDocumentBeans = new ArrayList<>();
CommunicationEntity communicationEntity = convertToCommunicationCommentEntity(communicationReq, amendmentId,communicationDocumentBeans,files);
/** This code is responsible for adding a version history log for the "adding comment to amendment request" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(communicationEntity).build());
log.info("Added comment: {}", communicationEntity);
return convertToCommunicationResponseBean(communicationEntity);
communicationDocumentBeans=getDocumentResponseBean(communicationEntity);
return convertToCommunicationResponseBean(communicationEntity,communicationDocumentBeans);
}
private List<DocumentResponseBean> getDocumentResponseBean(CommunicationEntity communicationEntity) {
List<Long> documentIds = applicationAmendmentRequestDao.extractIds(communicationEntity.getDocuments());
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;
}
public String deleteComment(Long amendmentId, Long commentId) {
@@ -77,19 +116,26 @@ public class CommunicationDao {
return "Deleted Comment Successfully.";
}
public ApplicationAmendmentResponse getAmendmentComments(Long amendmentId) {
public List<CommunicationResponseBean> getAmendmentComments(Long amendmentId) {
ApplicationAmendmentRequestEntity amendmentData = applicationAmendmentRequestService.validateApplicationAmendmentRequest(amendmentId);
List<CommunicationResponseBean> commentsList = communicationRepository.findCommentListDetailsByAmendmentId(amendmentId);
List<CommunicationEntity> commentsList = communicationRepository.findByApplicationAmendmentRequestIdAndIsDeletedFalse(amendmentId);
if (commentsList == null) {
throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.COMMENT_NOT_FOUND));
}
return new ApplicationAmendmentResponse(amendmentData, commentsList);
List<CommunicationResponseBean> communicationResponseBeans=new ArrayList<>();
for(CommunicationEntity communicationEntity:commentsList){
List<DocumentResponseBean> communicationDocumentBeans=getDocumentResponseBean(communicationEntity);
CommunicationResponseBean communicationResponseBean=convertToCommunicationResponseBean(communicationEntity,communicationDocumentBeans);
communicationResponseBeans.add(communicationResponseBean);
}
return communicationResponseBeans;
}
public CommunicationResponseBean updateAmendmentComment(CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) {
log.info("Updating communication comment...");
CommunicationEntity existingComment = communicationRepository.findById(commentId)
.orElseThrow(() -> new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.COMMENT_NOT_FOUND)));
//cloned for old data for communication
@@ -106,11 +152,11 @@ public class CommunicationDao {
/** This code is responsible for adding a version history log for the "updating comment to amendment request" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCommentData).newData(existingComment).build());
return convertToCommunicationResponseBean(existingComment);
List<DocumentResponseBean> communicationDocumentBeans=getDocumentResponseBean(existingComment);
return convertToCommunicationResponseBean(existingComment,communicationDocumentBeans);
}
private CommunicationResponseBean convertToCommunicationResponseBean(CommunicationEntity entity) {
private CommunicationResponseBean convertToCommunicationResponseBean(CommunicationEntity entity,List<DocumentResponseBean> communicationResponseBean) {
CommunicationResponseBean response = new CommunicationResponseBean();
response.setComment(entity.getCommunicationComment());
@@ -122,10 +168,11 @@ public class CommunicationDao {
response.setSenderUserId(entity.getSenderUserId());
response.setReceiverUserId(entity.getReceiverUserId());
response.setId(entity.getId());
response.setDocuments(communicationResponseBean);
return response;
}
private CommunicationEntity convertToCommunicationCommentEntity(CommunicationRequestBean communicationReq, Long amendmentId) {
private CommunicationEntity convertToCommunicationCommentEntity(CommunicationRequestBean communicationReq, Long amendmentId,List<DocumentResponseBean> communicationDocumentBean,List<MultipartFile> files) {
ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestService.validateApplicationAmendmentRequest(amendmentId);
@@ -136,12 +183,24 @@ public class CommunicationDao {
communicationEntity.setIsDeleted(false);
communicationEntity.setCommentedDate(LocalDateTime.now());
if(validator.checkIsPreInstructor()){
communicationEntity.setIntiatorType(CommunicationInitiatorTypeEnum.INSTRUCTOR.getValue());
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
} else if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
communicationEntity.setIntiatorType(CommunicationInitiatorTypeEnum.BENEFICIARY.getValue());
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
}
communicationEntity = communicationRepository.save(communicationEntity);
communicationDocumentBean=documentDao.uploadFiles(communicationEntity.getSenderUserId(),files,communicationEntity.getId(), DocumentSourceTypeEnum.COMMUNICATION, DocumentTypeEnum.DOCUMENT);
List<Long> communicationDocumentIds = communicationDocumentBean.stream()
.map(DocumentResponseBean::getId)
.collect(Collectors.toList());
String communicationDocumentId = communicationDocumentIds.stream()
.map(String::valueOf)
.collect(Collectors.joining(","));
communicationEntity.setDocuments(communicationDocumentId);
communicationEntity = communicationRepository.save(communicationEntity);
return communicationEntity;
}
}

View File

@@ -282,7 +282,7 @@ public class CompanyDocumentDao {
validator.validateUserWithCompany(request,companyDocumentEntity.getCompanyId());
String companyDocumentPath = companyDocumentEntity.getFilePath();
String documentPath = s3ConfigBean.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION,applicationEntity.getCall().getId(),applicationId,0L);
String documentPath = s3ConfigBean.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION,applicationEntity.getCall().getId(),applicationId,0L,0L);
log.info("Original Paths - oldPath: {}, newPath: {}", companyDocumentPath, documentPath);

View File

@@ -92,7 +92,7 @@ public class DelegationDao {
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
try {
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.TEMPLATE, 0L, 0L,0L);
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.TEMPLATE, 0L, 0L,0L,0L);
InputStream templateStream = amazonS3Service.getFile(s3Folder ,templateName);
XWPFDocument doc = loadTemplate(templateStream);
replacePlaceholders(doc, placeholders);

View File

@@ -89,6 +89,9 @@ public class DocumentDao {
@Autowired
private ApplicationEvaluationDao applicationEvaluationDao;
@Autowired
private CommunicationRepository communicationRepository;
// @Value("${aws.s3.url.folder}")
// private String s3Folder;
@@ -96,19 +99,22 @@ public class DocumentDao {
log.info("Uploading files userId={}, sourceType={}, fileType={}", userId,sourceType,fileType);
List<DocumentEntity> documentEntities = new ArrayList<>();
Long source = resolveSourceId(sourceId, sourceType);
for (MultipartFile file : files) {
log.info("Uploading file '{}'", file.getOriginalFilename());
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = uploadFileOnAmazonS3(file, sourceType, sourceId);
if (uploadFileOnAmazonS3Response != null) {
DocumentEntity documentEntity = new DocumentEntity();
documentEntity.setFileName(uploadFileOnAmazonS3Response.getFileName());
documentEntity.setSource(sourceType.getValue());
documentEntity.setSourceId(source);
documentEntity.setType(fileType.getValue());
documentEntity.setFilePath(uploadFileOnAmazonS3Response.getFilePath());
documentEntity.setIsDeleted(false);
documentEntity.setUploadedBy(userId);
documentEntities.add(documentEntity);
if(files!=null) {
for (MultipartFile file : files) {
log.info("Uploading file '{}'", file.getOriginalFilename());
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = uploadFileOnAmazonS3(file, sourceType, sourceId);
if (uploadFileOnAmazonS3Response != null) {
DocumentEntity documentEntity = new DocumentEntity();
documentEntity.setFileName(uploadFileOnAmazonS3Response.getFileName());
documentEntity.setSource(sourceType.getValue());
documentEntity.setSourceId(source);
documentEntity.setType(fileType.getValue());
documentEntity.setFilePath(uploadFileOnAmazonS3Response.getFilePath());
documentEntity.setIsDeleted(false);
documentEntity.setUploadedBy(userId);
documentEntities.add(documentEntity);
}
}
}
documentRepository.saveAll(documentEntities);
@@ -164,6 +170,7 @@ public class DocumentDao {
Long applicationId = 0L;
Long amendmentId = 0L;
Long evaluationId = 0L;
Long communicationId = 0L;
Long callId = sourceId;
if (type == DocumentSourceTypeEnum.APPLICATION) {
applicationId = sourceId;
@@ -181,9 +188,17 @@ public class DocumentDao {
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
log.info("Processing document of type EVALUATION .Resolved evaluationId={}, applicationId={}, callId={}", evaluationId, applicationId, callId);
}else if (type == DocumentSourceTypeEnum.COMMUNICATION) {
communicationId = sourceId;
Optional<CommunicationEntity> communicationEntity=communicationRepository.findByIdAndIsDeletedFalse(communicationId);
Optional<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntity=applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(communicationEntity.get().getApplicationAmendmentRequest().getId());
amendmentId=applicationAmendmentRequestEntity.get().getId();
applicationId=applicationAmendmentRequestEntity.get().getApplicationId();
callId = applicationAmendmentRequestEntity.get().getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getCall().getId();
log.info("Processing document of type COMMUNICATION .Resolved evaluationId={}, applicationId={}, callId={}", evaluationId, applicationId, callId);
}
try {
String s3Path = generateS3Path(type, callId, applicationId, amendmentId);
String s3Path = generateS3Path(type, callId, applicationId, amendmentId,communicationId);
log.info("Generated S3 path {}", s3Path);
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
} catch (Exception e) {
@@ -194,9 +209,9 @@ public class DocumentDao {
}
public String generateS3Path(DocumentSourceTypeEnum typeOfDocument, Long callId, Long applicationId, Long amendmentId) {
public String generateS3Path(DocumentSourceTypeEnum typeOfDocument, Long callId, Long applicationId, Long amendmentId,Long communicationId) {
try {
return s3ConfigBean.generateDocumentPath(typeOfDocument, callId, applicationId, amendmentId);
return s3ConfigBean.generateDocumentPath(typeOfDocument, callId, applicationId, amendmentId,communicationId);
} catch (IllegalArgumentException e) {
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
}
@@ -228,6 +243,7 @@ public class DocumentDao {
Long applicationId = null;
Long amendmentId = null;
Long evaluationId = null;
Long communicationId=null;
if (DocumentSourceTypeEnum.CALL.getValue().equalsIgnoreCase(documentEntity.getSource())) {
callId = documentEntity.getSourceId();
@@ -305,7 +321,7 @@ public class DocumentDao {
callId = applicationEntity.getCall().getId();
log.info("Processing document of type EVALUATION. Resolved evaluationId={}, applicationId={}, callId={}", evaluationId, applicationId, callId);
}
deleteFileFromS3(documentEntity, callId, applicationId,amendmentId);
deleteFileFromS3(documentEntity, callId, applicationId,amendmentId,communicationId);
log.info("Successfully deleted file from S3 for documentId={}", documentId);
}
@@ -349,6 +365,7 @@ public class DocumentDao {
Long applicationId=null;
Long amendmentId=null;
Long evaluationId=null;
Long communicationId=null;
if (type.equals(DocumentSourceTypeEnum.APPLICATION)) {
callId = applicationRepository.findCallIdById(id);
applicationId = id;
@@ -366,6 +383,14 @@ public class DocumentDao {
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
log.info("Processing document of type EVALUATION . Resolved evaluationId={}, applicationId={}, callId={}", evaluationId, applicationId, callId);
}else if (type == DocumentSourceTypeEnum.COMMUNICATION) {
communicationId = id;
Optional<CommunicationEntity> communicationEntity=communicationRepository.findByIdAndIsDeletedFalse(communicationId);
Optional<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntity=applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(communicationEntity.get().getApplicationAmendmentRequest().getId());
amendmentId=applicationAmendmentRequestEntity.get().getId();
applicationId=applicationAmendmentRequestEntity.get().getApplicationId();
callId = applicationAmendmentRequestEntity.get().getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getCall().getId();
log.info("Processing document of type EVALUATION .Resolved evaluationId={}, applicationId={}, callId={}", evaluationId, applicationId, callId);
}
else {
@@ -373,7 +398,7 @@ public class DocumentDao {
applicationId = 0L;
log.info("Processing document of type CALL . Resolved callId={}", callId);
}
String s3Path = generateS3Path(type, callId, applicationId,amendmentId);
String s3Path = generateS3Path(type, callId, applicationId,amendmentId,communicationId);
log.info("Generated S3 path {}", s3Path);
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
} catch (Exception e) {
@@ -386,12 +411,12 @@ public class DocumentDao {
return callDao.convertToDocumentResponseBean(documentEntity);
}
public void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId,Long amendmentId) {
public void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId,Long amendmentId,Long communicationId) {
try {
DocumentEntity oldDocumentEntity = Utils.getClonedEntityForData(documentEntity);
String oldS3Path = documentEntity.getFilePath();
String newS3Path = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.valueOf("DELETED_" + documentEntity.getSource().toUpperCase()), callId, applicationId,amendmentId);
String newS3Path = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.valueOf("DELETED_" + documentEntity.getSource().toUpperCase()), callId, applicationId,amendmentId,communicationId);
log.info("Moving file to deleted path: oldS3Path={}, newS3Path={}", oldS3Path, newS3Path);
UploadFileOnAmazonS3Response response = amazonS3Service.moveFile(documentEntity.getFileName(), oldS3Path, newS3Path);
documentEntity.setFileName(response.getFileName());

View File

@@ -94,14 +94,17 @@ public class EmailNotificationDao {
@Autowired
private ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
@Autowired
private ApplicationDao applicationDao;
public void sendEmail(ApplicationEntity applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType, Map<String, String> bodyPlaceholders,
List<String> additionalRecipients, Long amendmentId) {
List<String> additionalRecipients, Long amendmentId,String emailType) {
HubEntity hubEntity = hubService.valdateHub(applicationEntity.getHubId());
// String service = determineService(applicationEntity.getHubId());
// String legalMail = service.equals("Gepafin S.p.a.") ? "bandi.gepafin@legalmail.it" : "bandi.sviluppumbria@legalmail.it";
EmailContentResponse emailContent = prepareEmailContent(applicationEntity, templateType, hubEntity, bodyPlaceholders);
EmailContentResponse emailContent = prepareEmailContent(applicationEntity, templateType, hubEntity, bodyPlaceholders,emailType);
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
sendEmails(applicationEntity, userEntity, additionalRecipients,amendmentId,emailContent.getSystemEmailTemplateResponse(),emailContent.getSubject(),emailContent.getBody());
}
@@ -110,7 +113,7 @@ public class EmailNotificationDao {
ApplicationEntity applicationEntity,
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType,
HubEntity hubEntity,
Map<String, String> bodyPlaceholders
Map<String, String> bodyPlaceholders,String emailType
) {
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(templateType, hubEntity, null);
if(Boolean.TRUE.equals(templateType.equals(SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST)) && Boolean.TRUE.equals(validator.isProductionProfileActivated()) && applicationEntity.getCall().getId().equals(23l)) {
@@ -121,6 +124,7 @@ public class EmailNotificationDao {
subjectPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
// bodyPlaceholders.put("{{legal_mail}}", legalMail);
subjectPlaceholders.put("{{email_type}}",emailType);
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
@@ -131,21 +135,42 @@ public class EmailNotificationDao {
Optional<ApplicationEvaluationEntity> applicationEvaluationEntity = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationEntity.getId());
CompanyEntity company = companyService.validateCompany(applicationEntity.getCompanyId());
ApplicationAmendmentRequestEntity applicationAmendmentRequest=applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
ApplicationAmendmentRequestEntity applicationAmendmentRequest =null;
if(amendmentId!=null) {
applicationAmendmentRequest = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
}
List<AttachmentRequest> attachmentRequests =new ArrayList<>();
S3DocxProcessor processor = new S3DocxProcessor(s3Client);
List<String> urls=new ArrayList<>();
Map<String, String> replacements=new HashMap<>();
List<DocumentEntity> documentEntities=new ArrayList<>();
if(systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED)) {
S3DocxProcessor processor = new S3DocxProcessor(s3Client);
List<String> urls=new ArrayList<>();
Map<String, String> replacements = Map.of(
replacements = Map.of(
"{call_name}", applicationEntity.getCall().getName(),
"{amount_accepted}", String.valueOf(applicationEntity.getAmountAccepted()),
"{pec}", "bandi.gepafin@legalmail.it"
);
List<DocumentEntity> documentEntities=documentRepository.findBySourceInAndIsDeletedFalse(List.of(applicationAmendmentRequest.getAmendmentDocumentType(),"MODELLO_AUTOCERTIFICAZIONE","MODELLO_PRIVACY"));
urls = documentEntities.stream()
.map(DocumentEntity::getFilePath) // or getUrl()
.collect(Collectors.toList());
documentEntities=documentRepository.findBySourceInAndIsDeletedFalse(List.of(applicationAmendmentRequest.getAmendmentDocumentType(),"MODELLO_AUTOCERTIFICAZIONE","MODELLO_PRIVACY"));
}
if(Boolean.TRUE.equals(userEntity.getHub().getUniqueUuid().equals(defaultHubUuid)) && Boolean.TRUE.equals(systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.APPLICATION_AMENDMENT_REQUESTED))) {
List<Long> documentIds=applicationDao.validateDocumentIds(applicationAmendmentRequest.getAmendmentInitialDocument());
Set<Long> setOfDocumentIds = (documentIds == null)
? Collections.emptySet()
: new HashSet<>(documentIds);
documentEntities=documentRepository.findAllByIdInAndIsDeletedFalse(setOfDocumentIds);
}
if(Boolean.TRUE.equals(userEntity.getHub().getUniqueUuid().equals(defaultHubUuid)) && Boolean.TRUE.equals(systemEmailTemplateResponse.getEmailScenario().equals(EmailScenarioTypeEnum.APPLICATION_REJECTED))) {
List<Long> documentIds=applicationDao.validateDocumentIds(applicationEntity.getRejectedDocument());
Set<Long> setOfDocumentIds = (documentIds == null)
? Collections.emptySet()
: new HashSet<>(documentIds);
documentEntities=documentRepository.findAllByIdInAndIsDeletedFalse(setOfDocumentIds);
}
urls = documentEntities.stream()
.map(DocumentEntity::getFilePath) // or getUrl()
.collect(Collectors.toList());
if(Boolean.FALSE.equals(urls.isEmpty())) {
Map<String, AttachmentRequest> processedFiles = null;
try {
processedFiles = processor.processFiles(urls, replacements);
@@ -159,7 +184,6 @@ public class EmailNotificationDao {
attachmentRequests.add(attachmentRequest);
}
}
UserWithCompanyEntity userWithCompany=companyService.getUserWithCompany(userEntity.getId(),company.getId());
String companyEmail = userWithCompany.getEmail();
String contactEmail = userWithCompany.getContactEmail();
@@ -247,7 +271,7 @@ public class EmailNotificationDao {
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationAmendmentRequestEntity.getApplicationId());
Map<String, String> bodyPlaceholders = prepareEmailPlaceholders(applicationEntity, applicationAmendmentRequestEntity);
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, bodyPlaceholders, null,
applicationAmendmentRequestEntity.getId());
applicationAmendmentRequestEntity.getId(),null);
}
public Map<String, String> prepareEmailPlaceholders(ApplicationEntity applicationEntity, ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity){
Map<String, String> bodyPlaceholders = new HashMap<>();
@@ -339,7 +363,7 @@ public class EmailNotificationDao {
}
bodyPlaceholders.put("{{date_time_emailSend}}", DateTimeUtil.formatLocalDateTime(lastReminderDateTime, GepafinConstant.DD_MM_YYYY));
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, bodyPlaceholders, null,amendmentRequest.getId());
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, bodyPlaceholders, null,amendmentRequest.getId(),null);
}
public void sendAdmissibilityNotificationEmailForAdmissibleApplication(ApplicationEntity applicationEntity) {
@@ -357,10 +381,10 @@ public class EmailNotificationDao {
bodyPlaceholders.put("{{protocol_date}}", protocolDate);
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.ADMISSIBILITY_NOTIFICATION, bodyPlaceholders, null,null);
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.ADMISSIBILITY_NOTIFICATION, bodyPlaceholders, null,null,null);
}
public void sendInadmissibilityEmailForRejectedApplication(ApplicationEntity applicationEntity,ApplicationEvaluationEntity applicationEvaluationEntity) {
public void sendInadmissibilityEmailForRejectedApplication(ApplicationEntity applicationEntity,ApplicationEvaluationEntity applicationEvaluationEntity,String tipoInammissibilita,String emailType) {
Map<String, String> bodyPlaceholders = new HashMap<>();
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
String protocolNumber=applicationEntity.getProtocol().getExternalProtocolNumber();
@@ -374,9 +398,10 @@ public class EmailNotificationDao {
}
bodyPlaceholders.put("{{protocol_date}}", protocolDate);
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
HubEntity hubEntity = hubService.valdateHub(applicationEntity.getHubId());
bodyPlaceholders.put("{{tipo_inammissibilita}}", tipoInammissibilita);
bodyPlaceholders.put("{{form_text}}", applicationEvaluationEntity.getMotivation());
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE, bodyPlaceholders, null,null);
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE, bodyPlaceholders, null,null,emailType);
}
public void sendMail(Long hubId, String subject, String body, List<String> recipientEmails, EmailLogRequest emailLogRequest) {
@@ -404,7 +429,7 @@ public class EmailNotificationDao {
return emailConfig;
}
private EmailConfig parseEmailConfig(String configJson) {
private static EmailConfig parseEmailConfig(String configJson) {
ObjectMapper objectMapper = new ObjectMapper();
try {
@@ -413,12 +438,36 @@ public class EmailNotificationDao {
throw new IllegalArgumentException("Failed to parse email configuration JSON", e);
}
}
public void sendMailForApplicationTechnicalEvaluationRejected(ApplicationEntity applicationEntity,HubEntity hub,ApplicationEvaluationEntity applicationEvaluationEntity) {
Map<String, String> bodyPlaceholders = prepareEmailPlaceholdersForTechnicalEvaluationRejected(applicationEntity,hub,applicationEvaluationEntity);
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_TECHNICAL_EVALUATION_FAILURE, bodyPlaceholders, null,
null);
null,null);
}
// public void sendMailForApplicationTechnicalEvaluationRejected(ApplicationEntity applicationEntity,HubEntity hub,ApplicationEvaluationEntity applicationEvaluationEntity,Map<String, Object> emailJson) {
//
// HubEntity hubEntity = hubService.valdateHub(applicationEntity.getHubId());
// SystemEmailTemplateResponse systemEmailTemplateResponse=new SystemEmailTemplateResponse();
// systemEmailTemplateResponse.setSubject((String) emailJson.get("subject"));
// systemEmailTemplateResponse.setHtmlContent((String) emailJson.get("message"));
// Map<String, String> subjectPlaceholders = new HashMap<>();
// CompanyEntity company = companyService.validateCompany(applicationEntity.getCompanyId());
// subjectPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
// subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
// Map<String, String> bodyPlaceholders = prepareEmailPlaceholdersForTechnicalEvaluationRejected(applicationEntity,hub,applicationEvaluationEntity);
// String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
// String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
// SystemEmailTemplateResponse systemEmailTemplateResponse1=new SystemEmailTemplateResponse();
// systemEmailTemplateResponse1.setSubject(subject);
// systemEmailTemplateResponse1.setHtmlContent(body);
// systemEmailTemplateResponse1.setEmailScenario(EmailScenarioTypeEnum.APPLICATION_TECHNICAL_EVALUATION_REJECTED);
// EmailContentResponse emailContentResponse=new EmailContentResponse(subject,body,systemEmailTemplateResponse1);
// UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
// sendEmails(applicationEntity, userEntity, null,null,emailContentResponse.getSystemEmailTemplateResponse(),emailContentResponse.getSubject(),emailContentResponse.getBody());
//
// }
public Map<String, String> prepareEmailPlaceholdersForTechnicalEvaluationRejected(ApplicationEntity applicationEntity,HubEntity hub,ApplicationEvaluationEntity applicationEvaluationEntity) {
Map<String, String> bodyPlaceholders = new HashMap<>();
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
@@ -443,6 +492,6 @@ public class EmailNotificationDao {
Map<String, String> bodyPlaceholders = prepareEmailPlaceholders(applicationEntity, applicationAmendmentRequestEntity);
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.SPECIAL_APPLICATION_AMENDMENT_REQUESTED, bodyPlaceholders, null,
applicationAmendmentRequestEntity.getId());
applicationAmendmentRequestEntity.getId(),null);
}
}

View File

@@ -15,26 +15,27 @@ public class S3PathConfig {
@Autowired
S3ConfigRepository s3ConfigRepository;
public String generateDocumentPath(DocumentSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId) {
public String generateDocumentPath(DocumentSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId,Long communicationId) {
S3ConfigEntity config = getDocumentPath(type);
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId);
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId,communicationId);
}
public String generateDocumentPathForOther(DocOtherSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId) {
public String generateDocumentPathForOther(DocOtherSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId,Long communicationId) {
S3ConfigEntity config = getDocumentPathForOther(type);
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId);
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId,communicationId);
}
public String generateDocumentPathForDelegationAndSignedDocument(DocOtherSourceTypeEnum type) {
S3ConfigEntity config = getDocumentPathForOther(type);
return config.getParentFolder() + "/" + config.getPath();
}
private String buildS3Path(String pathTemplate, Long callId, Long applicationId, Long amendmentId) {
private String buildS3Path(String pathTemplate, Long callId, Long applicationId, Long amendmentId,Long communicationId) {
return pathTemplate
.replace("{call_id}", callId != null && callId != 0L ? "call_" + callId : "")
.replace("{application_id}", applicationId != null && applicationId != 0L ? "application_" + applicationId : "")
.replace("{amendment_id}", amendmentId != null && amendmentId != 0L ? "amendment_" + amendmentId : "");
.replace("{amendment_id}", amendmentId != null && amendmentId != 0L ? "amendment_" + amendmentId : "")
.replace("{communication_id}", communicationId != null && communicationId != 0L ? "communication_" + communicationId : "");
}
private S3ConfigEntity getDocumentPath(DocumentSourceTypeEnum type) {

View File

@@ -74,4 +74,7 @@ public class ApplicationAmendmentRequestEntity extends BaseEntity {
@Column(name = "AMENDMENT_DOCUMENT_TYPE")
private String amendmentDocumentType;
@Column(name = "AMENDMENT_INITIAL_DOCUMENT")
private String amendmentInitialDocument;
}

View File

@@ -79,4 +79,12 @@ public class ApplicationEntity extends BaseEntity {
@Column(name="VAT_NUMBER")
private String vatNumber;
@Column(name = "PREVIOUS_STATUS")
private String previousStatus;
@Column(name = "REJECTED_REASON")
private String rejectedReason;
@Column(name = "REJECTED_DOCUMENT")
private String rejectedDocument;
}

View File

@@ -35,4 +35,9 @@ public class CommunicationEntity extends BaseEntity {
@JoinColumn(name = "AMENDMENT_ID", referencedColumnName = "id", nullable = false)
private ApplicationAmendmentRequestEntity applicationAmendmentRequest;
@Column(name = "INITIATOR_TYPE")
private String intiatorType;
@Column(name = "DOCUMENTS")
private String documents;
}

View File

@@ -0,0 +1,18 @@
package net.gepafin.tendermanagement.enums;
public enum CommunicationInitiatorTypeEnum {
INSTRUCTOR("INSTRUCTOR"),
BENEFICIARY("BENEFICIARY");
private String value;
CommunicationInitiatorTypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}

View File

@@ -5,7 +5,8 @@ public enum DocumentSourceTypeEnum {
APPLICATION("APPLICATION"),
EVALUATION("EVALUATION"),
AMENDMENT("AMENDMENT");
AMENDMENT("AMENDMENT"),
COMMUNICATION("COMMUNICATION");
private String value;

View File

@@ -223,7 +223,8 @@ public enum UserActionContextEnum {
UPDATE_EXPIRED_CALL("UPDATE_EXPIRED_CALL"),
RESEND_EMAIL("RESEND_EMAIL"),
SEND_REMINDER_EMAIL("SEND_REMINDER_EMAIL"),
CREATE_SPECIAL_AMENDMENT("CREATE_SPECIAL_AMENDMENT");
CREATE_SPECIAL_AMENDMENT("CREATE_SPECIAL_AMENDMENT"),
UPDATE_APPLICATION_TO_TECHNICAL_EVALUATION_REJECTED("UPDATE_APPLICATION_TO_TECHNICAL_EVALUATION_REJECTED");
private final String value;

View File

@@ -16,4 +16,7 @@ public class ApplicationEvaluationFormRequestBean {
private List<ApplicationFormFieldRequestBean> formFields;
private String motivation;
private BigDecimal amountAccepted;
private String rejectedReason;
private String rejectedReasonSubject;
}

View File

@@ -17,4 +17,6 @@ public class ApplicationEvaluationRequest {
private ApplicationStatusForEvaluation applicationStatus;
private String motivation;
private BigDecimal amountAccepted;
private String rejectedReason;
private String rejectedReasonSubject;
}

View File

@@ -0,0 +1,13 @@
package net.gepafin.tendermanagement.model.request;
import lombok.Data;
import java.util.Map;
@Data
public class ApplicationTechnicalEvaluationRejectedRequest {
private Map<String, Object> emailJson;
}

View File

@@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.model.request;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
@@ -14,6 +15,7 @@ public class AppointmentCreationRequest {
private Long id;
private String ndg;
private List<RichiestaCliente> richiestaCliente;
private LocalDateTime dataAppuntamento;
}
@Data
@@ -32,6 +34,7 @@ public class AppointmentCreationRequest {
private String codProdotto;
private String codOperazione;
private Nota nota;
private LocalDateTime dataAppuntamento;
}
@Data

View File

@@ -2,11 +2,14 @@ package net.gepafin.tendermanagement.model.request;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class CreateAppointmentRequest {
private Double importoBreveTermine;
private Integer durataMesiFinanziamento;
private Nota nota;
private LocalDateTime dataAppuntamento;
@Data
public static class Nota {

View File

@@ -33,4 +33,7 @@ public class ApplicationAmendmentRequestResponse {
private ApplicationAmendmentRequestEnum status;
private String emailTemplate;
private List<EmailSendResponse> emailSendResponse;
private List<DocumentResponseBean> amendmentInitialDocuments;
private String amendmentType;
private String amendmentDocumentType;
}

View File

@@ -50,5 +50,6 @@ public class ApplicationEvaluationResponse {
private String companyVatNumber;
private String companyCodiceAteco;
private List<EmailSendResponse> emailSendResponse;
private List<DocumentResponseBean> rejectedDocument;
}

View File

@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.model.response;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class CommunicationResponseBean {
@@ -24,6 +25,8 @@ public class CommunicationResponseBean {
private Long amendmentId;
private List<DocumentResponseBean> documents;
public CommunicationResponseBean(LocalDateTime commentedDate, String comment, String title, LocalDateTime createdDate, LocalDateTime updatedDate, Long amendmentId, Long id) {
this.commentedDate = commentedDate;

View File

@@ -11,10 +11,12 @@ import java.util.Optional;
public interface CommunicationRepository extends JpaRepository<CommunicationEntity, Long> {
@Query("SELECT new net.gepafin.tendermanagement.model.response.CommunicationResponseBean( " + "c.commentedDate, c.communicationComment, c.communicationTitle, c.createdDate, c" +
".updatedDate, " + "c.applicationAmendmentRequest.id, c.senderUserId, c.receiverUserId, c.id " + ") " + "FROM CommunicationEntity c " + "WHERE c" +
".applicationAmendmentRequest.id = :amendmentId AND c.isDeleted = false")
List<CommunicationResponseBean> findCommentListDetailsByAmendmentId(@Param("amendmentId") Long amendmentId);
// @Query("SELECT new net.gepafin.tendermanagement.model.response.CommunicationResponseBean( " + "c.commentedDate, c.communicationComment, c.communicationTitle, c.createdDate, c" +
// ".updatedDate, " + "c.applicationAmendmentRequest.id, c.senderUserId, c.receiverUserId, c.id " + ") " + "FROM CommunicationEntity c " + "WHERE c" +
// ".applicationAmendmentRequest.id = :amendmentId AND c.isDeleted = false")
List<CommunicationEntity> findByApplicationAmendmentRequestIdAndIsDeletedFalse(Long amendmentId);
Optional<CommunicationEntity> findByIdAndIsDeletedFalse(Long commentId);
List<CommunicationEntity> findByApplicationAmendmentRequestIdInAndIsDeletedFalse(List<Long> amendmentId);
}

View File

@@ -161,7 +161,7 @@ public class ApplicationAmendmentScheduler {
public void updateApplicationStatus(ApplicationEntity applicationEntity){
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
applicationEntity.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue());
applicationEntity.setStatus(applicationEntity.getPreviousStatus());
applicationRepository.save(applicationEntity);
log.info("Updated status to EVALUATION for Application with ID: {}",applicationEntity.getId());

View File

@@ -6,12 +6,13 @@ import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
import net.gepafin.tendermanagement.model.request.*;
import net.gepafin.tendermanagement.model.response.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface ApplicationAmendmentRequestService {
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(HttpServletRequest request,Long applicationEvaluationId);
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest);
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , List<MultipartFile> files, ApplicationAmendmentRequest applicationAmendmentRequest);
void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id);
ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id);
List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId);

View File

@@ -3,11 +3,9 @@ package net.gepafin.tendermanagement.service;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
import net.gepafin.tendermanagement.enums.FormActionEnum;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationFormRequestBean;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
import net.gepafin.tendermanagement.model.request.*;
import net.gepafin.tendermanagement.model.response.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -15,7 +13,7 @@ public interface ApplicationEvaluationService {
ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
HttpServletRequest request,
ApplicationEvaluationRequest applicationEvaluationRequest,
Long assignedApplicationsId);
Long assignedApplicationsId, List<MultipartFile> rejectedDocuments);
void deleteApplicationEvaluation(HttpServletRequest request,Long id);
@@ -24,10 +22,11 @@ public interface ApplicationEvaluationService {
ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId);
ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long evaluationId, Long evaluationFormId);
ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, List<MultipartFile> rejectedDocuments, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long evaluationId, Long evaluationFormId);
ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId);
ApplicationEvaluationVersionResponse getApplicationEvaluationVersion(HttpServletRequest request, Long applicationId);
ApplicationEvaluationResponse updateApplicationToTechnicalEvaluationRejected(HttpServletRequest request, ApplicationTechnicalEvaluationRejectedRequest applicationRequest, Long assignedApplicationsId);
}

View File

@@ -2,15 +2,17 @@ package net.gepafin.tendermanagement.service;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface CommunicationService {
CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request ,CommunicationRequestBean communicationRequestBean, Long amendmentId);
CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request , CommunicationRequestBean communicationRequestBean, Long amendmentId, List<MultipartFile> files);
String deleteComment(HttpServletRequest request,Long amendmentId, Long commentId);
CommunicationResponseBean updateAmendmentComment(HttpServletRequest request,CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId);
ApplicationAmendmentResponse getAmendmentComments(HttpServletRequest request,Long id);
List<CommunicationResponseBean> getAmendmentComments(HttpServletRequest request,Long id);
}

View File

@@ -14,6 +14,7 @@ import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepo
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.util.Utils;
import net.gepafin.tendermanagement.util.Validator;
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
@@ -21,8 +22,10 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Service
@@ -50,10 +53,15 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest) {
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , List<MultipartFile> files, ApplicationAmendmentRequest applicationAmendmentRequest) {
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationEvaluationId);
entityOptional.ifPresent(applicationEvaluationEntity -> validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId()));
return applicationAmendmentRequestDao.createApplicationAmendmentRequest(applicationEvaluationId,applicationAmendmentRequest);
Map<String, Object> userInfo = validator.getUserInfoFromToken(request);
Long userId = validator.getUserId(userInfo);
if(files!=null) {
files.forEach(Utils::validateFileType);
}
return applicationAmendmentRequestDao.createApplicationAmendmentRequest(applicationEvaluationId,files,applicationAmendmentRequest,userId);
}
@Override

View File

@@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationFormRequestBean;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
import net.gepafin.tendermanagement.model.request.ApplicationTechnicalEvaluationRejectedRequest;
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationFormResponse;
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponseBean;
@@ -21,6 +22,7 @@ import net.gepafin.tendermanagement.util.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -46,13 +48,13 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
HttpServletRequest request,
ApplicationEvaluationRequest req,
Long assignedApplicationsId) {
Long assignedApplicationsId, List<MultipartFile> rejectedDocuments) {
AssignedApplicationsEntity assignedApplication =assignedApplicationsService.validateAssignedApplication(assignedApplicationsId);
UserEntity user = validator.validatePreInstructor(request, assignedApplication.getUserId());
return applicationEvaluationDao.createOrUpdateApplicationEvaluation(user, req, assignedApplication.getId());
return applicationEvaluationDao.createOrUpdateApplicationEvaluation(user, req, assignedApplication.getId(),rejectedDocuments);
}
@Override
@@ -87,10 +89,10 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long assignedApplicationId, Long evaluationFormId) {
public ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, List<MultipartFile> rejectedDocuments, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long assignedApplicationId, Long evaluationFormId) {
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
validator.validatePreInstructor(request, assignedApplicationsEntity.getUserId());
return applicationEvaluationDao.createApplicationEvaluation(request,applicationEvaluationFormRequestBean,evaluationFormId,assignedApplicationId);
return applicationEvaluationDao.createApplicationEvaluation(request,rejectedDocuments,applicationEvaluationFormRequestBean,evaluationFormId,assignedApplicationId);
}
@Override
@@ -106,6 +108,10 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
return applicationEvaluationDao.getApplicationEvaluationVersion(request,applicationId);
}
@Override
public ApplicationEvaluationResponse updateApplicationToTechnicalEvaluationRejected(HttpServletRequest request, ApplicationTechnicalEvaluationRejectedRequest applicationRequest, Long assignedApplicationsId) {
return applicationEvaluationDao.updateApplicationToTechnicalEvaluationRejected(applicationRequest,assignedApplicationsId);
}
}

View File

@@ -5,14 +5,15 @@ import net.gepafin.tendermanagement.dao.ApplicationAmendmentRequestDao;
import net.gepafin.tendermanagement.dao.CommunicationDao;
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.service.CommunicationService;
import net.gepafin.tendermanagement.util.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Service
@@ -29,14 +30,14 @@ public class CommunicationServiceImpl implements CommunicationService {
@Override
@Transactional(rollbackFor = Exception.class)
public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request ,CommunicationRequestBean communicationRequestBean, Long amendmentId) {
public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request , CommunicationRequestBean communicationRequestBean, Long amendmentId, List<MultipartFile> files) {
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
if (Boolean.FALSE.equals(validator.checkIsBeneficiary()) && Boolean.FALSE.equals(validator.checkIsConfidi())) {
validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId());
} else {
validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
}
return communicationDao.addCommentToAmendmentRequest(request,communicationRequestBean, amendmentId);
return communicationDao.addCommentToAmendmentRequest(request,communicationRequestBean, amendmentId,files);
}
@Override
@@ -64,7 +65,7 @@ public class CommunicationServiceImpl implements CommunicationService {
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationAmendmentResponse getAmendmentComments(HttpServletRequest request,Long id) {
public List<CommunicationResponseBean> getAmendmentComments(HttpServletRequest request,Long id) {
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(id);
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId());

View File

@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import net.gepafin.tendermanagement.dao.DocumentDao;
import net.gepafin.tendermanagement.dao.S3PathConfig;
import net.gepafin.tendermanagement.entities.ApplicationEntity;
import net.gepafin.tendermanagement.entities.CommunicationEntity;
import net.gepafin.tendermanagement.entities.DocumentEntity;
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
import net.gepafin.tendermanagement.repositories.*;
@@ -25,6 +26,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Optional;
@Slf4j
@Service
@@ -73,6 +75,9 @@ public class S3ReUploadMigrationService {
@Autowired
private ApplicationEvaluationRepository applicationEvaluationRepository;
@Autowired
private CommunicationRepository communicationRepository;
@Autowired
private DocumentDao documentDao;
@@ -108,6 +113,7 @@ public class S3ReUploadMigrationService {
Long applicationId = null;
Long amendmentId = null;
Long evaluationId = null;
Long communicationId=null;
if (DocumentSourceTypeEnum.CALL.getValue().equalsIgnoreCase(document.getSource())) {
callId = document.getSourceId();
} else if (DocumentSourceTypeEnum.APPLICATION.getValue().equalsIgnoreCase(document.getSource())) {
@@ -125,10 +131,16 @@ public class S3ReUploadMigrationService {
ApplicationEntity applicationEntity = applicationEvaluationRepository.findApplicationByEvaluationId(evaluationId);
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
}else if(DocumentSourceTypeEnum.COMMUNICATION.getValue().equalsIgnoreCase(document.getSource())){
communicationId = document.getSourceId();
Optional<CommunicationEntity> communicationEntity=communicationRepository.findByIdAndIsDeletedFalse(communicationId);
ApplicationEntity applicationEntity =communicationEntity.get().getApplicationAmendmentRequest().getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication();
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
}
documentDao.deleteFileFromS3(document,callId,applicationId,amendmentId);
documentDao.deleteFileFromS3(document,callId,applicationId,amendmentId,communicationId);
processDocuments++;
} catch (Exception e) {
@@ -219,10 +231,10 @@ public class S3ReUploadMigrationService {
Long callId;
if (sourceType.equals(DocumentSourceTypeEnum.CALL)) {
return s3ConfigBean.generateDocumentPath(sourceType, document.getSourceId(), 0L,0L);
return s3ConfigBean.generateDocumentPath(sourceType, document.getSourceId(), 0L,0L,0L);
} else {
callId = applicationRepository.findCallIdById(document.getSourceId());
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId(),0L);
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId(),0L,0L);
}
}

View File

@@ -139,7 +139,7 @@ public class UserSignedAndDelegationServiceImpl {
private String generateNewS3PathForDelegationDoc() {
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L,0L);
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L,0L,0L);
}
private String generateNewS3PathForUserSignedDoc(ApplicationSignedDocumentEntity document) {

View File

@@ -1095,6 +1095,22 @@ public class Utils {
return "Invalid amount format";
}
}
public static void validateEmailJson(Map<String, Object> emailJson) {
for (Map.Entry<String, Object> entry : emailJson.entrySet()) {
if (isEmpty(entry.getKey())) {
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_EMAIL_JSON));
}
}
validateJsonKeys(emailJson, GepafinConstant.MANUAL_EMAIL_KEYS);
}
private static void validateJsonKeys(Map<String, Object> actionJson, List<String> validkeys) {
for (String key : validkeys) {
if (!actionJson.containsKey(key)) {
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_EMAIL_JSON));
}
}
}
}

View File

@@ -18,6 +18,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -44,10 +45,16 @@ public interface ApplicationAmendmentRequestApi {
@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) })) })
@PostMapping(value = "", produces = "application/json")
ResponseEntity<Response<ApplicationAmendmentRequestResponse>> createApplicationAmendmentRequest(HttpServletRequest request,
@Parameter(description = "Application Evaluation Id", required = true) @RequestParam Long applicationEvaluationId,
@Valid @RequestBody ApplicationAmendmentRequest applicationAmendmentRequest);
@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<ApplicationAmendmentRequestResponse>> createApplicationAmendmentRequest(
HttpServletRequest request,
@Parameter(description = "Application Evaluation Id", required = true)
@RequestParam Long applicationEvaluationId,
@Parameter(description = "List of files to upload", required = false)
@RequestPart(required = false) List<MultipartFile> files,
@Parameter(description = "Amendment details as JSON", required = true)
@RequestPart("applicationAmendmentRequest") ApplicationAmendmentRequest applicationAmendmentRequest);
@Operation(summary = "Api to delete application amendment request",
responses = {

View File

@@ -8,16 +8,14 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import net.gepafin.tendermanagement.enums.FormActionEnum;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationFormRequestBean;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
import net.gepafin.tendermanagement.model.request.*;
import net.gepafin.tendermanagement.model.response.*;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -31,11 +29,12 @@ public interface ApplicationEvaluationApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PutMapping(value = "/{assignedApplicationsId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@PutMapping(value = "/{assignedApplicationsId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
ResponseEntity<Response<ApplicationEvaluationResponse>> createOrUpdateApplicationEvaluation(
HttpServletRequest request,
@Parameter(description = "Assigned Application ID", required = true) @PathVariable("assignedApplicationsId") Long assignedApplicationsId,
@Parameter(description = "Application Evaluation Request Body", required = true) @Valid @RequestBody ApplicationEvaluationRequest evaluationRequest);
@Parameter(description = "Assigned Application ID", required = true) @PathVariable("assignedApplicationsId") Long assignedApplicationsId, @Parameter(description = "List of files to upload", required = false)
@RequestPart(required = false) List<MultipartFile> rejectedDocuments,
@Parameter(description = "Application Evaluation Request Body", required = true) @RequestPart ApplicationEvaluationRequest evaluationRequest);
@Operation(summary = "API to get ApplicationEvaluation data for evaluation process",
responses = {
@@ -70,9 +69,10 @@ public interface ApplicationEvaluationApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@PutMapping(value = "/v2/assignedApplication/{id}",
produces = { "application/json" })
ResponseEntity<Response<ApplicationEvaluationFormResponse>> createApplicationEvaluation(HttpServletRequest request,
@Valid @RequestBody ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean,
produces = { "application/json" },consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
ResponseEntity<Response<ApplicationEvaluationFormResponse>> createApplicationEvaluation(HttpServletRequest request, @Parameter(description = "List of files to upload", required = false)
@RequestPart(required = false) List<MultipartFile> rejectedDocuments,
@RequestPart ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean,
@Parameter(description = "Assigned Application ID", required = true) @PathVariable(value = "id", required = true) Long assignedApplicationId,
@Parameter(description = "The evaluation form ID", required = true) @RequestParam("evaluationFormId") Long evaluationFormId);
@@ -104,5 +104,18 @@ public interface ApplicationEvaluationApi {
@Parameter(description = "The application id", required = true) @PathVariable("id") Long id);
@Operation(summary = "API to update Application to TECHNICAL EVALUATION REJECTED",
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 = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PutMapping(value = "/{assignedApplicationsId}/technicalEvaluationRejected", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationToTechnicalEvaluationRejected(
HttpServletRequest request,
@Parameter(description = "Assigned Application ID", required = true) @PathVariable("assignedApplicationsId") Long assignedApplicationsId,
@Parameter(description = "Application Request Body", required = true) @Valid @RequestBody ApplicationTechnicalEvaluationRejectedRequest applicationRequest);
}

View File

@@ -7,7 +7,6 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
@@ -16,12 +15,10 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Validated
public interface CommunicationApi {
@@ -32,10 +29,11 @@ public interface CommunicationApi {
@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) })) })
@PostMapping(value = "/{amendmentId}", produces = { "application/json" })
@PostMapping(value = "/{amendmentId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY') || hasRole('ROLE_INSTRUCTOR_MANAGER') || hasRole('ROLE_CONFIDI')")
ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request,
@RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId);
ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, @Parameter(description = "List of files to upload", required = false)
@RequestPart(required = false) List<MultipartFile> files,
@Parameter(description = "communication request body" ,required=true) @RequestPart CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId);
@Operation(summary = "API to Get Amendment Request Comment", responses = { @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
@@ -45,7 +43,7 @@ public interface CommunicationApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) })
@GetMapping(value = "/{amendmentId}", produces = "application/json")
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(HttpServletRequest request,@PathVariable(value = "amendmentId") Long amendmentId);
public ResponseEntity<Response<List<CommunicationResponseBean>>> getAmendmentComments(HttpServletRequest request,@PathVariable(value = "amendmentId") Long amendmentId);
@Operation(summary = "Api to update communication comments", responses = { @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {

View File

@@ -1,5 +1,7 @@
package net.gepafin.tendermanagement.web.rest.api.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.log4j.Log4j2;
import net.gepafin.tendermanagement.config.Translator;
@@ -19,6 +21,8 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@RestController
@@ -26,6 +30,9 @@ import java.util.List;
@Log4j2
public class ApplicationAmendmentRequestController implements ApplicationAmendmentRequestApi {
@Autowired
private ObjectMapper mapper;
@Autowired
ApplicationAmendmentRequestService applicationAmendmentRequestService;
@@ -45,13 +52,18 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme
}
@Override
public ResponseEntity<Response<ApplicationAmendmentRequestResponse>> createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId, ApplicationAmendmentRequest applicationAmendmentRequest) {
public ResponseEntity<Response<ApplicationAmendmentRequestResponse>> createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId, List<MultipartFile> files, ApplicationAmendmentRequest applicationAmendmentRequest) {
// ApplicationAmendmentRequest data=null;
// try {
// data = mapper.readValue(applicationAmendmentRequest,ApplicationAmendmentRequest.class);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
/** This code is responsible for creating user action logs for the "Create Application Amendment" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.INSERT)
.actionContext(UserActionContextEnum.CREATE_AMENDMENT).build());
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = applicationAmendmentRequestService.createApplicationAmendmentRequest(request,applicationEvaluationId,applicationAmendmentRequest);
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = applicationAmendmentRequestService.createApplicationAmendmentRequest(request,applicationEvaluationId,files,applicationAmendmentRequest);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(applicationAmendmentRequestResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.CREATE_APPLICATION_DATA_FOR_AMENDMENT_MSG)));
}

View File

@@ -18,6 +18,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -34,7 +35,7 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
@Override
public ResponseEntity<Response<ApplicationEvaluationResponse>> createOrUpdateApplicationEvaluation(
HttpServletRequest request,
Long assignedApplicationsId,
Long assignedApplicationsId, List<MultipartFile> rejectedDocuments,
ApplicationEvaluationRequest evaluationRequest) {
/** This code is responsible for creating user action logs for the "Create or update Application Evaluation" operation. **/
@@ -43,7 +44,7 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
ApplicationEvaluationResponse response = applicationEvaluationService.createOrUpdateApplicationEvaluation(
request, evaluationRequest, assignedApplicationsId);
request, evaluationRequest, assignedApplicationsId,rejectedDocuments);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_REQUEST_COMPLETED)));
@@ -82,13 +83,13 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
}
@Override
public ResponseEntity<Response<ApplicationEvaluationFormResponse>> createApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long assignedApplicationId, Long evaluationFormId) {
public ResponseEntity<Response<ApplicationEvaluationFormResponse>> createApplicationEvaluation(HttpServletRequest request, List<MultipartFile> rejectedDocuments, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long assignedApplicationId, Long evaluationFormId) {
/** This code is responsible for creating user action logs for the "Create or update application evaluation form" operation. **/
loggingUtil.logUserAction(
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.CREATE_UPDATE_APPLICATION_EVALUATION_FORM).build());
ApplicationEvaluationFormResponse applicationEvaluationResponseBean = applicationEvaluationService.createApplicationEvaluation(request, applicationEvaluationFormRequestBean, assignedApplicationId, evaluationFormId);
ApplicationEvaluationFormResponse applicationEvaluationResponseBean = applicationEvaluationService.createApplicationEvaluation(request,rejectedDocuments, applicationEvaluationFormRequestBean, assignedApplicationId, evaluationFormId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(applicationEvaluationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CREATED_SUCCESSFULLY)));
@@ -118,4 +119,15 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
.body(new Response<>(applicationEvaluationVersionResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_EVALUATION_VERSION_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationToTechnicalEvaluationRejected(HttpServletRequest request, Long assignedApplicationsId, ApplicationTechnicalEvaluationRejectedRequest applicationRequest) {
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.UPDATE_APPLICATION_TO_TECHNICAL_EVALUATION_REJECTED).build());
ApplicationEvaluationResponse applicationEvaluationVersionResponse = applicationEvaluationService.updateApplicationToTechnicalEvaluationRejected(request,applicationRequest,assignedApplicationsId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.UPDATE_APPLICATION_TECHNICAL_EVALUATION_REJECTED_MSG)));
}
}

View File

@@ -7,7 +7,6 @@ import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.request.UserActionRequest;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.CommunicationService;
@@ -19,6 +18,9 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/communication}")
@@ -31,23 +33,23 @@ public class CommunicationController implements CommunicationApi {
private LoggingUtil loggingUtil;
@Override
public ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationRequestBean,
Long amendmentId) {
public ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, List<MultipartFile> files, CommunicationRequestBean communicationRequestBean,
Long amendmentId) {
/** This code is responsible for creating user action logs for the "Adding comment to amendment request" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.INSERT).actionContext(UserActionContextEnum.ADD_COMMENT_TO_AMENDMENT_REQUEST).build());
CommunicationResponseBean communicationResponseBean = communicationService.addCommentToAmendmentRequest(request,communicationRequestBean, amendmentId);
CommunicationResponseBean communicationResponseBean = communicationService.addCommentToAmendmentRequest(request,communicationRequestBean, amendmentId,files);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS)));
}
@Override
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(HttpServletRequest request,Long amendmentId) {
public ResponseEntity<Response<List<CommunicationResponseBean>>> getAmendmentComments(HttpServletRequest request,Long amendmentId) {
/** This code is responsible for creating user action logs for the "getting comment of amendment" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_AMENDMENT_COMMENT).build());
ApplicationAmendmentResponse response = communicationService.getAmendmentComments(request,amendmentId);
List<CommunicationResponseBean> response = communicationService.getAmendmentComments(request,amendmentId);
return ResponseEntity.ok(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.AMENDMENT_FOUND_SUCCESS)));
}
@Override

View File

@@ -3027,4 +3027,62 @@
<sqlFile dbms="postgresql" path="db/dump/insert_document_for_special_amendment.sql"/>
</changeSet>
<changeSet id="08-10-2025_RK_184352" author="Rajesh Khore">
<addColumn tableName="application_amendment_request">
<column name="amendment_initial_document" type="VARCHAR(255)"></column>
</addColumn>
<addColumn tableName="application">
<column name="email_json" type="TEXT"></column>
</addColumn>
</changeSet>
<changeSet id="08-10-2025_RK_194824" author="Rajesh Khore">
<addColumn tableName="communication">
<column name="initiator_type" type="VARCHAR(255)"/>
<column name="documents" type="VARCHAR(255)"/>
</addColumn>
</changeSet>
<changeSet id="09-10-2025_RK_205135" author="Rajesh Khore">
<insert tableName="s3_path_configuration">
<column name="type" value="COMMUNICATION"/>
<column name="path" value="call/{call_id}/application/{application_id}/amendment/{amendment_id}/communication/{communication_id}"/>
<column name="bucket_name" value="mementoresources"/>
<column name="created_date" value="2025-10-09 03:00:00"/>
<column name="updated_date" value="2025-10-09 03:00:00"/>
<column name="parent_folder" value="gepafin/local"/>
</insert>
</changeSet>
<changeSet id="13-10-2025_RK_175232" author="Rajesh Khore">
<update tableName="hub">
<column name="email_service_config" value="JkFbBfuVvq7VWwp5LcWIi+hAa1RJ1ekI0jq3w7gLTXETZiTaN8zC4OBWD53x8FtbfFTh3L/5805CIYTH1BQGa3X9q16q9SDzMy7DKHdmJzOnLKhn74C5akoXKaeXUCGnzp0cSk2c01FV6lwefC29IhixeIvxG7puRVyjUIZK/W8/Kah9uWkDjFtxi8IL6L0QVHn1M/CUm0L/sMRYo7u7WunY+kbjlu/vXw9goy5tjlE="/>
<where>UNIQUE_UUID = 'p4lk3bcx1RStqTaIVVbXs'</where>
</update>
</changeSet>
<changeSet id="06-10-2025_RK_142435" author="Rajesh Khore">
<addColumn tableName="application">
<column name="previous_status" type="VARCHAR(255)"></column>
</addColumn>
</changeSet>
<changeSet id="15-10-2025_RK_152435" author="Rajesh Khore">
<dropColumn tableName="application" columnName="email_json"/>
<addColumn tableName="application">
<column name="rejected_reason" type="VARCHAR(255)"/>
<column name="rejected_document" type="VARCHAR(255)"/>
</addColumn>
</changeSet>
<changeSet id="16-10-2025_RK_13352" author="Rajesh Khore">
<sqlFile dbms="postgresql" path="db/dump/update_system_email_template_of_application_rejected_16_10_2025.sql"/>
</changeSet>
<changeSet id="17-10-2025_RK_140552" author="Rajesh Khore">
<sqlFile dbms="postgresql" path="db/dump/update_system_email_template_of_application_rejected_17_10_2025.sql"/>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,18 @@
UPDATE gepafin_schema.system_email_template
SET html_content = '<html>
<body style="font-family: Arial, sans-serif; color: #000; line-height: 1.6;">
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;">
<p>Buongiorno,</p>
<p>Si comunica che, in riferimento alla domanda a valere sul bando “<strong>{{call_name}}</strong>” di cui al
<strong>Protocollo n. {{protocol_number}} del {{protocol_date}} alle {{protocol_time}}</strong>,
</p>
<p>
{{tipo_inammissibilita}}.</p>
<p>Le motivazioni sono le seguenti: <strong>{{form_text}}</strong></p>
<p>Vi ricordiamo che i Beneficiari che hanno presentato richieste valutate non ammissibili entro 10 giorni dalla data di ricevimento della presente potranno finoltrare richiesta di chiarimenti e/o osservazioni alla scrivente Società ai sensi e per gli effetti dellart.10 bis della L.241/1990 e s.m.i.</p>
<p>Distinti Saluti,</p>
<p><strong>{{email_signature}}</strong></p>
</div>
</body>
</html>'
WHERE "type" = 'INADMISSIBILITY_NOTIFICATION' and "email_scenario" = 'APPLICATION_REJECTED' and "system" = true;

View File

@@ -0,0 +1,3 @@
UPDATE gepafin_schema.system_email_template
SET subject = 'BANDO {{call_name}} {{email_type}} {{company_name}}'
WHERE "type" = 'INADMISSIBILITY_NOTIFICATION' and "email_scenario" = 'APPLICATION_REJECTED' and "system" = true;

View File

@@ -413,4 +413,8 @@ email.pec.cannot.null=Email pec is required.
user.request.completed=User request completed successfully.
end.date.greater.than.now=End date must be greater than the current date and time.
pec.email.required=PEC email is required.
application.technical.evaluation.rejected.success=Application changes to status application technical evaluation rejected successfully.
invalid.email.json=Invalid email json.
more.fields.required=Subject, reason, and motivation are required when rejecting the application.

View File

@@ -404,4 +404,6 @@ email.pec.cannot.null=L'indirizzo email pec
user.request.completed=Richiesta utente completata con successo.
end.date.greater.than.now=La data di fine deve essere successiva alla data e all'ora correnti.
pec.email.required=Obbligatorio l'indirizzo e-mail PEC.
application.technical.evaluation.rejected.success=Lo stato dell'applicazione cambia: valutazione tecnica dell'applicazione rifiutata con successo.
invalid.email.json=Codice email json non valido.
more.fields.required=Per rifiutare la domanda sono richiesti oggetto, motivo e motivazione.