add the optional parameters 'distinct' and 'fieldList' to the performFind service

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@742328 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hans Bakker
2009-02-09 08:36:08 +00:00
parent cd8f50cef8
commit d4afd2a5bb
2 changed files with 14 additions and 5 deletions
+4
View File
@@ -236,9 +236,11 @@ under the License.
<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 @@ under the License.
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"/>
@@ -22,8 +22,10 @@ import java.sql.Timestamp;
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 @@ public class FindServices {
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 @@ public class FindServices {
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 @@ public class FindServices {
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());