Done ticket GEPAFINBE-154
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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+)?");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user