svn commit: r1840898 - in /ofbiz/ofbiz-framework/trunk: applications/product/groovyScripts/product/category/ framework/base/src/main/java/org/apache/ofbiz/base/ framework/service/src/main/java/org/apache/ofbiz/service/engine/

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

svn commit: r1840898 - in /ofbiz/ofbiz-framework/trunk: applications/product/groovyScripts/product/category/ framework/base/src/main/java/org/apache/ofbiz/base/ framework/service/src/main/java/org/apache/ofbiz/service/engine/

pgil
Author: pgil
Date: Fri Sep 14 08:19:39 2018
New Revision: 1840898

URL: http://svn.apache.org/viewvc?rev=1840898&view=rev
Log:
Improved : Update missing entries in GDSL descriptors and cleanup findOne to use EntityQuery instead.
(OFBIZ-10566)

Deprecation of findOne DSL method in favor of entityQuery from DSL method

Modified:
    ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForEclipse.dsld
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForIntelliJ.gdsl
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy

Modified: ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy?rev=1840898&r1=1840897&r2=1840898&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/groovyScripts/product/category/CategoryServices.groovy Fri Sep 14 08:19:39 2018
@@ -138,8 +138,7 @@ def removeProductFromCategory() {
         product.primaryProductCategoryId = null
         product.store()
     }
-    Map lookupPKMap = makeValue("ProductCategoryMember", parameters)
-    GenericValue lookedUpValue = findOne("ProductCategoryMember", lookupPKMap, false)
+    GenericValue lookedUpValue = from('ProductCategoryMember').where(parameters).queryOne()
     lookedUpValue.remove()
     return success()
 }
@@ -531,7 +530,7 @@ def duplicateProductCategory() {
     }
 
     // look up the old product category and clone it
-    GenericValue oldCategory = findOne("ProductCategory", [productCategoryId: parameters.oldProductCategoryId], false)
+    GenericValue oldCategory = from('ProductCategory').where([productCategoryId: parameters.oldProductCategoryId]).queryOne()
     GenericValue newCategory = oldCategory.clone()
 
     // set the new product category id, and write it to the datasource
@@ -762,7 +761,7 @@ def checkCategoryPermissionWithViewPurch
     String failMessage = ""
     for (Map prodCatalogCategory : prodCatalogCategoryList) {
         // Do not do a permission check, unless the ProdCatalog requires it
-        def prodCatalog = findOne("ProdCatalog", [prodCatalogId: prodCatalogCategory.prodCatalogId], false)
+        def prodCatalog = from('ProdCatalog').where([prodCatalogId: prodCatalogCategory.prodCatalogId]).queryOne()
         if (prodCatalog.viewAllowPermReqd.equals("Y")
             && !security.hasEntityPermission("CATALOG_VIEW", "_ALLOW", parameters.userLogin)) {
             logVerbose("Permission check failed, user does not have permission")
@@ -795,7 +794,7 @@ def getAssociatedProductsList() {
     productsList = EntityUtil.orderBy(productsList, ["sequenceNum"])
     List products = []
     for (Map productMember : productsList) {
-        GenericValue product = findOne("Product", [productId: productMember.productId], false)
+        GenericValue product = from('Product').where([productId: productMember.productId]).queryOne()
         String productName = "${product.internalName}: ${product.productId}"
         products.add(productName)
     }

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForEclipse.dsld
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForEclipse.dsld?rev=1840898&r1=1840897&r2=1840898&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForEclipse.dsld (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForEclipse.dsld Fri Sep 14 08:19:39 2018
@@ -25,9 +25,9 @@ contribute(currentType(subType('groovy.l
     property name: 'security', type: 'org.apache.ofbiz.security.Security'
 
     method name: 'runService', type: 'java.util.Map', params: [serviceName: 'String', inputMap: 'java.util.Map']
+    method name: 'run', type: 'java.util.Map', params: [args: 'java.util.Map']
     method name: 'makeValue', type: 'java.util.Map', params: [entityName: 'String']
     method name: 'findOne', type: 'java.util.Map', params: [entityName: 'String', fields: 'java.util.Map', useCache: 'boolean']
-    method name: 'findList', type: 'java.util.List', params: [entityName: 'String', inputMap: 'java.util.Map']
     method name: 'select', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'java.util.Set']
     method name: 'select', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'String...']
     method name: 'from', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'java.lang.Object']

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForIntelliJ.gdsl
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForIntelliJ.gdsl?rev=1840898&r1=1840897&r2=1840898&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForIntelliJ.gdsl (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/OfbizDslDescriptorForIntelliJ.gdsl Fri Sep 14 08:19:39 2018
@@ -31,6 +31,8 @@ contributor(groovyContext) {
     method name: 'runService', type: 'java.util.Map', params: [serviceName: 'String', inputMap: 'java.util.Map']
     method name: 'run', type: 'java.util.Map', params: [args: 'java.util.Map']
     method name: 'makeValue', type: 'java.util.Map', params: [entityName: 'String']
+    method name: 'findOne', type: 'java.util.Map', params: [entityName: 'String', fields: 'java.util.Map', useCache: 'boolean']
+
     method name: 'select', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'java.util.Set']
     method name: 'select', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'String...']
     method name: 'from', type: 'org.apache.ofbiz.entity.util.EntityQuery', params: [entity: 'java.lang.Object']
@@ -42,4 +44,5 @@ contributor(groovyContext) {
     method name: 'logInfo', type: 'void', params: [message: 'String']
     method name: 'logWarning', type: 'void', params: [message: 'String']
     method name: 'logError', type: 'void', params: [message: 'String']
+    method name: 'logVerbose', type: 'void', params: [message: 'String']
 }
\ No newline at end of file

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy?rev=1840898&r1=1840897&r2=1840898&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy Fri Sep 14 08:19:39 2018
@@ -76,8 +76,9 @@ abstract class GroovyBaseScript extends
         return EntityQuery.use(binding.getVariable('delegator')).select(fields)
     }
 
+    @Deprecated
     GenericValue findOne(String entityName, Map<String, ? extends Object> fields, boolean useCache) {
-        return binding.getVariable('delegator').findOne(entityName, fields, useCache)
+        return from(entityName).where(fields).cache(useCache).queryOne()
     }
 
     def success(String message) {