You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ar...@apache.org on 2017/07/08 23:45:11 UTC
svn commit: r1801342 - in
/ofbiz/ofbiz-framework/trunk/applications/accounting:
groovyScripts/agreement/ groovyScripts/agreement/AgreementServices.groovy
minilang/agreement/AgreementServices.xml servicedef/services_agreement.xml
Author: arunpatidar
Date: Sat Jul 8 23:45:10 2017
New Revision: 1801342
URL: http://svn.apache.org/viewvc?rev=1801342&view=rev
Log:
Improved: Convert AgreementServices.xml mini-lang to groovyDSL. (OFBIZ-9460)
Thanks Rishi Solanki for your contribution.
Added:
ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/agreement/
ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/agreement/AgreementServices.groovy (with props)
Removed:
ofbiz/ofbiz-framework/trunk/applications/accounting/minilang/agreement/AgreementServices.xml
Modified:
ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_agreement.xml
Added: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/agreement/AgreementServices.groovy
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/agreement/AgreementServices.groovy?rev=1801342&view=auto
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/agreement/AgreementServices.groovy (added)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/agreement/AgreementServices.groovy Sat Jul 8 23:45:10 2017
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 'License'); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.service.ServiceUtil
+
+/**
+ * Cancel an existing Agreement
+ */
+
+def cancelAgreement() {
+ agreement = from('Agreement').where('agreementId', parameters.agreementId).queryOne();
+ if (agreement) {
+ agreement.thruDate = UtilDateTime.nowTimestamp();
+ agreement.store();
+ }
+ return success()
+}
+
+/**
+ * Copy an existing Agreement
+ */
+
+def copyAgreement() {
+ agreement = from('Agreement').where('agreementId', parameters.agreementId).queryOne();
+ serviceResult = success()
+ if (agreement) {
+ Map createAgreementInMap = dispatcher.getDispatchContext().makeValidContext('createAgreement', 'IN', agreement)
+ result = run service: 'createAgreement', with: createAgreementInMap
+ if (ServiceUtil.isError(result)) return result
+ agreementIdTo = result.agreementId
+ agreementItems = agreement.getRelated('AgreementItem', null, null, false)
+ agreementItems.each { agreementItem ->
+ Map createAgreementItemInMap = dispatcher.getDispatchContext().makeValidContext('createAgreementItem', 'IN', agreementItem)
+ createAgreementItemInMap.agreementId = agreementIdTo
+ result = run service: 'createAgreementItem', with: createAgreementItemInMap
+ }
+ if (parameters.copyAgreementTerms && parameters.copyAgreementTerms == 'Y') {
+ agreementTerms = agreement.getRelated('AgreementTerm', null, null, false)
+ agreementTerms.each { agreementTerm ->
+ Map createAgreementTermInMap = dispatcher.getDispatchContext().makeValidContext('createAgreementTerm', 'IN', agreementTerm)
+ createAgreementTermInMap.agreementId = agreementIdTo
+ result = run service: 'createAgreementTerm', with: createAgreementTermInMap
+ }
+ }
+ if (parameters.copyAgreementProducts && parameters.copyAgreementProducts == 'Y') {
+ agreementProductAppls = agreement.getRelated('AgreementProductAppl', null, null, false)
+ agreementProductAppls.each { agreementProductAppl ->
+ Map createAgreementProductApplInMap = dispatcher.getDispatchContext().makeValidContext('createAgreementProductAppl', 'IN', agreementProductAppl)
+ createAgreementProductApplInMap.agreementId = agreementIdTo
+ result = run service: 'createAgreementProductAppl', with: createAgreementProductApplInMap
+ }
+ }
+ if (parameters.copyAgreementFacilities && parameters.copyAgreementFacilities == 'Y') {
+ agreementTerms = agreement.getRelated('AgreementFacilityAppl', null, null, false)
+ agreementFacilityAppls.each { agreementFacilityAppl ->
+ Map createAgreementFacilityApplInMap = dispatcher.getDispatchContext().makeValidContext('createAgreementFacilityAppl', 'IN', agreementFacilityAppl)
+ createAgreementFacilityApplInMap.agreementId = agreementIdTo
+ result = run service: 'createAgreementFacilityAppl', with: createAgreementFacilityApplInMap
+ }
+ }
+ if (parameters.copyAgreementParties && parameters.copyAgreementParties == 'Y') {
+ agreementPartyApplics = agreement.getRelated('AgreementPartyApplic', null, null, false)
+ agreementPartyApplics.each { agreementPartyApplic ->
+ Map createAgreementPartyApplicInMap = dispatcher.getDispatchContext().makeValidContext('createAgreementPartyApplic', 'IN', agreementPartyApplic)
+ createAgreementPartyApplicInMap.agreementId = agreementIdTo
+ result = run service: 'createAgreementPartyApplic', with: createAgreementPartyApplicInMap
+ }
+ }
+ serviceResult.agreementId = agreementIdTo
+ }
+ return serviceResult
+}
Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/agreement/AgreementServices.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/agreement/AgreementServices.groovy
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/ofbiz-framework/trunk/applications/accounting/groovyScripts/agreement/AgreementServices.groovy
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_agreement.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_agreement.xml?rev=1801342&r1=1801341&r2=1801342&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_agreement.xml (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/servicedef/services_agreement.xml Sat Jul 8 23:45:10 2017
@@ -38,15 +38,15 @@ under the License.
<auto-attributes include="nonpk" mode="IN" optional="true"/>
<override name="textData" allow-html="any"/>
</service>
- <service name="cancelAgreement" default-entity-name="Agreement" engine="simple"
- location="component://accounting/minilang/agreement/AgreementServices.xml" invoke="cancelAgreement" auth="true">
+ <service name="cancelAgreement" default-entity-name="Agreement" engine="groovy"
+ location="component://accounting/groovyScripts/agreement/AgreementServices.groovy" invoke="cancelAgreement" auth="true">
<description>Cancel an Agreement</description>
<permission-service service-name="acctgAgreementPermissionCheck" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
- <service name="copyAgreement" default-entity-name="Agreement" engine="simple"
- location="component://accounting/minilang/agreement/AgreementServices.xml" invoke="copyAgreement" auth="true">
+ <service name="copyAgreement" default-entity-name="Agreement" engine="groovy"
+ location="component://accounting/groovyScripts/agreement/AgreementServices.groovy" invoke="copyAgreement" auth="true">
<description>Copy an Agreement</description>
<permission-service service-name="acctgAgreementPermissionCheck" main-action="CREATE"/>
<auto-attributes include="pk" mode="INOUT" optional="false"/>