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 22bb77e Improved: Convert updateCommContentDataResource service from mini-lang to groovy DSL(OFBIZ-11379) 22bb77e is described below commit 22bb77ebc622310e247dc60efe5ba307acfc8354 Author: Pawan Verma <[hidden email]> AuthorDate: Sat Jul 18 14:21:33 2020 +0530 Improved: Convert updateCommContentDataResource service from mini-lang to groovy DSL(OFBIZ-11379) Thanks, Devanshu for the report, Sourabh for the initial patch and Nicolas for the updated patch. --- .../groovyScripts/content/ContentServices.groovy | 26 +++++++++++++++- .../content/minilang/content/ContentServices.xml | 36 ---------------------- .../content/servicedef/services_commevent.xml | 5 +-- 3 files changed, 28 insertions(+), 39 deletions(-) diff --git a/applications/content/groovyScripts/content/ContentServices.groovy b/applications/content/groovyScripts/content/ContentServices.groovy index 8309c8e..c4991ae 100644 --- a/applications/content/groovyScripts/content/ContentServices.groovy +++ b/applications/content/groovyScripts/content/ContentServices.groovy @@ -413,4 +413,28 @@ def deleteContentKeywords() { content = from('Content').where('contentId', contentId).queryOne() content.removeRelated('ContentKeyword') return success() -} \ No newline at end of file +} + +// This method first updates Content, DataResource and ElectronicText, +// ImageDataResource, etc. entities (if needed) by calling persistContentAndAssoc. +// It then takes the passed in contentId, communicationEventId and fromDate primary keys +// and calls the "updateCommEventContentAssoc" service to tie the CommunicationEvent and Content entities together. +def updateCommContentDataResource() { + Map serviceResult = run service: 'persistContentAndAssoc', with: parameters + run service: 'updateCommEventContentAssoc', with: [contentId : serviceResult.contentId, + fromDate : parameters.fromDate, + communicationEventId: parameters.communicationEventId, + sequenceNum : parameters.sequenceNum, + userLogin : userLogin] + + return [* : success(), + contentId : serviceResult.contentId, + dataResourceId : serviceResult.dataResourceId, + drDataResourceId : serviceResult.drDataResourceId, + caContentIdTo : serviceResult.caContentIdTo, + caContentId : serviceResult.caContentId, + caContentAssocTypeId: serviceResult.caContentAssocTypeId, + caFromDate : serviceResult.caFromDate, + caSequenceNum : serviceResult.caSequenceNum, + roleTypeList : serviceResult.roleTypeList] +} diff --git a/applications/content/minilang/content/ContentServices.xml b/applications/content/minilang/content/ContentServices.xml index 1446656..0ea5217 100644 --- a/applications/content/minilang/content/ContentServices.xml +++ b/applications/content/minilang/content/ContentServices.xml @@ -291,42 +291,6 @@ </simple-method> - <!-- This method first updates Content, DataResource and ElectronicText, ImageDataResource, etc. entities (if needed) - by calling persistContentAndAssoc. It then takes the passed in contentId, communicationEventId and fromDate primary keys - and calls the "updateCommEventContentAssoc" service to tie the CommunicationEvent and Content entities together. - --> - <simple-method method-name="updateCommContentDataResource" short-description="Update CommunicationEvent and Content"> - - <!-- - <check-permission permission="CONTENTMGR" action="_DELETE"> - <fail-property resource="ContentUiLabels" property="ContentSecurityDeletePermission"/> - </check-permission> - <check-errors/> - --> - <set-service-fields service-name="persistContentAndAssoc" map="parameters" to-map="persistIn"/> - <call-service service-name="persistContentAndAssoc" in-map-name="persistIn"> - <results-to-map map-name="persistOut"/> - </call-service> - - <set field="mapIn.contentId" from-field="persistOut.contentId"/> - <set field="mapIn.fromDate" from-field="parameters.fromDate"/> - <set field="mapIn.communicationEventId" from-field="parameters.communicationEventId"/> - <set field="mapIn.sequenceNum" from-field="parameters.sequenceNum"/> - <call-service service-name="updateCommEventContentAssoc" in-map-name="mapIn"> - </call-service> - - <field-to-result field="persistOut.contentId" result-name="contentId"/> - <field-to-result field="persistOut.dataResourceId" result-name="dataResourceId"/> - <field-to-result field="persistOut.drDataResourceId" result-name="drDataResourceId"/> - <field-to-result field="persistOut.caContentIdTo" result-name="caContentIdTo"/> - <field-to-result field="persistOut.caContentId" result-name="caContentId"/> - <field-to-result field="persistOut.caContentAssocTypeId" result-name="caContentAssocTypeId"/> - <field-to-result field="persistOut.caFromDate" result-name="caFromDate"/> - <field-to-result field="persistOut.caSequenceNum" result-name="caSequenceNum"/> - <field-to-result field="persistOut.roleTypeList" result-name="roleTypeList"/> - - </simple-method> - <!-- This service ties CommunicationEvent and Content entities together along with the standard from/thruDate fields. --> <simple-method method-name="createCommEventContentAssoc" short-description="Create CommEventContentAssoc"> diff --git a/applications/content/servicedef/services_commevent.xml b/applications/content/servicedef/services_commevent.xml index c440004..dc57c18 100644 --- a/applications/content/servicedef/services_commevent.xml +++ b/applications/content/servicedef/services_commevent.xml @@ -52,9 +52,10 @@ under the License. <attribute name="fromDate" type="java.sql.Timestamp" mode="OUT" optional="false"/> </service> - <service name="updateCommContentDataResource" engine="simple" - location="component://content/minilang/content/ContentServices.xml" invoke="updateCommContentDataResource" auth="true"> + <service name="updateCommContentDataResource" engine="groovy" + location="component://content/groovyScripts/content/ContentServices.groovy" invoke="updateCommContentDataResource" auth="true"> <description>Update CommunicationEvent and Content</description> + <permission-service service-name="genericContentPermission" main-action="UPDATE"/> <implements service="persistContentAndAssoc"/> <attribute name="communicationEventId" type="String" mode="IN" optional="false"> <type-validate> |
Free forum by Nabble | Edit this page |