Added audit for Application Evaluation

This commit is contained in:
rajesh
2024-11-24 14:17:57 +05:30
parent 6c37713e50
commit bd18f48802
3 changed files with 114 additions and 42 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;
@@ -82,6 +81,12 @@ public class ApplicationEvaluationDao {
@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.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

@@ -45,6 +45,11 @@ public enum UserActionContextEnum {
UPDATE_FAQ_DETAILS("UPDATE_FAQ_DETAILS"), UPDATE_FAQ_DETAILS("UPDATE_FAQ_DETAILS"),
DELETE_FAQ("DELETE_FAQ"), DELETE_FAQ("DELETE_FAQ"),
/** Application Evaluation action context **/
CREATE_UPDATE_APPLICATION_EVALUATION("CREATE_UPDATE_APPLICATION_EVALUATION"),
GET_APPLICATION_EVALUATION("GET_APPLICATION_EVALUATION"),
DELETE_APPLICATION_EVALUATION("DELETE_APPLICATION_EVALUATION"),
/** 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)));
} }