Author: nmalin
Date: Mon Nov 27 11:38:24 2017
New Revision: 1816437

URL: http://svn.apache.org/viewvc?rev=1816437&view=rev
Log:
Implemented: improve makeValue in groovy DSL to load directly with a map 
(OFBIZ-10020)

When you create a GenericValue with groovy, you need to initial it with 
makeValue and after set all fields.
***
GenericValue product = makeValue('Product')
product.internalName = parameters.internalName
***

I simplified this dsl with an automatic parameters check so you can directly 
write :
***
GenericValue product = makeValue('Product', parameters)

Modified:
    
ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyBaseScript.groovy

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=1816437&r1=1816436&r2=1816437&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
 Mon Nov 27 11:38:24 2017
@@ -57,6 +57,10 @@ abstract class GroovyBaseScript extends
         return result = binding.getVariable('delegator').makeValue(entityName)
     }
 
+    Map makeValue(String entityName, Map inputMap) throws 
ExecutionServiceException {
+        return result = 
binding.getVariable('delegator').makeValidValue(entityName, inputMap)
+    }
+
     EntityQuery from(def entity) {
         return EntityQuery.use(binding.getVariable('delegator')).from(entity)
     }


Reply via email to