diff --git a/src/main/java/net/gepafin/tendermanagement/dao/FormDao.java b/src/main/java/net/gepafin/tendermanagement/dao/FormDao.java index 3b910738..b9b4da07 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/FormDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/FormDao.java @@ -399,7 +399,7 @@ public class FormDao { String fieldId = contentResponseBean.getId(); String fieldLabel=contentResponseBean.getLabel(); Object object=formFieldMap.get(fieldId); - String value =Utils.convertToString(object); + String value =Utils.convertToStringForFormFieldValue(object); if(value == null && isApplicationFormExist) { return; } diff --git a/src/main/java/net/gepafin/tendermanagement/util/Utils.java b/src/main/java/net/gepafin/tendermanagement/util/Utils.java index 18c49a6e..2f063173 100644 --- a/src/main/java/net/gepafin/tendermanagement/util/Utils.java +++ b/src/main/java/net/gepafin/tendermanagement/util/Utils.java @@ -407,6 +407,29 @@ public class Utils { return input.toString(); } + public static String convertToStringForFormFieldValue(Object input) { + if (input == null) { + return null; // Return string "null" for null input + } + + if (input instanceof String) { + return (String) input; // Return the string directly if input is a string + } + + if (input instanceof Collection) { + // Handle collections (List, Set, etc.) + return convertCollectionToString((Collection) input); + } + + if (input instanceof Map) { + // Handle maps + return convertMapToString((Map) input); + } + + // For other types (like Integer, Boolean, etc.), use toString() + return input.toString(); + } + private static String convertCollectionToString(Collection collection) { try { return mapper.writeValueAsString(collection); // Convert the collection to a JSON string