Fixed vaidation errors for createupdate application API.

This commit is contained in:
piyushkag
2025-01-23 13:16:11 +05:30
parent 1101fe277e
commit 45aaf4f667
2 changed files with 24 additions and 1 deletions

View File

@@ -399,7 +399,7 @@ public class FormDao {
String fieldId = contentResponseBean.getId(); String fieldId = contentResponseBean.getId();
String fieldLabel=contentResponseBean.getLabel(); String fieldLabel=contentResponseBean.getLabel();
Object object=formFieldMap.get(fieldId); Object object=formFieldMap.get(fieldId);
String value =Utils.convertToString(object); String value =Utils.convertToStringForFormFieldValue(object);
if(value == null && isApplicationFormExist) { if(value == null && isApplicationFormExist) {
return; return;
} }

View File

@@ -407,6 +407,29 @@ public class Utils {
return input.toString(); 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) { private static String convertCollectionToString(Collection<?> collection) {
try { try {
return mapper.writeValueAsString(collection); // Convert the collection to a JSON string return mapper.writeValueAsString(collection); // Convert the collection to a JSON string