Resolved Conflicts

This commit is contained in:
rajesh
2024-11-24 17:18:37 +05:30
6 changed files with 179 additions and 47 deletions

View File

@@ -4,19 +4,18 @@ 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.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
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.*; import net.gepafin.tendermanagement.entities.*;
import net.gepafin.tendermanagement.enums.*; import net.gepafin.tendermanagement.enums.*;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.request.*;
import net.gepafin.tendermanagement.model.request.ChecklistRequest;
import net.gepafin.tendermanagement.model.request.CriteriaRequest;
import net.gepafin.tendermanagement.model.request.FieldRequest;
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.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.Utils; import net.gepafin.tendermanagement.util.Utils;
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;
@@ -78,10 +77,16 @@ public class ApplicationEvaluationDao {
@Autowired @Autowired
ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository; ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
@Autowired @Autowired
private FormDao formDao; private FormDao formDao;
@Autowired
private LoggingUtil loggingUtil;
@Autowired
private HttpServletRequest request;
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) { private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity(); ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
@@ -132,7 +137,6 @@ public class ApplicationEvaluationDao {
} }
private void setCriteriaResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<EvaluationCriteriaEntity> evaluationCriterias) { private void setCriteriaResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<EvaluationCriteriaEntity> evaluationCriterias) {
List<CriteriaResponse> criteriaResponsesFromEntity = entity.getCriteria() != null ? List<CriteriaResponse> criteriaResponsesFromEntity = entity.getCriteria() != null ?
@@ -326,7 +330,7 @@ public class ApplicationEvaluationDao {
FormEntity formEntity = applicationForm.getForm(); FormEntity formEntity = applicationForm.getForm();
if (formEntity != null) { if (formEntity != null) {
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); // List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
contentResponseBeans.forEach(contentResponseBean -> { contentResponseBeans.forEach(contentResponseBean -> {
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) { if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
String label = null; String label = null;
@@ -342,7 +346,7 @@ public class ApplicationEvaluationDao {
Optional<ApplicationFormFieldEntity> optionalFormField = Optional<ApplicationFormFieldEntity> optionalFormField =
applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId( applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
fieldResponse.getId(), applicationForm.getId(), entity.getApplicationId()); fieldResponse.getId(), applicationForm.getId(), entity.getApplicationId());
if (optionalFormField.isPresent()) { if (optionalFormField.isPresent()) {
ApplicationFormFieldEntity formField = optionalFormField.get(); ApplicationFormFieldEntity formField = optionalFormField.get();
@@ -403,7 +407,7 @@ public class ApplicationEvaluationDao {
response.setBeneficiary(beneficiary); response.setBeneficiary(beneficiary);
response.setMinScore(call.getThreshold() != null ? call.getThreshold() : null); response.setMinScore(call.getThreshold() != null ? call.getThreshold() : null);
response.setCallName(application.getCall().getName() != null ? application.getCall().getName() : null); response.setCallName(application.getCall().getName() != null ? application.getCall().getName() : null);
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null); response.setProtocolNumber((application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null) ? application.getProtocol().getProtocolNumber() : null);
response.setSubmissionDate(application.getSubmissionDate() != null ? application.getSubmissionDate() : null); response.setSubmissionDate(application.getSubmissionDate() != null ? application.getSubmissionDate() : null);
response.setEvaluationDate(application.getSubmissionDate() != null ? application.getSubmissionDate().plusDays(30) : null); response.setEvaluationDate(application.getSubmissionDate() != null ? application.getSubmissionDate().plusDays(30) : null);
LocalDateTime callEndDate = application.getCall().getEndDate(); LocalDateTime callEndDate = application.getCall().getEndDate();
@@ -418,23 +422,31 @@ public class ApplicationEvaluationDao {
Optional<ApplicationEvaluationEntity> existingEntityOptional = Optional<ApplicationEvaluationEntity> existingEntityOptional =
applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId); applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId);
ApplicationEvaluationEntity entity; ApplicationEvaluationEntity entity = null;
Optional<AssignedApplicationsEntity> assignedApplications = Optional<AssignedApplicationsEntity> assignedApplications =
assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId); assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId);
ApplicationEvaluationEntity oldApplicationEvaluation = null;
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
if (existingEntityOptional.isPresent()) { if (existingEntityOptional.isPresent()) {
entity = existingEntityOptional.get(); entity = existingEntityOptional.get();
oldApplicationEvaluation = Utils.getClonedEntityForData(entity);
entity.setCriteria(Utils.convertObjectToJson(filterNonNullCriteria(processCriteria(entity, req)))); entity.setCriteria(Utils.convertObjectToJson(filterNonNullCriteria(processCriteria(entity, req))));
entity.setChecklist(Utils.convertObjectToJson(filterNonNullChecklist(processChecklist(entity, req)))); entity.setChecklist(Utils.convertObjectToJson(filterNonNullChecklist(processChecklist(entity, req))));
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());
actionType = VersionActionTypeEnum.UPDATE;
} else { } else {
entity = convertToEntity(user, req, assignedApplicationId); entity = convertToEntity(user, req, assignedApplicationId);
actionType = VersionActionTypeEnum.INSERT;
} }
ApplicationStatusForEvaluation status = req.getApplicationStatus(); ApplicationStatusForEvaluation status = req.getApplicationStatus();
ApplicationEvaluationEntity savedEntity = applicationEvaluationRepository.save(entity); ApplicationEvaluationEntity savedEntity = applicationEvaluationRepository.save(entity);
/** This code is responsible for adding a version history log for the "Update Application Evaluation" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplicationEvaluation).newData(entity).build());
if (status != null) { if (status != null) {
ApplicationEntity application = applicationService.validateApplication(assignedApplications.get().getApplication().getId()); ApplicationEntity application = applicationService.validateApplication(assignedApplications.get().getApplication().getId());
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplications.get(); AssignedApplicationsEntity assignedApplicationsEntity = assignedApplications.get();
@@ -692,10 +704,10 @@ public class ApplicationEvaluationDao {
String formFieldId = criteriaFormField.getFormFieldId(); String formFieldId = criteriaFormField.getFormFieldId();
if (!mappedFieldMap.containsKey(formFieldId)) { if (!mappedFieldMap.containsKey(formFieldId)) {
// CriteriaMappedField mappedField = new CriteriaMappedField(); // CriteriaMappedField mappedField = new CriteriaMappedField();
CriteriaMappedField mappedField = populateMappedField(formFieldId, criteriaFormField, applicationForm, applicationId); CriteriaMappedField mappedField = populateMappedField(formFieldId, criteriaFormField, applicationForm, applicationId);
if(mappedField != null) { if(mappedField != null) {
mappedFieldMap.put(formFieldId, mappedField); mappedFieldMap.put(formFieldId, mappedField);
} }
} }
} }
} }
@@ -704,16 +716,16 @@ public class ApplicationEvaluationDao {
} }
private CriteriaMappedField populateMappedField(String formFieldId, private CriteriaMappedField populateMappedField(String formFieldId,
CriteriaFormFieldEntity criteriaFormField, CriteriaFormFieldEntity criteriaFormField,
ApplicationFormEntity applicationForm, Long applicationId) { ApplicationFormEntity applicationForm, Long applicationId) {
CriteriaMappedField mappedField = new CriteriaMappedField(); CriteriaMappedField mappedField = new CriteriaMappedField();
mappedField.setId(formFieldId); mappedField.setId(formFieldId);
if(Boolean.FALSE.equals(criteriaFormField.getFormId().equals(applicationForm.getForm().getId()))) { if(Boolean.FALSE.equals(criteriaFormField.getFormId().equals(applicationForm.getForm().getId()))) {
return null; return null;
} }
formRepository.findById(criteriaFormField.getFormId()).ifPresent(formEntity -> { formRepository.findById(criteriaFormField.getFormId()).ifPresent(formEntity -> {
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); // List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
contentResponseBeans.stream().filter(bean -> bean.getId().equals(formFieldId)).findFirst().ifPresent(contentResponseBean -> { contentResponseBeans.stream().filter(bean -> bean.getId().equals(formFieldId)).findFirst().ifPresent(contentResponseBean -> {
String label = getLabel(contentResponseBean); String label = getLabel(contentResponseBean);
mappedField.setFieldName(contentResponseBean.getName()); mappedField.setFieldName(contentResponseBean.getName());
@@ -832,7 +844,7 @@ public class ApplicationEvaluationDao {
} }
private void setChecklistResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, private void setChecklistResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response,
List<CallTargetAudienceChecklistEntity> checklistEntities) { List<CallTargetAudienceChecklistEntity> checklistEntities) {
List<ChecklistResponse> checklistResponses = entity.getChecklist() != null ? Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() { List<ChecklistResponse> checklistResponses = entity.getChecklist() != null ? Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {
}) : getChecklistResponse(applicationId); }) : getChecklistResponse(applicationId);
@@ -850,7 +862,7 @@ public class ApplicationEvaluationDao {
} }
private void setFileResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, private void setFileResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response,
List<ApplicationFormEntity> applicationFormEntities) { List<ApplicationFormEntity> applicationFormEntities) {
List<FieldResponse> fieldResponses = entity.getFile() != null ? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() { List<FieldResponse> fieldResponses = entity.getFile() != null ? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {
}) : getFieldResponses(applicationId); }) : getFieldResponses(applicationId);
@@ -865,7 +877,7 @@ public class ApplicationEvaluationDao {
FormEntity formEntity = applicationForm.getForm(); FormEntity formEntity = applicationForm.getForm();
if (formEntity != null) { if (formEntity != null) {
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); // List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
contentResponseBeans.forEach(contentResponseBean -> { contentResponseBeans.forEach(contentResponseBean -> {
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) { if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
String label = null; String label = null;
@@ -881,7 +893,7 @@ public class ApplicationEvaluationDao {
Optional<ApplicationFormFieldEntity> optionalFormField = Optional<ApplicationFormFieldEntity> optionalFormField =
applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId( applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
fieldResponse.getId(), applicationForm.getId(), applicationId); fieldResponse.getId(), applicationForm.getId(), applicationId);
if (optionalFormField.isPresent() && optionalFormField.get().getFieldValue() != null) { if (optionalFormField.isPresent() && optionalFormField.get().getFieldValue() != null) {
String[] documentIds = optionalFormField.get().getFieldValue().split(","); String[] documentIds = optionalFormField.get().getFieldValue().split(",");
@@ -926,7 +938,7 @@ public class ApplicationEvaluationDao {
response.setBeneficiary(beneficiary); response.setBeneficiary(beneficiary);
response.setCallName(application.getCall().getName() != null ? application.getCall().getName() : null); response.setCallName(application.getCall().getName() != null ? application.getCall().getName() : null);
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null); response.setProtocolNumber((application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null) ? application.getProtocol().getProtocolNumber() : null);
response.setSubmissionDate(application.getSubmissionDate() != null ? application.getSubmissionDate() : null); response.setSubmissionDate(application.getSubmissionDate() != null ? application.getSubmissionDate() : null);
response.setEvaluationDate(application.getSubmissionDate() != null ? application.getSubmissionDate().plusDays(30) : null); response.setEvaluationDate(application.getSubmissionDate() != null ? application.getSubmissionDate().plusDays(30) : null);
@@ -998,7 +1010,7 @@ public class ApplicationEvaluationDao {
FormEntity formEntity = formRepository.findById(criteriaFormField.getFormId()).orElse(null); FormEntity formEntity = formRepository.findById(criteriaFormField.getFormId()).orElse(null);
if (formEntity != null) { if (formEntity != null) {
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); // List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
contentResponseBeans.stream() contentResponseBeans.stream()
.filter(bean -> bean.getId().equals(criteriaFormField.getFormFieldId())) .filter(bean -> bean.getId().equals(criteriaFormField.getFormFieldId()))
.findFirst() .findFirst()
@@ -1083,15 +1095,15 @@ public class ApplicationEvaluationDao {
private void handleParagraphField(Long applicationId, CriteriaFormFieldEntity criteriaFormField, ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) { private void handleParagraphField(Long applicationId, CriteriaFormFieldEntity criteriaFormField, ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) {
findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> { findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> {
String paragraph = contentResponseBean.getSettings().stream() String paragraph = contentResponseBean.getSettings().stream()
.filter(setting -> "text".equals(setting.getName())) .filter(setting -> "text".equals(setting.getName()))
.map(SettingResponseBean::getValue) .map(SettingResponseBean::getValue)
.map(Object::toString) .map(Object::toString)
.findFirst() .findFirst()
.orElse(null); .orElse(null);
if (paragraph != null) { if (paragraph != null) {
mappedField.setFieldValue(paragraph.trim()); mappedField.setFieldValue(paragraph.trim());
} }
}); });
} }
@@ -1276,17 +1288,25 @@ public class ApplicationEvaluationDao {
public void deleteById(Long id) { public void deleteById(Long id) {
ApplicationEvaluationEntity applicationEvaluationEntity = validateApplicationEvaluation(id); ApplicationEvaluationEntity applicationEvaluationEntity = validateApplicationEvaluation(id);
ApplicationEvaluationEntity oldApplicationEvaluation = Utils.getClonedEntityForData(applicationEvaluationEntity);
applicationEvaluationEntity.setIsDeleted(true); applicationEvaluationEntity.setIsDeleted(true);
saveApplicationEvaluationEntity(applicationEvaluationEntity); saveApplicationEvaluationEntity(applicationEvaluationEntity, oldApplicationEvaluation);
} }
public ApplicationEvaluationEntity saveApplicationEvaluationEntity(ApplicationEvaluationEntity applicationEvaluationEntityData) { public ApplicationEvaluationEntity saveApplicationEvaluationEntity(ApplicationEvaluationEntity applicationEvaluationEntityData, ApplicationEvaluationEntity oldApplicationEvaluation) {
return applicationEvaluationRepository.save(applicationEvaluationEntityData); ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationRepository.save(applicationEvaluationEntityData);
/** This code is responsible for adding a version history log for the "Delete Application Evaluation" operation. **/
loggingUtil.addVersionHistory(
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldApplicationEvaluation).newData(applicationEvaluationEntityData)
.build());
return applicationEvaluationEntity;
} }
public ApplicationEvaluationResponse updateApplicationEvaluationStatus(ApplicationEntity application, AssignedApplicationsEntity assignedApplicationsEntity, public ApplicationEvaluationResponse updateApplicationEvaluationStatus(ApplicationEntity application, AssignedApplicationsEntity assignedApplicationsEntity,
ApplicationStatusForEvaluation newStatus) { ApplicationStatusForEvaluation newStatus) {
Optional<ApplicationEvaluationEntity> existingEntityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse( Optional<ApplicationEvaluationEntity> existingEntityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(
assignedApplicationsEntity.getId()); assignedApplicationsEntity.getId());
@@ -1297,8 +1317,16 @@ public class ApplicationEvaluationDao {
ApplicationEvaluationEntity existingEntity = existingEntityOptional.get(); ApplicationEvaluationEntity existingEntity = existingEntityOptional.get();
// UserEntity userEntity = userService.validateUser(application.getUserId()); // UserEntity userEntity = userService.validateUser(application.getUserId());
// callService.validatePublishedCall(application.getCall().getId(), userEntity.getHub().getId()); // callService.validatePublishedCall(application.getCall().getId(), userEntity.getHub().getId());
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(application);
application.setStatus(newStatus.getValue()); application.setStatus(newStatus.getValue());
application = applicationRepository.save(application); application = applicationRepository.save(application);
/** 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(application).build());
ApplicationEvaluationEntity oldApplicationEvaluation = Utils.getClonedEntityForData(existingEntity);
AssignedApplicationsEntity oldAssignedApplication = Utils.getClonedEntityForData(assignedApplicationsEntity);
String statusType = application.getStatus(); String statusType = application.getStatus();
if (application.getStatus().equals(ApplicationStatusTypeEnum.APPROVED.getValue()) || application.getStatus().equals(ApplicationStatusTypeEnum.REJECTED.getValue())) { if (application.getStatus().equals(ApplicationStatusTypeEnum.APPROVED.getValue()) || application.getStatus().equals(ApplicationStatusTypeEnum.REJECTED.getValue())) {
existingEntity.setStatus(ApplicationEvaluationStatusTypeEnum.CLOSE.getValue()); existingEntity.setStatus(ApplicationEvaluationStatusTypeEnum.CLOSE.getValue());
@@ -1307,9 +1335,24 @@ public class ApplicationEvaluationDao {
entity = applicationEvaluationRepository.save(existingEntity); entity = applicationEvaluationRepository.save(existingEntity);
assignedApplicationsRepository.save(assignedApplicationsEntity); assignedApplicationsRepository.save(assignedApplicationsEntity);
if (application.getStatus().equals(ApplicationStatusTypeEnum.APPROVED.getValue()) || application.getStatus().equals(ApplicationStatusTypeEnum.REJECTED.getValue())) {
/** 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(oldApplicationEvaluation).newData(entity).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(oldAssignedApplication).newData(assignedApplicationsEntity).build());
}
List<ApplicationAmendmentRequestEntity> amendmentRequest = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(entity.getId()); List<ApplicationAmendmentRequestEntity> amendmentRequest = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(entity.getId());
for (ApplicationAmendmentRequestEntity request : amendmentRequest) { for (ApplicationAmendmentRequestEntity amendment : amendmentRequest) {
request.setStatus(ApplicationAmendmentRequestEnum.CLOSE.getValue()); ApplicationAmendmentRequestEntity oldAmendment = Utils.getClonedEntityForData(amendment);
amendment.setStatus(ApplicationAmendmentRequestEnum.CLOSE.getValue());
/** This code is responsible for adding a version history log for the "Update Application Amendment" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldAmendment).newData(amendment).build());
} }
applicationAmendmentRequestRepository.saveAll(amendmentRequest); applicationAmendmentRequestRepository.saveAll(amendmentRequest);
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.APPROVED.getValue())))) { if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.APPROVED.getValue())))) {

View File

@@ -79,7 +79,7 @@ public class AssignedApplicationsDao {
application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue()); application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue());
applicationRepository.save(application); applicationRepository.save(application);
/** This code is responsible for adding a version history log for the "Create 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(application).build()); loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEntity).newData(application).build());
UserEntity user = userService.validateUser(userId); UserEntity user = userService.validateUser(userId);
@@ -170,7 +170,7 @@ public class AssignedApplicationsDao {
validator.validatePreInstructor(request, assignedApplicationsEntity.getUserId()); validator.validatePreInstructor(request, assignedApplicationsEntity.getUserId());
AssignedApplicationsEntity oldAssignedApplicationEntity = Utils.getClonedEntityForData(assignedApplicationsEntity); AssignedApplicationsEntity oldAssignedApplicationEntity = Utils.getClonedEntityForData(assignedApplicationsEntity);
assignedApplicationsEntity.setIsDeleted(true); assignedApplicationsEntity.setIsDeleted(true);
assignedApplicationsEntity = saveAssignedApplication(assignedApplicationsEntity, oldAssignedApplicationEntity, VersionActionTypeEnum.DELETE); assignedApplicationsEntity = saveAssignedApplication(assignedApplicationsEntity, oldAssignedApplicationEntity, VersionActionTypeEnum.SOFT_DELETE);
log.info("Assigned Application deleted with ID: {}", id); log.info("Assigned Application deleted with ID: {}", id);
} }

View File

@@ -2,13 +2,18 @@ package net.gepafin.tendermanagement.dao;
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.ApplicationEntity;
import net.gepafin.tendermanagement.entities.BeneficiaryPreferredCallEntity; import net.gepafin.tendermanagement.entities.BeneficiaryPreferredCallEntity;
import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus; import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq; import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean; import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository; import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository;
import net.gepafin.tendermanagement.util.LoggingUtil;
import net.gepafin.tendermanagement.util.Utils;
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.CustomValidationException;
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException; import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
@@ -32,10 +37,15 @@ public class BeneficiaryPreferredCallDao {
@Autowired @Autowired
private BeneficiaryPreferredCallRepository beneficiaryPreferredCallRepository; private BeneficiaryPreferredCallRepository beneficiaryPreferredCallRepository;
@Autowired @Autowired
private Validator validator; private Validator validator;
@Autowired
private LoggingUtil loggingUtil;
@Autowired
private HttpServletRequest httpServletRequest;
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest httpServletRequest, BeneficiaryPreferredCallReq request, UserEntity user) { public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest httpServletRequest, BeneficiaryPreferredCallReq request, UserEntity user) {
log.info("Creating new beneficiary preferred call with details: {}", request); log.info("Creating new beneficiary preferred call with details: {}", request);
@@ -51,6 +61,10 @@ public class BeneficiaryPreferredCallDao {
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request, user); BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request, user);
entity = beneficiaryPreferredCallRepository.save(entity); entity = beneficiaryPreferredCallRepository.save(entity);
/** This code is responsible for adding a version history log for "Create Beneficiary Preferred Call" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(httpServletRequest).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(entity).build());
log.info("Beneficiary preferred call created with ID: {}", entity.getId()); log.info("Beneficiary preferred call created with ID: {}", entity.getId());
return convertEntityToResponse(entity); return convertEntityToResponse(entity);
} }
@@ -92,13 +106,19 @@ public class BeneficiaryPreferredCallDao {
log.info("Soft deleting beneficiary preferred call with ID: {}", id); log.info("Soft deleting beneficiary preferred call with ID: {}", id);
BeneficiaryPreferredCallEntity entity = validateBeneficiaryPreferredCall(id); BeneficiaryPreferredCallEntity entity = validateBeneficiaryPreferredCall(id);
validator.validateUserId(request, entity.getUserId()); validator.validateUserId(request, entity.getUserId());
BeneficiaryPreferredCallEntity oldBeneficiaryPreferredCallEntity = Utils.getClonedEntityForData(entity);
entity.setIsDeleted(true); entity.setIsDeleted(true);
beneficiaryPreferredCallRepository.save(entity); beneficiaryPreferredCallRepository.save(entity);
/** This code is responsible for adding a version history log for the "Delete Beneficiary Preferred Call" operation. **/
loggingUtil.addVersionHistory(
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldBeneficiaryPreferredCallEntity).newData(entity).build());
log.info("Beneficiary preferred call soft deleted with ID: {}", id); log.info("Beneficiary preferred call soft deleted with ID: {}", id);
} }
public List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls(HttpServletRequest request) { public List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls(HttpServletRequest request) {
UserEntity userEntity = validator.validateUser(request); UserEntity userEntity = validator.validateUser(request);
log.info("Fetching all beneficiary preferred calls"); log.info("Fetching all beneficiary preferred calls");
List<BeneficiaryPreferredCallResponseBean> calls = beneficiaryPreferredCallRepository.findByUserIdAndIsDeletedFalse(userEntity.getId()) List<BeneficiaryPreferredCallResponseBean> calls = beneficiaryPreferredCallRepository.findByUserIdAndIsDeletedFalse(userEntity.getId())
.stream() .stream()
@@ -130,8 +150,13 @@ public class BeneficiaryPreferredCallDao {
public void updateBeneficiaryPreferredCallStatus(Long id, BeneficiaryCallStatus status) { public void updateBeneficiaryPreferredCallStatus(Long id, BeneficiaryCallStatus status) {
log.info("Updating status for beneficiary preferred call with ID: {}", id); log.info("Updating status for beneficiary preferred call with ID: {}", id);
BeneficiaryPreferredCallEntity existingEntity = validateBeneficiaryPreferredCall(id); BeneficiaryPreferredCallEntity existingEntity = validateBeneficiaryPreferredCall(id);
BeneficiaryPreferredCallEntity oldBeneficiaryPreferredCallEntity = Utils.getClonedEntityForData(existingEntity);
existingEntity.setStatus(status.getValue()); existingEntity.setStatus(status.getValue());
beneficiaryPreferredCallRepository.save(existingEntity); beneficiaryPreferredCallRepository.save(existingEntity);
/** This code is responsible for adding a version history log for the "Update Application" operation. **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(httpServletRequest).actionType(VersionActionTypeEnum.UPDATE).oldData(oldBeneficiaryPreferredCallEntity).newData(existingEntity).build());
log.info("Beneficiary preferred call status updated with ID: {}", existingEntity.getId()); log.info("Beneficiary preferred call status updated with ID: {}", existingEntity.getId());
} }
public List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(UserEntity userEntity, Long companyId) { public List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(UserEntity userEntity, Long companyId) {

View File

@@ -60,6 +60,17 @@ public enum UserActionContextEnum {
GET_ALL_HUB("GET_ALL_HUB"), GET_ALL_HUB("GET_ALL_HUB"),
GET_HUB_BY_UUID(" GET_HUB_BY_UUID"), GET_HUB_BY_UUID(" GET_HUB_BY_UUID"),
/** Application Evaluation action context **/
CREATE_UPDATE_APPLICATION_EVALUATION("CREATE_UPDATE_APPLICATION_EVALUATION"),
GET_APPLICATION_EVALUATION("GET_APPLICATION_EVALUATION"),
DELETE_APPLICATION_EVALUATION("DELETE_APPLICATION_EVALUATION"),
/** Beneficiary Preferred Call action context **/
CREATE_BENEFICIARY_PREFERRED_CALL("CREATE_BENEFICIARY_PREFERRED_CALL"),
DELETE_BENEFICIARY_PREFERRED_CALL("DELETE_BENEFICIARY_PREFERRED_CALL"),
GET_BENEFICIARY_PREFERRED_CALL("GET_BENEFICIARY_PREFERRED_CALL"),
UPDATE_BENEFICIARY_PREFERRED_CALL("UPDATE_BENEFICIARY_PREFERRED_CALL"),
/** Assigned Application action context **/ /** Assigned Application action context **/
CREATE_ASSIGNED_APPLICATION("CREATE_ASSIGNED_APPLICATION"), CREATE_ASSIGNED_APPLICATION("CREATE_ASSIGNED_APPLICATION"),
DELETE_ASSIGNED_APPLICATION("DELETE_ASSIGNED_APPLICATION"), DELETE_ASSIGNED_APPLICATION("DELETE_ASSIGNED_APPLICATION"),

View File

@@ -4,10 +4,14 @@ 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.enums.ApplicationStatusForEvaluation; import net.gepafin.tendermanagement.enums.ApplicationStatusForEvaluation;
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
import net.gepafin.tendermanagement.model.request.UserActionRequest;
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse; import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
import net.gepafin.tendermanagement.model.util.Response; import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.ApplicationEvaluationService; import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
import net.gepafin.tendermanagement.util.LoggingUtil;
import net.gepafin.tendermanagement.web.rest.api.ApplicationEvaluationApi; import net.gepafin.tendermanagement.web.rest.api.ApplicationEvaluationApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status; import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -23,12 +27,20 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
@Autowired @Autowired
private ApplicationEvaluationService applicationEvaluationService; private ApplicationEvaluationService applicationEvaluationService;
@Autowired
private LoggingUtil loggingUtil;
@Override @Override
public ResponseEntity<Response<ApplicationEvaluationResponse>> createOrUpdateApplicationEvaluation( public ResponseEntity<Response<ApplicationEvaluationResponse>> createOrUpdateApplicationEvaluation(
HttpServletRequest request, HttpServletRequest request,
Long assignedApplicationsId, Long assignedApplicationsId,
ApplicationEvaluationRequest evaluationRequest) { ApplicationEvaluationRequest evaluationRequest) {
/** This code is responsible for creating user action logs for the "Create or update Application Evaluation" operation. **/
loggingUtil.logUserAction(
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.CREATE_UPDATE_APPLICATION_EVALUATION).build());
ApplicationEvaluationResponse response = applicationEvaluationService.createOrUpdateApplicationEvaluation( ApplicationEvaluationResponse response = applicationEvaluationService.createOrUpdateApplicationEvaluation(
request, evaluationRequest, assignedApplicationsId); request, evaluationRequest, assignedApplicationsId);
@@ -41,6 +53,11 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
public ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId( public ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(
HttpServletRequest request, Long applicationId, Long assignedApplicationId) { HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
/** This code is responsible for creating user action logs for the "Get Application Evaluation" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_APPLICATION_EVALUATION).build());
ApplicationEvaluationResponse response = null; ApplicationEvaluationResponse response = null;
response = applicationEvaluationService.getApplicationEvaluationByApplicationId(request, applicationId,assignedApplicationId); response = applicationEvaluationService.getApplicationEvaluationByApplicationId(request, applicationId,assignedApplicationId);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
@@ -50,8 +67,15 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
@Override @Override
public ResponseEntity<Response<Void>> deleteApplicationEvaluation(HttpServletRequest request, public ResponseEntity<Response<Void>> deleteApplicationEvaluation(HttpServletRequest request,
Long id) { Long id) {
applicationEvaluationService.deleteApplicationEvaluation(request,id);
/** This code is responsible for creating user action logs for the "Delete Application Evaluation" operation. **/
loggingUtil.logUserAction(
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.DELETE).actionContext(UserActionContextEnum.DELETE_APPLICATION_EVALUATION).build());
applicationEvaluationService.deleteApplicationEvaluation(request, id);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_DELETED_SUCCESSFULLY))); .body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_DELETED_SUCCESSFULLY)));
} }

View File

@@ -4,11 +4,15 @@ 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.enums.BeneficiaryCallStatus; import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq; import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
import net.gepafin.tendermanagement.model.request.UserActionRequest;
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean; import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
import net.gepafin.tendermanagement.model.util.Response; import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.BeneficiaryPreferredCallService; import net.gepafin.tendermanagement.service.BeneficiaryPreferredCallService;
import net.gepafin.tendermanagement.util.LoggingUtil;
import net.gepafin.tendermanagement.web.rest.api.BeneficiaryPreferredCallApi; import net.gepafin.tendermanagement.web.rest.api.BeneficiaryPreferredCallApi;
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,10 +31,16 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
@Autowired @Autowired
private BeneficiaryPreferredCallService beneficiaryPreferredCallService; private BeneficiaryPreferredCallService beneficiaryPreferredCallService;
@Autowired
private LoggingUtil loggingUtil;
@Override @Override
public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> createBeneficiaryPreferredCall(HttpServletRequest request, BeneficiaryPreferredCallReq beneficiaryPreferredCallReq) { public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> createBeneficiaryPreferredCall(HttpServletRequest request, BeneficiaryPreferredCallReq beneficiaryPreferredCallReq) {
log.info("Creating Beneficiary Preferred Call"); log.info("Creating Beneficiary Preferred Call");
/** This code is responsible for creating user action logs for the "Create Beneficiary Preferred Call" operation. **/
loggingUtil.logUserAction(
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.INSERT).actionContext(UserActionContextEnum.CREATE_BENEFICIARY_PREFERRED_CALL).build());
BeneficiaryPreferredCallResponseBean responseBean = beneficiaryPreferredCallService.createBeneficiaryPreferredCall(request, beneficiaryPreferredCallReq); BeneficiaryPreferredCallResponseBean responseBean = beneficiaryPreferredCallService.createBeneficiaryPreferredCall(request, beneficiaryPreferredCallReq);
return ResponseEntity.status(HttpStatus.CREATED) return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_CREATED_SUCCESS_MSG))); .body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_CREATED_SUCCESS_MSG)));
@@ -47,6 +57,12 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
@Override @Override
public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> getBeneficiaryPreferredCallById(HttpServletRequest request, Long id) { public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> getBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
log.info("Fetching Beneficiary Preferred Call by ID - ID: {}", id); log.info("Fetching Beneficiary Preferred Call by ID - ID: {}", id);
/** This code is responsible for creating user action logs for the "Get Beneficiary Preferred Call by id" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
.actionContext(UserActionContextEnum.GET_BENEFICIARY_PREFERRED_CALL).build());
BeneficiaryPreferredCallResponseBean response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallById(request, id); BeneficiaryPreferredCallResponseBean response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallById(request, id);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG))); .body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG)));
@@ -55,6 +71,10 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
@Override @Override
public ResponseEntity<Response<Void>> deleteBeneficiaryPreferredCall(HttpServletRequest request, Long id) { public ResponseEntity<Response<Void>> deleteBeneficiaryPreferredCall(HttpServletRequest request, Long id) {
log.info("Deleting Beneficiary Preferred Call - ID: {}", id); log.info("Deleting Beneficiary Preferred Call - ID: {}", id);
/** This code is responsible for creating user action logs for the "Delete Beneficiary Preferred Call" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.DELETE).actionContext(UserActionContextEnum.DELETE_BENEFICIARY_PREFERRED_CALL).build());
beneficiaryPreferredCallService.deleteBeneficiaryPreferredCall(request, id); beneficiaryPreferredCallService.deleteBeneficiaryPreferredCall(request, id);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG))); .body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG)));
@@ -63,6 +83,11 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
@Override @Override
public ResponseEntity<Response<Void>> updateBeneficiaryPreferredCallStatus(HttpServletRequest request, Long id, BeneficiaryCallStatus status) { public ResponseEntity<Response<Void>> updateBeneficiaryPreferredCallStatus(HttpServletRequest request, Long id, BeneficiaryCallStatus status) {
log.info("Updating status of Beneficiary Preferred Call - ID: {}, Status: {}", id, status); log.info("Updating status of Beneficiary Preferred Call - ID: {}, Status: {}", id, status);
/** This code is responsible for "Updating Beneficiary Preferred Call details" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE)
.actionContext(UserActionContextEnum.UPDATE_BENEFICIARY_PREFERRED_CALL).build());
beneficiaryPreferredCallService.updateBeneficiaryPreferredCallStatus(request, id, status); beneficiaryPreferredCallService.updateBeneficiaryPreferredCallStatus(request, id, status);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_STATUS_UPDATED_SUCCESS_MSG))); .body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_STATUS_UPDATED_SUCCESS_MSG)));
@@ -71,6 +96,10 @@ public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferr
@Override @Override
public ResponseEntity<Response<List<BeneficiaryPreferredCallResponseBean>>> getBeneficiaryPreferredCallByUserId(HttpServletRequest request,Long userId,Long beneficiaryId,Long companyId) { public ResponseEntity<Response<List<BeneficiaryPreferredCallResponseBean>>> getBeneficiaryPreferredCallByUserId(HttpServletRequest request,Long userId,Long beneficiaryId,Long companyId) {
log.info("Fetching all Beneficiary Preferred Calls for User ID"); log.info("Fetching all Beneficiary Preferred Calls for User ID");
/** This code is responsible for creating user action logs for the "Get Beneficiary Preferred Call" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_BENEFICIARY_PREFERRED_CALL).build());
List<BeneficiaryPreferredCallResponseBean> response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallByUserId(request, userId,beneficiaryId,companyId); List<BeneficiaryPreferredCallResponseBean> response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallByUserId(request, userId,beneficiaryId,companyId);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ALL_BENEFICIARY_PREFERRED_CALLS_SUCCESS_MSG))); .body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ALL_BENEFICIARY_PREFERRED_CALLS_SUCCESS_MSG)));