svn commit: r451904 - in /incubator/ofbiz/trunk/framework/common: servicedef/services.xml src/org/ofbiz/common/FindServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r451904 - in /incubator/ofbiz/trunk/framework/common: servicedef/services.xml src/org/ofbiz/common/FindServices.java

hansbak-2
Author: hansbak
Date: Mon Oct  2 00:39:12 2006
New Revision: 451904

URL: http://svn.apache.org/viewvc?view=rev&rev=451904
Log:
add a service to get one generic item using the performFind service

Modified:
    incubator/ofbiz/trunk/framework/common/servicedef/services.xml
    incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java

Modified: incubator/ofbiz/trunk/framework/common/servicedef/services.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/servicedef/services.xml?view=diff&rev=451904&r1=451903&r2=451904
==============================================================================
--- incubator/ofbiz/trunk/framework/common/servicedef/services.xml (original)
+++ incubator/ofbiz/trunk/framework/common/servicedef/services.xml Mon Oct  2 00:39:12 2006
@@ -228,6 +228,18 @@
         <attribute name="queryString" type="String" mode="OUT" optional="true"/>
         <attribute name="queryStringMap" type="java.util.Map" mode="OUT" optional="true"/>
     </service>
+
+    <service name="performFindItem" auth="false" engine="java" invoke="performFindItem" location="org.ofbiz.common.FindServices">
+        <description>Generic service to return an single GenericValue.  set filterByDate to Y to exclude expired records.</description>
+        <attribute name="entityName" type="String" mode="IN" optional="false"/>
+        <attribute name="inputFields" type="java.util.Map" mode="IN" optional="false"/>
+        <attribute name="orderBy" type="String" mode="IN" optional="true"/>
+        <attribute name="filterByDate" type="String" mode="IN" optional="true"/>
+        <attribute name="item" type="GenericValue" mode="OUT" optional="true"/>
+        <attribute name="queryString" type="String" mode="OUT" optional="true"/>
+        <attribute name="queryStringMap" type="java.util.Map" mode="OUT" optional="true"/>
+    </service>
+    
     
     <!-- Keyword Thesaurus services -->
     <service name="createKeywordThesaurus" default-entity-name="KeywordThesaurus" engine="simple"

Modified: incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java?view=diff&rev=451904&r1=451903&r2=451904
==============================================================================
--- incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java (original)
+++ incubator/ofbiz/trunk/framework/common/src/org/ofbiz/common/FindServices.java Mon Oct  2 00:39:12 2006
@@ -623,4 +623,32 @@
         }
         return normalizedFields;
     }
+    /**
+     * Returns the first generic item of the service 'performFind'
+     * Same parameters as performFind service but returns a single GenericValue
+     *
+     * @param dctx
+     * @param context
+     * @return
+     */
+    public static Map performFindItem(DispatchContext dctx, Map context) {
+        Map result = org.ofbiz.common.FindServices.performFind(dctx,context);
+        
+        List list = null;
+        GenericValue item= null;
+        try{
+            EntityListIterator it = (EntityListIterator) result.get("listIt");
+            list = it.getPartialList(1, 1); // list starts at '1'
+            if (list != null && list.size() > 0 ) {
+                item = (GenericValue) list.get(0);
+            }
+            it.close();
+        } catch (Exception e) {
+            Debug.logInfo("Problem getting list Item" + e,module);
+        }
+        
+        result.put("item",item);
+        result.remove("listIt");
+        return result;
+    }
 }