*
* This is a generic method that returns an EntityListIterator.
*/
public static Map<String, Object> executeFind(DispatchContext dctx, Map<String, ?> context) {
String entityName = (String) context.get("entityName");
EntityConditionList entityConditionList = (EntityConditionList) context.get("entityConditionList");
List<String> orderByList = checkList(context.get("orderByList"), String.class);
boolean noConditionFind = "Y".equals((String) context.get("noConditionFind"));
boolean distinct = "Y".equals((String) context.get("distinct"));
List<String> fieldList = UtilGenerics.checkList(context.get("fieldList"));
Set<String> fieldSet = null;
if (fieldList != null) {
fieldSet = UtilMisc.makeSetWritable(fieldList);
}
Integer maxRows = (Integer) context.get("maxRows");
maxRows = maxRows != null ? maxRows : -1;
Delegator delegator = dctx.getDelegator();
// Retrieve entities - an iterator over all the values
EntityListIterator listIt = null;
try {
if (noConditionFind || (entityConditionList != null && entityConditionList.getConditionListSize() > 0)) {
listIt = delegator.find(entityName, entityConditionList, null, fieldSet, orderByList,
new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, -1, maxRows, distinct));
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError("Error running Find on the [" + entityName + "] entity: " + e.getMessage());