[ofbiz-framework] branch trunk updated: Improved: Enhance the Programmable Export feature for EntityQuery support (OFBIZ-11158)

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

[ofbiz-framework] branch trunk updated: Improved: Enhance the Programmable Export feature for EntityQuery support (OFBIZ-11158)

Pawan Verma-2
This is an automated email from the ASF dual-hosted git repository.

pawan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new f25c7d3  Improved: Enhance the Programmable Export feature for EntityQuery support (OFBIZ-11158)
f25c7d3 is described below

commit f25c7d33dc93b4be888f5edfb49389b45b59035f
Author: Pawan Verma <[hidden email]>
AuthorDate: Sat Feb 22 11:22:34 2020 +0530

    Improved: Enhance the Programmable Export feature for EntityQuery support
    (OFBIZ-11158)
   
    EntityQuery usage to perform data fetching is increasing, we should also add support for EntityQuery in ProgramExport feature.
   
    Thanks: Devanshu Vyas for report and patch and Suraj Khurana, Nicolas Malin for the review.
---
 .../webtools/groovyScripts/entity/ProgramExport.groovy     | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/framework/webtools/groovyScripts/entity/ProgramExport.groovy b/framework/webtools/groovyScripts/entity/ProgramExport.groovy
index 0a202eb..e78ae26 100644
--- a/framework/webtools/groovyScripts/entity/ProgramExport.groovy
+++ b/framework/webtools/groovyScripts/entity/ProgramExport.groovy
@@ -18,6 +18,8 @@
  */
 import org.apache.ofbiz.entity.Delegator
 import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.condition.EntityCondition
+import org.apache.ofbiz.entity.condition.EntityOperator
 import org.apache.ofbiz.entity.model.ModelEntity
 import org.apache.ofbiz.base.util.*
 import org.w3c.dom.Document
@@ -35,7 +37,8 @@ if (!parameters.groovyProgram) {
     
     groovyProgram = '''
 // Use the List variable recordValues to fill it with GenericValue maps.
-// full groovy syntaxt is available
+// full groovy syntax is available
+// Use full EntityQuery syntax instead of just the from method
 
 import org.apache.ofbiz.entity.util.EntityFindOptions
 
@@ -50,6 +53,12 @@ if (products != null) {
     recordValues.addAll(products)
 }
 
+// Get the last record created from the Product entity
+condition = EntityCondition.makeCondition("productId", EntityOperator.NOT_EQUAL, null)
+product = EntityQuery.use(delegator).from("Product").where(condition).orderBy("-productId").queryFirst()
+if (product) {
+    recordValues << product
+}
 
 '''
     parameters.groovyProgram = groovyProgram
@@ -61,6 +70,9 @@ if (products != null) {
 def importCustomizer = new ImportCustomizer()
 importCustomizer.addImport("org.apache.ofbiz.entity.GenericValue")
 importCustomizer.addImport("org.apache.ofbiz.entity.model.ModelEntity")
+importCustomizer.addImport("org.apache.ofbiz.entity.condition.EntityCondition")
+importCustomizer.addImport("org.apache.ofbiz.entity.condition.EntityOperator")
+importCustomizer.addImport("org.apache.ofbiz.entity.util.EntityQuery")
 def configuration = new CompilerConfiguration()
 configuration.addCompilationCustomizers(importCustomizer)