// - value:55 (note: these two "flds" wouldn't really go together)
// Also note that op/fld can be in any order. (eg. id_fld1_equals or id_equals_fld1)
// Note that "normalizedFields" will contain values other than those
// Contained in the associated entity.
// Those extra fields will be ignored in the second half of this method.
ModelEntity modelEntity = delegator.getModelEntity(entityName);
Map<String, Object> normalizedFields = FastMap.newInstance();
//StringBuffer queryStringBuf = new StringBuffer();
for (String fieldNameRaw: inputFields.keySet()) { // The name as it appeas in the HTML form
String fieldNameRoot = null; // The entity field name. Everything to the left of the first "_" if
// it exists, or the whole word, if not.
Object fieldValue = null; // If it is a "value" field, it will be the value to be used in the query.
// If it is an "op" field, it will be "equals", "greaterThan", etc.
int iPos = -1;
int iPos2 = -1;
fieldValue = inputFields.get(fieldNameRaw);
if (ObjectType.isEmpty(fieldValue)) {
continue;
}
//queryStringBuffer.append(fieldNameRaw + "=" + fieldValue);
iPos = fieldNameRaw.indexOf("_"); // Look for suffix
// This is a hack to skip fields from "multi" forms
// These would have the form "fieldName_o_1"
if (iPos >= 0) {
String suffix = fieldNameRaw.substring(iPos + 1);
iPos2 = suffix.indexOf("_");
if (iPos2 == 1) {
continue;
}
}
// If no suffix, assume no range (default to fld0) and operations of equals
// If no field op is present, it will assume "equals".
if (iPos < 0) {
fieldNameRoot = fieldNameRaw;
} else { // Must have at least "fld0/1" or "equals, greaterThan, etc."
// Some bogus fields will slip in, like "ENTITY_NAME", but they will be ignored
fieldNameRoot = fieldNameRaw.substring(0, iPos);
}
if (modelEntity.isField(fieldNameRoot)) {
normalizedFields.put(fieldNameRaw, fieldValue);
}
}
return normalizedFields;
}