} else {
iter = this.getModelEntity().getFieldsIterator();
}
while (iter != null && iter.hasNext()) {
ModelField curField = iter.next();
String fieldName = curField.getName();
String sourceFieldName = null;
if (UtilValidate.isNotEmpty(namePrefix)) {
sourceFieldName = namePrefix + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
} else {
sourceFieldName = curField.getName();
}
if (fields.containsKey(sourceFieldName)) {
Object field = fields.get(sourceFieldName);
// if (Debug.verboseOn()) Debug.logVerbose("Setting field " + curField.getName() + ": " + field + ", setIfEmpty = " + setIfEmpty, module);
if (setIfEmpty) {
// if empty string, set to null
if (field != null && field instanceof String && ((String) field).length() == 0) {
this.set(curField.getName(), null);
} else {
this.set(curField.getName(), field);
}
} else {
// okay, only set if not empty...
if (field != null) {
// if it's a String then we need to check length, otherwise set it because it's not null
if (field instanceof String) {
String fieldStr = (String) field;
if (fieldStr.length() > 0) {
this.set(curField.getName(), fieldStr);
}
} else {
this.set(curField.getName(), field);
}
}
}
}
}