Done ticket GEPAFINBE-154

This commit is contained in:
rajesh
2025-01-31 11:12:59 +05:30
parent fd6865e754
commit 4a534aa98e
4 changed files with 98 additions and 33 deletions

View File

@@ -1,4 +1,6 @@
package net.gepafin.tendermanagement.util;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
@@ -60,6 +62,24 @@ public class PdfUtils {
return cell;
}
public static Object extractRows(Object content) throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode;
// Check if input is already a JSON tree (Object) or a String
if (content instanceof String) {
rootNode = objectMapper.readTree((String) content);
} else {
rootNode = objectMapper.valueToTree(content);
}
// Extract "rows" dynamically
JsonNode rowsArray = rootNode.get("rows");
// Convert to a generic List
return objectMapper.convertValue(rowsArray, List.class);
}
}

View File

@@ -753,6 +753,12 @@ public class Utils {
private static Map<String, Object> defaultErrorResponse() {
return Collections.singletonMap("message", Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
}
public static boolean isNumeric(String input) {
if (input == null || input.trim().isEmpty()) {
return false;
}
return input.matches("-?\\d+(\\.\\d+)?");
}
}