Resolved conflicts for GEPAFINBE-31.
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -29,6 +29,13 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.mashape.unirest/unirest-java -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mashape.unirest</groupId>
|
||||||
|
<artifactId>unirest-java</artifactId>
|
||||||
|
<version>1.4.9</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- H2 Database for in-memory testing -->
|
<!-- H2 Database for in-memory testing -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
|
|||||||
@@ -292,6 +292,10 @@ public class GepafinConstant {
|
|||||||
public static final String ENCRYPT_KEY = "U2VjdXJlRW5jcnlwdEtleQ==";
|
public static final String ENCRYPT_KEY = "U2VjdXJlRW5jcnlwdEtleQ==";
|
||||||
public static final String APPLICATION_DOCUMENTS_NOT_FOUND_MSG = "application.documents.not.found";
|
public static final String APPLICATION_DOCUMENTS_NOT_FOUND_MSG = "application.documents.not.found";
|
||||||
public static final String DUPLICATE_BENEFICIARY_CALL = "beneficiary.call.duplicate";
|
public static final String DUPLICATE_BENEFICIARY_CALL = "beneficiary.call.duplicate";
|
||||||
|
public static final String USER_MUST_BE_ASSOCIATED_WITH_COMPANY="user.must.be.associated.with.company.to.create.application";
|
||||||
|
public static final String COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL = "company.id.required.for.preferred.call";
|
||||||
|
public static final String SUBMISSION_DATE = "submissionDate";
|
||||||
|
public static final String ASSIGNED_AT = "assignedAt";
|
||||||
public static final String AUTH = "auth";
|
public static final String AUTH = "auth";
|
||||||
|
|
||||||
//Logging
|
//Logging
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import jakarta.persistence.criteria.Join;
|
import jakarta.persistence.criteria.Join;
|
||||||
@@ -22,6 +21,8 @@ import net.gepafin.tendermanagement.util.Validator;
|
|||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
@@ -30,6 +31,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static net.gepafin.tendermanagement.util.Utils.log;
|
import static net.gepafin.tendermanagement.util.Utils.log;
|
||||||
@@ -81,26 +83,24 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SystemEmailTemplatesService systemEmailTemplatesService;
|
private SystemEmailTemplatesService systemEmailTemplatesService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CallDao callDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DocumentRepository documentRepository;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HubService hubService;
|
private HubService hubService;
|
||||||
// @Autowired
|
|
||||||
// private MailUtil mailUtil;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailLogDao emailLogDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
LoggingUtil loggingUtil;
|
LoggingUtil loggingUtil;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HttpServletRequest request;
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AssignedApplicationsDao assignedApplicationsDao;
|
||||||
|
|
||||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
||||||
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
||||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||||
@@ -213,6 +213,8 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
applicationAmendmentRequestEntity.setStartDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
applicationAmendmentRequestEntity.setStartDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
applicationAmendmentRequestEntity.setStatus(ApplicationAmendmentRequestEnum.AWAITING.getValue());
|
applicationAmendmentRequestEntity.setStatus(ApplicationAmendmentRequestEnum.AWAITING.getValue());
|
||||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||||
|
//cloned for old data entity
|
||||||
|
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(applicationEvaluationEntity);
|
||||||
|
|
||||||
applicationAmendmentRequestEntity.setApplicationEvaluationEntity(applicationEvaluationEntity);
|
applicationAmendmentRequestEntity.setApplicationEvaluationEntity(applicationEvaluationEntity);
|
||||||
Long applicationId = applicationEvaluationEntity.getApplicationId();
|
Long applicationId = applicationEvaluationEntity.getApplicationId();
|
||||||
@@ -220,10 +222,10 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
applicationAmendmentRequestEntity.setApplicationId(applicationId);
|
applicationAmendmentRequestEntity.setApplicationId(applicationId);
|
||||||
|
|
||||||
if (applicationAmendmentRequest.getFormFields() != null) {
|
if (applicationAmendmentRequest.getFormFields() != null) {
|
||||||
List<ApplicationFormFieldRequestBean> formFieldRequestBean = applicationAmendmentRequest.getFormFields().stream()
|
List<AmendmentFormField> formFieldRequestBean = applicationAmendmentRequest.getFormFields().stream()
|
||||||
.filter(AmendmentFormFieldResponse::isSelected)
|
.filter(AmendmentFormFieldResponse::isSelected)
|
||||||
.map(amendmentFormFieldRequest -> {
|
.map(amendmentFormFieldRequest -> {
|
||||||
ApplicationFormFieldRequestBean formField = new ApplicationFormFieldRequestBean();
|
AmendmentFormField formField = new AmendmentFormField();
|
||||||
formField.setFieldId(amendmentFormFieldRequest.getFieldId());
|
formField.setFieldId(amendmentFormFieldRequest.getFieldId());
|
||||||
formField.setFieldValue(null);
|
formField.setFieldValue(null);
|
||||||
return formField;
|
return formField;
|
||||||
@@ -239,31 +241,40 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
userEntity.getHub().getId());
|
userEntity.getHub().getId());
|
||||||
applicationAmendmentRequestEntity.setProtocol(protocolEntity);
|
applicationAmendmentRequestEntity.setProtocol(protocolEntity);
|
||||||
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT);
|
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT);
|
||||||
|
String evaluationStatusType = applicationEvaluationEntity.getStatus();
|
||||||
|
if (Boolean.FALSE.equals(evaluationStatusType.equals((ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue())))){
|
||||||
|
applicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||||
|
|
||||||
//Set Status
|
//Set Status
|
||||||
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(applicationEvaluationEntity);
|
|
||||||
applicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
applicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||||
applicationEvaluationRepository.save(applicationEvaluationEntity);
|
applicationEvaluationRepository.save(applicationEvaluationEntity);
|
||||||
|
|
||||||
/** This code is responsible for adding a version history log for the "Update Application Evaluation" operation. **/
|
/** This code is responsible for adding a version history log for the "Update Application Evaluation" operation. **/
|
||||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity).newData(applicationEvaluationEntity).build());
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity).newData(applicationEvaluationEntity).build());
|
||||||
|
}
|
||||||
|
|
||||||
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
||||||
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
|
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
|
||||||
|
String applicationStatusType = applicationEntity.getStatus();
|
||||||
|
if (Boolean.FALSE.equals(applicationStatusType.equals((ApplicationStatusTypeEnum.SOCCORSO.getValue())))) {
|
||||||
applicationEntity.setStatus(ApplicationStatusTypeEnum.SOCCORSO.getValue());
|
applicationEntity.setStatus(ApplicationStatusTypeEnum.SOCCORSO.getValue());
|
||||||
applicationRepository.save(applicationEntity);
|
applicationRepository.save(applicationEntity);
|
||||||
|
}
|
||||||
|
|
||||||
/** This code is responsible for adding a version history log for the "Update Application" operation. **/
|
/** This code is responsible for adding a version history log for the "Update Application" operation. **/
|
||||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEntity).newData(applicationEntity).build());
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEntity).newData(applicationEntity).build());
|
||||||
|
|
||||||
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
|
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
|
||||||
|
String assignedStatusType = assignedApplicationsEntity.getStatus();
|
||||||
AssignedApplicationsEntity oldAssignedApplication = Utils.getClonedEntityForData(assignedApplicationsEntity);
|
AssignedApplicationsEntity oldAssignedApplication = Utils.getClonedEntityForData(assignedApplicationsEntity);
|
||||||
|
if (Boolean.FALSE.equals(assignedStatusType.equals((AssignedApplicationEnum.SOCCORSO.getValue())))) {
|
||||||
assignedApplicationsEntity.setStatus(AssignedApplicationEnum.SOCCORSO.getValue());
|
assignedApplicationsEntity.setStatus(AssignedApplicationEnum.SOCCORSO.getValue());
|
||||||
assignedApplicationsRepository.save(assignedApplicationsEntity);
|
assignedApplicationsRepository.save(assignedApplicationsEntity);
|
||||||
|
|
||||||
/** This code is responsible for adding a version history log for the "Update Assigned Application" operation. **/
|
/** This code is responsible for adding a version history log for the "Update Assigned Application" operation. **/
|
||||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldAssignedApplication).newData(assignedApplicationsEntity).build());
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldAssignedApplication).newData(assignedApplicationsEntity).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return applicationAmendment;
|
return applicationAmendment;
|
||||||
}
|
}
|
||||||
@@ -278,130 +289,132 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationAmendmentRequestResponse convertEntityToResponse(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity) {
|
public ApplicationAmendmentRequestResponse convertEntityToResponse(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity) {
|
||||||
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = new ApplicationAmendmentRequestResponse();
|
ApplicationAmendmentRequestResponse response = initializeBasicResponse(applicationAmendmentRequestEntity);
|
||||||
applicationAmendmentRequestResponse.setId(applicationAmendmentRequestEntity.getId());
|
|
||||||
Long applicationId = applicationAmendmentRequestEntity.getApplicationId();
|
|
||||||
|
|
||||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
List<ApplicationFormEntity> forms = applicationFormRepository.findByApplicationId(applicationAmendmentRequestEntity.getApplicationId());
|
||||||
applicationAmendmentRequestResponse.setApplicationId(applicationId);
|
Map<String, String> fieldIdToLabelMap = extractFieldIdToLabelMap(forms);
|
||||||
applicationAmendmentRequestResponse.setCallEmail(application.getCall().getEmail());
|
|
||||||
applicationAmendmentRequestResponse.setApplicationEvaluationId(applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getId());
|
|
||||||
applicationAmendmentRequestResponse.setNote(applicationAmendmentRequestEntity.getNote());
|
|
||||||
applicationAmendmentRequestResponse.setStatus(ApplicationAmendmentRequestEnum.valueOf(applicationAmendmentRequestEntity.getStatus()));
|
|
||||||
applicationAmendmentRequestResponse.setResponseDays(applicationAmendmentRequestEntity.getResponseDays());
|
|
||||||
applicationAmendmentRequestResponse.setInternalNote(applicationAmendmentRequestEntity.getInternalNote());
|
|
||||||
LocalDateTime startDate = applicationAmendmentRequestEntity.getStartDate();
|
|
||||||
applicationAmendmentRequestResponse.setStartDate(startDate);
|
|
||||||
|
|
||||||
LocalDateTime expirationDate = startDate.plus(expirationDays, ChronoUnit.DAYS);
|
List<AmendmentFormField> amendmentFormFields = Utils.convertJsonStringToList(
|
||||||
applicationAmendmentRequestResponse.setExpirationDate(expirationDate);
|
applicationAmendmentRequestEntity.getFormFields(), AmendmentFormField.class);
|
||||||
|
Map<String, ApplicationFormFieldEntity> formFieldEntityMap = getApplicationFormFieldEntityMap(applicationAmendmentRequestEntity, amendmentFormFields);
|
||||||
|
|
||||||
applicationAmendmentRequestResponse.setIsSendEmail(applicationAmendmentRequestEntity.getIsEmail());
|
processFormFields(amendmentFormFields, fieldIdToLabelMap, formFieldEntityMap, response);
|
||||||
applicationAmendmentRequestResponse.setIsSendNotification(applicationAmendmentRequestEntity.getIsNotification());
|
|
||||||
String callName = application.getCall().getName();
|
|
||||||
Long protocolNumber = (applicationAmendmentRequestEntity.getProtocol() != null && applicationAmendmentRequestEntity.getProtocol().getProtocolNumber() != null)
|
|
||||||
? applicationAmendmentRequestEntity.getProtocol().getProtocolNumber()
|
|
||||||
: null;
|
|
||||||
UserEntity userEntity = userService.validateUser(application.getUserId());
|
|
||||||
String firstName = userEntity.getBeneficiary() != null ? userEntity.getBeneficiary().getFirstName() : "";
|
|
||||||
String lastName = userEntity.getBeneficiary() != null ? userEntity.getBeneficiary().getLastName() : "";
|
|
||||||
|
|
||||||
String beneficiaryName = (!firstName.isBlank() ? firstName : "") +
|
return response;
|
||||||
(!lastName.isBlank() ? " " + lastName : "");
|
|
||||||
|
|
||||||
beneficiaryName = beneficiaryName.isBlank() ? "" : beneficiaryName;
|
|
||||||
applicationAmendmentRequestResponse.setCallName(callName);
|
|
||||||
applicationAmendmentRequestResponse.setProtocolNumber(protocolNumber);
|
|
||||||
applicationAmendmentRequestResponse.setBeneficiaryName(beneficiaryName);
|
|
||||||
|
|
||||||
List<ApplicationFormEntity> forms = applicationFormRepository.findByApplicationId(applicationId);
|
|
||||||
List<AmendmentFormFieldResponse> allFormFields = new ArrayList<>();
|
|
||||||
|
|
||||||
for (ApplicationFormEntity form : forms) {
|
|
||||||
String content = form.getForm().getContent();
|
|
||||||
List<Map<String, Object>> result = filterByName(content, "fileupload");
|
|
||||||
allFormFields.addAll(getIdAndLabelFromResult(result));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> fieldIdToLabelMap = allFormFields.stream()
|
private ApplicationAmendmentRequestResponse initializeBasicResponse(ApplicationAmendmentRequestEntity entity) {
|
||||||
|
ApplicationAmendmentRequestResponse response = new ApplicationAmendmentRequestResponse();
|
||||||
|
response.setId(entity.getId());
|
||||||
|
response.setApplicationId(entity.getApplicationId());
|
||||||
|
response.setApplicationEvaluationId(entity.getApplicationEvaluationEntity().getId());
|
||||||
|
response.setNote(entity.getNote());
|
||||||
|
response.setStatus(ApplicationAmendmentRequestEnum.valueOf(entity.getStatus()));
|
||||||
|
response.setResponseDays(entity.getResponseDays());
|
||||||
|
response.setInternalNote(entity.getInternalNote());
|
||||||
|
|
||||||
|
LocalDateTime startDate = entity.getStartDate();
|
||||||
|
response.setStartDate(startDate);
|
||||||
|
response.setExpirationDate(startDate.plus(expirationDays, ChronoUnit.DAYS));
|
||||||
|
response.setIsSendEmail(entity.getIsEmail());
|
||||||
|
response.setIsSendNotification(entity.getIsNotification());
|
||||||
|
|
||||||
|
ApplicationEntity application = applicationService.validateApplication(entity.getApplicationId());
|
||||||
|
response.setCallEmail(application.getCall().getEmail());
|
||||||
|
response.setCallName(application.getCall().getName());
|
||||||
|
|
||||||
|
UserEntity userEntity = userService.validateUser(application.getUserId());
|
||||||
|
response.setBeneficiaryName(buildBeneficiaryName(userEntity));
|
||||||
|
|
||||||
|
Long protocolNumber = entity.getProtocol() != null ? entity.getProtocol().getProtocolNumber() : null;
|
||||||
|
response.setProtocolNumber(protocolNumber);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> extractFieldIdToLabelMap(List<ApplicationFormEntity> forms) {
|
||||||
|
return forms.stream()
|
||||||
|
.flatMap(form -> {
|
||||||
|
String content = form.getForm().getContent();
|
||||||
|
return getIdAndLabelFromResult(filterByName(content, "fileupload")).stream();
|
||||||
|
})
|
||||||
.collect(Collectors.toMap(AmendmentFormFieldResponse::getFieldId, AmendmentFormFieldResponse::getLabel));
|
.collect(Collectors.toMap(AmendmentFormFieldResponse::getFieldId, AmendmentFormFieldResponse::getLabel));
|
||||||
|
}
|
||||||
|
|
||||||
String formFieldsJson = applicationAmendmentRequestEntity.getFormFields();
|
private Map<String, ApplicationFormFieldEntity> getApplicationFormFieldEntityMap(
|
||||||
List<AmendmentFormFieldResponse> formFields = Utils.convertJsonToList(
|
ApplicationAmendmentRequestEntity entity, List<AmendmentFormField> amendmentFormFields) {
|
||||||
formFieldsJson, new TypeReference<List<AmendmentFormFieldResponse>>() {
|
List<String> fieldIds = amendmentFormFields.stream()
|
||||||
});
|
.map(AmendmentFormField::getFieldId)
|
||||||
|
.toList();
|
||||||
|
return getApplicationFormFieldList(entity, fieldIds).stream()
|
||||||
|
.collect(Collectors.toMap(ApplicationFormFieldEntity::getFieldId, Function.identity()));
|
||||||
|
}
|
||||||
|
|
||||||
for (AmendmentFormFieldResponse formField : formFields) {
|
private void processFormFields(List<AmendmentFormField> amendmentFormFields, Map<String, String> fieldIdToLabelMap,
|
||||||
String label = fieldIdToLabelMap.get(formField.getFieldId());
|
Map<String, ApplicationFormFieldEntity> formFieldEntityMap, ApplicationAmendmentRequestResponse response) {
|
||||||
|
List<AmendmentFormFieldResponse> formFields = new ArrayList<>();
|
||||||
|
List<ApplicationFormFieldResponseBean> fileDetails = new ArrayList<>();
|
||||||
|
|
||||||
|
for (AmendmentFormField amendmentFormField : amendmentFormFields) {
|
||||||
|
// Create form field response
|
||||||
|
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());
|
||||||
|
return responseBean;
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Map to application form field response bean
|
||||||
|
ApplicationFormFieldEntity formFieldEntity = formFieldEntityMap.get(amendmentFormField.getFieldId());
|
||||||
|
ApplicationFormFieldResponseBean responseBean = new ApplicationFormFieldResponseBean();
|
||||||
|
responseBean.setApplicationFormId(formFieldEntity.getApplicationForm().getId());
|
||||||
|
responseBean.setId(formFieldEntity.getId());
|
||||||
|
responseBean.setFieldId(amendmentFormField.getFieldId());
|
||||||
|
responseBean.setCreatedDate(formFieldEntity.getCreatedDate());
|
||||||
|
responseBean.setUpdatedDate(formFieldEntity.getUpdatedDate());
|
||||||
|
responseBean.setFieldValue(documentResponseBeans);
|
||||||
|
|
||||||
|
fileDetails.add(responseBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.setFormFields(formFields);
|
||||||
|
response.setApplicationFormFields(fileDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildBeneficiaryName(UserEntity userEntity) {
|
||||||
|
if (userEntity.getBeneficiary() == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String firstName = userEntity.getBeneficiary().getFirstName();
|
||||||
|
String lastName = userEntity.getBeneficiary().getLastName();
|
||||||
|
return (firstName != null ? firstName : "") +
|
||||||
|
(lastName != null && !lastName.isBlank() ? " " + lastName : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void createFormField(List<AmendmentFormFieldResponse> formFields, Map<String, String> fieldIdToLabelMap,
|
||||||
|
AmendmentFormField amendmentFormField) {
|
||||||
|
AmendmentFormFieldResponse formField = new AmendmentFormFieldResponse();
|
||||||
|
String label = fieldIdToLabelMap.get(amendmentFormField.getFieldId());
|
||||||
|
formField.setFieldId(amendmentFormField.getFieldId());
|
||||||
formField.setLabel(label);
|
formField.setLabel(label);
|
||||||
formField.setSelected(true);
|
formField.setSelected(true);
|
||||||
}
|
formFields.add(formField);
|
||||||
// Set the filtered formFields in the response
|
|
||||||
applicationAmendmentRequestResponse.setFormFields(formFields);
|
|
||||||
|
|
||||||
String applicationFormFieldsJson = applicationAmendmentRequestEntity.getFormFields();
|
|
||||||
List<ApplicationFormFieldResponseBean> applicationFormFields = Utils.convertJsonToList(
|
|
||||||
formFieldsJson, new TypeReference<List<ApplicationFormFieldResponseBean>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
List<ApplicationFormFieldResponseBean> fileDetailResponses = new ArrayList<>();
|
|
||||||
for (ApplicationFormFieldResponseBean field : applicationFormFields) {
|
|
||||||
ApplicationFormFieldResponseBean responseBean = new ApplicationFormFieldResponseBean();
|
|
||||||
responseBean.setFieldId(field.getFieldId());
|
|
||||||
|
|
||||||
Optional<ApplicationFormFieldEntity> formFieldEntity = Optional.empty();
|
|
||||||
for (ApplicationFormEntity form : forms) {
|
|
||||||
formFieldEntity = applicationFormFieldRepository
|
|
||||||
.findByApplicationFormIdAndFieldId(form.getId(), field.getFieldId());
|
|
||||||
if (formFieldEntity.isPresent()) {
|
|
||||||
// Set the applicationFormId from the matching form
|
|
||||||
responseBean.setApplicationFormId(form.getId());
|
|
||||||
responseBean.setId(formFieldEntity.get().getId());
|
|
||||||
responseBean.setCreatedDate(formFieldEntity.get().getCreatedDate());
|
|
||||||
responseBean.setUpdatedDate(formFieldEntity.get().getUpdatedDate());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if fieldValue is not null and is a String
|
|
||||||
if (field.getFieldValue() instanceof String && field.getFieldValue() != null && !((String) field.getFieldValue()).isBlank()) {
|
|
||||||
String fieldValueString = (String) field.getFieldValue();
|
|
||||||
String[] documentIds = fieldValueString.split(",");
|
|
||||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
|
||||||
|
|
||||||
// Process each document ID
|
|
||||||
for (String docId : documentIds) {
|
|
||||||
try {
|
|
||||||
Long documentId = Long.valueOf(docId.trim());
|
|
||||||
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
|
||||||
DocumentResponseBean docBean = new DocumentResponseBean();
|
|
||||||
docBean.setId(documentEntity.getId());
|
|
||||||
docBean.setName(documentEntity.getFileName());
|
|
||||||
docBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType()));
|
|
||||||
docBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource()));
|
|
||||||
docBean.setSourceId(documentEntity.getSourceId());
|
|
||||||
docBean.setFilePath(documentEntity.getFilePath());
|
|
||||||
docBean.setCreatedDate(documentEntity.getCreatedDate());
|
|
||||||
docBean.setUpdatedDate(documentEntity.getUpdatedDate());
|
|
||||||
documentResponseBeans.add(docBean);
|
|
||||||
});
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
// Handle the case where documentId is not a valid number
|
|
||||||
// Log the error if necessary
|
|
||||||
}
|
|
||||||
}
|
|
||||||
responseBean.setFieldValue(documentResponseBeans);
|
|
||||||
} else {
|
|
||||||
responseBean.setFieldValue(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
fileDetailResponses.add(responseBean);
|
|
||||||
}
|
|
||||||
|
|
||||||
applicationAmendmentRequestResponse.setApplicationFormFields(fileDetailResponses);
|
|
||||||
|
|
||||||
return applicationAmendmentRequestResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long id) {
|
public ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long id) {
|
||||||
return applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
|
return applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
|
||||||
@@ -464,9 +477,20 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
|
|
||||||
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
||||||
setIfUpdated(existingApplicationAmendment::getNote, existingApplicationAmendment::setNote, updateRequest.getNote());
|
setIfUpdated(existingApplicationAmendment::getNote, existingApplicationAmendment::setNote, updateRequest.getNote());
|
||||||
|
|
||||||
|
Map<String, AmendmentFormField> amendmentFormFieldMap = Utils
|
||||||
|
.convertJsonStringToList(existingApplicationAmendment.getFormFields(), AmendmentFormField.class)
|
||||||
|
.stream().collect(Collectors.toMap(AmendmentFormField::getFieldId, Function.identity()));
|
||||||
|
Map<String, ApplicationFormFieldEntity> applicationFormFieldMap = getApplicationFormFieldList(existingApplicationAmendment, amendmentFormFieldMap.keySet().stream().toList()).stream().collect(Collectors.toMap(ApplicationFormFieldEntity::getFieldId, Function.identity()));
|
||||||
|
|
||||||
if(updateRequest.getApplicationFormFields() != null) {
|
if(updateRequest.getApplicationFormFields() != null) {
|
||||||
updateApplicationFormFields(existingApplicationAmendment, updateRequest.getApplicationFormFields());
|
updateRequest.getApplicationFormFields().stream().forEach(applicationFormFieldRequest->{
|
||||||
updateFormFieldsJson(existingApplicationAmendment, updateRequest.getApplicationFormFields());
|
AmendmentFormField amendmentFormField = getAmendmentFormField(amendmentFormFieldMap,applicationFormFieldRequest.getFieldId());
|
||||||
|
ApplicationFormFieldEntity applicationFormFieldEntity = getApplicationFormField(applicationFormFieldMap, applicationFormFieldRequest.getFieldId());
|
||||||
|
updateApplicationFormField(applicationFormFieldEntity,applicationFormFieldRequest, amendmentFormField);
|
||||||
|
updateFormField(applicationFormFieldRequest, amendmentFormField);
|
||||||
|
});
|
||||||
|
existingApplicationAmendment.setFormFields(Utils.convertListToJsonString(amendmentFormFieldMap.values().stream().toList()));
|
||||||
}
|
}
|
||||||
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
|
|
||||||
@@ -476,185 +500,298 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateApplicationFormFields(ApplicationAmendmentRequestEntity applicationAmendment, ApplicationFormFieldRequestBean updatedFormField) {
|
private List<Long> updateApplicationFormField(ApplicationFormFieldEntity applicationFormFieldEntity,
|
||||||
if (updatedFormField.getFieldValue() == null || "".equals(updatedFormField.getFieldValue().toString().trim())) {
|
ApplicationFormFieldRequestBean applicationFormFieldRequest, AmendmentFormField amendmentFormField) {
|
||||||
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationAmendment.getApplicationId());
|
// Step 1: Extract IDs
|
||||||
|
List<Long> applicationFormFieldIds = extractIds(applicationFormFieldEntity.getFieldValue());
|
||||||
|
List<Long> amendmentFormFieldIds = extractIds(amendmentFormField.getFieldValue());
|
||||||
|
List<Long> requestedIds = extractIds(applicationFormFieldRequest.getFieldValue());
|
||||||
|
|
||||||
boolean fieldUpdated = false;
|
// Step 2: Optimize operations by finding differences
|
||||||
|
// Remove only those IDs from currentIds that exist in presentIds but not in requestedIds
|
||||||
|
List<Long> idsToRemove = amendmentFormFieldIds.stream()
|
||||||
|
.filter(id -> !requestedIds.contains(id))
|
||||||
|
.toList();
|
||||||
|
applicationFormFieldIds.removeAll(idsToRemove);
|
||||||
|
|
||||||
for (ApplicationFormEntity applicationForm : applicationForms) {
|
// Add only those IDs to currentIds that exist in requestedIds but not in presentIds
|
||||||
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
List<Long> idsToAdd = requestedIds.stream()
|
||||||
.findByApplicationFormIdAndFieldId(applicationForm.getId(), updatedFormField.getFieldId());
|
.filter(id -> !amendmentFormFieldIds.contains(id))
|
||||||
|
.toList();
|
||||||
|
applicationFormFieldIds.addAll(idsToAdd);
|
||||||
|
|
||||||
if (formFieldEntityOptional.isPresent()) {
|
// Step 3: Update the applicationFormFieldEntity fieldValue with requestedIds if it has changed
|
||||||
ApplicationFormFieldEntity formEntity = formFieldEntityOptional.get();
|
if (!amendmentFormFieldIds.equals(requestedIds)) {
|
||||||
formEntity.setFieldValue(null); // Set field value to null
|
String updatedFieldValue = applicationFormFieldIds.stream()
|
||||||
applicationFormFieldRepository.save(formEntity);
|
.map(String::valueOf)
|
||||||
log.info("Set field value to null for application ID {} and field ID {}", applicationAmendment.getApplicationId(), updatedFormField.getFieldId());
|
.collect(Collectors.joining(","));
|
||||||
fieldUpdated = true;
|
applicationFormFieldEntity.setFieldValue(updatedFieldValue);
|
||||||
break;
|
applicationFormFieldRepository.save(applicationFormFieldEntity);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fieldUpdated) {
|
// Step 4: Return the updated currentIds
|
||||||
throw new CustomValidationException(Status.NOT_FOUND, "No ApplicationFormField found for application ID " + applicationAmendment.getApplicationId() + " and field ID " + updatedFormField.getFieldId());
|
return applicationFormFieldIds;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ApplicationFormFieldEntity getApplicationFormField(
|
||||||
|
Map<String, ApplicationFormFieldEntity> applicationFormFieldMap, String fieldId) {
|
||||||
|
ApplicationFormFieldEntity applicationFormFieldEntity = applicationFormFieldMap.get(fieldId);
|
||||||
|
if (applicationFormFieldEntity == null) {
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST, GepafinConstant.APPLICATION_FORM_FIELD_NOT_FOUND);
|
||||||
|
}
|
||||||
|
return applicationFormFieldEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<ApplicationFormFieldEntity> getApplicationFormFieldList(
|
||||||
|
ApplicationAmendmentRequestEntity applicationAmendment,
|
||||||
|
List<String> fieldIds) {
|
||||||
|
List<ApplicationFormEntity> applicationFormList = applicationFormRepository
|
||||||
|
.findByApplicationId(applicationAmendment.getApplicationId());
|
||||||
|
|
||||||
|
return applicationFormList.stream().flatMap(applicationForm -> applicationFormFieldRepository
|
||||||
|
.findByApplicationFormIdAndFieldIdIn(applicationForm.getId(), fieldIds).stream()).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private AmendmentFormField getAmendmentFormField(Map<String, AmendmentFormField> amendmentFormFieldMap,
|
||||||
|
String fieldId) {
|
||||||
|
AmendmentFormField amendmentFormField = amendmentFormFieldMap.get(fieldId);
|
||||||
|
if (amendmentFormField == null) {
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST, GepafinConstant.APPLICATION_FORM_FIELD_NOT_FOUND);
|
||||||
|
}
|
||||||
|
return amendmentFormField;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateFormField(ApplicationFormFieldRequestBean applicationFormFieldRequest,
|
||||||
|
AmendmentFormField amendmentFormField) {
|
||||||
|
List<Long> requestedDocumentIds = extractIds(applicationFormFieldRequest.getFieldValue());
|
||||||
|
List<Long> existingDocumentIds = extractIds(amendmentFormField.getFieldValue());
|
||||||
|
|
||||||
|
if (requestedDocumentIds.isEmpty()) {
|
||||||
|
if (!existingDocumentIds.isEmpty()) {
|
||||||
|
existingDocumentIds.forEach(this::softDeleteDocument);
|
||||||
|
amendmentFormField.setFieldValue(null);
|
||||||
|
setIsUploadedBy(amendmentFormField);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> documentIds;
|
requestedDocumentIds.forEach(documentId -> documentService.validateDocument(documentId).getId());
|
||||||
|
existingDocumentIds.stream().filter(documentId -> !requestedDocumentIds.contains(documentId))
|
||||||
|
.forEach(this::softDeleteDocument);
|
||||||
|
|
||||||
if (updatedFormField.getFieldValue() instanceof String && updatedFormField.getFieldValue() != null) {
|
String newFieldValue = String.join(",",
|
||||||
documentIds = Arrays.asList(((String) updatedFormField.getFieldValue()).split(","));
|
requestedDocumentIds.stream().map(String::valueOf).collect(Collectors.toList()));
|
||||||
|
|
||||||
|
if (!newFieldValue.equals(amendmentFormField.getFieldValue())) {
|
||||||
|
amendmentFormField.setFieldValue(newFieldValue);
|
||||||
|
setIsUploadedBy(amendmentFormField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Long> extractIds(Object fieldValue) {
|
||||||
|
if (fieldValue instanceof String && !StringUtils.isEmpty((String) fieldValue)) {
|
||||||
|
return Arrays.stream(((String) fieldValue).split(","))
|
||||||
|
.map(Long::valueOf)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void setIsUploadedBy(AmendmentFormField amendmentFormField) {
|
||||||
|
if(validator.checkIsBeneficiary()) {
|
||||||
|
amendmentFormField.setIsUploadedBy(AmendmentFormField.AmendmentIsUploadedByEnum.BENEFICIARY.getValue());
|
||||||
}else {
|
}else {
|
||||||
log.warn("Expected fieldValue as a comma-separated String but got: {}", updatedFormField.getFieldValue());
|
amendmentFormField.setIsUploadedBy(AmendmentFormField.AmendmentIsUploadedByEnum.PRE_INSTRUCTOR.getValue());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> validDocumentIds = new ArrayList<>();
|
|
||||||
for (String documentId : documentIds) {
|
|
||||||
try {
|
|
||||||
DocumentEntity documentEntity = documentService.validateDocument(Long.parseLong(documentId.trim()));
|
|
||||||
if (documentEntity != null) {
|
|
||||||
validDocumentIds.add(documentId.trim());
|
|
||||||
} else {
|
|
||||||
log.warn("Document with ID {} does not exist. Skipping this ID.", documentId);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
log.error("Invalid document ID format: {}. Error: {}", documentId, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!validDocumentIds.isEmpty()) {
|
|
||||||
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationAmendment.getApplicationId());
|
|
||||||
|
|
||||||
boolean fieldUpdated = false;
|
|
||||||
|
|
||||||
// Parse the formFields JSON string to get amendment field values
|
|
||||||
String amendmentFieldValue = null;
|
|
||||||
try {
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
List<ApplicationFormFieldRequestBean> amendmentFields = mapper.readValue(
|
|
||||||
applicationAmendment.getFormFields(),
|
|
||||||
mapper.getTypeFactory().constructCollectionType(List.class, ApplicationFormFieldRequestBean.class)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Find the matching field value and convert to string if found
|
|
||||||
Optional<Object> amendmentFieldObj = amendmentFields.stream()
|
|
||||||
.filter(field -> updatedFormField.getFieldId().equals(field.getFieldId()))
|
|
||||||
.map(ApplicationFormFieldRequestBean::getFieldValue)
|
|
||||||
.findFirst();
|
|
||||||
|
|
||||||
if (amendmentFieldObj.isPresent() && amendmentFieldObj.get() instanceof String) {
|
|
||||||
amendmentFieldValue = (String) amendmentFieldObj.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
log.error("Error parsing formFields JSON: {}", e.getMessage());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amendmentFieldValue == null) {
|
|
||||||
log.warn("No matching field found in amendment for field ID {}", updatedFormField.getFieldId());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> amendmentDocumentIds = Arrays.asList(amendmentFieldValue.split(","));
|
|
||||||
|
|
||||||
for (ApplicationFormEntity applicationForm : applicationForms) {
|
|
||||||
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
|
||||||
.findByApplicationFormIdAndFieldId(applicationForm.getId(), updatedFormField.getFieldId());
|
|
||||||
|
|
||||||
if (formFieldEntityOptional.isPresent()) {
|
|
||||||
ApplicationFormFieldEntity formEntity = formFieldEntityOptional.get();
|
|
||||||
|
|
||||||
// Retrieve existing document IDs in ApplicationFormFieldTable
|
|
||||||
String existingFieldValue = formEntity.getFieldValue();
|
|
||||||
Set<String> existingDocumentIds = existingFieldValue != null
|
|
||||||
? new HashSet<>(Arrays.asList(existingFieldValue.split(",")))
|
|
||||||
: new HashSet<>();
|
|
||||||
|
|
||||||
// Remove amendment documents from existing document IDs
|
|
||||||
existingDocumentIds.removeAll(amendmentDocumentIds);
|
|
||||||
|
|
||||||
// Add valid new document IDs from the request
|
|
||||||
existingDocumentIds.addAll(validDocumentIds);
|
|
||||||
|
|
||||||
// Set the combined document IDs back as the field value
|
|
||||||
formEntity.setFieldValue(String.join(",", existingDocumentIds));
|
|
||||||
applicationFormFieldRepository.save(formEntity);
|
|
||||||
|
|
||||||
log.info("Updated field value for application ID {} and field ID {} with document IDs {}",
|
|
||||||
applicationAmendment.getApplicationId(), updatedFormField.getFieldId(), String.join(",", existingDocumentIds));
|
|
||||||
fieldUpdated = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fieldUpdated) {
|
|
||||||
throw new CustomValidationException(Status.NOT_FOUND,
|
|
||||||
String.format("No ApplicationFormField found for application ID %s and field ID %s. Skipping update.",
|
|
||||||
applicationAmendment.getApplicationId(), updatedFormField.getFieldId()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.warn("No valid document IDs found for update. Skipping field ID {}", updatedFormField.getFieldId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateFormFieldsJson(ApplicationAmendmentRequestEntity applicationAmendment, ApplicationFormFieldRequestBean updatedFormField) {
|
// private void updateApplicationFormFields(ApplicationAmendmentRequestEntity applicationAmendment, ApplicationFormFieldRequestBean updatedFormField) {
|
||||||
if (updatedFormField != null) {
|
// if (updatedFormField.getFieldValue() == null || "".equals(updatedFormField.getFieldValue().toString().trim())) {
|
||||||
try {
|
// List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationAmendment.getApplicationId());
|
||||||
// Step 1: Fetch the existing form fields JSON
|
//
|
||||||
String existingFormFieldsJson = applicationAmendment.getFormFields();
|
// boolean fieldUpdated = false;
|
||||||
List<ApplicationFormFieldRequestBean> formFieldsList;
|
//
|
||||||
|
// for (ApplicationFormEntity applicationForm : applicationForms) {
|
||||||
if (existingFormFieldsJson == null || existingFormFieldsJson.isEmpty()) {
|
// Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||||
formFieldsList = new ArrayList<>(); // If no existing data, start with an empty list
|
// .findByApplicationFormIdAndFieldId(applicationForm.getId(), updatedFormField.getFieldId());
|
||||||
} else {
|
//
|
||||||
// Step 2: Deserialize the existing JSON into a list of objects
|
// if (formFieldEntityOptional.isPresent()) {
|
||||||
formFieldsList = new ObjectMapper().readValue(existingFormFieldsJson, new TypeReference<List<ApplicationFormFieldRequestBean>>() {
|
// ApplicationFormFieldEntity formEntity = formFieldEntityOptional.get();
|
||||||
});
|
// formEntity.setFieldValue(null); // Set field value to null
|
||||||
}
|
// applicationFormFieldRepository.save(formEntity);
|
||||||
|
// log.info("Set field value to null for application ID {} and field ID {}", applicationAmendment.getApplicationId(), updatedFormField.getFieldId());
|
||||||
// Step 3: Check if the field ID already exists in the list and update it
|
// fieldUpdated = true;
|
||||||
boolean fieldUpdated = false;
|
// break;
|
||||||
for (ApplicationFormFieldRequestBean field : formFieldsList) {
|
// }
|
||||||
if (field.getFieldId().equals(updatedFormField.getFieldId())) {
|
// }
|
||||||
field.setFieldValue(updatedFormField.getFieldValue()); // Update field value
|
//
|
||||||
fieldUpdated = true;
|
// if (!fieldUpdated) {
|
||||||
break;
|
// throw new CustomValidationException(Status.NOT_FOUND, "No ApplicationFormField found for application ID " + applicationAmendment.getApplicationId() + " and field ID " + updatedFormField.getFieldId());
|
||||||
}
|
// }
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
// If field wasn't updated, log a warning message instead of adding a new field
|
//
|
||||||
if (!fieldUpdated) {
|
// List<String> documentIds;
|
||||||
log.warn("Field ID {} does not exist in the form fields for application amendment ID {}", updatedFormField.getFieldId(), applicationAmendment.getId());
|
//
|
||||||
throw new CustomValidationException(Status.NOT_FOUND, "Field ID {} does not exist in the form fields for application amendment ID {}");
|
// if (updatedFormField.getFieldValue() instanceof String && updatedFormField.getFieldValue() != null) {
|
||||||
|
// documentIds = Arrays.asList(((String) updatedFormField.getFieldValue()).split(","));
|
||||||
}
|
// } else {
|
||||||
|
// log.warn("Expected fieldValue as a comma-separated String but got: {}", updatedFormField.getFieldValue());
|
||||||
// Step 4: Serialize the updated list back to JSON if the update was successful
|
// return;
|
||||||
String updatedFormFieldsJson = new ObjectMapper().writeValueAsString(formFieldsList);
|
// }
|
||||||
applicationAmendment.setFormFields(updatedFormFieldsJson); // Update the form fields with the modified list
|
//
|
||||||
|
// List<String> validDocumentIds = new ArrayList<>();
|
||||||
log.info("Updated form fields JSON for application amendment ID {}: {}", applicationAmendment.getId(), updatedFormFieldsJson);
|
// for (String documentId : documentIds) {
|
||||||
|
// try {
|
||||||
} catch (JsonProcessingException e) {
|
// DocumentEntity documentEntity = documentService.validateDocument(Long.parseLong(documentId.trim()));
|
||||||
log.error("Error processing JSON for form fields for application amendment ID {}: {}", applicationAmendment.getId(), e.getMessage());
|
// if (documentEntity != null) {
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST, "Error processing JSON for form fields");
|
// validDocumentIds.add(documentId.trim());
|
||||||
}
|
// } else {
|
||||||
} else {
|
// log.warn("Document with ID {} does not exist. Skipping this ID.", documentId);
|
||||||
log.warn("No form field data to update for application amendment ID {}", applicationAmendment.getId());
|
// }
|
||||||
throw new CustomValidationException(Status.NOT_FOUND, "No form field data to update for application amendment ID {}");
|
// } catch (NumberFormatException e) {
|
||||||
}
|
// log.error("Invalid document ID format: {}. Error: {}", documentId, e.getMessage());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!validDocumentIds.isEmpty()) {
|
||||||
|
// List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationAmendment.getApplicationId());
|
||||||
|
//
|
||||||
|
// boolean fieldUpdated = false;
|
||||||
|
//
|
||||||
|
// // Parse the formFields JSON string to get amendment field values
|
||||||
|
// String amendmentFieldValue = null;
|
||||||
|
// try {
|
||||||
|
// ObjectMapper mapper = new ObjectMapper();
|
||||||
|
// List<ApplicationFormFieldRequestBean> amendmentFields = mapper.readValue(
|
||||||
|
// applicationAmendment.getFormFields(),
|
||||||
|
// mapper.getTypeFactory().constructCollectionType(List.class, ApplicationFormFieldRequestBean.class)
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// // Find the matching field value and convert to string if found
|
||||||
|
// Optional<Object> amendmentFieldObj = amendmentFields.stream()
|
||||||
|
// .filter(field -> updatedFormField.getFieldId().equals(field.getFieldId()))
|
||||||
|
// .map(ApplicationFormFieldRequestBean::getFieldValue)
|
||||||
|
// .findFirst();
|
||||||
|
//
|
||||||
|
// if (amendmentFieldObj.isPresent() && amendmentFieldObj.get() instanceof String) {
|
||||||
|
// amendmentFieldValue = (String) amendmentFieldObj.get();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// } catch (JsonProcessingException e) {
|
||||||
|
// log.error("Error parsing formFields JSON: {}", e.getMessage());
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (amendmentFieldValue == null) {
|
||||||
|
// log.warn("No matching field found in amendment for field ID {}", updatedFormField.getFieldId());
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// List<String> amendmentDocumentIds = Arrays.asList(amendmentFieldValue.split(","));
|
||||||
|
//
|
||||||
|
// for (ApplicationFormEntity applicationForm : applicationForms) {
|
||||||
|
// Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||||
|
// .findByApplicationFormIdAndFieldId(applicationForm.getId(), updatedFormField.getFieldId());
|
||||||
|
//
|
||||||
|
// if (formFieldEntityOptional.isPresent()) {
|
||||||
|
// ApplicationFormFieldEntity formEntity = formFieldEntityOptional.get();
|
||||||
|
//
|
||||||
|
// // Retrieve existing document IDs in ApplicationFormFieldTable
|
||||||
|
// String existingFieldValue = formEntity.getFieldValue();
|
||||||
|
// Set<String> existingDocumentIds = existingFieldValue != null
|
||||||
|
// ? new HashSet<>(Arrays.asList(existingFieldValue.split(",")))
|
||||||
|
// : new HashSet<>();
|
||||||
|
//
|
||||||
|
// // Remove amendment documents from existing document IDs
|
||||||
|
// existingDocumentIds.removeAll(amendmentDocumentIds);
|
||||||
|
//
|
||||||
|
// // Add valid new document IDs from the request
|
||||||
|
// existingDocumentIds.addAll(validDocumentIds);
|
||||||
|
// applicationDao.updateDocumentDeletionStatus(formEntity, updatedFormField, formEntity.getApplicationForm().getForm(), null,validDocumentIds,true);
|
||||||
|
// // Set the combined document IDs back as the field value
|
||||||
|
// formEntity.setFieldValue(String.join(",", existingDocumentIds));
|
||||||
|
// applicationFormFieldRepository.save(formEntity);
|
||||||
|
// log.info("Updated field value for application ID {} and field ID {} with document IDs {}",
|
||||||
|
// applicationAmendment.getApplicationId(), updatedFormField.getFieldId(), String.join(",", existingDocumentIds));
|
||||||
|
// fieldUpdated = true;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!fieldUpdated) {
|
||||||
|
// throw new CustomValidationException(Status.NOT_FOUND,
|
||||||
|
// String.format("No ApplicationFormField found for application ID %s and field ID %s. Skipping update.",
|
||||||
|
// applicationAmendment.getApplicationId(), updatedFormField.getFieldId()));
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// log.warn("No valid document IDs found for update. Skipping field ID {}", updatedFormField.getFieldId());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private void updateFormFieldsJson(ApplicationAmendmentRequestEntity applicationAmendment, ApplicationFormFieldRequestBean updatedFormField) {
|
||||||
|
// if (updatedFormField != null) {
|
||||||
|
// try {
|
||||||
|
// // Step 1: Fetch the existing form fields JSON
|
||||||
|
// String existingFormFieldsJson = applicationAmendment.getFormFields();
|
||||||
|
// List<ApplicationFormFieldRequestBean> formFieldsList;
|
||||||
|
//
|
||||||
|
// if (existingFormFieldsJson == null || existingFormFieldsJson.isEmpty()) {
|
||||||
|
// formFieldsList = new ArrayList<>(); // If no existing data, start with an empty list
|
||||||
|
// } else {
|
||||||
|
// // Step 2: Deserialize the existing JSON into a list of objects
|
||||||
|
// formFieldsList = new ObjectMapper().readValue(existingFormFieldsJson, new TypeReference<List<ApplicationFormFieldRequestBean>>() {
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Step 3: Check if the field ID already exists in the list and update it
|
||||||
|
// boolean fieldUpdated = false;
|
||||||
|
// for (ApplicationFormFieldRequestBean field : formFieldsList) {
|
||||||
|
// if (field.getFieldId().equals(updatedFormField.getFieldId())) {
|
||||||
|
// field.setFieldValue(updatedFormField.getFieldValue()); // Update field value
|
||||||
|
// fieldUpdated = true;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // If field wasn't updated, log a warning message instead of adding a new field
|
||||||
|
// if (!fieldUpdated) {
|
||||||
|
// log.warn("Field ID {} does not exist in the form fields for application amendment ID {}", updatedFormField.getFieldId(), applicationAmendment.getId());
|
||||||
|
// throw new CustomValidationException(Status.NOT_FOUND, "Field ID {} does not exist in the form fields for application amendment ID {}");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Step 4: Serialize the updated list back to JSON if the update was successful
|
||||||
|
// String updatedFormFieldsJson = new ObjectMapper().writeValueAsString(formFieldsList);
|
||||||
|
// applicationAmendment.setFormFields(updatedFormFieldsJson); // Update the form fields with the modified list
|
||||||
|
//
|
||||||
|
// log.info("Updated form fields JSON for application amendment ID {}: {}", applicationAmendment.getId(), updatedFormFieldsJson);
|
||||||
|
//
|
||||||
|
// } catch (JsonProcessingException e) {
|
||||||
|
// log.error("Error processing JSON for form fields for application amendment ID {}: {}", applicationAmendment.getId(), e.getMessage());
|
||||||
|
// throw new CustomValidationException(Status.BAD_REQUEST, "Error processing JSON for form fields");
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// log.warn("No form field data to update for application amendment ID {}", applicationAmendment.getId());
|
||||||
|
// throw new CustomValidationException(Status.NOT_FOUND, "No form field data to update for application amendment ID {}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
public List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(Long beneficiaryId) {
|
public List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(Long beneficiaryUserId) {
|
||||||
UserEntity userEntity = userService.validateUser(beneficiaryId);
|
UserEntity userEntity = userService.validateUser(beneficiaryUserId);
|
||||||
List<ApplicationAmendmentRequestEntity> entities =
|
List<ApplicationAmendmentRequestEntity> entities =
|
||||||
applicationAmendmentRequestRepository.findByUserId(beneficiaryId);
|
applicationAmendmentRequestRepository.findByUserId(beneficiaryUserId);
|
||||||
|
|
||||||
return entities.stream()
|
return entities.stream()
|
||||||
.map(this::convertEntityToResponse)
|
.map(this::convertEntityToResponse)
|
||||||
@@ -662,30 +799,60 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationAmendmentRequestResponse closeAmendmentRequest(Long id, CloseAmendmentRequest closeAmendmentRequest) {
|
public ApplicationAmendmentRequestResponse closeAmendmentRequest(Long id, CloseAmendmentRequest closeAmendmentRequest) {
|
||||||
|
|
||||||
log.info("Closing application amendement with ID: {}", id);
|
log.info("Closing application amendement with ID: {}", id);
|
||||||
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
||||||
|
//cloned entity for old data and versioning
|
||||||
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
||||||
|
|
||||||
setIfUpdated(existingApplicationAmendment::getInternalNote, existingApplicationAmendment::setInternalNote, closeAmendmentRequest.getInternalNote());
|
setIfUpdated(existingApplicationAmendment::getInternalNote, existingApplicationAmendment::setInternalNote, closeAmendmentRequest.getInternalNote());
|
||||||
setIfUpdated(existingApplicationAmendment::getStatus, existingApplicationAmendment::setStatus, ApplicationAmendmentRequestEnum.CLOSE.getValue());
|
setIfUpdated(existingApplicationAmendment::getStatus, existingApplicationAmendment::setStatus, ApplicationAmendmentRequestEnum.CLOSE.getValue());
|
||||||
|
|
||||||
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment,oldApplicationAmendmentEntity,VersionActionTypeEnum.UPDATE);
|
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment, oldApplicationAmendmentEntity,
|
||||||
|
VersionActionTypeEnum.UPDATE);
|
||||||
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment);
|
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment);
|
||||||
|
|
||||||
List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(existingApplicationAmendment.getApplicationEvaluationEntity().getId());
|
List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(
|
||||||
boolean allClosed = amendmentRequests.stream()
|
existingApplicationAmendment.getApplicationEvaluationEntity().getId());
|
||||||
.allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()));
|
Boolean allClosed = amendmentRequests.stream().allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()));
|
||||||
|
ApplicationEntity application = applicationService.validateApplication(existingApplicationAmendment.getApplicationId());
|
||||||
|
ApplicationEntity oldApplicationEntityData = Utils.getClonedEntityForData(application);
|
||||||
|
if (Boolean.TRUE.equals(allClosed)) {
|
||||||
|
existingApplicationAmendment.getApplicationEvaluationEntity().setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
||||||
|
|
||||||
if (allClosed) {
|
if (allClosed) {
|
||||||
ApplicationEvaluationEntity existingApplicationEvaluationEntity = existingApplicationAmendment.getApplicationEvaluationEntity();
|
ApplicationEvaluationEntity existingApplicationEvaluationEntity = existingApplicationAmendment.getApplicationEvaluationEntity();
|
||||||
|
|
||||||
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(existingApplicationEvaluationEntity);
|
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(existingApplicationEvaluationEntity);
|
||||||
existingApplicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
existingApplicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
||||||
applicationEvaluationRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity());
|
applicationEvaluationRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity());
|
||||||
|
|
||||||
|
application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue());
|
||||||
|
applicationRepository.save(application);
|
||||||
|
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().setStatus(AssignedApplicationEnum.OPEN.getValue());
|
||||||
|
|
||||||
|
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsDao.validateAssignedApplication(
|
||||||
|
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getId());
|
||||||
|
|
||||||
|
AssignedApplicationsEntity oldAssignedApplicationData = Utils.getClonedEntityForData(assignedApplicationsEntity);
|
||||||
|
assignedApplicationsEntity = assignedApplicationsRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity());
|
||||||
|
|
||||||
/** This code is responsible for adding a version history log for the "Update Application Evaluation" operation. **/
|
/** This code is responsible for adding a version history log for the "Update Application Evaluation" operation. **/
|
||||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity).newData(existingApplicationEvaluationEntity).build());
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity)
|
||||||
|
.newData(existingApplicationEvaluationEntity).build());
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Update Application status" operation. **/
|
||||||
|
loggingUtil.addVersionHistory(
|
||||||
|
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEntityData).newData(application).build());
|
||||||
|
|
||||||
|
/** This code is responsible for adding a version history log for the "Update assigned application " operation. **/
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldAssignedApplicationData)
|
||||||
|
.newData(assignedApplicationsEntity).build());
|
||||||
|
|
||||||
log.info("All amendments are closed. Application Evaluation status set to OPEN.");
|
log.info("All amendments are closed. Application Evaluation status set to OPEN.");
|
||||||
}
|
}
|
||||||
log.info("Application Amendment closed successfully: {}", response);
|
log.info("Application Amendment closed successfully: {}", response);
|
||||||
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,10 +905,10 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(
|
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(
|
||||||
Long id, ApplicationAmendmentRequestEnum statusTypeEnum) {
|
Long id, ApplicationAmendmentRequestEnum statusTypeEnum) {
|
||||||
|
|
||||||
log.info("Updating application amendement with status: {}", id);
|
log.info("Updating application amendment with status: {}", id);
|
||||||
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
||||||
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
||||||
if (Boolean.TRUE.equals(existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.AWAITING.getValue())) && Boolean.TRUE.equals(statusTypeEnum.equals(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED))) {
|
if (Boolean.TRUE.equals(existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.AWAITING.getValue())) || Boolean.TRUE.equals(statusTypeEnum.equals(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED))) {
|
||||||
existingApplicationAmendment.setStatus(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
|
existingApplicationAmendment.setStatus(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
|
||||||
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
applicationAmendmentRequestRepository.save(existingApplicationAmendment);
|
applicationAmendmentRequestRepository.save(existingApplicationAmendment);
|
||||||
@@ -755,22 +922,23 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendReminderEmail(Long amendmentId) {
|
public void sendReminderEmail(Long amendmentId) {
|
||||||
|
|
||||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(amendmentId)
|
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(amendmentId)
|
||||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
|
||||||
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
|
|
||||||
|
|
||||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
|
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
|
||||||
if (entityOptional.isPresent()) {
|
if (entityOptional.isPresent()) {
|
||||||
ApplicationEntity applicationEntity = applicationService.validateApplication(entityOptional.get().getApplicationId());
|
ApplicationEntity applicationEntity = applicationService.validateApplication(entityOptional.get().getApplicationId());
|
||||||
UserEntity beneficiaryUser = userService.validateUser(applicationEntity.getUserId());
|
UserEntity beneficiaryUser = userService.validateUser(applicationEntity.getUserId());
|
||||||
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
|
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
|
||||||
SystemEmailTemplateResponse emailTemplate = systemEmailTemplatesService
|
SystemEmailTemplateResponse emailTemplate = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum.AMENDMENT_REMINDER, hub, null);
|
||||||
.retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum.AMENDMENT_REMINDER, hub, null);
|
|
||||||
String subject = prepareSubject(emailTemplate, amendment, beneficiaryUser);
|
String subject = prepareSubject(emailTemplate, amendment, beneficiaryUser);
|
||||||
String body = prepareBody(emailTemplate, amendment, beneficiaryUser);
|
String body = prepareBody(emailTemplate, amendment, beneficiaryUser);
|
||||||
String email = beneficiaryUser.getEmail();
|
String email = beneficiaryUser.getEmail();
|
||||||
if (Boolean.TRUE.equals(amendment.getIsEmail()) && email != null && !email.isEmpty()) {
|
if (Boolean.TRUE.equals(amendment.getIsEmail()) && email != null && !email.isEmpty()) {
|
||||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email));
|
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(emailTemplate.getEmailScenario(), RecipientTypeEnum.USER, beneficiaryUser.getId(), email,
|
||||||
|
beneficiaryUser.getId(), applicationEntity.getId(), amendment.getId(), applicationEntity.getCall().getId());
|
||||||
|
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email), emailLogRequest);
|
||||||
} else {
|
} else {
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.BENEFICIARY_EMAIL_NOT_FOUND_MSG));
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.BENEFICIARY_EMAIL_NOT_FOUND_MSG));
|
||||||
}
|
}
|
||||||
@@ -805,5 +973,8 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
return Utils.replacePlaceholders(template.getHtmlContent(), bodyPlaceholders);
|
return Utils.replacePlaceholders(template.getHtmlContent(), bodyPlaceholders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void softDeleteDocument(Long documentId) {
|
||||||
|
documentService.deleteFile(documentId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.enums.*;
|
|||||||
import net.gepafin.tendermanagement.model.request.ApplicationFormFieldRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationFormFieldRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.repositories.*;
|
import net.gepafin.tendermanagement.repositories.*;
|
||||||
@@ -145,6 +146,9 @@ public class ApplicationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FormDao formDao;
|
private FormDao formDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailLogDao emailLogDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LoggingUtil loggingUtil;
|
private LoggingUtil loggingUtil;
|
||||||
|
|
||||||
@@ -353,6 +357,10 @@ public class ApplicationDao {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
predicate = builder.and(predicate, root.get("status").in(statusNames));
|
predicate = builder.and(predicate, root.get("status").in(statusNames));
|
||||||
}
|
}
|
||||||
|
query.orderBy(
|
||||||
|
builder.desc(builder.isNotNull(root.get(GepafinConstant.SUBMISSION_DATE))),
|
||||||
|
builder.desc(root.get(GepafinConstant.SUBMISSION_DATE))
|
||||||
|
);
|
||||||
predicate = builder.and(predicate, builder.equal(root.get("hubId"), userEntity.getHub().getId()));
|
predicate = builder.and(predicate, builder.equal(root.get("hubId"), userEntity.getHub().getId()));
|
||||||
return predicate;
|
return predicate;
|
||||||
};
|
};
|
||||||
@@ -432,6 +440,7 @@ public class ApplicationDao {
|
|||||||
|
|
||||||
ApplicationFormFieldEntity applicationFormFieldEntity = new ApplicationFormFieldEntity();
|
ApplicationFormFieldEntity applicationFormFieldEntity = new ApplicationFormFieldEntity();
|
||||||
|
|
||||||
|
List<Long> newDocumentIds = validateFileUploadDocuments(applicationFormFieldRequestBean, formEntity);
|
||||||
validateFileUploadDocuments(applicationFormFieldRequestBean, formEntity);
|
validateFileUploadDocuments(applicationFormFieldRequestBean, formEntity);
|
||||||
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
||||||
|
|
||||||
@@ -456,6 +465,13 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
|
Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
|
||||||
|
|
||||||
|
if (applicationFormFieldRequestBean.getFieldValue() != null) {
|
||||||
|
updateDocumentDeletionStatus(applicationFormFieldEntity, applicationFormFieldRequestBean, formEntity, newDocumentIds, null, false);
|
||||||
|
applicationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue()));
|
||||||
|
}
|
||||||
|
if (applicationFormFieldRequestBean.getFieldValue() == null) {
|
||||||
|
updateDocumentDeletionStatus(applicationFormFieldEntity, applicationFormFieldRequestBean, formEntity, newDocumentIds, null, false);
|
||||||
|
}
|
||||||
if (applicationFormFieldRequestBean.getFieldValue() != null) {
|
if (applicationFormFieldRequestBean.getFieldValue() != null) {
|
||||||
applicationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue()));
|
applicationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue()));
|
||||||
} else {
|
} else {
|
||||||
@@ -473,6 +489,67 @@ public class ApplicationDao {
|
|||||||
return applicationFormField;
|
return applicationFormField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateDocumentDeletionStatus(ApplicationFormFieldEntity applicationFormFieldEntity, ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity, List<Long> newDocumentIds,
|
||||||
|
List<String> preInstructorDocumentId,boolean isPreInstructor) {
|
||||||
|
if (newDocumentIds == null) {
|
||||||
|
newDocumentIds = Collections.emptyList();
|
||||||
|
}
|
||||||
|
if (preInstructorDocumentId == null) {
|
||||||
|
preInstructorDocumentId = Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||||
|
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
||||||
|
if (Boolean.FALSE.equals(contentResponseBean.getName().equals("fileupload"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isPreInstructor){
|
||||||
|
List<Long> currentDocumentIds = parseDocumentIds(applicationFormFieldEntity.getFieldValue());
|
||||||
|
if (Boolean.TRUE.equals(newDocumentIds.isEmpty())) {
|
||||||
|
currentDocumentIds.forEach(docId -> documentService.deleteFile(docId));
|
||||||
|
} else {
|
||||||
|
List<Long> finalNewDocumentIds = newDocumentIds;
|
||||||
|
List<Long> documentsToDelete = currentDocumentIds.stream()
|
||||||
|
.filter(docId -> !finalNewDocumentIds.contains(docId))
|
||||||
|
.toList();
|
||||||
|
documentsToDelete.forEach(docId -> documentService.deleteFile(docId));
|
||||||
|
}}
|
||||||
|
else{
|
||||||
|
List<Long> currentDocumentIds = parseDocumentIds(applicationFormFieldEntity.getFieldValue());
|
||||||
|
if (Boolean.TRUE.equals(preInstructorDocumentId.isEmpty())) {
|
||||||
|
currentDocumentIds.forEach(docId -> documentService.deleteFile(docId));
|
||||||
|
} else {
|
||||||
|
List<Long> preInstructorDocIds = preInstructorDocumentId.stream()
|
||||||
|
.map(Long::valueOf)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<Long> documentsToDelete = currentDocumentIds.stream()
|
||||||
|
.filter(docId -> !preInstructorDocIds.contains(docId))
|
||||||
|
.toList();
|
||||||
|
documentsToDelete.forEach(docId -> documentService.deleteFile(docId));
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<Long> parseDocumentIds(String fieldValue) {
|
||||||
|
if (fieldValue == null || fieldValue.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
if (fieldValue.contains(",")) {
|
||||||
|
return Arrays.stream(fieldValue.split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.map(Long::parseLong)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return Collections.singletonList(Long.parseLong(fieldValue.trim()));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<Long> validateFileUploadDocuments(ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity) {
|
private List<Long> validateFileUploadDocuments(ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity) {
|
||||||
List<Long> documentIds=null;
|
List<Long> documentIds=null;
|
||||||
@@ -862,12 +939,14 @@ public class ApplicationDao {
|
|||||||
// Replace placeholders in the subject and body
|
// Replace placeholders in the subject and body
|
||||||
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
||||||
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||||
|
EmailLogRequest emailLogRequest=emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(),RecipientTypeEnum.USER,userEntity.getId(),userEntity.getEmail(),userEntity.getId(),applicationEntity.getId(),null,applicationEntity.getCall().getId());
|
||||||
String email = userEntity.getEmail();
|
String email = userEntity.getEmail();
|
||||||
if (userEntity.getBeneficiary() != null) {
|
if (userEntity.getBeneficiary() != null) {
|
||||||
|
emailLogRequest.setRecipientType(RecipientTypeEnum.BENEFICIARY);
|
||||||
email = userEntity.getBeneficiary().getEmail();
|
email = userEntity.getBeneficiary().getEmail();
|
||||||
|
emailLogRequest.setUserId(userEntity.getBeneficiary().getId());
|
||||||
}
|
}
|
||||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email));
|
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email),emailLogRequest);
|
||||||
List<String> recipientEmails = new ArrayList<>();
|
List<String> recipientEmails = new ArrayList<>();
|
||||||
// recipientEmails.add(email);
|
// recipientEmails.add(email);
|
||||||
String companyEmail = company.getEmail();
|
String companyEmail = company.getEmail();
|
||||||
@@ -880,7 +959,12 @@ public class ApplicationDao {
|
|||||||
if (contactEmail != null && !contactEmail.isEmpty() && !contactEmail.equals(companyEmail)) {
|
if (contactEmail != null && !contactEmail.isEmpty() && !contactEmail.equals(companyEmail)) {
|
||||||
recipientEmails.add(contactEmail);
|
recipientEmails.add(contactEmail);
|
||||||
}
|
}
|
||||||
emailNotificationDao.sendMail(hub.getId(), subject, body, recipientEmails);
|
if(Boolean.FALSE.equals(recipientEmails.isEmpty())){
|
||||||
|
emailLogRequest.setRecipientId(applicationEntity.getCompany().getId());
|
||||||
|
emailLogRequest.setRecipientType(RecipientTypeEnum.COMPANY);
|
||||||
|
emailLogRequest.setRecipientEmails(companyEmail);
|
||||||
|
}
|
||||||
|
emailNotificationDao.sendMail(hub.getId(), subject, body, recipientEmails,emailLogRequest);
|
||||||
}
|
}
|
||||||
private void sendMailTodefaultSystemAndGepafin(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
private void sendMailTodefaultSystemAndGepafin(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
||||||
CallEntity call = applicationEntity.getCall();
|
CallEntity call = applicationEntity.getCall();
|
||||||
@@ -907,18 +991,22 @@ public class ApplicationDao {
|
|||||||
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
||||||
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||||
|
|
||||||
|
EmailLogRequest emailLogRequest=emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(),RecipientTypeEnum.PROPERTIES,null,userEntity.getEmail(),userEntity.getId(),applicationEntity.getId(),null,applicationEntity.getCall().getId());
|
||||||
|
|
||||||
// mailUtil.sendByMailGun(subject, body, List.of(defaultSystemReceiverEmail), null);
|
// mailUtil.sendByMailGun(subject, body, List.of(defaultSystemReceiverEmail), null);
|
||||||
// mailUtil.sendByMailGun(subject, body, List.of(gepafinEmail), null);
|
// mailUtil.sendByMailGun(subject, body, List.of(gepafinEmail), null);
|
||||||
// mailUtil.sendByMailGun(subject, body, List.of(rinaldoEmail), null);
|
// mailUtil.sendByMailGun(subject, body, List.of(rinaldoEmail), null);
|
||||||
if(validator.isProductionProfileActivated()) {
|
if(validator.isProductionProfileActivated()) {
|
||||||
|
emailLogRequest.setRecipientEmails(carloEmail);
|
||||||
// mailUtil.sendByMailGun(subject, body, List.of(carloEmail), null);
|
// mailUtil.sendByMailGun(subject, body, List.of(carloEmail), null);
|
||||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(carloEmail));
|
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(carloEmail),emailLogRequest);
|
||||||
}
|
}
|
||||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(hub.getEmail()));
|
emailLogRequest.setRecipientEmails(hub.getEmail());
|
||||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(defaultSystemReceiverEmail));
|
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(hub.getEmail()),emailLogRequest);
|
||||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(rinaldoEmail));
|
emailLogRequest.setRecipientEmails(defaultSystemReceiverEmail);
|
||||||
|
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(defaultSystemReceiverEmail),emailLogRequest);
|
||||||
|
emailLogRequest.setRecipientEmails(rinaldoEmail);
|
||||||
|
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(rinaldoEmail),emailLogRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId, MultipartFile file) {
|
public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId, MultipartFile file) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import net.gepafin.tendermanagement.model.request.*;
|
|||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.repositories.*;
|
import net.gepafin.tendermanagement.repositories.*;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
|
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||||
import net.gepafin.tendermanagement.service.CallService;
|
import net.gepafin.tendermanagement.service.CallService;
|
||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||||
@@ -81,6 +82,9 @@ public class ApplicationEvaluationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FormDao formDao;
|
private FormDao formDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AssignedApplicationsService assignedApplicationsService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LoggingUtil loggingUtil;
|
private LoggingUtil loggingUtil;
|
||||||
|
|
||||||
@@ -91,7 +95,7 @@ public class ApplicationEvaluationDao {
|
|||||||
|
|
||||||
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||||
|
|
||||||
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplciationId).orElse(null);
|
AssignedApplicationsEntity assignedApplications = assignedApplicationsService.validateAssignedApplication(assignedApplciationId);
|
||||||
ApplicationEntity application = applicationService.validateApplication(assignedApplications.getApplication().getId());
|
ApplicationEntity application = applicationService.validateApplication(assignedApplications.getApplication().getId());
|
||||||
entity.setApplicationId(application.getId());
|
entity.setApplicationId(application.getId());
|
||||||
entity.setAssignedApplicationsEntity(assignedApplications);
|
entity.setAssignedApplicationsEntity(assignedApplications);
|
||||||
@@ -100,6 +104,7 @@ public class ApplicationEvaluationDao {
|
|||||||
entity.setChecklist(Utils.convertObjectToJson(req.getChecklist()));
|
entity.setChecklist(Utils.convertObjectToJson(req.getChecklist()));
|
||||||
entity.setFile(Utils.convertObjectToJson(req.getFiles()));
|
entity.setFile(Utils.convertObjectToJson(req.getFiles()));
|
||||||
entity.setNote(req.getNote());
|
entity.setNote(req.getNote());
|
||||||
|
entity.setMotivation(req.getMotivation());
|
||||||
entity.setIsDeleted(false);
|
entity.setIsDeleted(false);
|
||||||
entity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
entity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
||||||
return entity;
|
return entity;
|
||||||
@@ -131,6 +136,7 @@ public class ApplicationEvaluationDao {
|
|||||||
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(entity.getAssignedApplicationsEntity().getId()).orElse(null);
|
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(entity.getAssignedApplicationsEntity().getId()).orElse(null);
|
||||||
response.setAssignedApplicationId(assignedApplications.getId());
|
response.setAssignedApplicationId(assignedApplications.getId());
|
||||||
response.setNote(entity.getNote());
|
response.setNote(entity.getNote());
|
||||||
|
response.setMotivation(entity.getMotivation());
|
||||||
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus()));
|
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus()));
|
||||||
response.setCreatedDate(entity.getCreatedDate());
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
response.setUpdatedDate(entity.getUpdatedDate());
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
@@ -253,6 +259,7 @@ public class ApplicationEvaluationDao {
|
|||||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||||
|
|
||||||
for (String docId : documentIds) {
|
for (String docId : documentIds) {
|
||||||
|
if (Boolean.FALSE.equals(docId.isEmpty())){
|
||||||
Long documentId = Long.valueOf(docId.trim());
|
Long documentId = Long.valueOf(docId.trim());
|
||||||
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||||
DocumentResponseBean responseBean = new DocumentResponseBean();
|
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||||
@@ -267,6 +274,7 @@ public class ApplicationEvaluationDao {
|
|||||||
documentResponseBeans.add(responseBean);
|
documentResponseBeans.add(responseBean);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mappedField.setFieldValue(documentResponseBeans);
|
mappedField.setFieldValue(documentResponseBeans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -355,6 +363,7 @@ public class ApplicationEvaluationDao {
|
|||||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||||
|
|
||||||
for (String docId : documentIds) {
|
for (String docId : documentIds) {
|
||||||
|
if (Boolean.FALSE.equals(docId.isEmpty())){
|
||||||
Long documentId = Long.valueOf(docId.trim());
|
Long documentId = Long.valueOf(docId.trim());
|
||||||
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||||
DocumentResponseBean responseBean = new DocumentResponseBean();
|
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||||
@@ -369,6 +378,7 @@ public class ApplicationEvaluationDao {
|
|||||||
documentResponseBeans.add(responseBean);
|
documentResponseBeans.add(responseBean);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fieldResponse.setFileDetail(documentResponseBeans);
|
fieldResponse.setFileDetail(documentResponseBeans);
|
||||||
}
|
}
|
||||||
@@ -435,6 +445,7 @@ public class ApplicationEvaluationDao {
|
|||||||
entity.setFile(Utils.convertObjectToJson(filterNonNullFields(processField(entity, req))));
|
entity.setFile(Utils.convertObjectToJson(filterNonNullFields(processField(entity, req))));
|
||||||
entity.setIsDeleted(false);
|
entity.setIsDeleted(false);
|
||||||
setIfUpdated(entity::getNote, entity::setNote, req.getNote());
|
setIfUpdated(entity::getNote, entity::setNote, req.getNote());
|
||||||
|
setIfUpdated(entity::getMotivation, entity::setMotivation, req.getMotivation());
|
||||||
actionType = VersionActionTypeEnum.UPDATE;
|
actionType = VersionActionTypeEnum.UPDATE;
|
||||||
} else {
|
} else {
|
||||||
entity = convertToEntity(user, req, assignedApplicationId);
|
entity = convertToEntity(user, req, assignedApplicationId);
|
||||||
@@ -640,6 +651,7 @@ public class ApplicationEvaluationDao {
|
|||||||
response.setApplicationId(application.getId());
|
response.setApplicationId(application.getId());
|
||||||
response.setAssignedApplicationId(assignedApplications.getId());
|
response.setAssignedApplicationId(assignedApplications.getId());
|
||||||
response.setNote(null);
|
response.setNote(null);
|
||||||
|
response.setMotivation(null);
|
||||||
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus()));
|
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus()));
|
||||||
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.OPEN.getValue()));
|
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.OPEN.getValue()));
|
||||||
response.setMinScore(call.getThreshold()!=null?call.getThreshold():null);
|
response.setMinScore(call.getThreshold()!=null?call.getThreshold():null);
|
||||||
@@ -900,6 +912,7 @@ public class ApplicationEvaluationDao {
|
|||||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||||
|
|
||||||
for (String docId : documentIds) {
|
for (String docId : documentIds) {
|
||||||
|
if (Boolean.FALSE.equals(docId.isEmpty())) {
|
||||||
Long documentId = Long.valueOf(docId.trim());
|
Long documentId = Long.valueOf(docId.trim());
|
||||||
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||||
DocumentResponseBean responseBean = new DocumentResponseBean();
|
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||||
@@ -914,6 +927,7 @@ public class ApplicationEvaluationDao {
|
|||||||
documentResponseBeans.add(responseBean);
|
documentResponseBeans.add(responseBean);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fieldResponse.setFileDetail(documentResponseBeans);
|
fieldResponse.setFileDetail(documentResponseBeans);
|
||||||
}
|
}
|
||||||
@@ -1259,6 +1273,7 @@ public class ApplicationEvaluationDao {
|
|||||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||||
|
|
||||||
for (String docId : documentIds) {
|
for (String docId : documentIds) {
|
||||||
|
if (Boolean.FALSE.equals(docId.isEmpty())){
|
||||||
Long documentId = Long.valueOf(docId.trim());
|
Long documentId = Long.valueOf(docId.trim());
|
||||||
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||||
DocumentResponseBean responseBean = new DocumentResponseBean();
|
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||||
@@ -1273,7 +1288,7 @@ public class ApplicationEvaluationDao {
|
|||||||
documentResponseBeans.add(responseBean);
|
documentResponseBeans.add(responseBean);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fieldResponse.setFileDetail(documentResponseBeans);
|
fieldResponse.setFileDetail(documentResponseBeans);
|
||||||
fieldResponses.add(fieldResponse);
|
fieldResponses.add(fieldResponse);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.gepafin.tendermanagement.entities.FaqEntity;
|
|||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||||
@@ -53,6 +54,10 @@ public class AssignedApplicationsDao {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEvaluationDao applicationEvaluationDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LoggingUtil loggingUtil;
|
private LoggingUtil loggingUtil;
|
||||||
|
|
||||||
@@ -85,7 +90,7 @@ public class AssignedApplicationsDao {
|
|||||||
UserEntity user = userService.validateUser(userId);
|
UserEntity user = userService.validateUser(userId);
|
||||||
AssignedApplicationsEntity assignment = createAssignmentEntity(application, user.getId(), assignedByUser, assignedApplicationsRequest);
|
AssignedApplicationsEntity assignment = createAssignmentEntity(application, user.getId(), assignedByUser, assignedApplicationsRequest);
|
||||||
AssignedApplicationsResponse assignApplicationToInstructorResponse = convertEntityToResponse(assignment);
|
AssignedApplicationsResponse assignApplicationToInstructorResponse = convertEntityToResponse(assignment);
|
||||||
|
applicationEvaluationDao.createOrUpdateApplicationEvaluation(user, new ApplicationEvaluationRequest(), assignApplicationToInstructorResponse.getId());
|
||||||
log.info("Application assigned succesfully {}", assignApplicationToInstructorResponse);
|
log.info("Application assigned succesfully {}", assignApplicationToInstructorResponse);
|
||||||
return assignApplicationToInstructorResponse;
|
return assignApplicationToInstructorResponse;
|
||||||
}
|
}
|
||||||
@@ -150,6 +155,7 @@ public class AssignedApplicationsDao {
|
|||||||
assignedApplicationsResponse.setAssignedAt(assignedApplications.getAssignedAt());
|
assignedApplicationsResponse.setAssignedAt(assignedApplications.getAssignedAt());
|
||||||
assignedApplicationsResponse.setProtocolNumber(protocolNumber);
|
assignedApplicationsResponse.setProtocolNumber(protocolNumber);
|
||||||
assignedApplicationsResponse.setCallName(callName);
|
assignedApplicationsResponse.setCallName(callName);
|
||||||
|
assignedApplicationsResponse.setCompanyName(application.getCompany().getCompanyName());
|
||||||
assignedApplicationsResponse.setBeneficiaryName(beneficiaryName);
|
assignedApplicationsResponse.setBeneficiaryName(beneficiaryName);
|
||||||
assignedApplicationsResponse.setSubmissionDate(submissionDate);
|
assignedApplicationsResponse.setSubmissionDate(submissionDate);
|
||||||
assignedApplicationsResponse.setCallEndDate(callEndDate);
|
assignedApplicationsResponse.setCallEndDate(callEndDate);
|
||||||
@@ -188,13 +194,16 @@ public class AssignedApplicationsDao {
|
|||||||
.map(entity -> convertEntityToResponse(entity))
|
.map(entity -> convertEntityToResponse(entity))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Specification<AssignedApplicationsEntity> search(Long hubId, Long userId) {
|
private Specification<AssignedApplicationsEntity> search(Long hubId, Long userId) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId));
|
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId));
|
||||||
}
|
}
|
||||||
|
query.orderBy(
|
||||||
|
builder.desc(builder.isNotNull(root.get(GepafinConstant.ASSIGNED_AT))),
|
||||||
|
builder.desc(root.get(GepafinConstant.ASSIGNED_AT))
|
||||||
|
);
|
||||||
predicate = builder.and(predicate, builder.equal(root.get("application").get("hubId"), hubId));
|
predicate = builder.and(predicate, builder.equal(root.get("application").get("hubId"), hubId));
|
||||||
return predicate;
|
return predicate;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -721,13 +721,29 @@ public class CallDao {
|
|||||||
return createCallResponseBean;
|
return createCallResponseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,UserEntity user, Long companyId) {
|
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,UserEntity user, Long companyId,Boolean onlyPreferredCall) {
|
||||||
String type = user.getRoleEntity().getRoleType();
|
String type = user.getRoleEntity().getRoleType();
|
||||||
List<String> callStatusList = CallStatusEnum.getStatusValues();
|
List<String> callStatusList = CallStatusEnum.getStatusValues();
|
||||||
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
|
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
|
||||||
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue());
|
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue());
|
||||||
}
|
}
|
||||||
List<CallEntity> calls = callRepository.findByStatusInAndHubId(callStatusList, user.getHub().getId());
|
List<CallEntity> calls;
|
||||||
|
if (Boolean.TRUE.equals(onlyPreferredCall) && companyId == null) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(onlyPreferredCall)) {
|
||||||
|
validator.validateUserWithCompany(request, companyId);
|
||||||
|
List<BeneficiaryPreferredCallEntity> preferredCalls = beneficiaryPreferredCallRepository
|
||||||
|
.findByUserIdAndCompanyIdAndIsDeletedFalse(user.getId(), companyId);
|
||||||
|
List<Long> preferredCallIds = preferredCalls.stream()
|
||||||
|
.map(BeneficiaryPreferredCallEntity::getCallId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
calls = callRepository.findByIdInAndStatusIn(preferredCallIds, callStatusList);
|
||||||
|
} else {
|
||||||
|
calls = callRepository.findByStatusInAndHubId(callStatusList, user.getHub().getId());
|
||||||
|
}
|
||||||
List<Long> callIds = calls.stream().map(CallEntity::getId).collect(Collectors.toList());
|
List<Long> callIds = calls.stream().map(CallEntity::getId).collect(Collectors.toList());
|
||||||
Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap =
|
Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap =
|
||||||
getBeneficiaryPreferredCallsForUser(request,user, callIds, companyId);
|
getBeneficiaryPreferredCallsForUser(request,user, callIds, companyId);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||||
@@ -9,6 +10,7 @@ import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
|
|||||||
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
|
||||||
import net.gepafin.tendermanagement.repositories.CommunicationRepository;
|
import net.gepafin.tendermanagement.repositories.CommunicationRepository;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
||||||
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -27,9 +29,12 @@ public class CommunicationDao {
|
|||||||
private CommunicationRepository communicationRepository;
|
private CommunicationRepository communicationRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ApplicationAmendmentRequestService applicationAmendmentRequestService;
|
private ApplicationAmendmentRequestService applicationAmendmentRequestService;
|
||||||
|
|
||||||
public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationReq, Long amendmentId) {
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
|
public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationReq, Long amendmentId) {
|
||||||
|
|
||||||
log.info("Adding communication request...");
|
log.info("Adding communication request...");
|
||||||
CommunicationEntity communicationEntity = convertToCommunicationCommentEntity(communicationReq, amendmentId);
|
CommunicationEntity communicationEntity = convertToCommunicationCommentEntity(communicationReq, amendmentId);
|
||||||
@@ -85,18 +90,28 @@ public class CommunicationDao {
|
|||||||
response.setCreatedDate(entity.getCreatedDate());
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
response.setUpdatedDate(entity.getUpdatedDate());
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
response.setTitle(entity.getCommunicationTitle());
|
response.setTitle(entity.getCommunicationTitle());
|
||||||
|
response.setSenderUserId(entity.getSenderUserId());
|
||||||
|
response.setReceiverUserId(entity.getReceiverUserId());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommunicationEntity convertToCommunicationCommentEntity(CommunicationRequestBean communicationReq, Long amendmentId) {
|
private CommunicationEntity convertToCommunicationCommentEntity(CommunicationRequestBean communicationReq, Long amendmentId) {
|
||||||
|
|
||||||
ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestService.validateApplicationAmendmentRequest(amendmentId);
|
ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestService.validateApplicationAmendmentRequest(amendmentId);
|
||||||
|
|
||||||
CommunicationEntity communicationEntity = new CommunicationEntity();
|
CommunicationEntity communicationEntity = new CommunicationEntity();
|
||||||
communicationEntity.setApplicationAmendmentRequest(amendmentRequest);
|
communicationEntity.setApplicationAmendmentRequest(amendmentRequest);
|
||||||
communicationEntity.setCommunicationTitle(communicationReq.getTitle());
|
communicationEntity.setCommunicationTitle(communicationReq.getTitle());
|
||||||
communicationEntity.setCommunicationComment(communicationReq.getComment());
|
communicationEntity.setCommunicationComment(communicationReq.getComment());
|
||||||
communicationEntity.setIsDeleted(false);
|
communicationEntity.setIsDeleted(false);
|
||||||
communicationEntity.setCommentedDate(LocalDateTime.now());
|
communicationEntity.setCommentedDate(LocalDateTime.now());
|
||||||
|
if(validator.checkIsPreInstructor()){
|
||||||
|
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
|
||||||
|
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||||
|
} else if(validator.checkIsBeneficiary()) {
|
||||||
|
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||||
|
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
|
||||||
|
}
|
||||||
return communicationEntity;
|
return communicationEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class DocumentDao {
|
|||||||
|
|
||||||
|
|
||||||
public DocumentEntity validateDocument(Long id) {
|
public DocumentEntity validateDocument(Long id) {
|
||||||
return documentRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
return documentRepository.findByIdAndNotDeleted(id).orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND)));
|
Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailEntityTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.RecipientTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||||
|
import net.gepafin.tendermanagement.repositories.EmailLogRepository;
|
||||||
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
|
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class EmailLogDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailLogRepository emailLogRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public EmailLogEntity createEmailLog(EmailLogRequest emailLogRequest) {
|
||||||
|
|
||||||
|
EmailLogEntity emailLogEntity = new EmailLogEntity();
|
||||||
|
emailLogEntity.setEmailType(emailLogRequest.getEmailType().getValue());
|
||||||
|
emailLogEntity.setRecipientType(emailLogRequest.getRecipientType().getValue());
|
||||||
|
emailLogEntity.setRecipientId(emailLogRequest.getRecipientId());
|
||||||
|
emailLogEntity.setEmailSubject(emailLogRequest.getEmailSubject());
|
||||||
|
emailLogEntity.setEmailBody(emailLogRequest.getEmailBody());
|
||||||
|
emailLogEntity.setSendStatus(emailLogRequest.getSendStatus());
|
||||||
|
emailLogEntity.setSendDateTime(DateTimeUtil.DateServerToUTC(LocalDateTime.now())); // Set to now if null
|
||||||
|
emailLogEntity.setErrorMessage(emailLogRequest.getErrorMessage());
|
||||||
|
emailLogEntity.setUserId(emailLogRequest.getUserId());
|
||||||
|
emailLogEntity.setEmailServiceResponse(emailLogRequest.getEmailServiceResponse());
|
||||||
|
emailLogEntity.setRecipientEmails(emailLogRequest.getRecipientEmails());
|
||||||
|
emailLogEntity.setEmailServiceType(emailLogRequest.getEmailServiceType().getValue());
|
||||||
|
emailLogEntity.setIsDeleted(false);
|
||||||
|
emailLogEntity.setApplicationId(emailLogRequest.getApplicatioId());
|
||||||
|
emailLogEntity.setAmendmentId(emailLogRequest.getAmendmentId());
|
||||||
|
emailLogEntity.setCallId(emailLogRequest.getCallId());
|
||||||
|
emailLogEntity = saveEmailLogEntity(emailLogEntity);
|
||||||
|
|
||||||
|
return emailLogEntity;
|
||||||
|
}
|
||||||
|
public EmailLogEntity saveEmailLogEntity(EmailLogEntity emailLogEntity){
|
||||||
|
return emailLogRepository.save(emailLogEntity);
|
||||||
|
}
|
||||||
|
public EmailLogRequest createEmailLogRequest(EmailScenarioTypeEnum emailType, RecipientTypeEnum recipientType, Long recipientId,
|
||||||
|
String recipientEmails, Long userId,Long applicationId,Long amendmentId,Long callId) {
|
||||||
|
EmailLogRequest emailLogRequest = new EmailLogRequest();
|
||||||
|
emailLogRequest.setEmailType(emailType);
|
||||||
|
emailLogRequest.setRecipientType(recipientType);
|
||||||
|
emailLogRequest.setRecipientId(recipientId);
|
||||||
|
emailLogRequest.setUserId(userId);
|
||||||
|
emailLogRequest.setRecipientEmails(recipientEmails);
|
||||||
|
emailLogRequest.setApplicatioId(applicationId);
|
||||||
|
emailLogRequest.setAmendmentId(amendmentId);
|
||||||
|
emailLogRequest.setCallId(callId);
|
||||||
|
return emailLogRequest;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,14 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.*;
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailEntityTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.RecipientTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.StatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
||||||
|
import net.gepafin.tendermanagement.repositories.EmailLogRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.HubRepository;
|
import net.gepafin.tendermanagement.repositories.HubRepository;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.service.HubService;
|
import net.gepafin.tendermanagement.service.HubService;
|
||||||
@@ -21,10 +27,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class EmailNotificationDao {
|
public class EmailNotificationDao {
|
||||||
@@ -49,8 +53,15 @@ public class EmailNotificationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
HubRepository hubRepository;
|
HubRepository hubRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailLogDao emailLogDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailLogRepository emailLogRepository;
|
||||||
|
|
||||||
|
|
||||||
private void sendEmail(ApplicationEntity applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType,
|
private void sendEmail(ApplicationEntity applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType,
|
||||||
Map<String, String> bodyPlaceholders, List<String> additionalRecipients) {
|
Map<String, String> bodyPlaceholders, List<String> additionalRecipients,Long amendmentId) {
|
||||||
|
|
||||||
HubEntity hubEntity = hubService.valdateHub(applicationEntity.getHubId());
|
HubEntity hubEntity = hubService.valdateHub(applicationEntity.getHubId());
|
||||||
String service = determineService(applicationEntity.getHubId());
|
String service = determineService(applicationEntity.getHubId());
|
||||||
@@ -66,7 +77,8 @@ public class EmailNotificationDao {
|
|||||||
|
|
||||||
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
||||||
List<String> recipientEmails = getRecipientEmails(applicationEntity, userEntity, additionalRecipients);
|
List<String> recipientEmails = getRecipientEmails(applicationEntity, userEntity, additionalRecipients);
|
||||||
sendMail(applicationEntity.getHubId(), subject, body, recipientEmails);
|
EmailLogRequest emailLogRequest=emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.BENEFICIARY,userEntity.getBeneficiary().getId(),Utils.listToCommaSeparatedString(recipientEmails),userEntity.getId(),applicationEntity.getId(),amendmentId ,applicationEntity.getCall().getId());
|
||||||
|
sendMail(applicationEntity.getHubId(), subject, body, recipientEmails,emailLogRequest);
|
||||||
}
|
}
|
||||||
private List<String> getRecipientEmails(ApplicationEntity applicationEntity, UserEntity userEntity, List<String> additionalRecipients) {
|
private List<String> getRecipientEmails(ApplicationEntity applicationEntity, UserEntity userEntity, List<String> additionalRecipients) {
|
||||||
List<String> recipientEmails = new ArrayList<>();
|
List<String> recipientEmails = new ArrayList<>();
|
||||||
@@ -125,17 +137,24 @@ public class EmailNotificationDao {
|
|||||||
log.error("Failed to parse form fields JSON: ", e);
|
log.error("Failed to parse form fields JSON: ", e);
|
||||||
}
|
}
|
||||||
bodyPlaceholders.put("{{note}}", applicationAmendmentRequest.getNote());
|
bodyPlaceholders.put("{{note}}", applicationAmendmentRequest.getNote());
|
||||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, bodyPlaceholders, null);
|
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, bodyPlaceholders, null,applicationAmendmentRequest.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendApplicationFailureNotificationEmail(ApplicationAmendmentRequestEntity amendmentRequest) {
|
public void sendApplicationFailureNotificationEmail(ApplicationAmendmentRequestEntity amendmentRequest) {
|
||||||
|
|
||||||
ApplicationEntity applicationEntity = applicationService.validateApplication(amendmentRequest.getApplicationId());
|
ApplicationEntity applicationEntity = applicationService.validateApplication(amendmentRequest.getApplicationId());
|
||||||
|
UserEntity user = userService.validateUser(applicationEntity.getUserId());
|
||||||
Map<String, String> bodyPlaceholders = new HashMap<>();
|
Map<String, String> bodyPlaceholders = new HashMap<>();
|
||||||
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
||||||
bodyPlaceholders.put("{{date_time_emailSend}}", DateTimeUtil.formatLocalDateTime(amendmentRequest.getCreatedDate(), GepafinConstant.DD_MM_YYYY_HH_MM));
|
LocalDateTime lastReminderDateTime=amendmentRequest.getCreatedDate();
|
||||||
|
List<EmailLogEntity> emailLogEntity = emailLogRepository.findByUserIdAndAmendmentIdAndIsDeletedFalse(user.getId(),amendmentRequest.getId());
|
||||||
|
if(emailLogEntity!=null && (!emailLogEntity.isEmpty())){
|
||||||
|
EmailLogEntity emailLogEntity1=emailLogEntity.get(0);
|
||||||
|
lastReminderDateTime=emailLogEntity1.getSendDateTime();
|
||||||
|
}
|
||||||
|
bodyPlaceholders.put("{{date_time_emailSend}}", DateTimeUtil.formatLocalDateTime(lastReminderDateTime, GepafinConstant.DD_MM_YYYY));
|
||||||
|
|
||||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, bodyPlaceholders, null);
|
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, bodyPlaceholders, null,amendmentRequest.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendAdmissibilityNotificationEmailForApprovedApplication(ApplicationEntity applicationEntity) {
|
public void sendAdmissibilityNotificationEmailForApprovedApplication(ApplicationEntity applicationEntity) {
|
||||||
@@ -145,7 +164,7 @@ public class EmailNotificationDao {
|
|||||||
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatCreatedDate(applicationEntity.getProtocol().getCreatedDate()));
|
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatCreatedDate(applicationEntity.getProtocol().getCreatedDate()));
|
||||||
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
||||||
|
|
||||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.ADMISSIBILITY_NOTIFICATION, bodyPlaceholders, null);
|
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.ADMISSIBILITY_NOTIFICATION, bodyPlaceholders, null,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendInadmissibilityEmailForRejectedApplication(ApplicationEntity applicationEntity,ApplicationEvaluationEntity applicationEvaluationEntity) {
|
public void sendInadmissibilityEmailForRejectedApplication(ApplicationEntity applicationEntity,ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||||
@@ -156,13 +175,14 @@ public class EmailNotificationDao {
|
|||||||
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
|
||||||
bodyPlaceholders.put("{{form_text}}", applicationEvaluationEntity.getNote());
|
bodyPlaceholders.put("{{form_text}}", applicationEvaluationEntity.getNote());
|
||||||
|
|
||||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE, bodyPlaceholders, null);
|
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE, bodyPlaceholders, null,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMail(Long hubId, String subject, String body, List<String> recipientEmails) {
|
public void sendMail(Long hubId, String subject, String body, List<String> recipientEmails, EmailLogRequest emailLogRequest) {
|
||||||
|
|
||||||
EmailConfig emailConfig = retrieveEmailConfig(hubId);
|
EmailConfig emailConfig = retrieveEmailConfig(hubId);
|
||||||
EmailService emailService = emailServiceFactory.getEmailService(emailConfig.getEmailServiceType());
|
EmailService emailService = emailServiceFactory.getEmailService(emailConfig.getEmailServiceType());
|
||||||
|
emailService.sendEmail(subject, body, recipientEmails, emailConfig,emailLogRequest);
|
||||||
// emailService.sendEmail(subject, body, recipientEmails, emailConfig);
|
// emailService.sendEmail(subject, body, recipientEmails, emailConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -78,6 +79,7 @@ public class SystemEmailTemplatesDao {
|
|||||||
systemEmailTemplateResponse.setHtmlContent(htmlContent);
|
systemEmailTemplateResponse.setHtmlContent(htmlContent);
|
||||||
systemEmailTemplateResponse.setSubject(subject);
|
systemEmailTemplateResponse.setSubject(subject);
|
||||||
systemEmailTemplateResponse.setJsonMap(languageMap);
|
systemEmailTemplateResponse.setJsonMap(languageMap);
|
||||||
|
systemEmailTemplateResponse.setEmailScenario(EmailScenarioTypeEnum.valueOf(dbSystemEmailTemplatesEntity.getEmailScenario()));
|
||||||
return systemEmailTemplateResponse;
|
return systemEmailTemplateResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ public class ApplicationEvaluationEntity extends BaseEntity{
|
|||||||
@Column(name = "status")
|
@Column(name = "status")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
@Column(name = "MOTIVATION")
|
||||||
|
private String motivation;
|
||||||
|
|
||||||
@Column(name="IS_DELETED")
|
@Column(name="IS_DELETED")
|
||||||
private Boolean isDeleted;
|
private Boolean isDeleted;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ public class CommunicationEntity extends BaseEntity {
|
|||||||
@Column(name = "COMMENTED_DATE")
|
@Column(name = "COMMENTED_DATE")
|
||||||
private LocalDateTime commentedDate;
|
private LocalDateTime commentedDate;
|
||||||
|
|
||||||
|
@Column(name = "SENDER_USER_ID")
|
||||||
|
private Long senderUserId;
|
||||||
|
|
||||||
|
@Column(name = "RECEIVER_USER_ID")
|
||||||
|
private Long receiverUserId;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "AMENDMENT_ID", referencedColumnName = "id", nullable = false)
|
@JoinColumn(name = "AMENDMENT_ID", referencedColumnName = "id", nullable = false)
|
||||||
private ApplicationAmendmentRequestEntity applicationAmendmentRequest;
|
private ApplicationAmendmentRequestEntity applicationAmendmentRequest;
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Table(name = "email_log")
|
||||||
|
public class EmailLogEntity extends BaseEntity{
|
||||||
|
|
||||||
|
@Column(name = "email_type", nullable = false, length = 255)
|
||||||
|
private String emailType;
|
||||||
|
|
||||||
|
@Column(name = "recipient_type", nullable = false, columnDefinition = "TEXT")
|
||||||
|
private String recipientType;
|
||||||
|
|
||||||
|
@Column(name = "recipient_id", nullable = false)
|
||||||
|
private Long recipientId;
|
||||||
|
|
||||||
|
@Column(name = "email_subject", columnDefinition = "TEXT")
|
||||||
|
private String emailSubject;
|
||||||
|
|
||||||
|
@Column(name = "email_body", columnDefinition = "TEXT")
|
||||||
|
private String emailBody;
|
||||||
|
|
||||||
|
@Column(name = "send_status", length = 255)
|
||||||
|
private String sendStatus;
|
||||||
|
|
||||||
|
@Column(name = "send_date_time")
|
||||||
|
private LocalDateTime sendDateTime;
|
||||||
|
|
||||||
|
@Column(name = "error_message", columnDefinition = "TEXT")
|
||||||
|
private String errorMessage;
|
||||||
|
|
||||||
|
@Column(name = "email_service_response")
|
||||||
|
private String emailServiceResponse;
|
||||||
|
|
||||||
|
@Column(name = "email_service_type")
|
||||||
|
private String emailServiceType;
|
||||||
|
|
||||||
|
@Column(name = "recipient_emails")
|
||||||
|
private String recipientEmails;
|
||||||
|
|
||||||
|
@Column(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Column(name = "application_id")
|
||||||
|
private Long applicationId;
|
||||||
|
|
||||||
|
@Column(name = "amendment_id")
|
||||||
|
private Long amendmentId;
|
||||||
|
|
||||||
|
@Column(name = "call_id")
|
||||||
|
private Long callId;
|
||||||
|
|
||||||
|
@Column(name = "is_deleted")
|
||||||
|
private Boolean isDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -36,6 +36,9 @@ public class SystemEmailTemplatesEntity extends BaseEntity {
|
|||||||
@Column(name ="IS_DELETED", nullable = false)
|
@Column(name ="IS_DELETED", nullable = false)
|
||||||
private Boolean isDeleted = false;
|
private Boolean isDeleted = false;
|
||||||
|
|
||||||
|
@Column(name = "email_scenario")
|
||||||
|
private String emailScenario;
|
||||||
|
|
||||||
public enum SystemEmailTemplatesEntityTypeEnum {
|
public enum SystemEmailTemplatesEntityTypeEnum {
|
||||||
|
|
||||||
APPLICATION_SUBMISSION_TO_USER_AND_COMPANY("APPLICATION_SUBMISSION_TO_USER_AND_COMPANY"),
|
APPLICATION_SUBMISSION_TO_USER_AND_COMPANY("APPLICATION_SUBMISSION_TO_USER_AND_COMPANY"),
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum EmailEntityTypeEnum {
|
||||||
|
|
||||||
|
AMENDMENT("AMENDMENT"),
|
||||||
|
APPLICATION("APPLICATION");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
EmailEntityTypeEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum EmailScenarioTypeEnum {
|
||||||
|
|
||||||
|
APPLICATION_SUBMITTED("APPLICATION_SUBMITTED"),
|
||||||
|
APPLICATION_AMENDMENT_REQUESTED("APPLICATION_AMENDMENT_REQUESTED"),
|
||||||
|
APPLICATION_AMENDMENT_EXPIRED("APPLICATION_AMENDMENT_EXPIRED"),
|
||||||
|
APPLICATION_AMENDMENT_REMINDER("APPLICATION_AMENDMENT_REMINDER"),
|
||||||
|
APPLICATION_APPROVED("APPLICATION_APPROVED"),
|
||||||
|
APPLICATION_REJECTED("APPLICATION_REJECTED");
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
EmailScenarioTypeEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum EmailServiceTypeEnum {
|
||||||
|
|
||||||
|
MAILGUN_SERVICE("MAILGUN_SERVICE"),
|
||||||
|
PEC_SERVICE("PEC_SERVICE");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
EmailServiceTypeEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum RecipientTypeEnum {
|
||||||
|
|
||||||
|
BENEFICIARY ("BENEFICIARY"),
|
||||||
|
USER("USER"),
|
||||||
|
COMPANY("COMPANY"),
|
||||||
|
PROPERTIES("PROPERTIES");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
RecipientTypeEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum StatusTypeEnum {
|
||||||
|
|
||||||
|
SUCCESS ("SUCCESS"),
|
||||||
|
FAILED("FAILED");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
StatusTypeEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AmendmentFormField {
|
||||||
|
|
||||||
|
private String fieldId;
|
||||||
|
|
||||||
|
private String fieldValue;
|
||||||
|
|
||||||
|
private String isUploadedBy;
|
||||||
|
|
||||||
|
|
||||||
|
public enum AmendmentIsUploadedByEnum {
|
||||||
|
PRE_INSTRUCTOR("PRE_INSTRUCTOR"),
|
||||||
|
BENEFICIARY("BENEFICIARY");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
AmendmentIsUploadedByEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package net.gepafin.tendermanagement.model.request;
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ApplicationAmendmentRequestBean {
|
public class ApplicationAmendmentRequestBean {
|
||||||
private String note;
|
private String note;
|
||||||
private ApplicationFormFieldRequestBean applicationFormFields;
|
private List<ApplicationFormFieldRequestBean> applicationFormFields;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ public class ApplicationEvaluationRequest {
|
|||||||
private List<FieldRequest> files;
|
private List<FieldRequest> files;
|
||||||
private String note;
|
private String note;
|
||||||
private ApplicationStatusForEvaluation applicationStatus;
|
private ApplicationStatusForEvaluation applicationStatus;
|
||||||
|
private String motivation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class EmailConfig {
|
|||||||
private String domain;
|
private String domain;
|
||||||
private String mailgunApiUrl;
|
private String mailgunApiUrl;
|
||||||
private String pecApiUrl;
|
private String pecApiUrl;
|
||||||
|
private String url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailEntityTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.RecipientTypeEnum;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EmailLogRequest {
|
||||||
|
|
||||||
|
private EmailScenarioTypeEnum emailType;
|
||||||
|
|
||||||
|
private RecipientTypeEnum recipientType;
|
||||||
|
|
||||||
|
private Long recipientId;
|
||||||
|
|
||||||
|
private String emailSubject;
|
||||||
|
|
||||||
|
private String emailBody;
|
||||||
|
|
||||||
|
private String sendStatus;
|
||||||
|
|
||||||
|
private String errorMessage;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private String emailServiceResponse;
|
||||||
|
|
||||||
|
private EmailServiceTypeEnum emailServiceType;
|
||||||
|
|
||||||
|
private String recipientEmails;
|
||||||
|
|
||||||
|
private Long applicatioId;
|
||||||
|
|
||||||
|
private Long amendmentId;
|
||||||
|
|
||||||
|
private Long callId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EmailTrackingRequest {
|
||||||
|
|
||||||
|
private EmailLogEntity emailLogEntity;
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private Long entityId;
|
||||||
|
|
||||||
|
private String entityType;
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ public class ApplicationEvaluationResponse {
|
|||||||
private String beneficiary;
|
private String beneficiary;
|
||||||
private Long protocolNumber;
|
private Long protocolNumber;
|
||||||
private String callName;
|
private String callName;
|
||||||
|
private String motivation;
|
||||||
private LocalDateTime submissionDate;
|
private LocalDateTime submissionDate;
|
||||||
private LocalDateTime evaluationDate;
|
private LocalDateTime evaluationDate;
|
||||||
private LocalDateTime callEndDate;
|
private LocalDateTime callEndDate;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class AssignedApplicationsResponse extends BaseBean {
|
|||||||
private LocalDateTime submissionDate;
|
private LocalDateTime submissionDate;
|
||||||
private LocalDateTime callStartDate;
|
private LocalDateTime callStartDate;
|
||||||
private LocalDateTime callEndDate;
|
private LocalDateTime callEndDate;
|
||||||
|
private String companyName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ public class CommunicationResponseBean {
|
|||||||
|
|
||||||
private LocalDateTime updatedDate;
|
private LocalDateTime updatedDate;
|
||||||
|
|
||||||
|
private Long senderUserId;
|
||||||
|
|
||||||
|
private Long receiverUserId;
|
||||||
|
|
||||||
private Long amendmentId;
|
private Long amendmentId;
|
||||||
public CommunicationResponseBean(LocalDateTime commentedDate, String comment, String title, LocalDateTime createdDate, LocalDateTime updatedDate, Long amendmentId) {
|
public CommunicationResponseBean(LocalDateTime commentedDate, String comment, String title, LocalDateTime createdDate, LocalDateTime updatedDate, Long amendmentId) {
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package net.gepafin.tendermanagement.model.response;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SystemEmailTemplateResponse {
|
public class SystemEmailTemplateResponse {
|
||||||
|
|
||||||
|
EmailScenarioTypeEnum emailScenario;
|
||||||
|
|
||||||
String htmlContent;
|
String htmlContent;
|
||||||
|
|
||||||
String subject;
|
String subject;
|
||||||
|
|||||||
@@ -38,4 +38,6 @@ public interface ApplicationFormFieldRepository extends JpaRepository<Applicatio
|
|||||||
public ApplicationFormFieldEntity findByFieldId(String FieldId);
|
public ApplicationFormFieldEntity findByFieldId(String FieldId);
|
||||||
|
|
||||||
Optional<ApplicationFormFieldEntity> findByApplicationFormIdAndFieldId(Long id, String fieldId);
|
Optional<ApplicationFormFieldEntity> findByApplicationFormIdAndFieldId(Long id, String fieldId);
|
||||||
|
|
||||||
|
public List<ApplicationFormFieldEntity> findByApplicationFormIdAndFieldIdIn(Long id, List<String> fieldIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public interface BeneficiaryPreferredCallRepository extends JpaRepository<Benefi
|
|||||||
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndIsDeletedFalse(Long beneficiaryId);
|
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndIsDeletedFalse(Long beneficiaryId);
|
||||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndIsDeletedFalse(Long userId);
|
List<BeneficiaryPreferredCallEntity> findByUserIdAndIsDeletedFalse(Long userId);
|
||||||
|
|
||||||
@Query("SELECT preferredCall FROM BeneficiaryPreferredCallEntity preferredCall where preferredCall.userId=:userId AND (:companyId is null OR preferredCall.companyId=:companyId)")
|
@Query("SELECT preferredCall FROM BeneficiaryPreferredCallEntity preferredCall where preferredCall.userId=:userId AND (:companyId is null OR preferredCall.companyId=:companyId) AND isDeleted=false")
|
||||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(@Param("userId") Long userId, @Param("companyId") Long companyId);
|
List<BeneficiaryPreferredCallEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(@Param("userId") Long userId, @Param("companyId") Long companyId);
|
||||||
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndCompanyId(Long beneficiaryId,Long companyId);
|
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndCompanyId(Long beneficiaryId,Long companyId);
|
||||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List<Long> callIds);
|
List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List<Long> callIds);
|
||||||
|
|||||||
@@ -45,4 +45,6 @@ public interface CallRepository extends JpaRepository<CallEntity, Long> {
|
|||||||
|
|
||||||
@Query("SELECT COALESCE(SUM(c.amount), 0) FROM CallEntity c WHERE c.status = 'PUBLISH' And c.hub.id = :hubId")
|
@Query("SELECT COALESCE(SUM(c.amount), 0) FROM CallEntity c WHERE c.status = 'PUBLISH' And c.hub.id = :hubId")
|
||||||
BigDecimal findTotalAmountOfPublishedCallsAndHubId(@Param("hubId") Long hubId);
|
BigDecimal findTotalAmountOfPublishedCallsAndHubId(@Param("hubId") Long hubId);
|
||||||
|
@Query("SELECT c FROM CallEntity c WHERE c.id IN :ids AND c.status IN :status")
|
||||||
|
List<CallEntity> findByIdInAndStatusIn(@Param("ids") List<Long> ids, @Param("status") List<String> status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface EmailLogRepository extends JpaRepository<EmailLogEntity,Long> {
|
||||||
|
|
||||||
|
List<EmailLogEntity> findByUserIdAndAmendmentIdAndIsDeletedFalse(Long userId,Long amendmentId);
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import net.gepafin.tendermanagement.dao.EmailNotificationDao;
|
|||||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||||
@@ -41,12 +43,12 @@ public class NotificationScheduler {
|
|||||||
ApplicationAmendmentRequestEntity amendmentRequest = getAmendmentRequestForApplication(application, amendmentRequestList);
|
ApplicationAmendmentRequestEntity amendmentRequest = getAmendmentRequestForApplication(application, amendmentRequestList);
|
||||||
|
|
||||||
if (amendmentRequest != null) {
|
if (amendmentRequest != null) {
|
||||||
LocalDateTime requestDate = amendmentRequest.getCreatedDate();
|
LocalDateTime requestDate = amendmentRequest.getStartDate();
|
||||||
if (requestDate.plusDays(amendmentRequest.getResponseDays()).isAfter(today)) {
|
if (requestDate.plusDays(amendmentRequest.getResponseDays()).isBefore(today)) {
|
||||||
// Update the application status to REJECTED
|
// Update the application status to REJECTED
|
||||||
application.setStatus("REJECTED");
|
application.setStatus(ApplicationStatusTypeEnum.REJECTED.getValue());
|
||||||
applicationRepository.save(application);
|
applicationRepository.save(application);
|
||||||
amendmentRequest.setStatus("CLOSE");
|
amendmentRequest.setStatus(ApplicationAmendmentRequestEnum.CLOSE.getValue());
|
||||||
applicationAmendmentRepository.save(amendmentRequest);
|
applicationAmendmentRepository.save(amendmentRequest);
|
||||||
emailNotificationDao.sendApplicationFailureNotificationEmail(amendmentRequest);
|
emailNotificationDao.sendApplicationFailureNotificationEmail(amendmentRequest);
|
||||||
}
|
}
|
||||||
@@ -56,6 +58,6 @@ public class NotificationScheduler {
|
|||||||
|
|
||||||
private ApplicationAmendmentRequestEntity getAmendmentRequestForApplication(ApplicationEntity application, List<ApplicationAmendmentRequestEntity> amendmentRequestList) {
|
private ApplicationAmendmentRequestEntity getAmendmentRequestForApplication(ApplicationEntity application, List<ApplicationAmendmentRequestEntity> amendmentRequestList) {
|
||||||
|
|
||||||
return amendmentRequestList.stream().filter(request -> request.getId().equals(application.getId())).findFirst().orElse(null);
|
return amendmentRequestList.stream().filter(request -> request.getApplicationId().equals(application.getId())).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public interface CallService {
|
|||||||
|
|
||||||
CallResponse getCallById (HttpServletRequest request, Long callId,Long companyId);
|
CallResponse getCallById (HttpServletRequest request, Long callId,Long companyId);
|
||||||
|
|
||||||
List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId);
|
List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall);
|
||||||
|
|
||||||
CallResponse validateCallData(HttpServletRequest request, Long callId);
|
CallResponse validateCallData(HttpServletRequest request, Long callId);
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
package net.gepafin.tendermanagement.service;
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
|
||||||
|
|
||||||
public interface CommunicationService {
|
public interface CommunicationService {
|
||||||
CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean, Long amendmentId);
|
CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request ,CommunicationRequestBean communicationRequestBean, Long amendmentId);
|
||||||
|
|
||||||
String deleteComment(Long amendmentId, Long commentId);
|
String deleteComment(HttpServletRequest request,Long amendmentId, Long commentId);
|
||||||
|
|
||||||
CommunicationResponseBean updateAmendmentComment(CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId);
|
CommunicationResponseBean updateAmendmentComment(HttpServletRequest request,CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId);
|
||||||
|
|
||||||
ApplicationAmendmentResponse getAmendmentComments(Long id);
|
ApplicationAmendmentResponse getAmendmentComments(HttpServletRequest request,Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package net.gepafin.tendermanagement.service.feignClient;
|
|
||||||
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@FeignClient(name = "mailgunClient", url = "${mailGun_base_url}")
|
|
||||||
public interface MailgunFeignClient {
|
|
||||||
@PostMapping("/v3/{domain}/messages")
|
|
||||||
ResponseEntity<Void> sendEmail(
|
|
||||||
@PathVariable("domain") String domain,
|
|
||||||
@RequestParam("from") String from,
|
|
||||||
@RequestParam("to") List<String> to,
|
|
||||||
@RequestParam("subject") String subject,
|
|
||||||
@RequestParam("html") String htmlBody,
|
|
||||||
@RequestHeader("Authorization") String authorizationHeader);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package net.gepafin.tendermanagement.service.feignClient;
|
|
||||||
|
|
||||||
import feign.Headers;
|
|
||||||
import net.gepafin.tendermanagement.model.request.PecEmailRequest;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
|
||||||
|
|
||||||
@FeignClient(name = "pecClient", url = "${api.pecUrl}")
|
|
||||||
public interface PecFeignClient {
|
|
||||||
@PostMapping("/send")
|
|
||||||
ResponseEntity<Void> sendEmail(@RequestHeader("Authorization") String token,
|
|
||||||
@RequestBody PecEmailRequest emailRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -87,13 +87,12 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
|
public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
|
||||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
|
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(id);
|
||||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
|
||||||
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
|
|
||||||
|
|
||||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
|
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||||
if (entityOptional.isPresent()) {
|
validator.validatePreInstructor(request, amendment.getApplicationEvaluationEntity().getUserId());
|
||||||
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
|
} else {
|
||||||
|
validator.validateUserId(request, amendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||||
}
|
}
|
||||||
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
|
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
|
||||||
}
|
}
|
||||||
@@ -105,9 +104,9 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request, Long beneficiaryId) {
|
public List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request, Long beneficiaryUserId) {
|
||||||
UserEntity user= validator.validateUser(request);
|
UserEntity user= validator.validateUser(request);
|
||||||
return applicationAmendmentRequestDao.getAllAmendmentRequestByBeneficiaryId(beneficiaryId);
|
return applicationAmendmentRequestDao.getAllAmendmentRequestByBeneficiaryId(beneficiaryUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.gepafin.tendermanagement.service.impl;
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.dao.ApplicationDao;
|
import net.gepafin.tendermanagement.dao.ApplicationDao;
|
||||||
import net.gepafin.tendermanagement.dao.FlowFormDao;
|
import net.gepafin.tendermanagement.dao.FlowFormDao;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
@@ -17,6 +19,8 @@ import net.gepafin.tendermanagement.model.response.ApplicationSignedDocumentResp
|
|||||||
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -64,6 +68,9 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ApplicationResponse createApplication(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId) {
|
public ApplicationResponse createApplication(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId) {
|
||||||
UserEntity userEntity = validator.validateUser(request);
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
if(companyId==null){
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.USER_MUST_BE_ASSOCIATED_WITH_COMPANY));
|
||||||
|
}
|
||||||
CompanyEntity companyEntity = validator.validateUserWithCompany(request, companyId);
|
CompanyEntity companyEntity = validator.validateUserWithCompany(request, companyId);
|
||||||
validator.validateUserWithCall(userEntity, callId);
|
validator.validateUserWithCall(userEntity, callId);
|
||||||
return applicationDao.createApplicationByCallId(companyEntity, applicationRequest, callId, userEntity);
|
return applicationDao.createApplicationByCallId(companyEntity, applicationRequest, callId, userEntity);
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ public class CallServiceImpl implements CallService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId) {
|
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall) {
|
||||||
UserEntity user = validator.validateUser(request);
|
UserEntity user = validator.validateUser(request);
|
||||||
return callDao.getAllCalls(request,user,companyId);
|
return callDao.getAllCalls(request,user,companyId,onlyPreferredCall);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,76 @@
|
|||||||
package net.gepafin.tendermanagement.service.impl;
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.dao.ApplicationAmendmentRequestDao;
|
||||||
import net.gepafin.tendermanagement.dao.CommunicationDao;
|
import net.gepafin.tendermanagement.dao.CommunicationDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||||
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
|
||||||
import net.gepafin.tendermanagement.service.CommunicationService;
|
import net.gepafin.tendermanagement.service.CommunicationService;
|
||||||
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CommunicationServiceImpl implements CommunicationService {
|
public class CommunicationServiceImpl implements CommunicationService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
CommunicationDao communicationDao;
|
CommunicationDao communicationDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
Validator validator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean, Long amendmentId) {
|
public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request ,CommunicationRequestBean communicationRequestBean, Long amendmentId) {
|
||||||
|
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
|
||||||
return communicationDao.addCommentToAmendmentRequest(communicationRequestBean, amendmentId);
|
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||||
|
validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId());
|
||||||
|
} else {
|
||||||
|
validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||||
}
|
}
|
||||||
|
return communicationDao.addCommentToAmendmentRequest(request,communicationRequestBean, amendmentId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String deleteComment(Long amendmentId, Long commentId) {
|
public String deleteComment(HttpServletRequest request ,Long amendmentId, Long commentId) {
|
||||||
|
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
|
||||||
|
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||||
|
validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId());
|
||||||
|
} else {
|
||||||
|
validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||||
|
}
|
||||||
return communicationDao.deleteComment(amendmentId, commentId);
|
return communicationDao.deleteComment(amendmentId, commentId);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public CommunicationResponseBean updateAmendmentComment(CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) {
|
public CommunicationResponseBean updateAmendmentComment(HttpServletRequest request,CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) {
|
||||||
|
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
|
||||||
|
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||||
|
validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId());
|
||||||
|
} else {
|
||||||
|
validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||||
|
}
|
||||||
return communicationDao.updateAmendmentComment(communicationRequestBean, amendmentId, commentId);
|
return communicationDao.updateAmendmentComment(communicationRequestBean, amendmentId, commentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public ApplicationAmendmentResponse getAmendmentComments(Long id) {
|
public ApplicationAmendmentResponse getAmendmentComments(HttpServletRequest request,Long id) {
|
||||||
|
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(id);
|
||||||
|
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||||
|
validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId());
|
||||||
|
} else {
|
||||||
|
validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||||
|
}
|
||||||
return communicationDao.getAmendmentComments(id);
|
return communicationDao.getAmendmentComments(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class DocumentServiceImpl implements DocumentService {
|
|||||||
@Override
|
@Override
|
||||||
public void deleteFile(Long documentId) {
|
public void deleteFile(Long documentId) {
|
||||||
documentDao.deleteFile(documentId);
|
documentDao.deleteFile(documentId);
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package net.gepafin.tendermanagement.service.impl;
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface EmailService {
|
public interface EmailService {
|
||||||
void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig);
|
void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig, EmailLogRequest emailLogRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
package net.gepafin.tendermanagement.service.impl;
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import com.mashape.unirest.http.HttpResponse;
|
||||||
|
import com.mashape.unirest.http.Unirest;
|
||||||
|
import net.gepafin.tendermanagement.dao.EmailLogDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.StatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||||
import net.gepafin.tendermanagement.service.feignClient.MailgunFeignClient;
|
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||||
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@@ -15,34 +21,56 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class MailgunEmailService implements EmailService {
|
public class MailgunEmailService implements EmailService {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MailgunFeignClient mailgunFeignClient;
|
|
||||||
|
|
||||||
@Value("${isMailSendingEnabled}")
|
@Value("${isMailSendingEnabled}")
|
||||||
private String isEmailSendingEnabled;
|
private String isEmailSendingEnabled;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailLogDao emailLogDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig) {
|
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig, EmailLogRequest emailLogRequest) {
|
||||||
|
|
||||||
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String domain = emailConfig.getDomain();
|
String url = emailConfig.getUrl();
|
||||||
String from = emailConfig.getSender();
|
String from = emailConfig.getSender();
|
||||||
String apiKey = emailConfig.getApiKey();
|
String apiKey = emailConfig.getApiKey();
|
||||||
String authHeader = "Basic " + Base64.getEncoder().encodeToString(("api:" + apiKey).getBytes());
|
String authHeader = "Basic " + Base64.getEncoder().encodeToString(("api:" + apiKey).getBytes());
|
||||||
|
|
||||||
// Send email via Mailgun API
|
// Send email via Mailgun API
|
||||||
|
HttpResponse<String> response2=null;
|
||||||
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
||||||
ResponseEntity<Void> response = mailgunFeignClient.sendEmail(domain, from, recipientEmails, subject, body, authHeader);
|
emailLogRequest.setEmailSubject(subject);
|
||||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
emailLogRequest.setEmailBody(body);
|
||||||
throw new RuntimeException("Failed to send email via Mailgun: " + response.getStatusCode());
|
emailLogRequest.setSendStatus(StatusTypeEnum.SUCCESS.getValue());
|
||||||
|
emailLogRequest.setRecipientEmails(Utils.listToCommaSeparatedString(recipientEmails));
|
||||||
|
try {
|
||||||
|
Unirest.setTimeouts(0, 0);
|
||||||
|
response2 = Unirest.post(url)
|
||||||
|
.header("Authorization", authHeader)
|
||||||
|
// .header("content-type", "multipart/form-data")
|
||||||
|
.field("from", from)
|
||||||
|
.field("to", recipientEmails)
|
||||||
|
.field("subject", subject)
|
||||||
|
.field("html", body)
|
||||||
|
.asString();
|
||||||
|
}catch(Exception e) {
|
||||||
|
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||||
|
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.MAILGUN_SERVICE);
|
||||||
|
emailLogRequest.setErrorMessage(e.getMessage());
|
||||||
|
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||||
|
throw new RuntimeException("Failed to send email via Mailgun: " + response2.getStatus());
|
||||||
}
|
}
|
||||||
|
emailLogRequest.setEmailServiceResponse(response2.getBody());
|
||||||
}
|
}
|
||||||
|
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.MAILGUN_SERVICE);
|
||||||
|
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
package net.gepafin.tendermanagement.service.impl;
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import com.mashape.unirest.http.HttpResponse;
|
||||||
|
import com.mashape.unirest.http.Unirest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.gepafin.tendermanagement.dao.EmailLogDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.StatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.PecEmailRequest;
|
import net.gepafin.tendermanagement.model.request.PecEmailRequest;
|
||||||
import net.gepafin.tendermanagement.service.feignClient.PecFeignClient;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,12 +22,6 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class PecEmailService implements EmailService {
|
public class PecEmailService implements EmailService {
|
||||||
private final PecFeignClient pecFeignClient;
|
|
||||||
|
|
||||||
public PecEmailService(PecFeignClient pecFeignClient) {
|
|
||||||
|
|
||||||
this.pecFeignClient = pecFeignClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Value("${isMailSendingEnabled}")
|
@Value("${isMailSendingEnabled}")
|
||||||
private String isEmailSendingEnabled;
|
private String isEmailSendingEnabled;
|
||||||
@@ -29,8 +29,11 @@ public class PecEmailService implements EmailService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailLogDao emailLogDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig) {
|
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig, EmailLogRequest emailLogRequest) {
|
||||||
|
|
||||||
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||||
return;
|
return;
|
||||||
@@ -38,20 +41,37 @@ public class PecEmailService implements EmailService {
|
|||||||
|
|
||||||
PecEmailRequest emailRequest = new PecEmailRequest();
|
PecEmailRequest emailRequest = new PecEmailRequest();
|
||||||
emailRequest.setSender(emailConfig.getSender());
|
emailRequest.setSender(emailConfig.getSender());
|
||||||
emailRequest.setRecipient(recipientEmails);
|
|
||||||
emailRequest.setSubject(subject);
|
emailRequest.setSubject(subject);
|
||||||
emailRequest.setBody(body);
|
emailRequest.setBody(body);
|
||||||
emailRequest.setUsername(emailConfig.getUsername());
|
emailRequest.setUsername(emailConfig.getUsername());
|
||||||
emailRequest.setPassword(emailConfig.getPassword());
|
emailRequest.setPassword(emailConfig.getPassword());
|
||||||
|
emailRequest.setRecipient(recipientEmails);
|
||||||
|
String url=emailConfig.getUrl();
|
||||||
String authToken = emailConfig.getAuthToken();
|
String authToken = emailConfig.getAuthToken();
|
||||||
|
HttpResponse<String> response2=null;
|
||||||
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
||||||
ResponseEntity<Void> response = pecFeignClient.sendEmail("Bearer " + authToken, emailRequest);
|
emailLogRequest.setEmailSubject(emailRequest.getSubject());
|
||||||
log.info("Mail response status: {}, headers: {}, body: {}", response.getStatusCode(), response.getHeaders(), response.getBody());
|
emailLogRequest.setEmailBody(emailRequest.getBody());
|
||||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
emailLogRequest.setSendStatus(StatusTypeEnum.SUCCESS.getValue());
|
||||||
throw new RuntimeException("Failed to send email via PEC: " + response.getStatusCode());
|
emailLogRequest.setRecipientEmails(Utils.listToCommaSeparatedString(emailRequest.getRecipient()));
|
||||||
|
try {
|
||||||
|
Unirest.setTimeouts(0, 0);
|
||||||
|
response2 = Unirest.post(url)
|
||||||
|
.header("Authorization", "Bearer " + authToken)
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.body(Utils.convertObjectToJson(emailRequest)) // Serialize the emailRequest object to JSON
|
||||||
|
.asString();
|
||||||
|
}catch(Exception e) {
|
||||||
|
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||||
|
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.PEC_SERVICE);
|
||||||
|
emailLogRequest.setErrorMessage(e.getMessage());
|
||||||
|
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||||
|
throw new RuntimeException("Failed to send email via PEC: " + response2.getStatus());
|
||||||
}
|
}
|
||||||
|
emailLogRequest.setEmailServiceResponse(response2.getBody());
|
||||||
}
|
}
|
||||||
|
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.PEC_SERVICE);
|
||||||
|
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import net.gepafin.tendermanagement.constants.GepafinConstant;
|
|||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
@@ -44,6 +45,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientForbiddenExce
|
|||||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientUnauthorizedException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientUnauthorizedException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientValidationException;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
@@ -519,6 +521,10 @@ public class Utils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> String listToCommaSeparatedString(List<T> list) {
|
||||||
|
return String.join(", ", list.stream().map(String::valueOf).toList());
|
||||||
|
}
|
||||||
|
|
||||||
public static String convertEntityToJsonForLogging(Object entity) {
|
public static String convertEntityToJsonForLogging(Object entity) {
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public interface ApplicationAmendmentRequestApi {
|
|||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
@GetMapping(value = "/beneficiary/user/{id}", produces = "application/json")
|
@GetMapping(value = "/beneficiary/user/{id}", produces = "application/json")
|
||||||
ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request,
|
ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request,
|
||||||
@Parameter(description = "Id", required = false) @PathVariable(value = "id",required = false) Long beneficiaryId);
|
@Parameter(description = "Id", required = false) @PathVariable(value = "id",required = false) Long beneficiaryUserId);
|
||||||
@Operation(summary = "Api to extend response days for an amendment request",
|
@Operation(summary = "Api to extend response days for an amendment request",
|
||||||
responses = {
|
responses = {
|
||||||
@ApiResponse(responseCode = "200", description = "OK"),
|
@ApiResponse(responseCode = "200", description = "OK"),
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public interface ApplicationApi {
|
|||||||
@PostMapping(value = "/call/{callId}",
|
@PostMapping(value = "/call/{callId}",
|
||||||
produces = { "application/json" })
|
produces = { "application/json" })
|
||||||
ResponseEntity<Response<ApplicationResponse>> createApplicationByCallId(HttpServletRequest request,
|
ResponseEntity<Response<ApplicationResponse>> createApplicationByCallId(HttpServletRequest request,
|
||||||
@Parameter(description = "The company ID", required = true) @RequestParam(value = "companyId", required = true) Long companyId,
|
@Parameter(description = "The company ID") @RequestParam(value = "companyId", required = false) Long companyId,
|
||||||
@Parameter(description = " Flow request object", required = true) @Valid @RequestBody ApplicationRequest applicationRequest,
|
@Parameter(description = " Flow request object", required = true) @Valid @RequestBody ApplicationRequest applicationRequest,
|
||||||
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
|
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public interface CallApi {
|
|||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
@GetMapping(value = "",
|
@GetMapping(value = "",
|
||||||
produces = { "application/json" })
|
produces = { "application/json" })
|
||||||
ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,@RequestParam(value = "companyId", required = false) Long companyId);
|
ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,@RequestParam(value = "companyId", required = false) Long companyId , @RequestParam(value = "onlyPreferredCall", required = false, defaultValue = "false") Boolean onlyPreferredCall);
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "Api to validate call",
|
@Operation(summary = "Api to validate call",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
|||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -32,6 +33,7 @@ public interface CommunicationApi {
|
|||||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
@PostMapping(value = "/{amendmentId}", produces = { "application/json" })
|
@PostMapping(value = "/{amendmentId}", produces = { "application/json" })
|
||||||
|
@PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY')")
|
||||||
ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request,
|
ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request,
|
||||||
@RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId);
|
@RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId);
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ public interface CommunicationApi {
|
|||||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
|
||||||
ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) })
|
ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) })
|
||||||
@GetMapping(value = "/{amendmentId}", produces = "application/json")
|
@GetMapping(value = "/{amendmentId}", produces = "application/json")
|
||||||
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(@PathVariable(value = "amendmentId") Long amendmentId);
|
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(HttpServletRequest request,@PathVariable(value = "amendmentId") Long amendmentId);
|
||||||
|
|
||||||
@Operation(summary = "Api to update communication comments", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
@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 = {
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@@ -53,6 +55,7 @@ public interface CommunicationApi {
|
|||||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
@PutMapping(value = "/{amendmentId}/{commentId}", produces = { "application/json" })
|
@PutMapping(value = "/{amendmentId}/{commentId}", produces = { "application/json" })
|
||||||
|
@PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY')")
|
||||||
ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request,
|
ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request,
|
||||||
@RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId, @PathVariable(value = "commentId") Long commentId);
|
@RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId, @PathVariable(value = "commentId") Long commentId);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class CallApiController implements CallApi {
|
|||||||
private LoggingUtil loggingUtil;
|
private LoggingUtil loggingUtil;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor=Exception.class)
|
||||||
public ResponseEntity<Response<CallResponse>> createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
|
public ResponseEntity<Response<CallResponse>> createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
|
||||||
|
|
||||||
/** This code is responsible for creating user action logs for the "Create Call Step 1" operation. **/
|
/** This code is responsible for creating user action logs for the "Create Call Step 1" operation. **/
|
||||||
@@ -53,6 +54,7 @@ public class CallApiController implements CallApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor=Exception.class)
|
||||||
public ResponseEntity<Response<CallResponse>> createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
|
public ResponseEntity<Response<CallResponse>> createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
|
||||||
|
|
||||||
/** This code is responsible for creating user action logs for the "Create or update Call step 2" operation. **/
|
/** This code is responsible for creating user action logs for the "Create or update Call step 2" operation. **/
|
||||||
@@ -65,6 +67,7 @@ public class CallApiController implements CallApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor=Exception.class)
|
||||||
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request, Long callId, UpdateCallRequestStep1 updateCallRequest) {
|
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request, Long callId, UpdateCallRequestStep1 updateCallRequest) {
|
||||||
|
|
||||||
/** This code is responsible for creating user action logs for the "update Call step 1" operation. **/
|
/** This code is responsible for creating user action logs for the "update Call step 1" operation. **/
|
||||||
@@ -89,19 +92,19 @@ public class CallApiController implements CallApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,Long companyId) {
|
@Transactional
|
||||||
|
public ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall) {
|
||||||
|
|
||||||
|
/** This code is responsible for creating user action logs for the "get all Calls" operation. **/
|
||||||
/** This code is responsible for creating user action logs for the "get Calls" operation. **/
|
|
||||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||||
.actionContext(UserActionContextEnum.GET_CALL).build());
|
.actionContext(UserActionContextEnum.GET_CALL).build());
|
||||||
|
|
||||||
List<CallDetailsResponseBean> calls = callService.getAllCalls(request,companyId);
|
List<CallDetailsResponseBean> calls = callService.getAllCalls(request, companyId, onlyPreferredCall);
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(calls, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
|
.body(new Response<>(calls, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<CallResponse>> validateCallData(HttpServletRequest request, Long callId) {
|
public ResponseEntity<Response<CallResponse>> validateCallData(HttpServletRequest request, Long callId) {
|
||||||
|
|
||||||
|
|||||||
@@ -27,28 +27,28 @@ public class CommunicationController implements CommunicationApi {
|
|||||||
public ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationRequestBean,
|
public ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationRequestBean,
|
||||||
Long amendmentId) {
|
Long amendmentId) {
|
||||||
|
|
||||||
CommunicationResponseBean communicationResponseBean = communicationService.addCommentToAmendmentRequest(communicationRequestBean, amendmentId);
|
CommunicationResponseBean communicationResponseBean = communicationService.addCommentToAmendmentRequest(request,communicationRequestBean, amendmentId);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED)
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS)));
|
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS)));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(Long amendmentId) {
|
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(HttpServletRequest request,Long amendmentId) {
|
||||||
|
|
||||||
ApplicationAmendmentResponse response = communicationService.getAmendmentComments(amendmentId);
|
ApplicationAmendmentResponse response = communicationService.getAmendmentComments(request,amendmentId);
|
||||||
return ResponseEntity.ok(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.AMENDMENT_FOUND_SUCCESS)));
|
return ResponseEntity.ok(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.AMENDMENT_FOUND_SUCCESS)));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, CommunicationRequestBean communicationRequestBean,
|
public ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, CommunicationRequestBean communicationRequestBean,
|
||||||
Long amendmentId, Long commentId) {
|
Long amendmentId, Long commentId) {
|
||||||
|
|
||||||
CommunicationResponseBean communicationResponseBean = communicationService.updateAmendmentComment(communicationRequestBean, amendmentId, commentId);
|
CommunicationResponseBean communicationResponseBean = communicationService.updateAmendmentComment(request,communicationRequestBean, amendmentId, commentId);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_UPDATED_SUCCESS_MSG)));
|
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_UPDATED_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<String>> deleteApplicationAmendmentComment(HttpServletRequest request, Long applicationAmendId, Long commentId) {
|
public ResponseEntity<Response<String>> deleteApplicationAmendmentComment(HttpServletRequest request, Long applicationAmendId, Long commentId) {
|
||||||
|
|
||||||
String communicationResponseBean = communicationService.deleteComment(applicationAmendId, commentId);
|
String communicationResponseBean = communicationService.deleteComment(request,applicationAmendId, commentId);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_DELETED_SUCCESS_MSG)));
|
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_DELETED_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ spid.ipd.base.url=https://login.regione.umbria.it
|
|||||||
active.profile.folder=production
|
active.profile.folder=production
|
||||||
|
|
||||||
isMailSendingEnabled = true
|
isMailSendingEnabled = true
|
||||||
default_System_Receiver_Email=antonio.manca@bflows.net
|
default_System_Receiver_Email=c.moretti@gepafin.it
|
||||||
gepafin_email=bandi@pec.gepafin.it
|
gepafin_email=bandi@pec.gepafin.it
|
||||||
rinaldo_email=rinaldo.bonazzo@bflows.net
|
rinaldo_email=rinaldo.bonazzo@bflows.net
|
||||||
carlo_email=carlo.mancosu@bflows.net
|
carlo_email=carlo.mancosu@bflows.net
|
||||||
|
|||||||
@@ -1716,6 +1716,7 @@
|
|||||||
<sqlFile dbms="postgresql"
|
<sqlFile dbms="postgresql"
|
||||||
path="db/dump/update_system_email_template_for_notification_mail_04_11_2024_1.sql"/>
|
path="db/dump/update_system_email_template_for_notification_mail_04_11_2024_1.sql"/>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
<changeSet id="05-11-2024_4" author="Harish Bagora">
|
<changeSet id="05-11-2024_4" author="Harish Bagora">
|
||||||
<sqlFile dbms="postgresql"
|
<sqlFile dbms="postgresql"
|
||||||
path="db/dump/update_system_email_template_for_notification_mail_05_11_2024_4.sql"/>
|
path="db/dump/update_system_email_template_for_notification_mail_05_11_2024_4.sql"/>
|
||||||
@@ -1725,6 +1726,7 @@
|
|||||||
<dropNotNullConstraint tableName="application_amendment_request" columnName="is_email"/>
|
<dropNotNullConstraint tableName="application_amendment_request" columnName="is_email"/>
|
||||||
<dropNotNullConstraint tableName="application_amendment_request" columnName="is_notification"/>
|
<dropNotNullConstraint tableName="application_amendment_request" columnName="is_notification"/>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
<changeSet id="13-11-2024_2" author="Harish Bagora">
|
<changeSet id="13-11-2024_2" author="Harish Bagora">
|
||||||
<addColumn tableName="beneficiary_preferred_call">
|
<addColumn tableName="beneficiary_preferred_call">
|
||||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||||
@@ -1733,6 +1735,58 @@
|
|||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="15-11-2024_1" author="Nisha Kashyap">
|
||||||
|
<createTable tableName="email_log">
|
||||||
|
<column autoIncrement="true" name="id" type="INTEGER">
|
||||||
|
<constraints nullable="false" primaryKey="true"
|
||||||
|
primaryKeyName="pk_email_logs"/>
|
||||||
|
</column>
|
||||||
|
<column name="email_type" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="recipient_type" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="recipient_id" type="INTEGER">
|
||||||
|
</column>
|
||||||
|
<column name="email_subject" type="TEXT"/>
|
||||||
|
<column name="email_body" type="TEXT"/>
|
||||||
|
<column name="send_status" type="VARCHAR(255)"/>
|
||||||
|
<column name="send_date_time" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||||
|
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE" defaultValueComputed="CURRENT_TIMESTAMP"/>
|
||||||
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||||
|
<column name="email_service_response" type="TEXT"></column>
|
||||||
|
<column name="email_service_type" type="VARCHAR(255)"></column>
|
||||||
|
<column name="recipient_emails" type="TEXT"></column>
|
||||||
|
<column name="user_id" type="INTEGER"></column>
|
||||||
|
<column name="error_message" type="TEXT"/>
|
||||||
|
<column name="entity_id" type="INTEGER"></column>
|
||||||
|
<column name="entity_type" type="VARCHAR(255)"></column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet id="15-11-2024_2" author="Nisha kashyap">
|
||||||
|
<addColumn tableName="system_email_template">
|
||||||
|
<column name="email_scenario" type="VARCHAR(255)"></column>
|
||||||
|
</addColumn>
|
||||||
|
<sqlFile dbms="postgresql"
|
||||||
|
path="db/dump/updated_system_email_template_for_email_scenario_15-11-2024.sql"/>
|
||||||
|
<sqlFile dbms="postgresql"
|
||||||
|
path="db/dump/updated_hub_data_for_email_service_config_15-11-2024.sql"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="18-11-2024_1" author="Nisha Kashyap">
|
||||||
|
<addColumn tableName="email_log">
|
||||||
|
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false"></column>
|
||||||
|
<column name="application_id" type="INTEGER"></column>
|
||||||
|
<column name="amendment_id" type="INTEGER"></column>
|
||||||
|
<column name="call_id" type="INTEGER"></column>
|
||||||
|
</addColumn>
|
||||||
|
<dropColumn tableName="email_log">
|
||||||
|
<column name="entity_id"></column>
|
||||||
|
<column name="entity_type"></column>
|
||||||
|
</dropColumn>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
<changeSet id="20-11-2024_1" author="Piyush">
|
<changeSet id="20-11-2024_1" author="Piyush">
|
||||||
<createTable tableName="user_action">
|
<createTable tableName="user_action">
|
||||||
<column autoIncrement="true" name="id" type="INTEGER">
|
<column autoIncrement="true" name="id" type="INTEGER">
|
||||||
@@ -1786,6 +1840,26 @@
|
|||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="21-11-2024_1" author="Rajesh Khore">
|
||||||
|
<addColumn tableName="communication">
|
||||||
|
<column name="sender_user_id" type="INTEGER"></column>
|
||||||
|
<column name="receiver_user_id" type="INTEGER"></column>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="21-11-2024_2" author="Rajesh Khore">
|
||||||
|
<update tableName="role">
|
||||||
|
<column name="role_name" value='Instructor'/>
|
||||||
|
<where>role_type = 'ROLE_PRE_INSTRUCTOR'</where>
|
||||||
|
</update>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="22-11-2024_1" author="Rajesh Khore">
|
||||||
|
<addColumn tableName="application_evaluation">
|
||||||
|
<column name="MOTIVATION" type="TEXT"></column>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
<changeSet id="22-11-2024_2" author="Piyush">
|
<changeSet id="22-11-2024_2" author="Piyush">
|
||||||
<addColumn tableName="user_action">
|
<addColumn tableName="user_action">
|
||||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
UPDATE hub
|
||||||
|
SET email_service_type = 'PEC_SERVICE',
|
||||||
|
email_service_config = 'JkFbBfuVvq7VWwp5LcWIi+hAa1RJ1ekI0jq3w7gLTXETZiTaN8zC4OBWD53x8FtbfFTh3L/5805CIYTH1BQGa3X9q16q9SDzMy7DKHdmJzOnLKhn74C5akoXKaeXUCGnzp0cSk2c01FV6lwefC29IshijFSumCHtVlgWNeZigBzmWK+M7NS+EXf4goIMzguL5bHpYXfoQunQozeY1SpOo+28gDDpzZRMXdtcwKkTgESFGwsy6S1m1TBxJwZC7p8W'
|
||||||
|
WHERE UNIQUE_UUID = 'p4lk3bcx1RStqTaIVVbXs';
|
||||||
|
|
||||||
|
UPDATE hub
|
||||||
|
SET email_service_type = 'MAILGUN_SERVICE',
|
||||||
|
email_service_config = 'QlICHJMvBHd09ci/B2+EDR0q6kFsEdu5gOSI1hgG/7SAm2wXQZagDsAbkBrA6JPHXUS3Bkw6UD9x5boYYxBi3tnpu16i0NgdZqcc2BBhMF1VgRlJMgX+KgsOJsnQbHAJ/9YZaeIVrJpxceHFx93NTbfjT3TzzaZ9cW/64wbeZFspEp6WwgKgV1/3+j297Q1QtKIiWKanolYaU9myx9KwPJZc8AmPe0PR2ViyA7VyGn6iQSrX2pr15tBw3xVIm0tfHh6pktHro4gRYs5CEypQ2cSbP5wv4Z6pDa//FHXzYpRvnb1AUh0thGOix5FZl9Kn'
|
||||||
|
WHERE UNIQUE_UUID = 't7jh5wfg9QXylNaTZkPoE';
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
UPDATE gepafin_schema.system_email_template SET email_scenario='APPLICATION_SUBMITTED' WHERE "type"='APPLICATION_SUBMISSION_TO_USER_AND_COMPANY' AND "system"=true ;
|
||||||
|
|
||||||
|
UPDATE gepafin_schema.system_email_template SET email_scenario='APPLICATION_SUBMITTED' WHERE "type"='APPLICATION_SUBMISSION_TO_GEPAFIN' AND "system"=true ;
|
||||||
|
|
||||||
|
UPDATE gepafin_schema.system_email_template SET email_scenario='APPLICATION_AMENDMENT_REMINDER' WHERE "type"='AMENDMENT_REMINDER' AND "system"=true ;
|
||||||
|
|
||||||
|
UPDATE gepafin_schema.system_email_template SET email_scenario='APPLICATION_AMENDMENT_EXPIRED' WHERE "type"='INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE' AND "system"=true ;
|
||||||
|
|
||||||
|
UPDATE gepafin_schema.system_email_template SET email_scenario='APPLICATION_APPROVED' WHERE "type"='ADMISSIBILITY_NOTIFICATION' AND "system"=true ;
|
||||||
|
|
||||||
|
UPDATE gepafin_schema.system_email_template SET email_scenario='APPLICATION_REJECTED' WHERE "type"='INADMISSIBILITY_NOTIFICATION' AND "system"=true ;
|
||||||
|
|
||||||
|
UPDATE gepafin_schema.system_email_template SET email_scenario='APPLICATION_AMENDMENT_REQUESTED' WHERE "type"='DOCUMENTATION_INTEGRATION_REQUEST' AND "system"=true ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -308,3 +308,5 @@ invalid.amendment.for.comment = Invalid Amendment Request for the Given Comment.
|
|||||||
DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm
|
DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm
|
||||||
application.documents.not.found=No documents found for the application.
|
application.documents.not.found=No documents found for the application.
|
||||||
beneficiary.call.duplicate = A preferred call with this call ID and company ID already exists for this user.
|
beneficiary.call.duplicate = A preferred call with this call ID and company ID already exists for this user.
|
||||||
|
user.must.be.associated.with.company.to.create.application=You must be associated with a company to apply for this application.
|
||||||
|
company.id.required.for.preferred.call=Company ID is required when requesting only preferred calls.
|
||||||
|
|||||||
@@ -303,3 +303,5 @@ beneficiary.email.not.found.msg=L'indirizzo email per il beneficiario non <20> st
|
|||||||
reminder.email.sent.success.msg=Email di promemoria inviata con successo!
|
reminder.email.sent.success.msg=Email di promemoria inviata con successo!
|
||||||
application.documents.not.found=Nessun documento trovato per la domanda.
|
application.documents.not.found=Nessun documento trovato per la domanda.
|
||||||
beneficiary.call.duplicate = Una chiamata preferita con questo ID di chiamata e ID azienda esiste gi<67> per questo utente.
|
beneficiary.call.duplicate = Una chiamata preferita con questo ID di chiamata e ID azienda esiste gi<67> per questo utente.
|
||||||
|
user.must.be.associated.with.company.to.create.application=Devi essere associato a un'azienda per poter presentare domanda per questa applicazione.
|
||||||
|
company.id.required.for.preferred.call=ID azienda obbligatorio quando si richiedono solo chiamate preferite.
|
||||||
|
|||||||
Reference in New Issue
Block a user