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:20 UTC

[ofbiz-framework] branch trunk updated (dfb75fb -> 9c53861)

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

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


    from dfb75fb  Improved: Convert createSimpleTextContent service from mini-lang to groovy DSL (OFBIZ-11374)
     new 46d53b5  Improved: Convert findAssocContent service from mini-lang to groovy DSL (OFBIZ-11369)
     new 85c6220  Improved: Convert updateSimpleTextContent service from mini-lang to groovy DSL (OFBIZ-11375)
     new 9c53861  Improved: Convert createPaymentAndPaymentGroupForInvoices service from mini-lang to groovy DSL (OFBIZ-11490)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../groovyScripts/payment/PaymentServices.groovy   | 43 ++++++++++++++++-
 .../minilang/payment/PaymentServices.xml           | 54 ----------------------
 .../accounting/servicedef/services_payment.xml     |  5 +-
 .../groovyScripts/content/ContentServices.groovy   | 29 ++++++++++++
 .../content/minilang/content/ContentServices.xml   | 34 --------------
 applications/content/servicedef/services.xml       | 19 ++------
 6 files changed, 78 insertions(+), 106 deletions(-)

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

Posted by nm...@apache.org.
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"/>

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

Posted by nm...@apache.org.
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 9c538612f56381d647d5f2b4588249b3e4ee48dd
Author: Nicolas Malin <ni...@nereide.fr>
AuthorDate: Tue Sep 14 19:59:31 2021 +0200

    Improved: Convert createPaymentAndPaymentGroupForInvoices service from mini-lang to groovy DSL (OFBIZ-11490)
    
    Thanks to Sourabh Punyani for initiate the patch
---
 .../groovyScripts/payment/PaymentServices.groovy   | 43 ++++++++++++++++-
 .../minilang/payment/PaymentServices.xml           | 54 ----------------------
 .../accounting/servicedef/services_payment.xml     |  5 +-
 3 files changed, 44 insertions(+), 58 deletions(-)

diff --git a/applications/accounting/groovyScripts/payment/PaymentServices.groovy b/applications/accounting/groovyScripts/payment/PaymentServices.groovy
index 795713b..f559df0 100644
--- a/applications/accounting/groovyScripts/payment/PaymentServices.groovy
+++ b/applications/accounting/groovyScripts/payment/PaymentServices.groovy
@@ -18,9 +18,9 @@
  */
 import org.apache.ofbiz.accounting.invoice.InvoiceWorker
 import org.apache.ofbiz.accounting.payment.PaymentWorker
-import org.apache.ofbiz.base.util.Debug
 import org.apache.ofbiz.base.util.UtilDateTime
 import org.apache.ofbiz.base.util.UtilFormatOut
+import org.apache.ofbiz.base.util.UtilMisc
 import org.apache.ofbiz.base.util.UtilProperties
 import org.apache.ofbiz.entity.condition.EntityCondition
 import org.apache.ofbiz.entity.condition.EntityOperator
@@ -507,6 +507,47 @@ def cancelCheckRunPayments() {
     return success()
 }
 
+def createPaymentAndPaymentGroupForInvoices() {
+    Map result
+    GenericValue paymentMethod = from("PaymentMethod").where("paymentMethodId", parameters.paymentMethodId).queryOne()
+
+    if (paymentMethod) {
+        GenericValue finAccount = from("FinAccount").where("finAccountId", paymentMethod.finAccountId).queryOne()
+        if (finAccount.statusId == "FNACT_MANFROZEN") {
+            return error(UtilProperties.getMessage('AccountingErrorUiLabels', 'AccountingFinAccountInactiveStatusError', locale))
+        } else if (finAccount.statusId == "FNACT_CANCELLED") {
+            return error(UtilProperties.getMessage('AccountingErrorUiLabels', 'AccountingFinAccountStatusNotValidError', locale))
+        }
+    }
+    Map partyInvoices = [:]
+    parameters.invoiceIds.each {invoiceId ->
+        GenericValue invoice = from("Invoice").where("invoiceId", invoiceId).queryOne()
+        UtilMisc.addToListInMap(invoice, partyInvoices, invoice.partyIdFrom)
+    }
+    List paymentIds = []
+    partyInvoices.each { partyId, invoice ->
+        if (parameters.checkStartNumber) {
+            parameters.checkStartNumber = parameters.checkStartNumber + 1
+        }
+        result = run service: 'createPaymentAndApplicationForParty', with: [*                  : parameters,
+                                                                            paymentMethodTypeId: paymentMethod.paymentMethodTypeId,
+                                                                            finAccountId       : paymentMethod.finAccountId,
+                                                                            partyId            : partyId,
+                                                                            invoices           : invoice]
+        paymentIds << result.paymentId
+    }
+    if (paymentIds) {
+        result = run service: 'createPaymentGroupAndMember', with: [paymentIds        : paymentIds,
+                                                                    paymentGroupTypeId: 'CHECK_RUN',
+                                                                    paymentGroupName  : "Payment group for Check Run(InvoiceIds-${parameters.invoiceIds})"]
+        paymentGroupId = result.paymentGroupId
+    }
+    if (!result.paymentGroupId) {
+        return error(UtilProperties.getMessage("AccountingUiLabels", "AccountingNoInvoicesReadyOrOutstandingAmountZero", parameters.locale))
+    }
+    return result
+}
+
 def createPaymentFromOrder() {
     Map serviceResult = success()
 
diff --git a/applications/accounting/minilang/payment/PaymentServices.xml b/applications/accounting/minilang/payment/PaymentServices.xml
index 642e9a0..c91e74f 100644
--- a/applications/accounting/minilang/payment/PaymentServices.xml
+++ b/applications/accounting/minilang/payment/PaymentServices.xml
@@ -211,60 +211,6 @@ under the License.
         </iterate>
     </simple-method>
 
-    <simple-method method-name="createPaymentAndPaymentGroupForInvoices" short-description="Creates Payments, PaymentApplications and PaymentGroup for the same">
-        <entity-one entity-name="PaymentMethod" value-field="paymentMethod" auto-field-map="true"/>
-        <entity-one entity-name="FinAccount" value-field="finAccount" auto-field-map="false">
-            <field-map field-name="finAccountId" from-field="paymentMethod.finAccountId"/>
-        </entity-one>
-        <if-compare field="finAccount.statusId" operator="equals" value="FNACT_MANFROZEN">
-            <add-error>
-                <fail-property resource="AccountingErrorUiLabels.xml" property="AccountingFinAccountInactiveStatusError"/>
-            </add-error>
-        </if-compare>
-        <if-compare field="finAccount.statusId" operator="equals" value="FNACT_CANCELLED">
-            <add-error>
-                <fail-property resource="AccountingErrorUiLabels.xml" property="AccountingFinAccountStatusNotValidError"/>
-            </add-error>
-        </if-compare>
-        <check-errors/>
-        <set field="invoices" type="List"/>
-        <iterate list="parameters.invoiceIds" entry="invoiceId">
-            <entity-one entity-name="Invoice" value-field="invoice" auto-field-map="true"/>
-            <clear-field field="invoices"/>
-            <set field="invoices" from-field="partyInvoices.${invoice.partyIdFrom}"/>
-            <field-to-list field="invoice" list="invoices"/>
-            <set field="partyInvoices.${invoice.partyIdFrom}" from-field="invoices"/>
-        </iterate>
-        <clear-field field="invoices"/>
-        <iterate-map map="partyInvoices" key="partyId" value="invoices">
-            <set-service-fields service-name="createPaymentAndApplicationForParty" map="parameters" to-map="createPaymentAndApplicationForPartyMap"/>
-            <set field="createPaymentAndApplicationForPartyMap.paymentMethodTypeId" from-field="paymentMethod.paymentMethodTypeId"/>
-            <set field="createPaymentAndApplicationForPartyMap.finAccountId" from-field="paymentMethod.finAccountId"/>
-            <set field="createPaymentAndApplicationForPartyMap.partyId" from-field="partyId"/>
-            <set field="createPaymentAndApplicationForPartyMap.invoices" from-field="invoices"/>
-            <if-not-empty field="parameters.checkStartNumber">
-                 <set field="parameters.checkStartNumber" value="${parameters.checkStartNumber + 1}" type="Long"/>
-            </if-not-empty>
-            <call-service service-name="createPaymentAndApplicationForParty" in-map-name="createPaymentAndApplicationForPartyMap">
-                <result-to-field result-name="paymentId" field="paymentId"/>
-            </call-service>
-            <field-to-list field="paymentId" list="paymentIds"/>
-        </iterate-map>
-        <if-not-empty field="paymentIds">
-            <set field="createPaymentGroupAndMemberMap.paymentIds" from-field="paymentIds"/>
-            <set field="createPaymentGroupAndMemberMap.paymentGroupTypeId" value="CHECK_RUN"/>
-            <set field="createPaymentGroupAndMemberMap.paymentGroupName" value="Payment group for Check Run(InvoiceIds-${parameters.invoiceIds})"/>
-            <call-service service-name="createPaymentGroupAndMember" in-map-name="createPaymentGroupAndMemberMap">
-                <result-to-field result-name="paymentGroupId"/>
-                <result-to-result result-name="paymentGroupId"/>
-            </call-service>
-        </if-not-empty>
-        <if-empty field="paymentGroupId">
-            <property-to-field property="AccountingNoInvoicesReadyOrOutstandingAmountZero" resource="AccountingUiLabels" field="errorMessage"/>
-            <field-to-result field="errorMessage" result-name="errorMessage"/>
-        </if-empty>
-    </simple-method>
-
     <simple-method method-name="createPaymentGroupAndMember" short-description="creates PaymentGroup and PaymentGroupMembers">
         <if-empty field="parameters.fromDate">
             <now-timestamp field="parameters.fromDate"/>
diff --git a/applications/accounting/servicedef/services_payment.xml b/applications/accounting/servicedef/services_payment.xml
index 233dff2..3941c9d 100644
--- a/applications/accounting/servicedef/services_payment.xml
+++ b/applications/accounting/servicedef/services_payment.xml
@@ -163,8 +163,8 @@ under the License.
         <description>cancel payment batch</description>
         <attribute name="paymentGroupId" type="String" mode="IN" optional="false"/>
     </service>
-    <service name="createPaymentAndPaymentGroupForInvoices" engine="simple"
-            location="component://accounting/minilang/payment/PaymentServices.xml" invoke="createPaymentAndPaymentGroupForInvoices" auth="true">
+    <service name="createPaymentAndPaymentGroupForInvoices" engine="groovy"
+            location="component://accounting/groovyScripts/payment/PaymentServices.groovy" invoke="createPaymentAndPaymentGroupForInvoices" auth="true">
         <description>Creates Payments, Payment Application and Payment Group for the same</description>
         <attribute name="organizationPartyId" type="String" mode="IN" optional="false"/>
         <attribute name="checkStartNumber" type="Long" mode="IN" optional="true"/>
@@ -172,7 +172,6 @@ under the License.
         <attribute name="paymentMethodTypeId" type="String" mode="IN" optional="true"/>
         <attribute name="paymentMethodId" type="String" mode="IN" optional="false"/>
         <attribute name="paymentGroupId" type="String" mode="OUT" optional="true"/>
-        <attribute name="errorMessage" type="String" optional="true" mode="OUT"/>
     </service>
     <service name="createPaymentAndApplicationForParty" engine="groovy"
             location="component://accounting/groovyScripts/payment/PaymentServices.groovy" invoke="createPaymentAndApplicationForParty" auth="true">

[ofbiz-framework] 01/03: Improved: Convert findAssocContent service from mini-lang to groovy DSL (OFBIZ-11369)

Posted by nm...@apache.org.
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 46d53b513eb455f453950db221d45e9023a0b04c
Author: Nicolas Malin <ni...@nereide.fr>
AuthorDate: Tue Sep 14 14:24:22 2021 +0200

    Improved: Convert findAssocContent service from mini-lang to groovy DSL (OFBIZ-11369)
    
    Thanks to Prakhar Kumar
---
 .../groovyScripts/content/ContentServices.groovy   | 17 ++++++++++++++
 .../content/minilang/content/ContentServices.xml   | 26 ----------------------
 applications/content/servicedef/services.xml       | 17 ++++----------
 3 files changed, 21 insertions(+), 39 deletions(-)

diff --git a/applications/content/groovyScripts/content/ContentServices.groovy b/applications/content/groovyScripts/content/ContentServices.groovy
index 7d33c96..c689bd3 100644
--- a/applications/content/groovyScripts/content/ContentServices.groovy
+++ b/applications/content/groovyScripts/content/ContentServices.groovy
@@ -28,6 +28,7 @@ import org.apache.ofbiz.entity.condition.EntityOperator
 import org.apache.ofbiz.entity.util.EntityListIterator
 import org.apache.ofbiz.service.GenericServiceException
 
+import org.apache.ofbiz.entity.condition.EntityConditionBuilder
 import org.apache.ofbiz.service.ModelService
 import org.apache.ofbiz.service.ServiceUtil
 import org.apache.ofbiz.base.util.UtilDateTime
@@ -52,6 +53,22 @@ def createTextAndUploadedContent() {
     return result
 }
 
+def findAssocContent() {
+    EntityCondition condition = new EntityConditionBuilder().AND() {
+        EQUALS(contentId: parameters.contentId)
+        IN(mapKey: parameters.mapKeys)
+    }
+    List contentAssocs = from("ContentAssoc")
+            .where(condition)
+            .filterByDate()
+            .cache()
+            .queryList()
+
+    Map result = success()
+    if (contentAssocs) result.contentAssocs = contentAssocs
+    return result
+}
+
 def updateSingleContentPurpose() {
     delegator.removeByAnd("ContentPurpose", [contentId: parameters.contentId])
     run service : "createContentPurpose", with: parameters
diff --git a/applications/content/minilang/content/ContentServices.xml b/applications/content/minilang/content/ContentServices.xml
index 6ae3e1d..2aef8a1 100644
--- a/applications/content/minilang/content/ContentServices.xml
+++ b/applications/content/minilang/content/ContentServices.xml
@@ -136,32 +136,6 @@
         <check-errors/>
     </simple-method>
 
-    <!-- Util -->
-    <simple-method method-name="findAssocContent" short-description="Find associated content">
-        <set from-field="parameters.contentId" field="queryMap.contentId"/>
-        <set field="mapKeys" from-field="parameters.mapKeys"/>
-        <field-to-list field="mapKey" list="mapKeys"/>
-        <iterate list="mapKeys" entry="mapKey">
-            <set from-field="mapKey" field="queryMap.mapKey"/>
-            <find-by-and list="resultMap" entity-name="ContentAssoc" map="queryMap"/>
-            <filter-list-by-date list="resultMap" to-list="validContent"/>
-            <iterate list="validContent" entry="contentAssoc">
-                <field-to-list field="contentAssoc" list="result"/>
-            </iterate>
-        </iterate>
-        <if>
-            <condition>
-                <if-empty field="parameters.mapKey"/>
-            </condition>
-            <then>
-                <field-to-result field="result" result-name="contentAssocs"/>
-            </then>
-            <else>
-                <field-to-result field="result" result-name="contentAssoc"/>
-            </else>
-        </if>
-    </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 37b44e7..40c8775 100644
--- a/applications/content/servicedef/services.xml
+++ b/applications/content/servicedef/services.xml
@@ -176,19 +176,10 @@
     </service>
 
     <!-- Util -->
-    <service name="findAssocContent" engine="simple"
-            location="component://content/minilang/content/ContentServices.xml" invoke="findAssocContent" auth="true">
-        <attribute name="contentId" type="String" mode="IN" optional="false">
-            <type-validate>
-                <fail-property resource="ContentErrorUiLabels" property="ContentRequiredFieldMissingContentId"/>
-            </type-validate>
-        </attribute>
-        <attribute name="mapKeys" type="List" mode="IN" optional="false">
-            <type-validate>
-                <fail-property resource="ContentErrorUiLabels" property="ContentRequiredFieldMissingMapKeys"/>
-            </type-validate>
-        </attribute>
-        <attribute name="contentAssocs" type="List" mode="OUT" optional="true"/>
+    <service name="findAssocContent" engine="groovy" location="component://content/groovyScripts/content/ContentServices.groovy" invoke="findAssocContent" auth="true">
+        <attribute name="contentId" mode="IN" type="String" optional="false"/>
+        <attribute name="mapKeys" mode="IN" type="List" optional="false"/>
+        <attribute name="contentAssocs" mode="OUT" type="List" optional="true"/>
     </service>
 
     <!-- Complex Contentservices -->