Resolved conflicts
This commit is contained in:
@@ -31,6 +31,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundExceptio
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
import org.h2.util.IOUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -49,11 +50,16 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -94,29 +100,29 @@ public class ApplicationDao {
|
||||
|
||||
@Autowired
|
||||
private FlowDataRepository flowDataRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
@Autowired
|
||||
private S3PathConfig s3PathConfig;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SystemEmailTemplatesService systemEmailTemplatesService;
|
||||
@Autowired
|
||||
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||
|
||||
|
||||
@Value("${default_System_Receiver_Email}")
|
||||
private String defaultSystemReceiverEmail;
|
||||
|
||||
|
||||
@Value("${rinaldo_email}")
|
||||
private String rinaldoEmail;
|
||||
|
||||
|
||||
@Value("${carlo_email}")
|
||||
private String carloEmail;
|
||||
|
||||
@@ -125,37 +131,37 @@ public class ApplicationDao {
|
||||
|
||||
@Autowired
|
||||
private AmazonS3Service amazonS3Service;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ApplicationSignedDocumentRepository applicationSignedDocumentRepository;
|
||||
|
||||
|
||||
// @Value("${aws.s3.url.folder.signed.document}")
|
||||
// private String signedDocumentS3Folder;
|
||||
|
||||
|
||||
@Value("${default.hub.uuid}")
|
||||
private String defaultHubUuid;
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private S3PathConfig s3ConfigBean;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ProtocolDao protocolDao;
|
||||
|
||||
|
||||
@Autowired
|
||||
private HubService hubService;
|
||||
|
||||
@Autowired
|
||||
private EmailNotificationDao emailNotificationDao;
|
||||
|
||||
|
||||
@Autowired
|
||||
private FormDao formDao;
|
||||
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
@@ -183,6 +189,7 @@ public class ApplicationDao {
|
||||
@Autowired
|
||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||
|
||||
|
||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
||||
FormEntity formEntity = formService.validateForm(formId);
|
||||
// callService.validatePublishedCall(formEntity.getCall().getId());
|
||||
@@ -258,7 +265,7 @@ public class ApplicationDao {
|
||||
|
||||
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(
|
||||
// applicationFormEntity.getForm().getContent(), ContentResponseBean.class);
|
||||
|
||||
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(applicationFormEntity.getForm()).getContent();
|
||||
|
||||
for (ApplicationFormFieldEntity applicationFormFieldEntity : applicationFormFieldEntities) {
|
||||
@@ -309,7 +316,7 @@ public class ApplicationDao {
|
||||
);
|
||||
}
|
||||
ApplicationEntity oldApplicationDataEntity = Utils.getClonedEntityForData(applicationEntity);
|
||||
|
||||
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
applicationEntity.setIsDeleted(true);
|
||||
applicationEntity = applicationRepository.save(applicationEntity);
|
||||
@@ -356,9 +363,9 @@ public class ApplicationDao {
|
||||
//
|
||||
// return applicationResponses;
|
||||
// }
|
||||
|
||||
|
||||
public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId, Long companyId,List<ApplicationStatusTypeEnum> statusList) {
|
||||
|
||||
|
||||
log.info("Fetching applications for RoleType: {}", userEntity.getRoleEntity().getRoleType());
|
||||
|
||||
Specification<ApplicationEntity> spec = search(userEntity, callId, companyId,statusList);
|
||||
@@ -482,15 +489,18 @@ public class ApplicationDao {
|
||||
|
||||
public List<ApplicationFormFieldEntity> createOrUpdateMultipleFormFields(List<ApplicationFormFieldRequestBean> formFieldResponseBeans,
|
||||
ApplicationFormEntity applicationFormEntity, FormEntity formEntity) {
|
||||
FieldValidator fieldValidator = FieldValidator.create();
|
||||
|
||||
List<ApplicationFormFieldEntity> existingFields = applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId());
|
||||
|
||||
return formFieldResponseBeans.stream().map(requestBean -> createOrUpdateApplicationFormField(requestBean, applicationFormEntity, existingFields, formEntity))
|
||||
List<ApplicationFormFieldEntity> applicationFormFieldEntities=formFieldResponseBeans.stream().map(requestBean -> createOrUpdateApplicationFormField(requestBean, applicationFormEntity, existingFields, formEntity,fieldValidator))
|
||||
.collect(Collectors.toList());
|
||||
fieldValidator.validate();
|
||||
return applicationFormFieldEntities;
|
||||
}
|
||||
|
||||
public ApplicationFormFieldEntity createOrUpdateApplicationFormField(ApplicationFormFieldRequestBean applicationFormFieldRequestBean,
|
||||
ApplicationFormEntity applicationFormEntity, List<ApplicationFormFieldEntity> applicationFormFieldEntities, FormEntity formEntity) {
|
||||
ApplicationFormEntity applicationFormEntity, List<ApplicationFormFieldEntity> applicationFormFieldEntities, FormEntity formEntity,FieldValidator fieldValidator) {
|
||||
|
||||
ApplicationFormFieldEntity applicationFormFieldEntity = new ApplicationFormFieldEntity();
|
||||
|
||||
@@ -506,7 +516,7 @@ public class ApplicationDao {
|
||||
.filter(setting -> "isRequestedAmount".equals(setting.getName()) && Boolean.TRUE.equals(setting.getValue()))
|
||||
.findFirst()
|
||||
.ifPresent(setting -> {
|
||||
|
||||
|
||||
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
|
||||
if(fieldValue!=null) {
|
||||
try {
|
||||
@@ -538,6 +548,7 @@ public class ApplicationDao {
|
||||
}
|
||||
}
|
||||
}
|
||||
calculationProcessForFormula(applicationFormEntity,contentResponseBeans,applicationFormFieldRequestBean,fieldValidator);
|
||||
Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
|
||||
|
||||
if (applicationFormFieldRequestBean.getFieldValue() != null) {
|
||||
@@ -560,7 +571,6 @@ public class ApplicationDao {
|
||||
VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplicationFormFieldData).newData(applicationFormField).build());
|
||||
|
||||
log.info("Version history logged for action: {}, Field ID: {}", actionType, applicationFormFieldEntity.getFieldId());
|
||||
|
||||
return applicationFormField;
|
||||
}
|
||||
|
||||
@@ -669,7 +679,7 @@ public class ApplicationDao {
|
||||
return documentIds;
|
||||
}
|
||||
|
||||
private List<Long> validateDocumentIds(String documentId) {
|
||||
public List<Long> validateDocumentIds(String documentId) {
|
||||
if (documentId != null && !documentId.isEmpty()) {
|
||||
return Arrays.stream(documentId.split(","))
|
||||
.map(Long::parseLong)
|
||||
@@ -818,7 +828,7 @@ public class ApplicationDao {
|
||||
if(formApplicationResponse.getContent() != null && formApplicationResponse.getFormFields() != null) {
|
||||
formApplicationResponses.add(formApplicationResponse);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public FormApplicationResponse processForm(FormEntity formEntity, ApplicationEntity applicationEntity) {
|
||||
@@ -954,7 +964,7 @@ public class ApplicationDao {
|
||||
return (int) Math.round(progress);
|
||||
}
|
||||
public void validateFormFields(ApplicationRequestBean request, FormEntity formEntity) {
|
||||
|
||||
|
||||
// List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class);
|
||||
List<ContentResponseBean> contentResponseBeans=formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
|
||||
@@ -1034,7 +1044,7 @@ public class ApplicationDao {
|
||||
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
|
||||
.retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum.APPLICATION_SUBMISSION_TO_USER_AND_COMPANY,
|
||||
hub, null);
|
||||
|
||||
|
||||
// Create the map for subject placeholders
|
||||
Map<String, String> subjectPlaceholders = new HashMap<>();
|
||||
subjectPlaceholders.put("{{call_name}}", call.getName());
|
||||
@@ -1114,8 +1124,13 @@ public class ApplicationDao {
|
||||
}
|
||||
emailLogRequest.setRecipientEmails(hub.getEmail());
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(hub.getEmail()),emailLogRequest);
|
||||
List<String> listDefaultSystemReceiverEmail = Arrays.stream(defaultSystemReceiverEmail.split(","))
|
||||
.map(String::trim)
|
||||
.filter(email -> !email.isEmpty())
|
||||
.toList();
|
||||
|
||||
emailLogRequest.setRecipientEmails(defaultSystemReceiverEmail);
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(defaultSystemReceiverEmail),emailLogRequest);
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, listDefaultSystemReceiverEmail,emailLogRequest);
|
||||
emailLogRequest.setRecipientEmails(rinaldoEmail);
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(rinaldoEmail),emailLogRequest);
|
||||
}
|
||||
@@ -1211,17 +1226,17 @@ public class ApplicationDao {
|
||||
}
|
||||
|
||||
public ApplicationSignedDocumentResponse getSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||
|
||||
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
// validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
|
||||
|
||||
if (validator.checkIsPreInstructor()) {
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluationByApplicationId(applicationId);
|
||||
validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId());
|
||||
} else {
|
||||
validator.validateUserId(request, applicationEntity.getUserId());
|
||||
}
|
||||
|
||||
|
||||
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
|
||||
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
if(applicationSignedDocument == null) {
|
||||
@@ -1230,11 +1245,11 @@ public class ApplicationDao {
|
||||
}
|
||||
return convertApplicationSignedDocumentToApplicationSignedDocumentResponse(applicationSignedDocument);
|
||||
}
|
||||
|
||||
|
||||
public void deleteSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
|
||||
|
||||
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
|
||||
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
//cloned entity for old data
|
||||
@@ -1552,5 +1567,135 @@ public class ApplicationDao {
|
||||
}
|
||||
}
|
||||
|
||||
public void calculationProcessForFormula(ApplicationFormEntity applicationFormEntity, List<ContentResponseBean> contentResponseBeans, ApplicationFormFieldRequestBean applicationFormFieldRequestBean,FieldValidator fieldValidator) {
|
||||
List<String> formulaValue = new ArrayList<>();
|
||||
String formulaValueOpt=null;
|
||||
String label=null;
|
||||
for (ContentResponseBean contentResponseBean:contentResponseBeans){
|
||||
if(contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())){
|
||||
for (SettingResponseBean settingResponseBean:contentResponseBean.getSettings()){
|
||||
if (settingResponseBean.getName().equals("label")){
|
||||
label= String.valueOf(settingResponseBean.getValue());
|
||||
}
|
||||
if(settingResponseBean.getName().equals("formula")){
|
||||
String value= (String) settingResponseBean.getValue();
|
||||
formulaValueOpt=value;
|
||||
formulaValue=Utils.extractValues(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> mappedFormulaValue = new HashMap<>();
|
||||
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
|
||||
if (formulaValueOpt != null && fieldValue==null) {
|
||||
fieldValue=0;
|
||||
}
|
||||
|
||||
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
||||
String contentId = contentResponseBean.getId();
|
||||
|
||||
// Extract variable values once per contentResponseBean to avoid repeated stream operations
|
||||
Set<String> variableValues = contentResponseBean.getSettings().stream()
|
||||
.filter(setting -> "variable".equals(setting.getName()))
|
||||
.flatMap(setting -> {
|
||||
Object value = setting.getValue(); // Get the raw value
|
||||
if (value instanceof String) {
|
||||
return Stream.of((String) value); // Handle single String case
|
||||
} else if (value instanceof List) {
|
||||
return ((List<?>) value).stream()
|
||||
.filter(item -> item instanceof String) // Ensure it's a String
|
||||
.map(item -> (String) item); // Convert to String
|
||||
} else {
|
||||
return Stream.empty(); // Ignore unexpected types
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toSet()); // Collect into a Set for uniqueness
|
||||
|
||||
for (String formula : formulaValue) {
|
||||
if (variableValues.contains(formula)) { // O(1) lookup instead of O(n)
|
||||
mappedFormulaValue.put(formula, contentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> updatedMappedFormulaValue = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : mappedFormulaValue.entrySet()) {
|
||||
String variable = entry.getKey();
|
||||
String contentId = entry.getValue();
|
||||
|
||||
// Repository call using contentId
|
||||
Optional<ApplicationFormFieldEntity> optionalEntity = applicationFormFieldRepository.findByApplicationFormIdAndFieldId(applicationFormEntity.getId(),contentId);
|
||||
// If entity is found, extract fieldValue and fieldId
|
||||
optionalEntity.ifPresent(entity -> {
|
||||
String entityFieldValue = entity.getFieldValue(); // Assuming getter method exists
|
||||
String fieldId = entity.getFieldId(); // Assuming getter method exists
|
||||
String tableType = contentResponseBeans.stream()
|
||||
.filter(content -> content.getId().equals(fieldId)) // Match Content ID with fieldId
|
||||
.flatMap(content -> content.getSettings().stream()) // Extract settings
|
||||
.filter(setting -> "criteria_table_columns".equals(setting.getName())) // Match name
|
||||
.map(setting -> setting.getName()) // Return the name of the setting
|
||||
.findFirst() // Get the first match
|
||||
.orElse(null); // Default to null if no match
|
||||
|
||||
if(tableType!=null){
|
||||
JSONObject jsonObject = new JSONObject(entityFieldValue);
|
||||
|
||||
// Extract the value of total
|
||||
entityFieldValue = jsonObject.getString("total");
|
||||
|
||||
}
|
||||
|
||||
updatedMappedFormulaValue.put(fieldId, entityFieldValue);
|
||||
});
|
||||
}
|
||||
if(formulaValueOpt==null || formulaValueOpt.isEmpty()){
|
||||
return;
|
||||
}
|
||||
double finalValue = evaluateFormula(formulaValueOpt, mappedFormulaValue, updatedMappedFormulaValue);
|
||||
|
||||
fieldValidator.formulaValidation(fieldValue, finalValue, label);
|
||||
}
|
||||
|
||||
|
||||
public static double evaluateFormula(String formula, Map<String, String> mappedFormulaValue, Map<String, String> updatedMappedFormulaValue) {
|
||||
// Step 1: Extract all placeholders (variables) like {rest}, {another_var}, etc.
|
||||
Pattern pattern = Pattern.compile("\\{(.*?)\\}");
|
||||
Matcher matcher = pattern.matcher(formula);
|
||||
List<String> variables = new ArrayList<>();
|
||||
|
||||
while (matcher.find()) {
|
||||
variables.add(matcher.group(1)); // Extract variable names inside the curly braces
|
||||
}
|
||||
|
||||
// Step 2: Replace placeholders with corresponding fieldValue
|
||||
Map<String, Double> variableValues = new HashMap<>();
|
||||
|
||||
for (String variable : variables) {
|
||||
String fieldId = mappedFormulaValue.get(variable);
|
||||
if (fieldId != null && updatedMappedFormulaValue.containsKey(fieldId)) {
|
||||
String fieldValueStr = updatedMappedFormulaValue.get(fieldId);
|
||||
try {
|
||||
double fieldValue = Double.parseDouble(fieldValueStr); // Assuming fieldValue is numeric
|
||||
variableValues.put(variable, fieldValue);
|
||||
} catch (NumberFormatException e) {
|
||||
// Handle invalid number format gracefully (e.g., log an error or default to 0)
|
||||
variableValues.put(variable, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Replace variables in the formula with their corresponding values
|
||||
String expression = formula;
|
||||
for (String variable : variables) {
|
||||
Double value = variableValues.get(variable);
|
||||
if (value != null) {
|
||||
// Replace {variable} with its corresponding value in the formula
|
||||
expression = expression.replace("{" + variable + "}", String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Evaluate the mathematical expression
|
||||
return Utils.evaluateExpression(expression);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,7 @@ import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.*;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.util.*;
|
||||
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.Status;
|
||||
@@ -25,6 +22,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.MessageFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@@ -32,6 +30,7 @@ import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.log;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Component
|
||||
@@ -116,6 +115,34 @@ public class ApplicationEvaluationDao {
|
||||
@Autowired
|
||||
private HubService hubService;
|
||||
|
||||
@Autowired
|
||||
private EvaluationFormService evaluationFormService;
|
||||
|
||||
@Autowired
|
||||
private EvaluationFormDao evaluationFormDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationFormRepository applicationEvaluationFormRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationFormFieldRepository applicationEvaluationFormFieldRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationDao applicationDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationService applicationEvaluationService;
|
||||
|
||||
@Autowired
|
||||
private CallDao callDao;
|
||||
|
||||
@Autowired
|
||||
private EvaluationFormRepository evaluationFormRepository;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
|
||||
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
|
||||
|
||||
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||
@@ -142,6 +169,7 @@ public class ApplicationEvaluationDao {
|
||||
entity.setSuspendedDays(0L);
|
||||
entity.setStartDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
entity.setEndDate(DateTimeUtil.DateServerToUTC(application.getSubmissionDate().plusDays(30)));
|
||||
entity.setEvaluationVersion(application.getEvaluationVersion());
|
||||
entity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
||||
return entity;
|
||||
}
|
||||
@@ -263,9 +291,13 @@ public class ApplicationEvaluationDao {
|
||||
response.setNote(entity.getNote());
|
||||
response.setMotivation(entity.getMotivation());
|
||||
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus()));
|
||||
response.setEvaluationVersion(EvaluationVersionEnum.valueOf(entity.getEvaluationVersion()));
|
||||
response.setEvaluationEndDate(entity.getEndDate());
|
||||
response.setCreatedDate(entity.getCreatedDate());
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
response.setNumberOfCheck(entity.getAssignedApplicationsEntity().getApplication().getCall().getNumberOfCheck());
|
||||
response.setProductId(entity.getAssignedApplicationsEntity().getApplication().getCall().getProductId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -612,6 +644,7 @@ public class ApplicationEvaluationDao {
|
||||
ApplicationEvaluationEntity oldApplicationEvaluation = null;
|
||||
ApplicationEntity application = applicationService.validateApplication(assignedApplications.get().getApplication().getId());
|
||||
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
||||
validateApplicationEvaluationRequest(req, application);
|
||||
if (existingEntityOptional.isPresent()) {
|
||||
entity = existingEntityOptional.get();
|
||||
oldApplicationEvaluation = Utils.getClonedEntityForData(entity);
|
||||
@@ -683,7 +716,14 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAmendmentDocumentsAndFormFields(List<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntities, List<AmendmentDetailsRequest> amendmentFormFields) {
|
||||
private void validateApplicationEvaluationRequest(ApplicationEvaluationRequest req, ApplicationEntity application) {
|
||||
if(EvaluationVersionEnum.V2.getValue().equals(application.getEvaluationVersion())) {
|
||||
req.setChecklist(null);
|
||||
req.setCriteria(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAmendmentDocumentsAndFormFields(List<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntities, List<AmendmentDetailsRequest> amendmentFormFields) {
|
||||
// Iterate through amendment request entities
|
||||
|
||||
//
|
||||
@@ -1107,6 +1147,7 @@ public class ApplicationEvaluationDao {
|
||||
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
||||
response.setApplicationId(application.getId());
|
||||
response.setAssignedApplicationId(assignedApplications.getId());
|
||||
response.setEvaluationVersion(EvaluationVersionEnum.valueOf(application.getEvaluationVersion()));
|
||||
response.setNote(null);
|
||||
response.setMotivation(null);
|
||||
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus()));
|
||||
@@ -1115,6 +1156,8 @@ public class ApplicationEvaluationDao {
|
||||
response.setEvaluationEndDate(entity.getEndDate());
|
||||
LocalDateTime callEndDate = application.getCall().getEndDate();
|
||||
response.setCallEndDate(callEndDate);
|
||||
response.setNumberOfCheck(call.getNumberOfCheck());
|
||||
response.setProductId(call.getProductId());
|
||||
setCriteriaResponses(entity, application.getId(), response, evaluationCriterias);
|
||||
setChecklistResponses(entity, application.getId(), response, checklistEntities);
|
||||
setFileResponses(entity, application.getId(), response, applicationFormEntities);
|
||||
@@ -1907,5 +1950,321 @@ public class ApplicationEvaluationDao {
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluation).newData(savedEntity).build());
|
||||
return convertToResponse(savedEntity);
|
||||
}
|
||||
|
||||
public ApplicationEvaluationFormResponse createApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationFormRequestBean applicationEvaluationFormRequestBean, Long evaluationFormId, Long assignedApplicationId){
|
||||
|
||||
UserEntity user = validator.validateUser(request);
|
||||
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
|
||||
ApplicationEntity application = applicationService.validateApplication(assignedApplicationsEntity.getApplication().getId());
|
||||
|
||||
// Convert FormRequestBean to ApplicationEvaluationRequest
|
||||
ApplicationEvaluationRequest req = convertToApplicationEvaluationRequest(applicationEvaluationFormRequestBean);
|
||||
|
||||
// Call the existing method to create or update evaluation
|
||||
ApplicationEvaluationResponse evaluationResponse = createOrUpdateApplicationEvaluation(user, req, assignedApplicationId);
|
||||
|
||||
ApplicationEvaluationEntity entity = applicationEvaluationService.validateApplicationEvaluation(evaluationResponse.getId());
|
||||
|
||||
//Handling Application Evaluation form
|
||||
EvaluationFormEntity evaluationFormEntity = evaluationFormService.validateEvaluationForm(evaluationFormId);
|
||||
validateFormFields(applicationEvaluationFormRequestBean,evaluationFormEntity);
|
||||
// ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationRepository.findByAssignedApplicationsId(assignedApplicationId);
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = getApplicationEvaluationFormOrCreate(evaluationFormEntity,entity);
|
||||
createOrUpdateMultipleFormFields(applicationEvaluationFormRequestBean.getFormFields(), applicationEvaluationFormEntity, evaluationFormEntity);
|
||||
return processEvaluationForm(entity);
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormEntity getApplicationEvaluationFormOrCreate(EvaluationFormEntity evaluationFormEntity, ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = applicationEvaluationFormRepository.findByEvaluationIdAndEvaluationFormId(applicationEvaluationEntity.getId(), evaluationFormEntity.getId());
|
||||
ApplicationEvaluationFormEntity oldApplicationEvaluationFormEntity = Utils.getClonedEntityForData(applicationEvaluationFormEntity);
|
||||
if (applicationEvaluationFormEntity == null) {
|
||||
applicationEvaluationFormEntity = createApplicationEvaluationFormEntity(applicationEvaluationEntity, evaluationFormEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Create application evalaution form" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(oldApplicationEvaluationFormEntity).newData(applicationEvaluationFormEntity)
|
||||
.build());
|
||||
}
|
||||
return applicationEvaluationFormEntity;
|
||||
}
|
||||
|
||||
public ApplicationEvaluationFormEntity createApplicationEvaluationFormEntity(ApplicationEvaluationEntity applicationEvaluationEntity, EvaluationFormEntity evaluationFormEntity) {
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = new ApplicationEvaluationFormEntity();
|
||||
applicationEvaluationFormEntity.setApplicationId(applicationEvaluationEntity.getApplicationId());
|
||||
applicationEvaluationFormEntity.setEvaluationForm(evaluationFormEntity);
|
||||
applicationEvaluationFormEntity.setApplicationEvaluation(applicationEvaluationEntity);
|
||||
applicationEvaluationFormEntity.setIsDeleted(false);
|
||||
return saveApplicationEvaluationFormEntity(applicationEvaluationFormEntity);
|
||||
}
|
||||
|
||||
public void validateFormFields(ApplicationEvaluationFormRequestBean request, EvaluationFormEntity evaluationFormEntity) {
|
||||
|
||||
List<ContentResponseBean> contentResponseBeans=evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent();
|
||||
|
||||
List<ApplicationFormFieldRequestBean> requestFields = request.getFormFields();
|
||||
|
||||
Map<String, String> contentMap = contentResponseBeans.stream()
|
||||
.collect(Collectors.toMap(ContentResponseBean::getId, ContentResponseBean::getLabel)); // Change getLabel() if needed
|
||||
FieldValidator validator = FieldValidator.create();
|
||||
for (ApplicationFormFieldRequestBean requestField : requestFields) {
|
||||
String fieldId = requestField.getFieldId();
|
||||
|
||||
if (!contentMap.containsKey(fieldId)) {
|
||||
validator.addError(MessageFormat.format(Translator.toLocale(GepafinConstant.FIELD_ID_NOT_FOUND), fieldId));
|
||||
}
|
||||
|
||||
}
|
||||
validator.validate();
|
||||
}
|
||||
|
||||
public ApplicationEvaluationFormEntity saveApplicationEvaluationFormEntity(ApplicationEvaluationFormEntity applicationEvaluationFormEntity) {
|
||||
return applicationEvaluationFormRepository.save(applicationEvaluationFormEntity);
|
||||
}
|
||||
|
||||
public List<ApplicationEvaluationFormFieldEntity> createOrUpdateMultipleFormFields(List<ApplicationFormFieldRequestBean> formFieldRequestBeans,
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity, EvaluationFormEntity evaluationFormEntity) {
|
||||
|
||||
List<ApplicationEvaluationFormFieldEntity> existingFields = applicationEvaluationFormFieldRepository.findByApplicationEvaluationFormId(applicationEvaluationFormEntity.getId());
|
||||
|
||||
return formFieldRequestBeans.stream().map(requestBean -> createOrUpdateApplicationEvaluationFormField(requestBean, applicationEvaluationFormEntity, existingFields, evaluationFormEntity))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public ApplicationEvaluationFormFieldEntity createOrUpdateApplicationEvaluationFormField(ApplicationFormFieldRequestBean applicationFormFieldRequestBean,
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity,
|
||||
List<ApplicationEvaluationFormFieldEntity> applicationEvaluationFormFieldEntities,
|
||||
EvaluationFormEntity evaluationFormEntity){
|
||||
ApplicationEvaluationFormFieldEntity applicationEvaluationFormFieldEntity = new ApplicationEvaluationFormFieldEntity();
|
||||
validateFileUploadDocuments(applicationFormFieldRequestBean, evaluationFormEntity);
|
||||
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
||||
ApplicationEvaluationFormFieldEntity oldApplicationEvaluationFormFieldData = null;
|
||||
if (applicationEvaluationFormFieldEntities == null || applicationEvaluationFormFieldEntities.isEmpty()) {
|
||||
applicationEvaluationFormFieldEntity = new ApplicationEvaluationFormFieldEntity();
|
||||
applicationEvaluationFormFieldEntity.setApplicationEvaluationForm(applicationEvaluationFormEntity);
|
||||
applicationEvaluationFormFieldEntity.setIsDeleted(false);
|
||||
}else{
|
||||
for (ApplicationEvaluationFormFieldEntity existingFieldEntity : applicationEvaluationFormFieldEntities) {
|
||||
if (existingFieldEntity.getFieldId().equals(applicationFormFieldRequestBean.getFieldId())) {
|
||||
applicationEvaluationFormFieldEntity = existingFieldEntity;
|
||||
oldApplicationEvaluationFormFieldData = Utils.getClonedEntityForData(existingFieldEntity);
|
||||
actionType = VersionActionTypeEnum.UPDATE;
|
||||
break;
|
||||
} else {
|
||||
applicationEvaluationFormFieldEntity.setApplicationEvaluationForm(applicationEvaluationFormEntity);
|
||||
applicationEvaluationFormFieldEntity.setIsDeleted(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
Utils.setIfUpdated(applicationEvaluationFormFieldEntity::getFieldId, applicationEvaluationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
|
||||
|
||||
if (applicationFormFieldRequestBean.getFieldValue() != null) {
|
||||
applicationEvaluationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue()));
|
||||
} else {
|
||||
applicationEvaluationFormFieldEntity.setFieldValue(null);
|
||||
}
|
||||
|
||||
ApplicationEvaluationFormFieldEntity savedEvaluationFormFieldEntity = applicationEvaluationFormFieldRepository.save(applicationEvaluationFormFieldEntity);
|
||||
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplicationEvaluationFormFieldData).newData(savedEvaluationFormFieldEntity).build());
|
||||
|
||||
log.info("Version history logged for action: {}, Field ID: {}", actionType, applicationEvaluationFormFieldEntity.getFieldId());
|
||||
|
||||
return savedEvaluationFormFieldEntity;
|
||||
}
|
||||
|
||||
private List<Long> validateFileUploadDocuments(ApplicationFormFieldRequestBean applicationFormFieldRequestBean, EvaluationFormEntity evaluationFormEntity) {
|
||||
List<Long> documentIds=null;
|
||||
|
||||
List<ContentResponseBean> contentResponseBeans=evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent();
|
||||
for (ContentResponseBean contentResponseBean:contentResponseBeans){
|
||||
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload"))) {
|
||||
if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) {
|
||||
Object fieldValueObject = applicationFormFieldRequestBean.getFieldValue();
|
||||
if (fieldValueObject instanceof String) {
|
||||
// Safely cast the object to a string
|
||||
String documentId = (String) fieldValueObject;
|
||||
// Now you can use documentId as needed
|
||||
documentIds = applicationDao.validateDocumentIds(documentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return documentIds;
|
||||
}
|
||||
|
||||
|
||||
private List<ApplicationEvaluationFormFieldReponseBean> createEvaluationFormFieldResponse(
|
||||
List<ApplicationEvaluationFormFieldEntity> evaluationFormFieldEntities,
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity){
|
||||
List<ApplicationEvaluationFormFieldReponseBean> evaluationFormFieldResponseBeans = new ArrayList<>();
|
||||
List<ContentResponseBean> contentResponseBeans =evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(applicationEvaluationFormEntity.getEvaluationForm()).getContent();
|
||||
|
||||
for (ApplicationEvaluationFormFieldEntity applicationEvaluationFormFieldEntity : evaluationFormFieldEntities) {
|
||||
|
||||
Optional<ContentResponseBean> fileUploadContent = contentResponseBeans.stream()
|
||||
.filter(contentResponseBean -> "fileupload".equals(contentResponseBean.getName()) &&
|
||||
contentResponseBean.getId().equals(applicationEvaluationFormFieldEntity.getFieldId()))
|
||||
.findFirst();
|
||||
|
||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||
if (fileUploadContent.isPresent()) {
|
||||
String documentId = applicationEvaluationFormFieldEntity.getFieldValue();
|
||||
if (documentId != null && !documentId.isEmpty()) {
|
||||
documentResponseBeans = Arrays.stream(documentId.split(","))
|
||||
.map(String::trim)
|
||||
.map(Long::parseLong)
|
||||
.map(docId -> {
|
||||
DocumentEntity documentEntity = documentService.validateDocument(docId);
|
||||
// if (Boolean.FALSE.equals(DocumentSourceTypeEnum.APPLICATION.getValue().equals(documentEntity.getSource()))) {
|
||||
// throw new CustomValidationException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND));
|
||||
// }
|
||||
return documentEntity;
|
||||
})
|
||||
.map(callDao::convertToDocumentResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
ApplicationEvaluationFormFieldReponseBean responseBean = convertToEvaluationFormFieldResponseBean(
|
||||
applicationEvaluationFormFieldEntity, applicationEvaluationFormEntity.getId());
|
||||
if (!documentResponseBeans.isEmpty()) {
|
||||
responseBean.setFieldValue(documentResponseBeans);
|
||||
}
|
||||
evaluationFormFieldResponseBeans.add(responseBean);
|
||||
}
|
||||
return evaluationFormFieldResponseBeans;
|
||||
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormFieldReponseBean convertToEvaluationFormFieldResponseBean(ApplicationEvaluationFormFieldEntity entity,Long applicationEvaluationFormId){
|
||||
ApplicationEvaluationFormFieldReponseBean applicationEvaluationFormFieldReponseBean = new ApplicationEvaluationFormFieldReponseBean();
|
||||
applicationEvaluationFormFieldReponseBean.setApplicationEvaluationFormId(applicationEvaluationFormId);
|
||||
applicationEvaluationFormFieldReponseBean.setFieldId(entity.getFieldId());
|
||||
if(entity.getFieldValue() != null) {
|
||||
applicationEvaluationFormFieldReponseBean.setFieldValue(Utils.getFieldValueAsObject(entity.getFieldValue()));
|
||||
}
|
||||
applicationEvaluationFormFieldReponseBean.setId(entity.getId());
|
||||
applicationEvaluationFormFieldReponseBean.setCreatedDate(entity.getCreatedDate());
|
||||
applicationEvaluationFormFieldReponseBean.setUpdatedDate(entity.getUpdatedDate());
|
||||
return applicationEvaluationFormFieldReponseBean;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponse convertToApplicationEvaluationResponseBean(ApplicationEvaluationResponse applicationEvaluationResponse){
|
||||
ApplicationEvaluationFormResponse response = new ApplicationEvaluationFormResponse();
|
||||
response.setId(applicationEvaluationResponse.getId());
|
||||
response.setApplicationId(applicationEvaluationResponse.getApplicationId());
|
||||
response.setNote(applicationEvaluationResponse.getNote());
|
||||
response.setEvaluationVersion(applicationEvaluationResponse.getEvaluationVersion());
|
||||
response.setCreatedDate(applicationEvaluationResponse.getCreatedDate());
|
||||
response.setUpdatedDate(applicationEvaluationResponse.getUpdatedDate());
|
||||
response.setApplicationStatus(applicationEvaluationResponse.getApplicationStatus());
|
||||
response.setAssignedApplicationId(applicationEvaluationResponse.getAssignedApplicationId());
|
||||
response.setMinScore(applicationEvaluationResponse.getMinScore());
|
||||
response.setStatus(applicationEvaluationResponse.getStatus());
|
||||
response.setFiles(applicationEvaluationResponse.getFiles());
|
||||
response.setEvaluationDocument(applicationEvaluationResponse.getEvaluationDocument());
|
||||
response.setAmendmentDetails(applicationEvaluationResponse.getAmendmentDetails());
|
||||
response.setBeneficiary(applicationEvaluationResponse.getBeneficiary());
|
||||
response.setAssignedUserId(applicationEvaluationResponse.getAssignedUserId());
|
||||
response.setAssignedUserName(applicationEvaluationResponse.getAssignedUserName());
|
||||
response.setProtocolNumber(applicationEvaluationResponse.getProtocolNumber());
|
||||
response.setCallName(applicationEvaluationResponse.getCallName());
|
||||
response.setMotivation(applicationEvaluationResponse.getMotivation());
|
||||
response.setSubmissionDate(applicationEvaluationResponse.getSubmissionDate());
|
||||
response.setEvaluationEndDate(applicationEvaluationResponse.getEvaluationEndDate());
|
||||
response.setCallEndDate(applicationEvaluationResponse.getCallEndDate());
|
||||
response.setCompanyName(applicationEvaluationResponse.getCompanyName());
|
||||
response.setAssignedAt(applicationEvaluationResponse.getAssignedAt());
|
||||
response.setNdg(applicationEvaluationResponse.getNdg());
|
||||
response.setAppointmentId(applicationEvaluationResponse.getAppointmentId());
|
||||
response.setAmountRequested(applicationEvaluationResponse.getAmountRequested());
|
||||
response.setAmountAccepted(applicationEvaluationResponse.getAmountAccepted());
|
||||
response.setDateAccepted(applicationEvaluationResponse.getDateAccepted());
|
||||
response.setDateRejected(applicationEvaluationResponse.getDateRejected());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId ){
|
||||
|
||||
if (applicationId == null && assignedApplicationId == null) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.EITHER_APPLICATION_ID_OR_ASSIGNED_APPLICATION_ID_MUST_BE_PROVIDED));
|
||||
}
|
||||
|
||||
ApplicationEvaluationEntity evaluationEntity = applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationId(applicationId, assignedApplicationId);
|
||||
|
||||
return (evaluationEntity != null) ? processEvaluationForm(evaluationEntity) : null;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponse processEvaluationForm(ApplicationEvaluationEntity evaluationEntity){
|
||||
|
||||
Object convertedResponse = convertToResponse(evaluationEntity);
|
||||
|
||||
ApplicationEvaluationFormResponse response = objectMapper.convertValue(convertedResponse, ApplicationEvaluationFormResponse.class);
|
||||
EvaluationFormEntity evaluationFormEntity = evaluationFormRepository.findByCallIdAndIsDeletedFalse(evaluationEntity.getAssignedApplicationsEntity().getApplication().getCall().getId());
|
||||
|
||||
if (evaluationFormEntity != null) {
|
||||
response.setApplicationEvaluationFormResponse(convertEvaluationFormToResponse(evaluationFormEntity, evaluationEntity));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponseBean convertEvaluationFormToResponse(EvaluationFormEntity evaluationForm, ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||
ApplicationEvaluationFormResponseBean applicationEvaluationFormResponseBean = createEvaluationFormResponse(evaluationForm);
|
||||
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = applicationEvaluationFormRepository.findByEvaluationIdAndEvaluationFormId(applicationEvaluationEntity.getId(), evaluationForm.getId());
|
||||
|
||||
if(applicationEvaluationFormEntity!=null) {
|
||||
List<ApplicationEvaluationFormFieldEntity> applicationEvaluationFormFieldEntities = applicationEvaluationFormFieldRepository.findByApplicationEvaluationFormId(applicationEvaluationFormEntity.getId());
|
||||
List<ApplicationEvaluationFormFieldReponseBean> evaluationFormFieldResponseBeans = createEvaluationFormFieldResponse(applicationEvaluationFormFieldEntities, applicationEvaluationFormEntity);
|
||||
applicationEvaluationFormResponseBean.setFormFields(evaluationFormFieldResponseBeans);
|
||||
}
|
||||
|
||||
return applicationEvaluationFormResponseBean;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponseBean createEvaluationFormResponse(EvaluationFormEntity evaluationFormEntity) {
|
||||
ApplicationEvaluationFormResponseBean evaluationFormResponseBean = new ApplicationEvaluationFormResponseBean();
|
||||
evaluationFormResponseBean.setId(evaluationFormEntity.getId());
|
||||
evaluationFormResponseBean.setLabel(evaluationFormEntity.getLabel());
|
||||
evaluationFormResponseBean.setCallId(evaluationFormEntity.getCall().getId());
|
||||
evaluationFormResponseBean.setContent(evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent());
|
||||
return evaluationFormResponseBean;
|
||||
}
|
||||
|
||||
public ApplicationEvaluationVersionResponse getApplicationEvaluationVersion(HttpServletRequest request, Long applicationId){
|
||||
|
||||
log.info("Fetching application evaluation version with ID: {}", applicationId);
|
||||
|
||||
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
||||
return buildApplicationEvaluationVersionResponse(applicationEntity);
|
||||
|
||||
}
|
||||
private ApplicationEvaluationVersionResponse buildApplicationEvaluationVersionResponse(ApplicationEntity applicationEntity) {
|
||||
ApplicationEvaluationVersionResponse response = new ApplicationEvaluationVersionResponse();
|
||||
response.setApplicationId(applicationEntity.getId());
|
||||
response.setCallId(applicationEntity.getCall().getId());
|
||||
response.setCompanyId(applicationEntity.getCompanyId());
|
||||
response.setEvaluationVersion(EvaluationVersionEnum.valueOf(applicationEntity.getEvaluationVersion()));
|
||||
response.setEvaluationId(applicationEntity.getApplicationEvaluationId());
|
||||
return response;
|
||||
}
|
||||
|
||||
public static ApplicationEvaluationRequest convertToApplicationEvaluationRequest(ApplicationEvaluationFormRequestBean formRequestBean) {
|
||||
ApplicationEvaluationRequest request = new ApplicationEvaluationRequest();
|
||||
request.setFiles(formRequestBean.getFiles());
|
||||
request.setEvaluationDocument(formRequestBean.getEvaluationDocument());
|
||||
request.setAmendmentDetails(formRequestBean.getAmendmentDetails());
|
||||
request.setNote(formRequestBean.getNote());
|
||||
request.setApplicationStatus(formRequestBean.getApplicationStatus());
|
||||
request.setMotivation(formRequestBean.getMotivation());
|
||||
request.setAmountAccepted(formRequestBean.getAmountAccepted());
|
||||
|
||||
request.setCriteria(null);
|
||||
request.setChecklist(null);
|
||||
|
||||
return request;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,6 +200,8 @@ public class AssignedApplicationsDao {
|
||||
if(applicationEvaluationEntity.isPresent()){
|
||||
assignedApplicationsResponse.setEvaluationEndDate(applicationEvaluationEntity.get().getEndDate());
|
||||
}
|
||||
assignedApplicationsResponse.setNumberOfCheck(application.getCall().getNumberOfCheck());
|
||||
assignedApplicationsResponse.setProductId(application.getCall().getProductId());
|
||||
return assignedApplicationsResponse;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +201,8 @@ public class CallDao {
|
||||
callEntity.setStartTime(DateTimeUtil.parseTime(createCallRequest.getStartTime()));
|
||||
callEntity.setEndTime(DateTimeUtil.parseTime(createCallRequest.getEndTime()));
|
||||
callEntity.setHub(userEntity.getHub());
|
||||
callEntity.setNumberOfCheck(createCallRequest.getNumberOfCheck());
|
||||
callEntity.setProductId(createCallRequest.getProductId());
|
||||
callEntity = callRepository.save(callEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Create Call" operation. **/
|
||||
@@ -607,6 +609,8 @@ public class CallDao {
|
||||
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
|
||||
setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi());
|
||||
setIfUpdated(callEntity::getEvaluationVersion, callEntity::setEvaluationVersion, updateCallRequest.getEvaluationVersion().getValue());
|
||||
setIfUpdated(callEntity::getNumberOfCheck, callEntity::setNumberOfCheck, updateCallRequest.getNumberOfCheck());
|
||||
setIfUpdated(callEntity::getProductId, callEntity::setProductId, updateCallRequest.getProductId());
|
||||
callEntity = callRepository.save(callEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "update call step 1" operation **/
|
||||
@@ -713,7 +717,8 @@ public class CallDao {
|
||||
callDetailsResponseBean.setPhoneNumber(callEntity.getPhoneNumber());
|
||||
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
|
||||
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
|
||||
|
||||
callDetailsResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck());
|
||||
callDetailsResponseBean.setProductId(callEntity.getProductId());
|
||||
return callDetailsResponseBean;
|
||||
}
|
||||
|
||||
@@ -737,6 +742,8 @@ public class CallDao {
|
||||
createCallResponseBean.setFaq(faqService.getFaqByCallId(callEntity.getId()));
|
||||
createCallResponseBean.setAimedTo(amiedTo);
|
||||
createCallResponseBean.setCheckList(checkList);
|
||||
createCallResponseBean.setNumberOfCheck(callEntity.getNumberOfCheck());
|
||||
createCallResponseBean.setProductId(callEntity.getProductId());
|
||||
return createCallResponseBean;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,8 +230,8 @@ public class CompanyDao {
|
||||
String responseJson = companyRequest.getVatCheckResponse() != null ? Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) : null;
|
||||
setIfUpdated(userWithCompanyEntity::getJson, userWithCompanyEntity::setJson, responseJson);
|
||||
}
|
||||
setIfUpdated(userWithCompanyEntity::getPec, userWithCompanyEntity::setPec, userWithCompanyEntity.getPec());
|
||||
setIfUpdated(userWithCompanyEntity::getEmail, userWithCompanyEntity::setEmail, userWithCompanyEntity.getEmail());
|
||||
setIfUpdated(userWithCompanyEntity::getPec, userWithCompanyEntity::setPec, companyRequest.getPec());
|
||||
setIfUpdated(userWithCompanyEntity::getEmail, userWithCompanyEntity::setEmail, companyRequest.getEmail());
|
||||
setIfUpdated(userWithCompanyEntity::getContactName, userWithCompanyEntity::setContactName, companyRequest.getContactName());
|
||||
setIfUpdated(userWithCompanyEntity::getContactEmail, userWithCompanyEntity::setContactEmail, companyRequest.getContactEmail());
|
||||
setIfUpdated(userWithCompanyEntity::getIsLegalRepresentant, userWithCompanyEntity::setIsLegalRepresentant, companyRequest.getIsLegalRepresentant());
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
@@ -11,17 +12,21 @@ import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -60,7 +65,7 @@ public class DashboardDao {
|
||||
public SuperAdminWidgetResponseBean getDashboardWidget(UserEntity requestedUserEntity) {
|
||||
SuperAdminWidgetResponseBean widgetResponseBean = new SuperAdminWidgetResponseBean();
|
||||
widgetResponseBean.setWidget1(createWidget1(requestedUserEntity));
|
||||
Map<String, Object> widgetBars =getStatistics(requestedUserEntity);
|
||||
Map<String, Object> widgetBars = getStatistics(requestedUserEntity);
|
||||
widgetResponseBean.setWidgetBars(widgetBars);
|
||||
return widgetResponseBean;
|
||||
}
|
||||
@@ -74,8 +79,8 @@ public class DashboardDao {
|
||||
setSubmittedApplications(widget1, requestedUserEntity);
|
||||
setDraftApplications(widget1, requestedUserEntity);
|
||||
setNumberOfCompanies(widget1, requestedUserEntity);
|
||||
setAmountRequested(widget1,requestedUserEntity);
|
||||
setAmountAccepted(widget1,requestedUserEntity);
|
||||
setAmountRequested(widget1, requestedUserEntity);
|
||||
setAmountAccepted(widget1, requestedUserEntity);
|
||||
return widget1;
|
||||
}
|
||||
|
||||
@@ -193,6 +198,7 @@ public class DashboardDao {
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
// public Page<UserActionEntity> getUserAction(UserEntity requestedUserEntity){
|
||||
// Pageable pageable = PageRequest.of(0, 20); // Get the first 20 records
|
||||
// List<String> roles=List.of(RoleStatusEnum.ROLE_PRE_INSTRUCTOR.getValue(),RoleStatusEnum.ROLE_GEPAFIN_OPERATOR.getValue(),RoleStatusEnum.ROLE_INSTRUCTOR_MANAGER.getValue());
|
||||
@@ -251,7 +257,7 @@ public class DashboardDao {
|
||||
responseBean.setEvaluationAverageTime(averageTime != null ? averageTime.setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO);
|
||||
}
|
||||
LocalDate twoDaysLater = LocalDate.now().plusDays(2);
|
||||
List<String> statusList =Arrays.asList( ApplicationEvaluationStatusTypeEnum.OPEN.getValue(), ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||
List<String> statusList = Arrays.asList(ApplicationEvaluationStatusTypeEnum.OPEN.getValue(), ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||
Long dueApplications = applicationEvaluationRepository.countDueApplicationsBetween(
|
||||
applicationIds,
|
||||
LocalDate.now(),
|
||||
@@ -263,6 +269,7 @@ public class DashboardDao {
|
||||
responseBean.setNumberOfDueApplication(dueApplications);
|
||||
}
|
||||
}
|
||||
|
||||
private AmendmentWidgetResponseBean initializeAmendmentResponseBean() {
|
||||
return AmendmentWidgetResponseBean.builder()
|
||||
.totalAmendments(0L)
|
||||
@@ -278,21 +285,24 @@ public class DashboardDao {
|
||||
AmendmentWidgetResponseBean amendmentWidgetResponseBean = initializeAmendmentResponseBean();
|
||||
|
||||
Long hubId = userEntity.getHub().getId();
|
||||
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity,hubId);
|
||||
setAmendmentCounts(applicationIds,amendmentWidgetResponseBean, hubId);
|
||||
calculateExpiringRequestsIn48Hours(applicationIds,amendmentWidgetResponseBean, hubId);
|
||||
calculateAverageResponseDays(applicationIds,amendmentWidgetResponseBean,hubId);
|
||||
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity, hubId, null);
|
||||
setAmendmentCounts(applicationIds, amendmentWidgetResponseBean, hubId);
|
||||
calculateExpiringRequestsIn48Hours(applicationIds, amendmentWidgetResponseBean, hubId);
|
||||
calculateAverageResponseDays(applicationIds, amendmentWidgetResponseBean, hubId);
|
||||
return amendmentWidgetResponseBean;
|
||||
}
|
||||
public List<Long> getApplicationIdsForUserOrHub(UserEntity userEntity, Long hubId) {
|
||||
if (validator.checkIsPreInstructor()) {
|
||||
|
||||
public List<Long> getApplicationIdsForUserOrHub(UserEntity userEntity, Long hubId, Long userId) {
|
||||
if (userId != null) {
|
||||
return assignedApplicationsRepository.findApplicationIdsByUserIdAndIsDeletedFalse(userId);
|
||||
} else if (validator.checkIsPreInstructor()) {
|
||||
return assignedApplicationsRepository.findApplicationIdsByUserIdAndIsDeletedFalse(userEntity.getId());
|
||||
} else {
|
||||
return applicationRepository.findApplicationIdsByHubId(hubId);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAmendmentCounts(List<Long> applicationIds,AmendmentWidgetResponseBean responseBean, Long hubId) {
|
||||
private void setAmendmentCounts(List<Long> applicationIds, AmendmentWidgetResponseBean responseBean, Long hubId) {
|
||||
|
||||
Long totalAmendment = applicationAmendmentRequestRepository.countAmendmentsByApplicationIds(applicationIds);
|
||||
if (totalAmendment != null) {
|
||||
@@ -316,7 +326,7 @@ public class DashboardDao {
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateExpiringRequestsIn48Hours(List<Long> applicationIds ,AmendmentWidgetResponseBean responseBean, Long hubId) {
|
||||
private void calculateExpiringRequestsIn48Hours(List<Long> applicationIds, AmendmentWidgetResponseBean responseBean, Long hubId) {
|
||||
|
||||
// Define the statuses to filter
|
||||
List<String> statuses = List.of(
|
||||
@@ -338,7 +348,7 @@ public class DashboardDao {
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateAverageResponseDays(List<Long> applicationIds ,AmendmentWidgetResponseBean responseBean, Long hubId) {
|
||||
private void calculateAverageResponseDays(List<Long> applicationIds, AmendmentWidgetResponseBean responseBean, Long hubId) {
|
||||
|
||||
if (!applicationIds.isEmpty()) {
|
||||
BigDecimal averageResponseDays = applicationAmendmentRequestRepository
|
||||
@@ -361,7 +371,7 @@ public class DashboardDao {
|
||||
List<Long> applicationIds;
|
||||
if (validator.checkIsPreInstructor()) {
|
||||
results = assignedApplicationsRepository.countAssignedApplicationsWithStatus(userId, hubId);
|
||||
applicationIds = assignedApplicationsRepository.findApplicationIdsByUserIdAndHubIdAndIsDeletedFalse(userId,hubId);
|
||||
applicationIds = assignedApplicationsRepository.findApplicationIdsByUserIdAndHubIdAndIsDeletedFalse(userId, hubId);
|
||||
} else {
|
||||
results = assignedApplicationsRepository.countAssignedApplicationsForHub(hubId);
|
||||
applicationIds = assignedApplicationsRepository.findApplicationIdsByHubId(hubId);
|
||||
@@ -383,9 +393,9 @@ public class DashboardDao {
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
LocalDate twoDaysLater = today.plusDays(2);
|
||||
List<String> statusList =Arrays.asList( ApplicationEvaluationStatusTypeEnum.OPEN.getValue(), ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||
List<String> statusList = Arrays.asList(ApplicationEvaluationStatusTypeEnum.OPEN.getValue(), ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||
Long dueApplications = applicationEvaluationRepository.countDueApplicationsBetween(
|
||||
applicationIds, today, twoDaysLater,statusList
|
||||
applicationIds, today, twoDaysLater, statusList
|
||||
);
|
||||
response.setNumberOfApplicationExpiringIn48Hours(dueApplications != null ? dueApplications : 0L);
|
||||
}
|
||||
@@ -415,22 +425,24 @@ public class DashboardDao {
|
||||
ApplicationStatusTypeEnum.ADMISSIBLE.getValue()
|
||||
);
|
||||
}
|
||||
|
||||
public BeneficiaryStatisticsResponseBean getStatisticsPageForBeneficiary(UserEntity userEntity, CompanyEntity company) {
|
||||
BeneficiaryStatisticsResponseBean widgetResponseBean = initializeBeneficiaryStatisticsBean();
|
||||
UserWithCompanyEntity userWithCompanyEntity = companyService.getUserWithCompany(userEntity.getId(), company.getId());
|
||||
Long hubId = userEntity.getHub().getId();
|
||||
List<String> statusList = getStatusList();
|
||||
Long submittedApplication = applicationRepository.countSubmittedApplicationsByHubIdAndUserId(hubId, userEntity.getId(), userWithCompanyEntity.getId(),statusList);
|
||||
Long submittedApplication = applicationRepository.countSubmittedApplicationsByHubIdAndUserId(hubId, userEntity.getId(), userWithCompanyEntity.getId(), statusList);
|
||||
Long approvedApplication = getApplicationCountByStatus(hubId, userEntity.getId(), userWithCompanyEntity.getId(), ApplicationStatusTypeEnum.APPROVED);
|
||||
BigDecimal successRate = getSuccessRate(hubId, userEntity.getId(), userWithCompanyEntity.getId());
|
||||
BigDecimal totalAmountRequested = applicationRepository.sumAmountRequestedByHubIdAndUserId(hubId, userEntity.getId(), userWithCompanyEntity.getId());
|
||||
|
||||
updateApplicationWidget(widgetResponseBean.getApplicationWidget(), submittedApplication, approvedApplication, successRate,totalAmountRequested);
|
||||
updateApplicationWidget(widgetResponseBean.getApplicationWidget(), submittedApplication, approvedApplication, successRate, totalAmountRequested);
|
||||
|
||||
Map<String, Object> widgetBars = getApplicationStatistics(userEntity,userWithCompanyEntity.getId());
|
||||
Map<String, Object> widgetBars = getApplicationStatistics(userEntity, userWithCompanyEntity.getId());
|
||||
widgetResponseBean.setApplicationWidgetBars(widgetBars);
|
||||
return widgetResponseBean;
|
||||
}
|
||||
|
||||
private BeneficiaryStatisticsResponseBean initializeBeneficiaryStatisticsBean() {
|
||||
return BeneficiaryStatisticsResponseBean.builder()
|
||||
.applicationWidget(ApplicationWidget.builder()
|
||||
@@ -441,12 +453,15 @@ public class DashboardDao {
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
private Long getApplicationCountByStatus(Long hubId, Long userId, Long userWithCompanyId, ApplicationStatusTypeEnum status) {
|
||||
return applicationRepository.countSubmittedApplicationsByHubIdAndUserIdAndStatus(hubId, userId, userWithCompanyId, status.getValue());
|
||||
}
|
||||
|
||||
private BigDecimal getSuccessRate(Long hubId, Long userId, Long userWithCompanyId) {
|
||||
return applicationRepository.findSuccessRateByHubIdAndUserIdAndUserWithCompanyId(hubId, userId, userWithCompanyId);
|
||||
}
|
||||
|
||||
private void updateApplicationWidget(ApplicationWidget applicationWidget, Long submittedApplication, Long approvedApplication, BigDecimal successRate, BigDecimal totalAmountRequested) {
|
||||
applicationWidget.setSubmittedApplication(submittedApplication != null ? submittedApplication : 0L);
|
||||
applicationWidget.setApprovedApplication(approvedApplication != null ? approvedApplication : 0L);
|
||||
@@ -454,7 +469,7 @@ public class DashboardDao {
|
||||
applicationWidget.setTotalAmountFinanced(totalAmountRequested != null ? totalAmountRequested : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
public Map<String, Object> getApplicationStatistics(UserEntity requestedUser,Long userWithCompanyId) {
|
||||
public Map<String, Object> getApplicationStatistics(UserEntity requestedUser, Long userWithCompanyId) {
|
||||
Map<String, Object> stats = new HashMap<>();
|
||||
|
||||
Map<String, Long> statusData = new HashMap<>();
|
||||
@@ -499,11 +514,107 @@ public class DashboardDao {
|
||||
data.put(GepafinConstant.TOTAL_APPROVED, result[2]);
|
||||
return data;
|
||||
}).toList());
|
||||
|
||||
|
||||
|
||||
|
||||
return stats;
|
||||
}
|
||||
private PreInstructorWidgetResponseBean initializeDashboardPreInstructorResponseBean() {
|
||||
return PreInstructorWidgetResponseBean.builder()
|
||||
.assignedApplication(ApplicationToConsider.builder()
|
||||
.totalAssignedApplication(0L)
|
||||
.additionalApplicationPercentage(BigDecimal.ZERO)
|
||||
.build())
|
||||
.evaluatedApplication(EvaluatedApplication.builder()
|
||||
.evaluatedApplication(0L)
|
||||
.dailyAverage(BigDecimal.ZERO)
|
||||
.build())
|
||||
.averageEvaluationDays(AverageEvaluationTime.builder()
|
||||
.averageEvlauationDaysRating(BigDecimal.ZERO)
|
||||
.timeDifferenceFromAverage(BigDecimal.ZERO)
|
||||
.build())
|
||||
.amendmentInProgress(RescueInstructorInProgress.builder()
|
||||
.totalAmendmentInProgress(0L)
|
||||
.expiringToday(0L)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
public PreInstructorWidgetResponseBean getDashboardWidgetForPreInstructor(HttpServletRequest request, Long userId) {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
if (validator.checkIsPreInstructor() && userId == null) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
||||
}
|
||||
if (userId != null) {
|
||||
validator.validatePreInstructor(request, userId);
|
||||
if (validator.checkIsInstructorManager() && !userEntity.getId().equals(userId)) {
|
||||
throw new ForbiddenAccessException(Status.FORBIDDEN,
|
||||
Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||
}
|
||||
}
|
||||
PreInstructorWidgetResponseBean preInstructorWidgetResponseBean = initializeDashboardPreInstructorResponseBean();
|
||||
Long hubId = userEntity.getHub().getId();
|
||||
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity, hubId,userId);
|
||||
setPreInstructorWidgets(applicationIds, preInstructorWidgetResponseBean,hubId);
|
||||
calculateAverageEvaluationTime(applicationIds, preInstructorWidgetResponseBean, hubId);
|
||||
return preInstructorWidgetResponseBean;
|
||||
}
|
||||
private void setPreInstructorWidgets(List<Long> applicationIds, PreInstructorWidgetResponseBean responseBean,Long hubId) {
|
||||
List<String> assignedApplicationStatus = Arrays.asList(AssignedApplicationEnum.AWAITING.getValue(), AssignedApplicationEnum.OPEN.getValue());
|
||||
Long totalAssignedApplications = assignedApplicationsRepository.countAssignedApplicationsByApplicationIds(applicationIds,assignedApplicationStatus);
|
||||
if (totalAssignedApplications != null) {
|
||||
responseBean.getAssignedApplication().setTotalAssignedApplication(totalAssignedApplications);
|
||||
}
|
||||
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
||||
|
||||
}
|
||||
Long newApplicationsAddedYesterday = assignedApplicationsRepository.countApplicationsAddedYesterdayForHub(applicationIds, hubId, yesterday,assignedApplicationStatus);
|
||||
if (newApplicationsAddedYesterday != null && totalAssignedApplications != null && totalAssignedApplications > 0) {
|
||||
BigDecimal percentageAdded = BigDecimal.valueOf(newApplicationsAddedYesterday)
|
||||
.divide(BigDecimal.valueOf(totalAssignedApplications), 4, RoundingMode.HALF_UP)
|
||||
.multiply(BigDecimal.valueOf(100));
|
||||
responseBean.getAssignedApplication().setAdditionalApplicationPercentage(percentageAdded.setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
List<String> statuses = Arrays.asList(ApplicationStatusTypeEnum.APPROVED.getValue(), ApplicationStatusTypeEnum.REJECTED.getValue());
|
||||
LocalDateTime sevenDaysAgo = LocalDateTime.now().minusDays(7);
|
||||
Long evaluatedApplication = assignedApplicationsRepository.countEvaluatedApplicationsInLast7Days(applicationIds, statuses, sevenDaysAgo);
|
||||
if (evaluatedApplication != null) {
|
||||
responseBean.getEvaluatedApplication().setEvaluatedApplication(evaluatedApplication);
|
||||
|
||||
BigDecimal dailyAverage = assignedApplicationsRepository.countDailyAverageEvaluatedApplicationsInLast7Days(applicationIds, statuses, sevenDaysAgo);
|
||||
if (dailyAverage != null) {
|
||||
responseBean.getEvaluatedApplication().setDailyAverage(dailyAverage.setScale(2, RoundingMode.HALF_UP)); // Rounded to 2 decimal places
|
||||
}
|
||||
}
|
||||
List<String> amendmentStatus =Arrays.asList( ApplicationAmendmentRequestEnum.AWAITING.getValue(), ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
|
||||
Long rescueInstructorsInProgress = applicationAmendmentRequestRepository.countAmendmentsByApplicationIds(applicationIds,amendmentStatus);
|
||||
if (rescueInstructorsInProgress != null) {
|
||||
responseBean.getAmendmentInProgress().setTotalAmendmentInProgress(rescueInstructorsInProgress);
|
||||
}
|
||||
calculateExpiringRescueInstructorsToday(applicationIds,responseBean);
|
||||
|
||||
}
|
||||
private void calculateExpiringRescueInstructorsToday(List<Long> applicationIds, PreInstructorWidgetResponseBean responseBean) {
|
||||
List<String> statuses =Arrays.asList( ApplicationAmendmentRequestEnum.AWAITING.getValue(), ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
|
||||
|
||||
LocalDateTime startOfDay = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||
|
||||
LocalDateTime endOfDay = startOfDay.plusDays(1).minusNanos(1);
|
||||
|
||||
Long expiringToday = applicationAmendmentRequestRepository.countAmendmentsExpiringToday(applicationIds, statuses, startOfDay, endOfDay);
|
||||
|
||||
if (expiringToday != null) {
|
||||
responseBean.getAmendmentInProgress().setExpiringToday(expiringToday);
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateAverageEvaluationTime(List<Long> applicationIds, PreInstructorWidgetResponseBean responseBean, Long hubId) {
|
||||
|
||||
if (Boolean.FALSE.equals(applicationIds.isEmpty())) {
|
||||
BigDecimal averageTime = applicationEvaluationRepository.findAverageEvaluationTimeByApplicationIds(applicationIds);
|
||||
responseBean.getAverageEvaluationDays().setAverageEvlauationDaysRating(
|
||||
averageTime != null ? averageTime.setScale(2, RoundingMode.HALF_UP) : BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)
|
||||
);
|
||||
|
||||
//
|
||||
// BigDecimal timeDifference = applicationEvaluationRepository.findTimeDifferenceFromAverage(applicationIds);
|
||||
// responseBean.getAverageEvaluationTime().setTimeDifferenceFromAverage(timeDifference != null ? timeDifference : BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,19 @@ public class EmailNotificationDao {
|
||||
subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
|
||||
// bodyPlaceholders.put("{{legal_mail}}", legalMail);
|
||||
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
||||
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||
String body;
|
||||
if ("t7jh5wfg9QXylNaTZkPoE".equals(hubEntity.getUniqueUuid()) && templateType.equals(SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST)) {
|
||||
bodyPlaceholders.put("{{email_signature}}", hubEntity.getEmailSignature());
|
||||
bodyPlaceholders.put("{{platform_link}}",hubEntity.getDomainName());
|
||||
body = Utils.replacePlaceholders(GepafinConstant.DOCUMENTATION_INTEGRATION_REQUEST_SVILUPPUMBRIA, bodyPlaceholders);
|
||||
}
|
||||
else if ("t7jh5wfg9QXylNaTZkPoE".equals(hubEntity.getUniqueUuid()) && templateType.equals(SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_TEMPLATE)) {
|
||||
bodyPlaceholders.put("{{email_signature}}", hubEntity.getEmailSignature());
|
||||
body = Utils.replacePlaceholders(GepafinConstant.APPLICATION_REJECTED_SVILUPPUMBRIA, bodyPlaceholders);
|
||||
}
|
||||
else {
|
||||
body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||
}
|
||||
|
||||
return new EmailContentResponse(subject, body, systemEmailTemplateResponse);
|
||||
}
|
||||
|
||||
@@ -21,17 +21,13 @@ package net.gepafin.tendermanagement.dao;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class EvaluationFormDao {
|
||||
|
||||
@Autowired
|
||||
private EvalualtionFormRepository evaluationFormRepository;
|
||||
private EvaluationFormRepository evaluationFormRepository;
|
||||
|
||||
@Autowired
|
||||
private CallDao callDao;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.ContentResponseBean;
|
||||
@@ -35,6 +38,8 @@ import java.util.stream.Collectors;
|
||||
@Component
|
||||
public class FormDao {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(FormDao.class);
|
||||
|
||||
@Autowired
|
||||
private FormRepository formRepository;
|
||||
|
||||
@@ -118,6 +123,10 @@ public class FormDao {
|
||||
//cloned entity for old call data.
|
||||
CallEntity oldCallData = Utils.getClonedEntityForData(callEntity);
|
||||
|
||||
if(callEntity.getStatus().equals(CallStatusEnum.PUBLISH.getValue())) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.PUBLISHED_CALL_NOT_UPDATE));
|
||||
}
|
||||
List<FlowDataEntity> flowDataEntities = flowDataRepository.findByCallId(callEntity.getId());
|
||||
List<FlowEdgesEntity> flowEdgesEntities = flowEdgesRepository.findByCallId(callEntity.getId());
|
||||
if (Boolean.FALSE.equals(flowDataEntities.isEmpty() || flowDataEntities == null) || Boolean.FALSE.equals(flowEdgesEntities.isEmpty() || flowEdgesEntities == null)) {
|
||||
@@ -198,8 +207,9 @@ public class FormDao {
|
||||
String formFieldId,Long evaluationCriteriaId) {
|
||||
EvaluationCriteriaEntity evaluationCriteria = evaluationCriteriaService.validateEvaluationCriteria(evaluationCriteriaId);
|
||||
if (Boolean.FALSE.equals(evaluationCriteria.getCall().getId().equals(callEntity.getId()))) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.EVALUATIONCRITERIA_INVALID));
|
||||
log.info("This evaluation criterion does not belong to the current call. Expected Call ID = {}, Found Call ID = {}",
|
||||
callEntity.getId(), evaluationCriteria.getCall().getId());
|
||||
return;
|
||||
}
|
||||
CriteriaFormFieldEntity criteriaFormField = new CriteriaFormFieldEntity();
|
||||
criteriaFormField.setCallId(callEntity.getId());
|
||||
@@ -466,7 +476,9 @@ public class FormDao {
|
||||
|
||||
FieldValidatorBean fieldValidatorBean = Utils.convertSourceObjectToDestinationObject(contentResponseBean.getValidators(), FieldValidatorBean.class);
|
||||
String fieldValue = getFieldValue(contentResponseBean);
|
||||
validator.isRequired(value, fieldValidatorBean.getIsRequired(), fieldValue);
|
||||
|
||||
validator.isRequired(value, fieldValidatorBean.getIsRequired(), fieldValue)
|
||||
.validateCustomTableValidation(value,fieldValidatorBean.getCustom(),fieldValue,contentResponseBean);
|
||||
});
|
||||
if (Boolean.TRUE.equals(isSendValidationError)) {
|
||||
validator.validate();
|
||||
|
||||
@@ -152,6 +152,31 @@ public class PdfDao {
|
||||
// Create value cell with rounded corners
|
||||
PdfPTable valueTable = new PdfPTable(1);
|
||||
valueTable.setWidthPercentage(100);
|
||||
|
||||
|
||||
Object finalValue = value;
|
||||
List<Object> criteriaObject = (List<Object>) contentResponseBean.getSettings().stream()
|
||||
.filter(setting -> GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(setting.getName()))
|
||||
.findFirst()
|
||||
.map(setting -> {
|
||||
try {
|
||||
// Assuming setting.getValue() contains the JSON string or object
|
||||
return PdfUtils.extractRows(finalValue);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error extracting rows from setting value", e);
|
||||
}
|
||||
})
|
||||
.orElse(null);
|
||||
|
||||
|
||||
// Update value if criteriaObject is not null
|
||||
if (criteriaObject != null) {
|
||||
value = criteriaObject;
|
||||
}
|
||||
|
||||
|
||||
// Update value if criteriaObject is not null
|
||||
|
||||
if (value instanceof List<?>) {
|
||||
// Further check if the list contains Strings
|
||||
List<?> list = (List<?>) value;
|
||||
@@ -181,11 +206,10 @@ public class PdfDao {
|
||||
document.add(valueTable);
|
||||
}
|
||||
else if (!list.isEmpty() && list.get(0) instanceof Map<?, ?>) {
|
||||
Object object = value;
|
||||
String stringvalue = Utils.convertToString(object);
|
||||
List<Map<String, Object>> fieldValueList = Utils.convertJsonStringIntoJsonList(stringvalue);
|
||||
|
||||
document = createPdfTable(fieldValueList, document, contentResponseBean);
|
||||
Object object = value;
|
||||
String stringvalue = Utils.convertToString(object);
|
||||
List<Map<String, Object>> fieldValueList = Utils.convertJsonStringIntoJsonList(stringvalue);
|
||||
document = createPdfTable(fieldValueList, document, contentResponseBean);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -231,27 +255,29 @@ public class PdfDao {
|
||||
document.add(valueTable);
|
||||
}
|
||||
else {
|
||||
String fieldValue1= (String) value;
|
||||
if(Utils.isValidDateString(fieldValue1)){
|
||||
fieldValue1=Utils.formatDateString(String.valueOf(value));
|
||||
}
|
||||
if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){
|
||||
fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue));
|
||||
}
|
||||
if (value instanceof String) {
|
||||
String fieldValue1 = (String) value;
|
||||
if (Utils.isValidDateString(fieldValue1)) {
|
||||
fieldValue1 = Utils.formatDateString(String.valueOf(value));
|
||||
}
|
||||
if(contentResponseBean.getName().equals("numberinput") && Boolean.TRUE.equals(Utils.isNumeric(fieldValue))){
|
||||
fieldValue1=Utils.convertToItalianFormat(fieldValue);
|
||||
}
|
||||
// PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont));
|
||||
PdfPCell valueCell = PdfUtils.htmlToPdfPCell(fieldValue1, valueFont);
|
||||
valueCell.setMinimumHeight(30f); // Set a fixed height for the cell
|
||||
valueCell.setPaddingLeft(10f); // Adjust left padding as needed
|
||||
valueCell.setPaddingTop(0f); // Remove padding from top to allow vertical centering
|
||||
valueCell.setPaddingBottom(6f);
|
||||
valueCell.setPaddingLeft(leftMargin); // Increase left margin for value
|
||||
valueCell.setBorder(Rectangle.NO_BORDER); // Remove border for value cell
|
||||
valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||
valueCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
||||
valueCell.setCellEvent(new RoundedCorners()); // Apply rounded corners
|
||||
valueTable.addCell(valueCell);
|
||||
document.add(valueTable);
|
||||
}
|
||||
PdfPCell valueCell = PdfUtils.htmlToPdfPCell(fieldValue1, valueFont);
|
||||
valueCell.setMinimumHeight(30f); // Set a fixed height for the cell
|
||||
valueCell.setPaddingLeft(10f); // Adjust left padding as needed
|
||||
valueCell.setPaddingTop(0f); // Remove padding from top to allow vertical centering
|
||||
valueCell.setPaddingBottom(6f);
|
||||
valueCell.setPaddingLeft(leftMargin); // Increase left margin for value
|
||||
valueCell.setBorder(Rectangle.NO_BORDER); // Remove border for value cell
|
||||
valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||
valueCell.setHorizontalAlignment(Element.ALIGN_LEFT);
|
||||
valueCell.setCellEvent(new RoundedCorners()); // Apply rounded corners
|
||||
valueTable.addCell(valueCell);
|
||||
document.add(valueTable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
document.add(new Paragraph("\n")); // Add line break after each value
|
||||
@@ -264,11 +290,12 @@ public class PdfDao {
|
||||
Map<String, Boolean> formulaEnabledMap = new HashMap<>();
|
||||
Map<String, String> formulaTypeMap = new HashMap<>();
|
||||
Map<String, String> fieldTypeMap = new HashMap<>();
|
||||
Map<String, String> totalMap = new HashMap<>();
|
||||
Font lightGrayFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(110, 110, 110)); // Light gray
|
||||
|
||||
|
||||
contentResponseBean.getSettings().stream()
|
||||
.filter(setting -> "table_columns".equals(setting.getName())) // Check for "table_columns"
|
||||
.filter(setting -> "table_columns".equals(setting.getName()) || "criteria_table_columns".equals(setting.getName())) // Check for "table_columns"
|
||||
.map(SettingResponseBean::getValue)
|
||||
.filter(Objects::nonNull) // Ensure value is not null
|
||||
.filter(settingValue -> settingValue instanceof Map) // Ensure value is a Map
|
||||
@@ -283,7 +310,7 @@ public class PdfDao {
|
||||
Boolean isFormulaEnabled = (Boolean) fieldData.get("enableFormula");
|
||||
String formulaType = (String) fieldData.get("lastRowFormula");
|
||||
String fieldType = (String) fieldData.get("fieldtype"); // Get the field type (e.g., numeric)
|
||||
|
||||
String total= (String) fieldData.get("lastRowText");
|
||||
if (fieldName != null && fieldDataValue != null) {
|
||||
stateFieldMap.put(fieldName, fieldDataValue);
|
||||
}
|
||||
@@ -297,6 +324,9 @@ public class PdfDao {
|
||||
if (fieldType != null) {
|
||||
fieldTypeMap.put(fieldName, fieldType); // Store the fieldType in the map
|
||||
}
|
||||
if(total!=null){
|
||||
totalMap.put(fieldName,total);
|
||||
}
|
||||
});
|
||||
|
||||
PdfPTable table = new PdfPTable(stateFieldMap.size()); // Number of columns equals the number of map entries
|
||||
@@ -342,12 +372,15 @@ public class PdfDao {
|
||||
Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present
|
||||
// String fieldValue= (String) value;
|
||||
String fieldValue = value != null ? value.toString() : "";
|
||||
if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){
|
||||
fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue));
|
||||
}
|
||||
// if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){
|
||||
//// fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue));
|
||||
// }
|
||||
if (Boolean.TRUE.equals(formulaEnabledMap.get(key)) && Boolean.TRUE.equals(GepafinConstant.NUMERIC.equalsIgnoreCase(fieldTypeMap.get(key)))) {
|
||||
calculateValue(key, fieldValue, formulaTypeMap, columnSums);
|
||||
}
|
||||
if(Boolean.TRUE.equals(Utils.isNumeric(fieldValue))){
|
||||
fieldValue=Utils.convertToItalianFormat(fieldValue);
|
||||
}
|
||||
|
||||
PdfPCell dataCell = PdfUtils.htmlToPdfPCell(fieldValue != null ? fieldValue : "", textFont);
|
||||
dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell
|
||||
@@ -397,14 +430,19 @@ public class PdfDao {
|
||||
table.addCell(emptyCell);
|
||||
}
|
||||
} else {
|
||||
PdfPCell emptyCell = new PdfPCell(new Phrase(""));
|
||||
String total=null;
|
||||
if (totalMap.containsKey(key)) {
|
||||
total=totalMap.getOrDefault(key, "");
|
||||
}
|
||||
PdfPCell emptyCell = new PdfPCell(new Phrase(total,lightGrayFont));
|
||||
emptyCell.setPaddingTop(8f);
|
||||
emptyCell.setPaddingLeft(8f);
|
||||
emptyCell.setBackgroundColor(new BaseColor(239, 243, 248));
|
||||
table.addCell(emptyCell);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Add the last table to the document
|
||||
document.add(table);
|
||||
|
||||
@@ -415,7 +453,7 @@ public class PdfDao {
|
||||
try {
|
||||
if (Boolean.FALSE.equals(StringUtils.isEmpty(fieldValue))) {
|
||||
// Use Locale.ITALY to parse the number with the Italian format (comma as decimal separator)
|
||||
NumberFormat format = NumberFormat.getInstance(Locale.ITALY);
|
||||
NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH);
|
||||
Number number = format.parse(fieldValue); // Parse the fieldValue as a number
|
||||
double numericValue = number.doubleValue(); // Convert the parsed number to double
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
@@ -597,5 +598,58 @@ public class UserDao {
|
||||
return userResponseBeans;
|
||||
}
|
||||
|
||||
public UserResponseBean updateUserDetails(HttpServletRequest request , Long userId, UpdateUserReqForBeneficiary userReq){
|
||||
log.info("Updating user by beneficiary with ID: {}", userId);
|
||||
UserEntity userEntity = validator.validateUserId(request, userId);
|
||||
|
||||
UserEntity oldUserEntity = Utils.getClonedEntityForData(userEntity);
|
||||
log.info("Current user details: {}", userEntity);
|
||||
log.info("New user details: {}", userReq);
|
||||
|
||||
HubEntity hubEntity = hubService.valdateHub(userEntity.getHub().getId());
|
||||
String beneficiaryRoleType = RoleStatusEnum.ROLE_BENEFICIARY.getValue();
|
||||
|
||||
if (validator.checkIsBeneficiary()) {
|
||||
// Validate if the new email already exists for another beneficiary in the same hub
|
||||
boolean emailExistsForBeneficiary = userRepository.existsByEmailIgnoreCaseForBeneficiaries(
|
||||
userReq.getEmail(), hubEntity.getUniqueUuid(), beneficiaryRoleType);
|
||||
|
||||
if (emailExistsForBeneficiary) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.EMAIL_ALREADY_EXISTS));
|
||||
}
|
||||
|
||||
setIfUpdated(userEntity::getEmail,userEntity::setEmail,userReq.getEmail()); // Only update email if role is beneficiary
|
||||
}
|
||||
|
||||
BeneficiaryEntity oldBeneficiaryEntity = null;
|
||||
|
||||
if(userEntity.getBeneficiary()!=null) {
|
||||
oldBeneficiaryEntity = Utils.getClonedEntityForData(userEntity.getBeneficiary());
|
||||
setIfUpdated(userEntity.getBeneficiary()::getFirstName, userEntity.getBeneficiary()::setFirstName, userReq.getFirstName());
|
||||
setIfUpdated(userEntity.getBeneficiary()::getLastName, userEntity.getBeneficiary()::setLastName, userReq.getLastName());
|
||||
setIfUpdated(userEntity.getBeneficiary()::getOrganization, userEntity.getBeneficiary()::setOrganization, userReq.getOrganization());
|
||||
setIfUpdated(userEntity.getBeneficiary()::getAddress, userEntity.getBeneficiary()::setAddress, userReq.getAddress());
|
||||
setIfUpdated(userEntity.getBeneficiary()::getPhoneNumber, userEntity.getBeneficiary()::setPhoneNumber, userReq.getPhoneNumber());
|
||||
setIfUpdated(userEntity.getBeneficiary()::getDateOfBirth, userEntity.getBeneficiary()::setDateOfBirth, userReq.getDateOfBirth());
|
||||
setIfUpdated(userEntity.getBeneficiary()::getCity, userEntity.getBeneficiary()::setCity, userReq.getCity());
|
||||
setIfUpdated(userEntity.getBeneficiary()::getCountry, userEntity.getBeneficiary()::setCountry, userReq.getCountry());
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update beneficiary details " operation **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(oldBeneficiaryEntity).newData(userEntity.getBeneficiary()).build());
|
||||
}
|
||||
|
||||
userEntity = userRepository.save(userEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update user details by beneficiary" operation **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(oldUserEntity).newData(userEntity).build());
|
||||
|
||||
return convertUserEntityToUserResponse(userEntity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user