You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by nm...@apache.org on 2021/09/14 18:00:22 UTC

[ofbiz-framework] 02/03: Improved: Convert updateSimpleTextContent service from mini-lang to groovy DSL (OFBIZ-11375)

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 85c62202981d40e93f08d7d44349591ea11f7c4e
Author: Nicolas Malin <ni...@nereide.fr>
AuthorDate: Tue Sep 14 14:50:52 2021 +0200

    Improved: Convert updateSimpleTextContent service from mini-lang to groovy DSL (OFBIZ-11375)
    
    Thanks to vivek singh bisen for initiate the patch
---
 .../content/groovyScripts/content/ContentServices.groovy     | 12 ++++++++++++
 applications/content/minilang/content/ContentServices.xml    |  8 --------
 applications/content/servicedef/services.xml                 |  2 +-
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/applications/content/groovyScripts/content/ContentServices.groovy b/applications/content/groovyScripts/content/ContentServices.groovy
index c689bd3..d307cbd 100644
--- a/applications/content/groovyScripts/content/ContentServices.groovy
+++ b/applications/content/groovyScripts/content/ContentServices.groovy
@@ -517,4 +517,16 @@ def createSimpleTextContent() {
                                                          dataResourceId: serviceResult.dataResourceId]
 
     return serviceResult
+}
+
+def updateSimpleTextContent() {
+    Map result = success()
+
+    if (parameters.textDataResourceId) {
+        run service: 'updateElectronicText', with: [dataResourceId: parameters.textDataResourceId,
+                                                    textData      : parameters.text]
+        result.dataResourceId = parameters.textdataResourceId
+        result.textData = parameters.text
+    }
+    return result
 }
\ No newline at end of file
diff --git a/applications/content/minilang/content/ContentServices.xml b/applications/content/minilang/content/ContentServices.xml
index 2aef8a1..17f1abf 100644
--- a/applications/content/minilang/content/ContentServices.xml
+++ b/applications/content/minilang/content/ContentServices.xml
@@ -136,14 +136,6 @@
         <check-errors/>
     </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"/>
-            <set from-field="parameters.text" field="updateSimpleText.textData"/>
-            <call-service service-name="updateElectronicText" in-map-name="updateSimpleText"/>
-        </if-not-empty>
-    </simple-method>
-
     <!-- This method first creates Content, DataResource and ElectronicText, ImageDataResource, etc. entities (if needed)
          by calling persistContentAndAssoc.
 
diff --git a/applications/content/servicedef/services.xml b/applications/content/servicedef/services.xml
index 40c8775..5338abf 100644
--- a/applications/content/servicedef/services.xml
+++ b/applications/content/servicedef/services.xml
@@ -169,7 +169,7 @@
         </attribute>
         <override name="contentId" mode="INOUT"/>
     </service>
-    <service name="updateSimpleTextContent" engine="simple" location="component://content/minilang/content/ContentServices.xml" invoke="updateSimpleTextContent">
+    <service name="updateSimpleTextContent" engine="groovy" location="component://content/groovyScripts/content/ContentServices.groovy" invoke="updateSimpleTextContent">
         <permission-service service-name="contentManagerPermission" main-action="UPDATE"/>
         <attribute name="textDataResourceId" type="String" mode="IN" optional="true"/>
         <attribute name="text" type="String" mode="IN" optional="true" allow-html="safe"/>