Resolved conflicts

This commit is contained in:
rajesh
2025-02-06 15:26:47 +05:30
31 changed files with 523 additions and 148 deletions

View File

@@ -139,6 +139,10 @@ public class ApplicationEvaluationDao {
@Autowired
private EvaluationFormRepository evaluationFormRepository;
@Autowired
private ObjectMapper objectMapper;
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
@@ -1942,13 +1946,27 @@ public class ApplicationEvaluationDao {
return convertToResponse(savedEntity);
}
public ApplicationEvaluationResponseBean createApplicationEvaluation(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long evaluationFormId, Long assignedApplicationId){
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(applicationRequestBean,evaluationFormEntity);
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationRepository.findByAssignedApplicationsId(assignedApplicationId);
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = getApplicationEvaluationFormOrCreate(evaluationFormEntity,applicationEvaluationEntity);
createOrUpdateMultipleFormFields(applicationRequestBean.getFormFields(), applicationEvaluationFormEntity, evaluationFormEntity);
return getEvaluationById(applicationEvaluationEntity.getId(),evaluationFormEntity.getId());
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) {
@@ -1975,7 +1993,7 @@ public class ApplicationEvaluationDao {
return saveApplicationEvaluationFormEntity(applicationEvaluationFormEntity);
}
public void validateFormFields(ApplicationRequestBean request, EvaluationFormEntity evaluationFormEntity) {
public void validateFormFields(ApplicationEvaluationFormRequestBean request, EvaluationFormEntity evaluationFormEntity) {
List<ContentResponseBean> contentResponseBeans=evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent();
@@ -2070,17 +2088,6 @@ public class ApplicationEvaluationDao {
return documentIds;
}
public ApplicationEvaluationResponseBean getEvaluationById(Long evaluationId, Long evaluationFormId){
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(evaluationId);
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = applicationEvaluationFormRepository.findByEvaluationIdAndEvaluationFormId(applicationEvaluationEntity.getId(),evaluationFormId);
List<ApplicationEvaluationFormFieldEntity> applicationEvaluationFormFieldEntities = applicationEvaluationFormFieldRepository.findByApplicationEvaluationFormId(applicationEvaluationFormEntity.getId());
List<ApplicationEvaluationFormFieldReponseBean> evaluationFormFieldResponseBeans = createEvaluationFormFieldResponse(applicationEvaluationFormFieldEntities, applicationEvaluationFormEntity);
ApplicationEvaluationResponseBean applicationEvaluationResponseBean = convertApplicationEvaluationEntityToApplicationEvaluationResponseBean(applicationEvaluationEntity);
applicationEvaluationResponseBean.setFormFields(evaluationFormFieldResponseBeans);
return applicationEvaluationResponseBean;
}
private List<ApplicationEvaluationFormFieldReponseBean> createEvaluationFormFieldResponse(
List<ApplicationEvaluationFormFieldEntity> evaluationFormFieldEntities,
@@ -2137,15 +2144,39 @@ public class ApplicationEvaluationDao {
return applicationEvaluationFormFieldReponseBean;
}
private ApplicationEvaluationResponseBean convertApplicationEvaluationEntityToApplicationEvaluationResponseBean(ApplicationEvaluationEntity entity){
ApplicationEvaluationResponseBean response = new ApplicationEvaluationResponseBean();
response.setId(entity.getId());
response.setApplicationId(entity.getApplicationId());
response.setEvaluationId(entity.getId());
response.setNote(entity.getNote());
response.setEvaluationVersion(EvaluationVersionEnum.valueOf(entity.getEvaluationVersion()));
response.setCreatedDate(entity.getCreatedDate());
response.setUpdatedDate(entity.getUpdatedDate());
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;
}
@@ -2161,17 +2192,13 @@ public class ApplicationEvaluationDao {
}
private ApplicationEvaluationFormResponse processEvaluationForm(ApplicationEvaluationEntity evaluationEntity){
ApplicationEvaluationFormResponse response = new ApplicationEvaluationFormResponse();
response.setApplicationId(evaluationEntity.getApplicationId());
response.setNote(evaluationEntity.getNote());
response.setStatus(evaluationEntity.getStatus());
response.setEvaluationVersion(EvaluationVersionEnum.valueOf(evaluationEntity.getEvaluationVersion()));
response.setAssignedApplicationId(evaluationEntity.getAssignedApplicationsEntity().getId());
Object convertedResponse = convertToResponse(evaluationEntity);
ApplicationEvaluationFormResponse response = objectMapper.convertValue(convertedResponse, ApplicationEvaluationFormResponse.class);
EvaluationFormEntity evaluationFormEntity = evaluationFormRepository.findByCallIdAndIsDeletedFalse(evaluationEntity.getAssignedApplicationsEntity().getApplication().getCall().getId());
if (evaluationFormEntity != null) {
response.setEvaluationFormId(evaluationFormEntity.getId());
response.setApplicationEvaluationFormResponse(convertEvaluationFormToResponse(evaluationFormEntity, evaluationEntity));
}
@@ -2201,5 +2228,38 @@ public class ApplicationEvaluationDao {
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;
}
}

View File

@@ -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());

View File

@@ -1,5 +1,7 @@
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.UserEntity;
@@ -10,6 +12,9 @@ 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;
@@ -278,14 +283,16 @@ public class DashboardDao {
AmendmentWidgetResponseBean amendmentWidgetResponseBean = initializeAmendmentResponseBean();
Long hubId = userEntity.getHub().getId();
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity,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);
@@ -423,23 +430,34 @@ public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(
.build())
.build();
}
public PreInstructorWidgetResponseBean getDashboardWidgetForPreInstructor(UserEntity userEntity) {
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);
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) {
Long totalAssignedApplications = assignedApplicationsRepository.countAssignedApplicationsByApplicationIds(applicationIds);
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);
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)
@@ -449,17 +467,17 @@ public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(
List<String> statuses = Arrays.asList(ApplicationStatusTypeEnum.APPROVED.getValue(), ApplicationStatusTypeEnum.REJECTED.getValue());
LocalDateTime sevenDaysAgo = LocalDateTime.now().minusDays(7);
Long evaluatedApplication = applicationRepository.countEvaluatedApplicationsInLast7Days(applicationIds, statuses, sevenDaysAgo);
Long evaluatedApplication = assignedApplicationsRepository.countEvaluatedApplicationsInLast7Days(applicationIds, statuses, sevenDaysAgo);
if (evaluatedApplication != null) {
responseBean.getEvaluatedApplication().setEvaluatedApplication(evaluatedApplication);
BigDecimal dailyAverage = applicationRepository.countDailyAverageEvaluatedApplicationsInLast7Days(applicationIds, statuses, sevenDaysAgo);
BigDecimal dailyAverage = assignedApplicationsRepository.countDailyAverageEvaluatedApplicationsInLast7Days(applicationIds, statuses, sevenDaysAgo);
if (dailyAverage != null) {
responseBean.getEvaluatedApplication().setDailyAverage(dailyAverage.setScale(2, RoundingMode.HALF_UP)); // Rounded to 2 decimal places
}
}
Long rescueInstructorsInProgress = assignedApplicationsRepository.countApplicationsByIdsAndStatus(applicationIds, AssignedApplicationEnum.SOCCORSO.getValue());
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);
}

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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