[ofbiz-framework] branch trunk updated: Improved: Convert updateSingleContentPurpose service from mini-lang to groovy DSL(OFBIZ-11367)

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: Convert updateSingleContentPurpose service from mini-lang to groovy DSL(OFBIZ-11367)

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 568fa2c  Improved: Convert updateSingleContentPurpose service from mini-lang to groovy DSL(OFBIZ-11367)
568fa2c is described below

commit 568fa2c1738334cdb3d4c184d9ad49ba0c1b79ca
Author: Pawan Verma <[hidden email]>
AuthorDate: Sat Aug 22 10:44:02 2020 +0530

    Improved: Convert updateSingleContentPurpose service from mini-lang to groovy DSL(OFBIZ-11367)
   
    Thanks: Devanshu for report and Sourabh for the patch.
---
 applications/content/groovyScripts/content/ContentServices.groovy | 5 +++++
 applications/content/minilang/content/ContentServices.xml         | 8 --------
 applications/content/servicedef/services_content.xml              | 4 ++--
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/applications/content/groovyScripts/content/ContentServices.groovy b/applications/content/groovyScripts/content/ContentServices.groovy
index 75e2d8f..cb53aa5 100644
--- a/applications/content/groovyScripts/content/ContentServices.groovy
+++ b/applications/content/groovyScripts/content/ContentServices.groovy
@@ -52,6 +52,11 @@ def createTextAndUploadedContent(){
     return result
 }
 
+def updateSingleContentPurpose() {
+    delegator.removeByAnd("ContentPurpose", ["contentId": parameters.contentId])
+    run service : "createContentPurpose", with: parameters
+}
+
 def createEmailContent() {
     Map result = success()
     Map createContentMap = dispatcher.getDispatchContext()
diff --git a/applications/content/minilang/content/ContentServices.xml b/applications/content/minilang/content/ContentServices.xml
index 61e528f..68d6a47 100644
--- a/applications/content/minilang/content/ContentServices.xml
+++ b/applications/content/minilang/content/ContentServices.xml
@@ -136,14 +136,6 @@
         <check-errors/>
     </simple-method>
 
-    <!-- Methods for ContentRole -->
-
-    <simple-method method-name="updateSingleContentPurpose" short-description="Updates the purpose making sure there is only one">
-        <set field="toRemove.contentId" from-field="parameters.contentId"/>
-        <remove-by-and entity-name="ContentPurpose" map="toRemove"/>
-        <call-service service-name="createContentPurpose" in-map-name="parameters"/>
-    </simple-method>
-
     <!-- Util -->
     <simple-method method-name="findAssocContent" short-description="Find associated content">
         <set from-field="parameters.contentId" field="queryMap.contentId"/>
diff --git a/applications/content/servicedef/services_content.xml b/applications/content/servicedef/services_content.xml
index 6f12c3b..2719d11 100644
--- a/applications/content/servicedef/services_content.xml
+++ b/applications/content/servicedef/services_content.xml
@@ -412,8 +412,8 @@
         <permission-service service-name="contentManagerPermission" main-action="DELETE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
-    <service name="updateSingleContentPurpose" engine="simple" default-entity-name="ContentPurpose" auth="true"
-            location="component://content/minilang/content/ContentServices.xml" invoke="updateSingleContentPurpose">
+    <service name="updateSingleContentPurpose" engine="groovy" default-entity-name="ContentPurpose" auth="true"
+            location="component://content/groovyScripts/content/ContentServices.groovy" invoke="updateSingleContentPurpose">
         <description>Removes content purposes and creates a new one</description>
         <permission-service service-name="contentManagerPermission" main-action="UPDATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>