From 1f3a5f8debf368555575d3f737d82fd804b32031 Mon Sep 17 00:00:00 2001 From: nisha Date: Mon, 28 Oct 2024 18:11:41 +0530 Subject: [PATCH 1/9] Updated code for pdf tabel updation --- .../gepafin/tendermanagement/dao/PdfDao.java | 166 +++++++++--------- .../gepafin/tendermanagement/util/Utils.java | 26 +++ 2 files changed, 112 insertions(+), 80 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java index a2c03a5b..702c61d1 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java @@ -16,6 +16,7 @@ import net.gepafin.tendermanagement.model.response.*; import net.gepafin.tendermanagement.service.CallService; import net.gepafin.tendermanagement.util.Utils; import net.gepafin.tendermanagement.util.Validator; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -91,73 +92,73 @@ public class PdfDao { Font boldSmallFont = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD,new BaseColor(105, 105, 105)); // Adding the "Documenti Allegati" section title - document.add(new Paragraph(" ")); - -// pageEvent.setTotalPages(writer.getPageNumber()); - document.newPage(); -// pageEvent.setTotalPages(writer.getPageNumber()); - document.add(new Paragraph("Documenti Allegati", sectionFont)); - document.add(new Paragraph(" ")); - - -// 1. Autocertificazione possesso Requisiti - Paragraph p1 = new Paragraph(); - p1.add(new Chunk("1. ", boldSmallFont)); - p1.add(new Chunk("Autocertificazione possesso Requisiti ", boldSmallFont)); - p1.add(new Chunk("ai sensi degli artt. 46 e 47 del DPR 445/2000", smallFont)); - document.add(p1); - document.add(new Paragraph(" ")); - - - -// 2. Informativa Privacy relativa al trattamento dei dati personali - Paragraph p2 = new Paragraph(); - p2.add(new Chunk("2. ", boldSmallFont)); - p2.add(new Chunk("Informativa Privacy relativa al trattamento dei dati personali", boldSmallFont)); - document.add(p2); - document.add(new Paragraph(" ")); - - -// 3. Dati richiesti per la valutazione dell’adeguatezza dei flussi finanziari - Paragraph p3 = new Paragraph(); - p3.add(new Chunk("3. ", boldSmallFont)); - p3.add(new Chunk("Dati richiesti per la valutazione dell’adeguatezza dei flussi finanziari prospettici come da tabella di cui all’Appendice 9", boldSmallFont)); - document.add(p3); - document.add(new Paragraph(" ")); - - -// 4. Rilevazione Centrale dei Rischi - Paragraph p4 = new Paragraph(); - p4.add(new Chunk("4. ", boldSmallFont)); - p4.add(new Chunk("Rilevazione Centrale dei Rischi riferita agli ultimi 36 mesi disponibili alla data di presentazione della Domanda", boldSmallFont)); - document.add(p4); - document.add(new Paragraph(" ")); - - -// 5. Schema di presentazione dei dati di bilancio - Paragraph p5 = new Paragraph(); - p5.add(new Chunk("5. ", boldSmallFont)); - p5.add(new Chunk("Schema di presentazione dei dati di bilancio", boldSmallFont)); - document.add(p5); - document.add(new Paragraph(" ")); - - -// 6. Dettagli bilanci in forma abbreviata - Paragraph p6 = new Paragraph(); - p6.add(new Chunk("6. ", boldSmallFont)); - p6.add(new Chunk("Dettagli bilanci in forma abbreviata", boldSmallFont)); - document.add(p6); - document.add(new Paragraph(" ")); - - -// 7. Relazione aziendale illustrativa - Paragraph p7 = new Paragraph(); - p7.add(new Chunk("7. ", boldSmallFont)); - p7.add(new Chunk("Relazione aziendale illustrativa", boldSmallFont)); - document.add(p7); - document.add(new Paragraph(" ")); - - addColoredLines(writer,document,greenColor); +// document.add(new Paragraph(" ")); +// +//// pageEvent.setTotalPages(writer.getPageNumber()); +// document.newPage(); +//// pageEvent.setTotalPages(writer.getPageNumber()); +// document.add(new Paragraph("Documenti Allegati", sectionFont)); +// document.add(new Paragraph(" ")); +// +// +//// 1. Autocertificazione possesso Requisiti +// Paragraph p1 = new Paragraph(); +// p1.add(new Chunk("1. ", boldSmallFont)); +// p1.add(new Chunk("Autocertificazione possesso Requisiti ", boldSmallFont)); +// p1.add(new Chunk("ai sensi degli artt. 46 e 47 del DPR 445/2000", smallFont)); +// document.add(p1); +// document.add(new Paragraph(" ")); +// +// +// +//// 2. Informativa Privacy relativa al trattamento dei dati personali +// Paragraph p2 = new Paragraph(); +// p2.add(new Chunk("2. ", boldSmallFont)); +// p2.add(new Chunk("Informativa Privacy relativa al trattamento dei dati personali", boldSmallFont)); +// document.add(p2); +// document.add(new Paragraph(" ")); +// +// +//// 3. Dati richiesti per la valutazione dell’adeguatezza dei flussi finanziari +// Paragraph p3 = new Paragraph(); +// p3.add(new Chunk("3. ", boldSmallFont)); +// p3.add(new Chunk("Dati richiesti per la valutazione dell’adeguatezza dei flussi finanziari prospettici come da tabella di cui all’Appendice 9", boldSmallFont)); +// document.add(p3); +// document.add(new Paragraph(" ")); +// +// +//// 4. Rilevazione Centrale dei Rischi +// Paragraph p4 = new Paragraph(); +// p4.add(new Chunk("4. ", boldSmallFont)); +// p4.add(new Chunk("Rilevazione Centrale dei Rischi riferita agli ultimi 36 mesi disponibili alla data di presentazione della Domanda", boldSmallFont)); +// document.add(p4); +// document.add(new Paragraph(" ")); +// +// +//// 5. Schema di presentazione dei dati di bilancio +// Paragraph p5 = new Paragraph(); +// p5.add(new Chunk("5. ", boldSmallFont)); +// p5.add(new Chunk("Schema di presentazione dei dati di bilancio", boldSmallFont)); +// document.add(p5); +// document.add(new Paragraph(" ")); +// +// +//// 6. Dettagli bilanci in forma abbreviata +// Paragraph p6 = new Paragraph(); +// p6.add(new Chunk("6. ", boldSmallFont)); +// p6.add(new Chunk("Dettagli bilanci in forma abbreviata", boldSmallFont)); +// document.add(p6); +// document.add(new Paragraph(" ")); +// +// +//// 7. Relazione aziendale illustrativa +// Paragraph p7 = new Paragraph(); +// p7.add(new Chunk("7. ", boldSmallFont)); +// p7.add(new Chunk("Relazione aziendale illustrativa", boldSmallFont)); +// document.add(p7); +// document.add(new Paragraph(" ")); +// +// addColoredLines(writer,document,greenColor); document.close(); @@ -272,14 +273,17 @@ public class PdfDao { document.add(valueTable); } else { - PdfPCell valueCell = new PdfPCell(new Phrase(String.valueOf(value), valueFont)); + String fieldValue1= (String) value; + if(Utils.isValidDateString(fieldValue1)){ + fieldValue1=Utils.formatDateString(String.valueOf(value)); + } + PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont)); valueCell.setPadding(5f); // Increase padding for better spacing valueCell.setPaddingLeft(leftMargin); // Increase left margin for value valueCell.setBorder(Rectangle.NO_BORDER); // Remove border for value cell valueCell.setMinimumHeight(30f); valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE); valueCell.setCellEvent(new RoundedCorners()); // Apply rounded corners - valueTable.addCell(valueCell); document.add(valueTable); } @@ -356,6 +360,7 @@ public class PdfDao { PdfPCell headerCell = new PdfPCell(new Phrase(headerValue)); // Create a new PdfPCell for the header headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE); + headerCell.setFixedHeight(rowHeight); headerCell.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header table.addCell(headerCell); // Add the header cell to the table @@ -364,16 +369,15 @@ public class PdfDao { } // Add data rows matching stateFieldMap keys - for (Map.Entry stateField : stateFieldMap.entrySet()) { - for (String key : orderedKeys) { // Iterate over the ordered keys - Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present - PdfPCell dynamicCell = new PdfPCell(new Phrase(value != null ? value.toString() : "", textFont)); - dynamicCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell - dynamicCell.setMinimumHeight(rowHeight); - dynamicCell.setPadding(7f); + for (String key : orderedKeys) { + Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present + PdfPCell dataCell = new PdfPCell(new Phrase(value != null ? value.toString() : "", textFont)); + dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell + dataCell.setMinimumHeight(rowHeight); + dataCell.setFixedHeight(rowHeight); + dataCell.setPadding(7f); - table.addCell(dynamicCell); // Add the dynamically created cell to the table - } + table.addCell(dataCell); // Add the cell to the table } // Check if adding another row would exceed max height @@ -485,7 +489,7 @@ public class PdfDao { } fieldValue = matchedLabels; } - + // Further processing of field value (e.g., finding labels in options) fieldValue = findLabelInOptions(content.getSettings(), fieldValue); } else { @@ -494,7 +498,9 @@ public class PdfDao { } try { - addLabelValuePair(writer,document, contentLabel, fieldValue, labelFont,valueFont,content); + if((contentLabel!=null && Boolean.FALSE.equals(contentLabel.isEmpty())) || (fieldValue!=null && !StringUtils.isEmpty((CharSequence) fieldValue))) { + addLabelValuePair(writer, document, contentLabel, fieldValue, labelFont, valueFont, content); + } } catch (DocumentException e) { log.error("Error checking object: " + e.getMessage(), e); diff --git a/src/main/java/net/gepafin/tendermanagement/util/Utils.java b/src/main/java/net/gepafin/tendermanagement/util/Utils.java index a845aaad..1c86aa6b 100644 --- a/src/main/java/net/gepafin/tendermanagement/util/Utils.java +++ b/src/main/java/net/gepafin/tendermanagement/util/Utils.java @@ -4,12 +4,18 @@ import java.lang.reflect.Field; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.security.SecureRandom; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.*; import java.util.function.Consumer; import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Collectors; +import com.itextpdf.styledxmlparser.jsoup.Jsoup; import jakarta.servlet.http.HttpServletRequest; import org.apache.commons.collections4.MapUtils; import org.slf4j.Logger; @@ -369,5 +375,25 @@ public class Utils { throw new RuntimeException("Error converting map to string", e); } } + public static boolean isValidDateString(String dateStr) { + Pattern datePattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}"); + return datePattern.matcher(dateStr).matches(); + } + // Method to convert a valid date string to the "dd-MM-yyyy" format + public static String formatDateString(String dateStr) { + String originalFormatPattern = "yyyy-MM-dd'T'HH:mm:ss"; + String targetFormatPattern = "dd-MM-yyyy"; + + try { + SimpleDateFormat originalFormat = new SimpleDateFormat(originalFormatPattern); + Date date = originalFormat.parse(dateStr); + SimpleDateFormat targetFormat = new SimpleDateFormat(targetFormatPattern); + + return targetFormat.format(date); + } catch (ParseException e) { + log.error("error while prcoessing date formate"); + return null; + } + } } From 1031cfc7b549298b7c4f32991f935d6cb7c6782b Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 28 Oct 2024 18:58:52 +0530 Subject: [PATCH 2/9] Updated evaluation status end point --- .../dao/ApplicationEvaluationDao.java | 24 ++++++++++--------- .../enums/AssignedEvaluationStatus.java | 19 +++++++++++++++ .../service/ApplicationEvaluationService.java | 3 ++- .../ApplicationEvaluationServiceImpl.java | 5 ++-- .../rest/api/ApplicationEvaluationApi.java | 4 +++- .../ApplicationEvaluationApiController.java | 5 ++-- 6 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 src/main/java/net/gepafin/tendermanagement/enums/AssignedEvaluationStatus.java diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index 37641033..656f4777 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -890,25 +890,27 @@ public class ApplicationEvaluationDao { return applicationEvaluationRepository.save(applicationEvaluationEntityData); } - public ApplicationEvaluationResponse updateApplicationEvaluationStatus(ApplicationEntity application, AssignedApplicationsEntity assignedApplicationsEntity) { + public ApplicationEvaluationResponse updateApplicationEvaluationStatus(ApplicationEntity application, AssignedApplicationsEntity assignedApplicationsEntity, AssignedEvaluationStatus newStatus) { Optional existingEntityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationsEntity.getId()); ApplicationEvaluationEntity entity = null; if (existingEntityOptional.isPresent()) { ApplicationEvaluationEntity existingEntity = existingEntityOptional.get(); - if (Boolean.TRUE.equals( - application.getStatus().equals(ApplicationStatusTypeEnum.APPROVED.getValue()) || - application.getStatus().equals(ApplicationStatusTypeEnum.REJECTED.getValue()) - )) { + application.setStatus(newStatus.getValue()); + application = applicationRepository.save(application); + if (application.getStatus().equals(ApplicationStatusTypeEnum.APPROVED.getValue()) || + application.getStatus().equals(ApplicationStatusTypeEnum.REJECTED.getValue())) { existingEntity.setStatus(ApplicationEvaluationStatusTypeEnum.CLOSE.getValue()); assignedApplicationsEntity.setStatus(AssignedApplicationEnum.CLOSE.getValue()); - } entity = applicationEvaluationRepository.save(existingEntity); - assignedApplicationsEntity=assignedApplicationsRepository.save(assignedApplicationsEntity); - - return convertToResponse(entity);}return null; - - + } + entity = applicationEvaluationRepository.save(existingEntity); + assignedApplicationsEntity = assignedApplicationsRepository.save(assignedApplicationsEntity); + return convertToResponse(entity); + } + return null; } + + } diff --git a/src/main/java/net/gepafin/tendermanagement/enums/AssignedEvaluationStatus.java b/src/main/java/net/gepafin/tendermanagement/enums/AssignedEvaluationStatus.java new file mode 100644 index 00000000..f595843c --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/enums/AssignedEvaluationStatus.java @@ -0,0 +1,19 @@ +package net.gepafin.tendermanagement.enums; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AssignedEvaluationStatus { + APPROVED("APPROVED"), + REJECTED("REJECTED"); + + private String value; + + AssignedEvaluationStatus(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } +} diff --git a/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java b/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java index a43b06e5..04766777 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java @@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.service; import jakarta.servlet.http.HttpServletRequest; import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity; import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum; +import net.gepafin.tendermanagement.enums.AssignedEvaluationStatus; import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse; @@ -14,7 +15,7 @@ public interface ApplicationEvaluationService { void deleteApplicationEvaluation(HttpServletRequest request,Long id); List getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId); - ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId); + ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedEvaluationStatus status); ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId); diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java index 2e511272..e0fa1133 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java @@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity; import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity; import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum; +import net.gepafin.tendermanagement.enums.AssignedEvaluationStatus; import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse; @@ -106,11 +107,11 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe @Override @Transactional(rollbackFor = Exception.class) - public ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId) { + public ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedEvaluationStatus status) { AssignedApplicationsEntity assignedApplication = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId).orElseThrow(()-> new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG))); validator.validatePreInstructor(request,assignedApplication.getUserId()); - return applicationEvaluationDao.updateApplicationEvaluationStatus(assignedApplication.getApplication(),assignedApplication); + return applicationEvaluationDao.updateApplicationEvaluationStatus(assignedApplication.getApplication(),assignedApplication,status); } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java index aca53c6f..b6bc4cfb 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java @@ -9,6 +9,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum; import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; +import net.gepafin.tendermanagement.enums.AssignedEvaluationStatus; import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.request.UpdateApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse; @@ -74,6 +75,7 @@ public interface ApplicationEvaluationApi { @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @PutMapping(value = "/{assignedApplicationId}/status", produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity> updateApplicationEvaluationStatus(HttpServletRequest request, - @Parameter( required = true) @PathVariable("assignedApplicationId") Long assignedApplicationId); + @Parameter( required = true) @PathVariable("assignedApplicationId") Long assignedApplicationId, + @Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) AssignedEvaluationStatus status); } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java index b41a65ed..18614cce 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java @@ -5,6 +5,7 @@ import net.gepafin.tendermanagement.config.Translator; import net.gepafin.tendermanagement.constants.GepafinConstant; import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum; import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; +import net.gepafin.tendermanagement.enums.AssignedEvaluationStatus; import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.request.UpdateApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse; @@ -57,8 +58,8 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation } @Override - public ResponseEntity> updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId) { - ApplicationEvaluationResponse applicationEvaluationResponse = applicationEvaluationService.updateApplicationEvaluationStatus(request, assignedApplicationId); + public ResponseEntity> updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedEvaluationStatus status) { + ApplicationEvaluationResponse applicationEvaluationResponse = applicationEvaluationService.updateApplicationEvaluationStatus(request, assignedApplicationId,status); return ResponseEntity.status(HttpStatus.OK) .body(new Response<>(applicationEvaluationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_EVALUATION_STATUS_UPDATED_SUCCESSFULLY))); } From 353e52572e36f579813cdf531dd08e7268ac9b17 Mon Sep 17 00:00:00 2001 From: rajesh Date: Mon, 28 Oct 2024 19:54:35 +0530 Subject: [PATCH 3/9] updated pdf code --- src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java index 702c61d1..4318127e 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java @@ -465,7 +465,7 @@ public class PdfDao { .collect(Collectors.toList()); fieldValue = names; } - } else if (name.equals("checkboxes")) { + } else if (name.equals("checkboxes") && fieldValue instanceof List) { List check = (List) fieldValue; List settingResponseBeans = content.getSettings(); List matchedLabels = new ArrayList<>(); From ff013827fbcbbee75c80ef2b4fe0a8983d5f0434 Mon Sep 17 00:00:00 2001 From: nisha Date: Mon, 28 Oct 2024 20:07:11 +0530 Subject: [PATCH 4/9] Updated code for pdf table issue --- .../gepafin/tendermanagement/dao/PdfDao.java | 29 ++++++++++++------- .../gepafin/tendermanagement/util/Utils.java | 27 +++++++++++++++++ 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java index 702c61d1..3e93f84a 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java @@ -277,6 +277,9 @@ public class PdfDao { if(Utils.isValidDateString(fieldValue1)){ fieldValue1=Utils.formatDateString(String.valueOf(value)); } + if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){ + fieldValue= String.valueOf(Utils.convertItalianAmountToDouble(fieldValue)); + } PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont)); valueCell.setPadding(5f); // Increase padding for better spacing valueCell.setPaddingLeft(leftMargin); // Increase left margin for value @@ -352,7 +355,6 @@ public class PdfDao { List orderedKeys = new ArrayList<>(trueKeys); orderedKeys.addAll(falseKeys); // Iterate through extracted data to populate the table - for (Map row : extractedData) { // Add headers once if (!headersAdded) { for (String key : orderedKeys) { @@ -369,16 +371,23 @@ public class PdfDao { } // Add data rows matching stateFieldMap keys - for (String key : orderedKeys) { - Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present - PdfPCell dataCell = new PdfPCell(new Phrase(value != null ? value.toString() : "", textFont)); - dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell - dataCell.setMinimumHeight(rowHeight); - dataCell.setFixedHeight(rowHeight); - dataCell.setPadding(7f); + for (Map row : extractedData) { + // Add data rows matching stateFieldMap keys + for (String key : orderedKeys) { + if (stateFieldMap.containsKey(key)) { // Only add data cell if key is in stateFieldMap + Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present + String fieldValue= (String) value; + if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){ + fieldValue= String.valueOf(Utils.convertItalianAmountToDouble(fieldValue)); + } + PdfPCell dataCell = new PdfPCell(new Phrase(fieldValue != null ?fieldValue: "", textFont)); + dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell + dataCell.setMinimumHeight(rowHeight); + dataCell.setPadding(7f); - table.addCell(dataCell); // Add the cell to the table - } + table.addCell(dataCell); // Add the cell to the table + } + } // Check if adding another row would exceed max height if (table.getTotalHeight() + rowHeight > maxTableHeight) { diff --git a/src/main/java/net/gepafin/tendermanagement/util/Utils.java b/src/main/java/net/gepafin/tendermanagement/util/Utils.java index 7dea2276..563a1805 100644 --- a/src/main/java/net/gepafin/tendermanagement/util/Utils.java +++ b/src/main/java/net/gepafin/tendermanagement/util/Utils.java @@ -5,6 +5,8 @@ import java.lang.reflect.Field; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.security.SecureRandom; +import java.text.DecimalFormat; +import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDate; @@ -414,4 +416,29 @@ public class Utils { return null; } } + public static String convertItalianAmountToDouble(String amount) throws NumberFormatException { + // Step 1: Remove the thousands separator and replace the decimal separator + String normalizedAmount = amount.replace(".", "").replace(",", "."); + + // Step 2: Parse the string to a double + double value = Double.parseDouble(normalizedAmount); + if (value <= 0) { + return amount; + } + // Step 3: Format the double to 2 decimal places + DecimalFormat decimalFormat = new DecimalFormat("#.00"); + return decimalFormat.format(value); // Return formatted string + } + public static boolean isItalianFormattedAmount(String input) { + // Regular expression to match Italian-style amounts (e.g., 41.003,00 or 123,45) + if (!input.contains(",")) { + return false; // Return false if there is no comma + } + String sanitizedInput = input.replace(",", ""); + + // Step 2: Check if the remaining string is a whole number + String wholeNumberPattern = "^\\d+$"; // Regex to match whole numbers + + return sanitizedInput.matches(wholeNumberPattern); + } } From 528d266cb8e6d910db2ca253cff848b089342fce Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 28 Oct 2024 21:09:33 +0530 Subject: [PATCH 5/9] Updated Application Evaluation API to return single object response instead of array --- .../constants/GepafinConstant.java | 2 +- .../dao/ApplicationEvaluationDao.java | 59 ++++++++++--------- .../ApplicationEvaluationRepository.java | 4 +- .../AssignedApplicationsRepository.java | 14 ++--- .../service/ApplicationEvaluationService.java | 2 +- .../ApplicationEvaluationServiceImpl.java | 47 ++++----------- .../rest/api/ApplicationEvaluationApi.java | 12 ++-- .../ApplicationEvaluationApiController.java | 9 ++- src/main/resources/message_en.properties | 1 + src/main/resources/message_it.properties | 1 + 10 files changed, 61 insertions(+), 90 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index e53385fa..fff61dcb 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -242,7 +242,7 @@ public class GepafinConstant { public static final String APPLICATION_EVALUATION_STATUS_UPDATED_SUCCESSFULLY = "application.evaluation.status.updated.successfully"; public static final String ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG = "assigned.application.not.found.with.id"; public static final String EITHER_APPLICATION_OR_ASSIGNED_APPLICATION_ID_REQUIRED_MSG = "either.application.or.assigned.application.id.required"; - + public static final String EVALUATION_ALREADY_EXISTS_MSG = "evaluation.already.exists"; public static final String APPLICATION_ASSIGNED= "application.assigned.success.msg"; public static final String APPLICATION_ALREADY_ASSIGNED = "application.already.assigned.msg"; public static final String ASSIGNED_APPLICATION_NOT_FOUND_MSG="aasigned.application.not.found"; diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index 656f4777..c1a47b63 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -14,6 +14,7 @@ import net.gepafin.tendermanagement.repositories.*; import net.gepafin.tendermanagement.service.ApplicationService; import net.gepafin.tendermanagement.service.UserService; import net.gepafin.tendermanagement.util.Utils; +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; import org.springframework.beans.factory.annotation.Autowired; @@ -93,17 +94,8 @@ public class ApplicationEvaluationDao { private void populateBasicDetails(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response) { response.setId(entity.getId()); response.setApplicationId(entity.getApplicationId()); - - List assignedApplicationsList = - assignedApplicationsRepository.findAllByApplicationId(entity.getApplicationId()); - - if (assignedApplicationsList.isEmpty()) { - response.setAssignedApplicationId(null); - } else { -// AssignedApplicationsEntity assignedApplications = assignedApplicationsList.get(0); - response.setAssignedApplicationId(entity.getAssignedApplicationsEntity().getId()); - } - + AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(entity.getApplicationId()).orElse(null); + response.setAssignedApplicationId(assignedApplications.getId()); response.setNote(entity.getNote()); response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus())); response.setCreatedDate(entity.getCreatedDate()); @@ -111,6 +103,7 @@ public class ApplicationEvaluationDao { } + private void setCriteriaResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List evaluationCriterias) { List criteriaResponsesFromEntity = entity.getCriteria() != null ? Utils.convertJsonToList(entity.getCriteria(), new TypeReference>() { @@ -341,7 +334,14 @@ public class ApplicationEvaluationDao { public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) { Optional existingEntityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplciationId); ApplicationEvaluationEntity entity; - + Optional assignedApplications=assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplciationId); + {if(assignedApplications.isPresent()) + if (applicationEvaluationRepository.existsByApplicationIdAndIsDeletedFalse(assignedApplications.get().getApplication().getId())) { + throw new CustomValidationException( + Status.BAD_REQUEST, + GepafinConstant.EVALUATION_ALREADY_EXISTS_MSG + ); + }} if (existingEntityOptional.isPresent()) { entity = existingEntityOptional.get(); entity.setCriteria(Utils.convertObjectToJson(filterNonNullCriteria(processCriteria(entity, req)))); @@ -508,26 +508,27 @@ public class ApplicationEvaluationDao { } - public List getApplicationEvaluationByApplicationId(UserEntity user, Long applicationId, Long assignedApplicationId) { - if (applicationId != null && assignedApplicationId == null) { - applicationService.validateApplication(applicationId); - List evaluationEntities = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationId); - return evaluationEntities.stream() - .map(this::convertToResponse) - .collect(Collectors.toList()); + public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(UserEntity user, Long applicationId, Long assignedApplicationId) { + + applicationService.validateApplication(applicationId); + + Optional entityOptional; + + if (applicationId != null && assignedApplicationId != null) { + entityOptional = applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(applicationId, assignedApplicationId); + } else if (applicationId != null) { + entityOptional = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationId); + } else if (assignedApplicationId != null) { + entityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId); + } else { + entityOptional = applicationEvaluationRepository.findFirstByIsDeletedFalseOrderByCreatedDateDesc(); } - - Optional entityOptional = - (applicationId != null && assignedApplicationId != null) - ? applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(applicationId, assignedApplicationId) - : applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId); - - return entityOptional - .map(entity -> Collections.singletonList(convertToResponse(entity))) - .orElseGet(() -> Collections.singletonList(getEvaluationResponseByApplicationid(user, applicationId, assignedApplicationId))); + return entityOptional.map(this::convertToResponse) + .orElseGet(() -> { + return getEvaluationResponseByApplicationid(user, applicationId, assignedApplicationId); + }); } - public ApplicationEvaluationResponse getEvaluationResponseByApplicationid(UserEntity user, Long applicationId, Long assignedApplicationId) { ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity(); ApplicationEvaluationResponse response = new ApplicationEvaluationResponse(); diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationEvaluationRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationEvaluationRepository.java index 69aa74fe..9ec88ffa 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationEvaluationRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationEvaluationRepository.java @@ -12,12 +12,14 @@ import java.util.Optional; @Repository public interface ApplicationEvaluationRepository extends JpaRepository { - List findByApplicationIdAndIsDeletedFalse(Long applicationId); + Optional findByApplicationIdAndIsDeletedFalse(Long applicationId); Optional findByIdAndIsDeletedFalse(Long id); Optional findByAssignedApplicationsEntity_IdAndIsDeletedFalse(Long assignedApplicationId); Optional findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(Long applicationId, Long assignedApplicationId); Optional findFirstByIsDeletedFalseOrderByCreatedDateDesc(); + boolean existsByApplicationIdAndIsDeletedFalse(Long applicationId); + } diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/AssignedApplicationsRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/AssignedApplicationsRepository.java index a2ceec9e..b9c02945 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/AssignedApplicationsRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/AssignedApplicationsRepository.java @@ -13,15 +13,11 @@ import java.util.Optional; public interface AssignedApplicationsRepository extends JpaRepository, JpaSpecificationExecutor{ Optional findByApplicationIdAndIsDeletedFalse(Long applicationId); Optional findByIdAndIsDeletedFalse(Long id); - @Query("SELECT aa FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false AND aa.application.id = :applicationId") - List findAllByApplicationId(@Param("applicationId") Long applicationId); - - @Query("SELECT aa FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false AND aa.application.id = :applicationId AND aa.id = :assignedApplicationId") - Optional findByApplicationIdAndAssignedApplicationId( - @Param("applicationId") Long applicationId, - @Param("assignedApplicationId") Long assignedApplicationId); - @Query("SELECT aa FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false AND aa.id = :assignedApplicationId") - Optional findByAssignedApplicationId(@Param("assignedApplicationId") Long assignedApplicationId); + @Query("SELECT aa FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false " + + "AND (:applicationId IS NULL OR aa.application.id = :applicationId) " + + "AND (:id IS NULL OR aa.id = :id)") + Optional findByApplicationIdOrId(@Param("applicationId") Long applicationId, + @Param("id") Long id); } diff --git a/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java b/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java index 04766777..a8b8f419 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java @@ -14,7 +14,7 @@ public interface ApplicationEvaluationService { ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationRequest applicationEvaluationRequest,Long assignedApplicationsId); void deleteApplicationEvaluation(HttpServletRequest request,Long id); - List getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId); + ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId); ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedEvaluationStatus status); diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java index e0fa1133..a5e0c8c4 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java @@ -48,7 +48,7 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe @Override @Transactional(readOnly = true) - public List getApplicationEvaluationByApplicationId( + public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId( HttpServletRequest request, Long applicationId, Long assignedApplicationId) { if (applicationId == null && assignedApplicationId == null) { throw new CustomValidationException( @@ -56,45 +56,20 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe Translator.toLocale(GepafinConstant.EITHER_APPLICATION_OR_ASSIGNED_APPLICATION_ID_REQUIRED_MSG) ); } - AssignedApplicationsEntity assignedApplications; + Optional assignedApplicationsOptional = + assignedApplicationsRepository.findByApplicationIdOrId(applicationId, assignedApplicationId); - if (applicationId != null && assignedApplicationId != null) { - assignedApplications = assignedApplicationsRepository - .findByApplicationIdAndAssignedApplicationId(applicationId, assignedApplicationId) - .orElseThrow(() -> new CustomValidationException( - Status.BAD_REQUEST, - Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG) - )); - } else if (assignedApplicationId != null) { - assignedApplications = assignedApplicationsRepository - .findByAssignedApplicationId(assignedApplicationId) - .orElseThrow(() -> new CustomValidationException( - Status.BAD_REQUEST, - Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG) - )); - } else { - List assignedApplicationsList = assignedApplicationsRepository - .findAllByApplicationId(applicationId); - - if (assignedApplicationsList.isEmpty()) { - throw new CustomValidationException( + AssignedApplicationsEntity assignedApplications = assignedApplicationsOptional + .orElseThrow(() -> new CustomValidationException( Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG) - ); - } - - assignedApplications = assignedApplicationsList.get(0); - } - + )); UserEntity user = validator.validatePreInstructor(request, assignedApplications.getUserId()); - if (applicationId != null && assignedApplicationId == null) { - return applicationEvaluationDao.getApplicationEvaluationByApplicationId(user, assignedApplications.getApplication().getId(), null); - } - - if (applicationId != null && assignedApplicationId != null) { - return applicationEvaluationDao.getApplicationEvaluationByApplicationId(user, assignedApplications.getApplication().getId(), assignedApplications.getId()); - } - return applicationEvaluationDao.getApplicationEvaluationByApplicationId(user, null, assignedApplications.getId()); + return applicationEvaluationDao.getApplicationEvaluationByApplicationId( + user, + assignedApplications.getApplication().getId(), + assignedApplications.getId() + ); } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java index b6bc4cfb..42455042 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationEvaluationApi.java @@ -39,21 +39,17 @@ public interface ApplicationEvaluationApi { @Parameter(required = true) @PathVariable("assignedApplicationsId") Long assignedApplicationsId, @Parameter( required = true) @Valid @RequestBody ApplicationEvaluationRequest evaluationRequest); - @Operation( - summary = "API to get ApplicationEvaluation data for evaluation process", + @Operation(summary = "API to get ApplicationEvaluation data for evaluation process", responses = { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { - @ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })), - @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { - @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) + @ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })) }) @GetMapping(value = "/application", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity>> getApplicationEvaluationByApplicationId( + ResponseEntity> getApplicationEvaluationByApplicationId( HttpServletRequest request, @Parameter(required = false) @RequestParam(value = "applicationId", required = false) Long applicationId, - @Parameter(required = false) @RequestParam(value = "assignedApplicationId", required = false) Long assignedApplicationId); - + @Parameter( required = false) @RequestParam(value = "assignedApplicationId", required = false) Long assignedApplicationId); @Operation(summary = "API to delete ApplicationEvaluation", responses = { @ApiResponse(responseCode = "200", description = "OK"), diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java index 18614cce..5e31135a 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationEvaluationApiController.java @@ -38,14 +38,13 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation } @Override - public ResponseEntity>> getApplicationEvaluationByApplicationId( + public ResponseEntity> getApplicationEvaluationByApplicationId( HttpServletRequest request, Long applicationId, Long assignedApplicationId) { - List responseList = - applicationEvaluationService.getApplicationEvaluationByApplicationId(request, applicationId, assignedApplicationId); - + ApplicationEvaluationResponse response = null; + response = applicationEvaluationService.getApplicationEvaluationByApplicationId(request, applicationId,assignedApplicationId); return ResponseEntity.status(HttpStatus.OK) - .body(new Response<>(responseList, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_FETCHED_SUCCESSFULLY))); + .body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_FETCHED_SUCCESSFULLY))); } diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index e47a62c8..cb1abbef 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -263,6 +263,7 @@ application.evaluation.status.updated.successfully=Application evaluation status evaluationCriteria.invalid=This evaluation criterion does not belong to the current call. assigned.application.not.found.with.id=Assigned application with this application ID not found either.application.or.assigned.application.id.required=Either applicationId or assignedApplicationId is required. +evaluation.already.exists=An application evaluation already exists for this application ID. # Hub Messages hub_create_success=Hub created successfully diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index 1eaa302f..6a8e4a2f 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -261,6 +261,7 @@ evaluations.fetched.successfully = Tutte le valutazioni delle applicazioni recup application.evaluation.status.updated.successfully=Stato della valutazione dell'applicazione aggiornato con successo. assigned.application.not.found.with.id=Applicazione assegnata con questo ID dell'applicazione non trovata either.application.or.assigned.application.id.required=È richiesto almeno uno tra applicationId o assignedApplicationId. +evaluation.already.exists=Una valutazione dell'applicazione esiste già per questo ID applicazione. application.assigned.success.msg =Domanda assegnata con successo application.already.assigned.msg =La domanda � gi� assegnata From d29ac8cc05effbee91ef6def7f3f7fca785009a5 Mon Sep 17 00:00:00 2001 From: nisha Date: Mon, 28 Oct 2024 22:15:25 +0530 Subject: [PATCH 6/9] Updated code for pdf updation --- .../gepafin/tendermanagement/dao/PdfDao.java | 7 ++- .../gepafin/tendermanagement/util/Utils.java | 52 ++++++++++++++----- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java index 2cf1d32b..d2e29e84 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java @@ -278,7 +278,7 @@ public class PdfDao { fieldValue1=Utils.formatDateString(String.valueOf(value)); } if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){ - fieldValue= String.valueOf(Utils.convertItalianAmountToDouble(fieldValue)); + fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue)); } PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont)); valueCell.setPadding(5f); // Increase padding for better spacing @@ -362,7 +362,6 @@ public class PdfDao { PdfPCell headerCell = new PdfPCell(new Phrase(headerValue)); // Create a new PdfPCell for the header headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE); - headerCell.setFixedHeight(rowHeight); headerCell.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header table.addCell(headerCell); // Add the header cell to the table @@ -378,7 +377,7 @@ public class PdfDao { Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present String fieldValue= (String) value; if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){ - fieldValue= String.valueOf(Utils.convertItalianAmountToDouble(fieldValue)); + fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue)); } PdfPCell dataCell = new PdfPCell(new Phrase(fieldValue != null ?fieldValue: "", textFont)); dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell @@ -498,7 +497,7 @@ public class PdfDao { } fieldValue = matchedLabels; } - + // Further processing of field value (e.g., finding labels in options) fieldValue = findLabelInOptions(content.getSettings(), fieldValue); } else { diff --git a/src/main/java/net/gepafin/tendermanagement/util/Utils.java b/src/main/java/net/gepafin/tendermanagement/util/Utils.java index 563a1805..3bd7041e 100644 --- a/src/main/java/net/gepafin/tendermanagement/util/Utils.java +++ b/src/main/java/net/gepafin/tendermanagement/util/Utils.java @@ -416,24 +416,50 @@ public class Utils { return null; } } - public static String convertItalianAmountToDouble(String amount) throws NumberFormatException { - // Step 1: Remove the thousands separator and replace the decimal separator - String normalizedAmount = amount.replace(".", "").replace(",", "."); +// public static String convertItalianAmountToDouble(String amount) throws NumberFormatException { +// // Step 1: Remove the thousands separator and replace the decimal separator +// String normalizedAmount = amount.replace(".", "").replace(",", "."); +// +// // Step 2: Parse the string to a double +// double value = Double.parseDouble(normalizedAmount); +// if (value <= 0) { +// return amount; +// } +// // Step 3: Format the double to 2 decimal places +// DecimalFormat decimalFormat = new DecimalFormat("#.00"); +// return decimalFormat.format(value); // Return formatted string +// } - // Step 2: Parse the string to a double - double value = Double.parseDouble(normalizedAmount); - if (value <= 0) { - return amount; + public static String convertToItalianFormat(String amount) { + try { + // Step 1: Sanitize and standardize the input + String sanitizedAmount = amount.trim(); + if (sanitizedAmount.matches("\\d")) { + return sanitizedAmount; + } + // Step 2: Handle Italian-style input (e.g., "37.192,00") + if (sanitizedAmount.contains(".") && sanitizedAmount.contains(",")) { + // Assume the period is a thousand separator and the comma is a decimal separator + sanitizedAmount = sanitizedAmount.replace(".", "").replace(",", "."); + } else if (sanitizedAmount.contains(",")) { + // If the input contains only a comma, treat it as a decimal separator + sanitizedAmount = sanitizedAmount.replace(",", "."); + } + // Step 3: Parse the cleaned-up string into a double + double parsedAmount = Double.parseDouble(sanitizedAmount); + // Step 4: Format the parsed amount to Italian format + NumberFormat italianFormat = NumberFormat.getInstance(Locale.ITALY); + italianFormat.setMinimumFractionDigits(2); + italianFormat.setMaximumFractionDigits(2); + + return italianFormat.format(parsedAmount); + } catch (NumberFormatException e) { + // In case of any issues with parsing, return a default or error message + return "Invalid amount format"; } - // Step 3: Format the double to 2 decimal places - DecimalFormat decimalFormat = new DecimalFormat("#.00"); - return decimalFormat.format(value); // Return formatted string } public static boolean isItalianFormattedAmount(String input) { // Regular expression to match Italian-style amounts (e.g., 41.003,00 or 123,45) - if (!input.contains(",")) { - return false; // Return false if there is no comma - } String sanitizedInput = input.replace(",", ""); // Step 2: Check if the remaining string is a whole number From ce9b9c73d11f1612655ae215aed466c0089cdbf7 Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 28 Oct 2024 22:53:14 +0530 Subject: [PATCH 7/9] Updated code --- .../dao/ApplicationEvaluationDao.java | 15 ++++++--------- .../response/ApplicationEvaluationResponse.java | 1 + .../AssignedApplicationsRepository.java | 10 +++++++--- .../impl/ApplicationEvaluationServiceImpl.java | 13 ++++++++++--- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index c1a47b63..e4ddac90 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -20,6 +20,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -94,7 +95,7 @@ public class ApplicationEvaluationDao { private void populateBasicDetails(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response) { response.setId(entity.getId()); response.setApplicationId(entity.getApplicationId()); - AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(entity.getApplicationId()).orElse(null); + AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(entity.getAssignedApplicationsEntity().getId()).orElse(null); response.setAssignedApplicationId(assignedApplications.getId()); response.setNote(entity.getNote()); response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus())); @@ -327,7 +328,8 @@ public class ApplicationEvaluationDao { response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null); response.setSubmissionDate(application.getSubmissionDate() != null ? application.getSubmissionDate() : null); response.setEvaluationDate(application.getSubmissionDate() != null ? application.getSubmissionDate().plusDays(30) : null); - + LocalDateTime callEndDate = application.getCall().getEndDate(); + response.setCallEndDate(callEndDate); } @@ -335,13 +337,6 @@ public class ApplicationEvaluationDao { Optional existingEntityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplciationId); ApplicationEvaluationEntity entity; Optional assignedApplications=assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplciationId); - {if(assignedApplications.isPresent()) - if (applicationEvaluationRepository.existsByApplicationIdAndIsDeletedFalse(assignedApplications.get().getApplication().getId())) { - throw new CustomValidationException( - Status.BAD_REQUEST, - GepafinConstant.EVALUATION_ALREADY_EXISTS_MSG - ); - }} if (existingEntityOptional.isPresent()) { entity = existingEntityOptional.get(); entity.setCriteria(Utils.convertObjectToJson(filterNonNullCriteria(processCriteria(entity, req)))); @@ -558,6 +553,8 @@ public class ApplicationEvaluationDao { response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus())); response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.OPEN.getValue())); response.setMinScore(call.getThreshold()!=null?call.getThreshold():null); + LocalDateTime callEndDate = application.getCall().getEndDate(); + response.setCallEndDate(callEndDate); setCriteriaResponses(entity, application.getId(), response, evaluationCriterias); setChecklistResponses(entity, application.getId(), response, checklistEntities); setFileResponses(entity, application.getId(), response, applicationFormEntities); diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationResponse.java b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationResponse.java index 08425f4c..f0be1236 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationResponse.java +++ b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationResponse.java @@ -28,4 +28,5 @@ public class ApplicationEvaluationResponse { private String callName; private LocalDateTime submissionDate; private LocalDateTime evaluationDate; + private LocalDateTime callEndDate; } diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/AssignedApplicationsRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/AssignedApplicationsRepository.java index b9c02945..beeb4610 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/AssignedApplicationsRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/AssignedApplicationsRepository.java @@ -15,9 +15,13 @@ public interface AssignedApplicationsRepository extends JpaRepository findByIdAndIsDeletedFalse(Long id); @Query("SELECT aa FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false " + "AND (:applicationId IS NULL OR aa.application.id = :applicationId) " + - "AND (:id IS NULL OR aa.id = :id)") - Optional findByApplicationIdOrId(@Param("applicationId") Long applicationId, - @Param("id") Long id); + "AND (:id IS NULL OR aa.id = :id) " + + "AND (:userId IS NULL OR aa.userId = :userId)") + Optional findByApplicationIdOrIdAndUserIdAndIsDeletedFalse( + @Param("applicationId") Long applicationId, + @Param("id") Long id, + @Param("userId") Long userId); + } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java index a5e0c8c4..691ae8f9 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java @@ -50,29 +50,36 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe @Transactional(readOnly = true) public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId( HttpServletRequest request, Long applicationId, Long assignedApplicationId) { + if (applicationId == null && assignedApplicationId == null) { throw new CustomValidationException( Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.EITHER_APPLICATION_OR_ASSIGNED_APPLICATION_ID_REQUIRED_MSG) ); } + UserEntity preInstructor = validator.validateUser(request); Optional assignedApplicationsOptional = - assignedApplicationsRepository.findByApplicationIdOrId(applicationId, assignedApplicationId); + assignedApplicationsRepository.findByApplicationIdOrIdAndUserIdAndIsDeletedFalse(applicationId,assignedApplicationId, preInstructor.getId()); + if (assignedApplicationId != null) { + assignedApplicationsOptional = assignedApplicationsOptional.filter(a -> a.getId().equals(assignedApplicationId)); + } AssignedApplicationsEntity assignedApplications = assignedApplicationsOptional .orElseThrow(() -> new CustomValidationException( Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG) )); - UserEntity user = validator.validatePreInstructor(request, assignedApplications.getUserId()); + validator.validatePreInstructor(request, assignedApplications.getUserId()); + return applicationEvaluationDao.getApplicationEvaluationByApplicationId( - user, + preInstructor, assignedApplications.getApplication().getId(), assignedApplications.getId() ); } + @Override @Transactional(rollbackFor = Exception.class) public void deleteApplicationEvaluation(HttpServletRequest request,Long id) { From 97b9a521da1ffe4035b4e423704532dcfbaf545b Mon Sep 17 00:00:00 2001 From: rajesh Date: Mon, 28 Oct 2024 23:21:16 +0530 Subject: [PATCH 8/9] updated code for html content for pdf --- .../gepafin/tendermanagement/dao/PdfDao.java | 14 ++-- .../tendermanagement/util/PdfUtils.java | 66 +++++++++++++++++++ 2 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 src/main/java/net/gepafin/tendermanagement/util/PdfUtils.java diff --git a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java index d2e29e84..766492ec 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java @@ -14,6 +14,7 @@ import net.gepafin.tendermanagement.entities.*; import net.gepafin.tendermanagement.model.request.FieldLabelValuePairRequest; import net.gepafin.tendermanagement.model.response.*; import net.gepafin.tendermanagement.service.CallService; +import net.gepafin.tendermanagement.util.PdfUtils; import net.gepafin.tendermanagement.util.Utils; import net.gepafin.tendermanagement.util.Validator; import org.apache.commons.lang3.StringUtils; @@ -207,7 +208,9 @@ public class PdfDao { // Loop through the list of strings and create a cell for each string for (String item : values) { - PdfPCell valueCell = new PdfPCell(new Phrase(item, valueFont)); + +// PdfPCell valueCell = new PdfPCell(new Phrase(item, valueFont)); + PdfPCell valueCell = PdfUtils.htmlToPdfPCell(item, valueFont); valueCell.setPadding(5f); // Increase padding for better spacing valueCell.setPaddingLeft(leftMargin); // Increase left margin for value valueCell.setBorder(Rectangle.NO_BORDER); // Remove border for value cell @@ -280,7 +283,8 @@ public class PdfDao { if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){ fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue)); } - PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont)); +// PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont)); + PdfPCell valueCell = PdfUtils.htmlToPdfPCell(fieldValue1, valueFont); valueCell.setPadding(5f); // Increase padding for better spacing valueCell.setPaddingLeft(leftMargin); // Increase left margin for value valueCell.setBorder(Rectangle.NO_BORDER); // Remove border for value cell @@ -359,7 +363,8 @@ public class PdfDao { if (!headersAdded) { for (String key : orderedKeys) { String headerValue = stateFieldMap.get(key); // Header text - PdfPCell headerCell = new PdfPCell(new Phrase(headerValue)); // Create a new PdfPCell for the header +// PdfPCell headerCell = new PdfPCell(new Phrase(headerValue)); // Create a new PdfPCell for the header + PdfPCell headerCell = PdfUtils.htmlToPdfPCell(headerValue, null); headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE); headerCell.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header @@ -379,7 +384,8 @@ public class PdfDao { if(Boolean.TRUE.equals(Utils.isItalianFormattedAmount(fieldValue)) ){ fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue)); } - PdfPCell dataCell = new PdfPCell(new Phrase(fieldValue != null ?fieldValue: "", textFont)); +// PdfPCell dataCell = new PdfPCell(new Phrase(fieldValue != null ?fieldValue: "", textFont)); + PdfPCell dataCell = PdfUtils.htmlToPdfPCell(value != null ? value.toString() : "", textFont); dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell dataCell.setMinimumHeight(rowHeight); dataCell.setPadding(7f); diff --git a/src/main/java/net/gepafin/tendermanagement/util/PdfUtils.java b/src/main/java/net/gepafin/tendermanagement/util/PdfUtils.java new file mode 100644 index 00000000..cfa32b03 --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/util/PdfUtils.java @@ -0,0 +1,66 @@ +package net.gepafin.tendermanagement.util; +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.Element; +import com.itextpdf.text.Font; +import com.itextpdf.text.pdf.PdfPCell; +import com.itextpdf.text.html.simpleparser.HTMLWorker; +import com.itextpdf.text.html.simpleparser.StyleSheet; +import com.itextpdf.text.Paragraph; + +import java.io.StringReader; +import java.util.List; + +import org.springframework.stereotype.Component; + +@Component +public class PdfUtils { + + + + public static PdfPCell htmlToPdfPCell(String htmlContent, Font font) { + PdfPCell cell = new PdfPCell(); + + // Check if the content is not null or empty + if (htmlContent != null && !htmlContent.trim().isEmpty()) { + // Wrap plain text in a paragraph tag if it doesn't contain any HTML + // Check if the string does not contain any '<' or '>' characters + if (!htmlContent.contains("<") || !htmlContent.contains(">")) { + htmlContent = "

" + htmlContent + "

"; // Wrap in paragraph tags + } + + try { + // Create a list to hold the elements parsed from the HTML + List elements = HTMLWorker.parseToList(new StringReader(htmlContent), new StyleSheet()); + + // Create a paragraph to hold the formatted text + Paragraph paragraph = new Paragraph(); + + // Add each element to the paragraph + for (Element element : elements) { + // If the element is a Paragraph, set the font directly + if (element instanceof Paragraph) { + ((Paragraph) element).setFont(font); + } + // If the element is a Chunk, set the font directly + else if (element instanceof com.itextpdf.text.Chunk) { + ((com.itextpdf.text.Chunk) element).setFont(font); + } + // Add the element to the paragraph + paragraph.add(element); + } + + // Add the paragraph to the cell + cell.addElement(paragraph); + + } catch (Exception e) { + e.printStackTrace(); // Log the exception for debugging + } + } + + return cell; + } + +} + + + From a3e027876ecc6bff6e51d3a517cf3f7e1af2cffc Mon Sep 17 00:00:00 2001 From: nisha Date: Tue, 29 Oct 2024 13:15:36 +0530 Subject: [PATCH 9/9] Updated code for removing attached document from pdf --- .../gepafin/tendermanagement/dao/PdfDao.java | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java index 766492ec..6a2c2b8c 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java @@ -211,12 +211,14 @@ public class PdfDao { // PdfPCell valueCell = new PdfPCell(new Phrase(item, valueFont)); PdfPCell valueCell = PdfUtils.htmlToPdfPCell(item, valueFont); - valueCell.setPadding(5f); // Increase padding for better spacing + valueCell.setFixedHeight(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.setMinimumHeight(30f); valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE); - valueCell.setCellEvent(new RoundedCorners()); // Apply rounded corners + valueCell.setHorizontalAlignment(Element.ALIGN_LEFT); valueCell.setCellEvent(new RoundedCorners()); // Apply rounded corners // Add the cell to the table valueTable.addCell(valueCell); @@ -285,11 +287,14 @@ public class PdfDao { } // PdfPCell valueCell = new PdfPCell(new Phrase(fieldValue1, valueFont)); PdfPCell valueCell = PdfUtils.htmlToPdfPCell(fieldValue1, valueFont); - valueCell.setPadding(5f); // Increase padding for better spacing + valueCell.setFixedHeight(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.setMinimumHeight(30f); valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE); + valueCell.setHorizontalAlignment(Element.ALIGN_LEFT); valueCell.setCellEvent(new RoundedCorners()); // Apply rounded corners valueTable.addCell(valueCell); document.add(valueTable); @@ -303,6 +308,7 @@ public class PdfDao { // Create a PdfPTable with dynamic column count based on stateFieldMap size Map stateFieldMap = new HashMap<>(); Map stateFieldBoolean = new HashMap<>(); +// Font textFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(178, 190, 181)); // Gray text // Populate stateFieldMap from contentResponseBean settings contentResponseBean.getSettings().stream() @@ -364,11 +370,14 @@ public class PdfDao { for (String key : orderedKeys) { String headerValue = stateFieldMap.get(key); // Header text // PdfPCell headerCell = new PdfPCell(new Phrase(headerValue)); // Create a new PdfPCell for the header - PdfPCell headerCell = PdfUtils.htmlToPdfPCell(headerValue, null); + PdfPCell headerCell = PdfUtils.htmlToPdfPCell(headerValue, textFont); headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE); headerCell.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header - + headerCell.setFixedHeight(30f); // Set a fixed height for the cell + headerCell.setPaddingLeft(10f); // Adjust left padding as needed + headerCell.setPaddingTop(0f); // Remove padding from top to allow vertical centering + headerCell.setPaddingBottom(6f); table.addCell(headerCell); // Add the header cell to the table } headersAdded = true; // Prevent headers from being added again @@ -385,11 +394,13 @@ public class PdfDao { fieldValue= String.valueOf(Utils.convertToItalianFormat(fieldValue)); } // PdfPCell dataCell = new PdfPCell(new Phrase(fieldValue != null ?fieldValue: "", textFont)); - PdfPCell dataCell = PdfUtils.htmlToPdfPCell(value != null ? value.toString() : "", textFont); + PdfPCell dataCell = PdfUtils.htmlToPdfPCell(fieldValue != null ? fieldValue : "", textFont); dataCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell - dataCell.setMinimumHeight(rowHeight); - dataCell.setPadding(7f); - + dataCell.setPaddingLeft(10f); // Adjust left padding as needed + dataCell.setPaddingTop(0f); // Remove padding from top to allow vertical centering + dataCell.setPaddingBottom(6f); + dataCell.setVerticalAlignment(Element.ALIGN_MIDDLE); + dataCell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(dataCell); // Add the cell to the table } } @@ -472,13 +483,7 @@ public class PdfDao { // Process 'fileupload' and 'checkboxes' cases as in the original logic if (name.equals("fileupload")) { - if (fieldValue instanceof List && ((List) fieldValue).stream().allMatch(item -> item instanceof DocumentResponseBean)) { - List documentList = (List) fieldValue; - List names = documentList.stream() - .map(DocumentResponseBean::getName) - .collect(Collectors.toList()); - fieldValue = names; - } + continue; } else if (name.equals("checkboxes") && fieldValue instanceof List) { List check = (List) fieldValue; List settingResponseBeans = content.getSettings();