Author: hansbak
Date: Mon Feb 9 08:36:08 2009 New Revision: 742328 URL: http://svn.apache.org/viewvc?rev=742328&view=rev Log: add the optional parameters 'distinct' and 'fieldList' to the performFind service Modified: ofbiz/trunk/framework/common/servicedef/services.xml ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java Modified: ofbiz/trunk/framework/common/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services.xml?rev=742328&r1=742327&r2=742328&view=diff ============================================================================== --- ofbiz/trunk/framework/common/servicedef/services.xml (original) +++ ofbiz/trunk/framework/common/servicedef/services.xml Mon Feb 9 08:36:08 2009 @@ -236,9 +236,11 @@ <service name="executeFind" auth="false" engine="java" invoke="executeFind" location="org.ofbiz.common.FindServices"> <description>Generic service to return an entity iterator</description> <attribute name="entityName" type="String" mode="IN" optional="false"/> + <attribute name="fieldList" type="java.util.List" mode="IN" optional="true"/> <attribute name="orderByList" type="java.util.List" mode="IN" optional="true"/> <attribute name="entityConditionList" type="org.ofbiz.entity.condition.EntityConditionList" mode="IN" optional="true"/> <attribute name="noConditionFind" type="String" mode="IN" optional="true"><!-- find with no condition (empty entityConditionList) only done when this is Y --></attribute> + <attribute name="distinct" type="String" mode="IN" optional="true"><!-- distinct find only done when this is Y --></attribute> <attribute name="listIt" type="org.ofbiz.entity.util.EntityListIterator" mode="OUT" optional="true"/> </service> @@ -247,8 +249,10 @@ set noConditionFind to Y to find without conditions. </description> <attribute name="entityName" type="String" mode="IN" optional="false"/> <attribute name="inputFields" type="java.util.Map" mode="IN" optional="false"/> + <attribute name="fieldList" type="java.util.List" mode="IN" optional="true"/> <attribute name="orderBy" type="String" mode="IN" optional="true"/> <attribute name="noConditionFind" type="String" mode="IN" optional="true"><!-- find with no condition (empty entityConditionList) only done when this is Y --></attribute> + <attribute name="distinct" type="String" mode="IN" optional="true"><!-- distinct find only done when this is Y --></attribute> <attribute name="filterByDate" type="String" mode="IN" optional="true"/> <attribute name="filterByDateValue" type="Timestamp" mode="IN" optional="true"/> <attribute name="listIt" type="org.ofbiz.entity.util.EntityListIterator" mode="OUT" optional="true"/> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java?rev=742328&r1=742327&r2=742328&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java Mon Feb 9 08:36:08 2009 @@ -22,8 +22,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import javolution.util.FastMap; @@ -403,6 +405,8 @@ String orderBy = (String) context.get("orderBy"); Map<String, ?> inputFields = checkMap(context.get("inputFields"), String.class, Object.class); // Input String noConditionFind = (String) context.get("noConditionFind"); + String distinct = (String) context.get("distinct"); + List fieldList = (List) context.get("fieldList"); GenericValue userLogin = (GenericValue) context.get("userLogin"); if (UtilValidate.isEmpty(noConditionFind)) { // try finding in inputFields Map @@ -432,7 +436,7 @@ Map<String, Object> executeResult = null; try { - executeResult = dispatcher.runSync("executeFind", UtilMisc.toMap("entityName", entityName, "orderByList", orderByList, "entityConditionList", exprList, "noConditionFind", noConditionFind, "locale", context.get("locale"), "timeZone", context.get("timeZone"))); + executeResult = dispatcher.runSync("executeFind", UtilMisc.toMap("entityName", entityName, "orderByList", orderByList, "fieldList", fieldList, "entityConditionList", exprList, "noConditionFind", noConditionFind, "distinct", distinct, "locale", context.get("locale"), "timeZone", context.get("timeZone"))); } catch (GenericServiceException gse) { return ServiceUtil.returnError("Error finding iterator: " + gse.getMessage()); } @@ -538,15 +542,16 @@ 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 fieldList = (List) context.get("fieldList"); + Set fieldSet = new HashSet(fieldList); GenericDelegator 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, null, orderByList, - new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, false)); + listIt = delegator.find(entityName, entityConditionList, null, fieldSet, orderByList, + new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, distinct)); } } catch (GenericEntityException e) { return ServiceUtil.returnError("Error running Find on the [" + entityName + "] entity: " + e.getMessage()); |
Free forum by Nabble | Edit this page |