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

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

commit dfb75fbcc73fc90b796680fad7d23e73a6c407cb
Author: Nicolas Malin <nicolas.ma...@nereide.fr>
AuthorDate: Tue Sep 14 14:04:41 2021 +0200

    Improved: Convert createSimpleTextContent service from mini-lang to groovy 
DSL (OFBIZ-11374)
    
    Thanks to Sourabh Punyani
---
 .../groovyScripts/content/ContentServices.groovy    | 16 ++++++++++++++++
 .../content/minilang/content/ContentServices.xml    | 21 ---------------------
 applications/content/servicedef/services.xml        |  2 +-
 3 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/applications/content/groovyScripts/content/ContentServices.groovy 
b/applications/content/groovyScripts/content/ContentServices.groovy
index c5e7106..7d33c96 100644
--- a/applications/content/groovyScripts/content/ContentServices.groovy
+++ b/applications/content/groovyScripts/content/ContentServices.groovy
@@ -485,3 +485,19 @@ def forceIndexContentKeywords() {
     ContentKeywordIndex.forceIndexKeywords(content)
     return success()
 }
+
+def createSimpleTextContent() {
+    Map serviceResult = run service: 'createDataResource', with: [*            
     : parameters,
+                                                                  
dataResourceTypeId: 'ELECTRONIC_TEXT',
+                                                                  
dataTemplateTypeId: 'FTL']
+
+    run service: 'createElectronicText', with: [*             : parameters,
+                                                textData      : 
parameters.text,
+                                                dataResourceId: 
serviceResult.dataResourceId]
+
+    serviceResult = run service: 'createContent', with: [*             : 
parameters,
+                                                         contentTypeId : 
'DOCUMENT',
+                                                         dataResourceId: 
serviceResult.dataResourceId]
+
+    return serviceResult
+}
\ No newline at end of file
diff --git a/applications/content/minilang/content/ContentServices.xml 
b/applications/content/minilang/content/ContentServices.xml
index 6218094..6ae3e1d 100644
--- a/applications/content/minilang/content/ContentServices.xml
+++ b/applications/content/minilang/content/ContentServices.xml
@@ -162,27 +162,6 @@
         </if>
     </simple-method>
 
-    <simple-method method-name="createSimpleTextContent" 
short-description="Create Simple Text Content">
-        <set-service-fields service-name="createContent" map="parameters" 
to-map="createSimpleTextContent"/>
-        <set value="DOCUMENT" field="createSimpleTextContent.contentTypeId"/>
-
-        <set from-field="parameters.text" field="createSimpleText.textData"/>
-
-        <set-service-fields service-name="createDataResource" map="parameters" 
to-map="createSimpleTextDataResource"/>
-        <set value="ELECTRONIC_TEXT" 
field="createSimpleTextDataResource.dataResourceTypeId"/>
-        <set value="FTL" 
field="createSimpleTextDataResource.dataTemplateTypeId"/>
-
-        <call-service service-name="createDataResource" 
in-map-name="createSimpleTextDataResource">
-            <result-to-field result-name="dataResourceId" 
field="createSimpleText.dataResourceId"/>
-            <result-to-field result-name="dataResourceId" 
field="createSimpleTextContent.dataResourceId"/>
-        </call-service>
-
-        <call-service service-name="createElectronicText" 
in-map-name="createSimpleText"/>
-
-        <call-service service-name="createContent" 
in-map-name="createSimpleTextContent">
-            <result-to-result result-name="contentId"/>
-        </call-service>
-    </simple-method>
     <simple-method method-name="updateSimpleTextContent" 
short-description="Update Simple Text Content">
         <if-not-empty field="parameters.textDataResourceId">
             <set from-field="parameters.textDataResourceId" 
field="updateSimpleText.dataResourceId"/>
diff --git a/applications/content/servicedef/services.xml 
b/applications/content/servicedef/services.xml
index 994581c..37b44e7 100644
--- a/applications/content/servicedef/services.xml
+++ b/applications/content/servicedef/services.xml
@@ -159,7 +159,7 @@
         <attribute name="file" type="String" mode="IN" optional="true"/>
     </service>
 
-    <service name="createSimpleTextContent" engine="simple" 
location="component://content/minilang/content/ContentServices.xml" 
invoke="createSimpleTextContent">
+    <service name="createSimpleTextContent" engine="groovy" 
location="component://content/groovyScripts/content/ContentServices.groovy" 
invoke="createSimpleTextContent">
         <permission-service service-name="contentManagerPermission" 
main-action="CREATE"/>
         <auto-attributes mode="IN" entity-name="Content" optional="true"/>
         <attribute name="text" type="String" mode="IN" optional="false" 
allow-html="safe">

Reply via email to