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

ashishvijaywargiya pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 543f2015b Groovy dsl enhancement applied (#411)
543f2015b is described below

commit 543f2015bff2273db3699b0c0d76b4abbf4ed57f
Author: Ashish Vijaywargiya <[email protected]>
AuthorDate: Wed Sep 16 23:37:27 2026 +0530

    Groovy dsl enhancement applied (#411)
    
    Groovy DSL enhancement applied in the plugins folder.
---
 .../org/apache/ofbiz/bi/DimensionServices.groovy   |  4 +--
 .../groovy/org/apache/ofbiz/bi/FactServices.groovy | 12 +++----
 .../ofbiz/example/ExamplePermissionServices.groovy |  4 +--
 .../ofbiz/lucene/content/IndexProducts.groovy      |  2 +-
 .../ofbiz/projectmgr/ProjectServicesScript.groovy  | 41 ++++++++--------------
 5 files changed, 23 insertions(+), 40 deletions(-)

diff --git a/bi/src/main/groovy/org/apache/ofbiz/bi/DimensionServices.groovy 
b/bi/src/main/groovy/org/apache/ofbiz/bi/DimensionServices.groovy
index 318f40be8..e9f711425 100644
--- a/bi/src/main/groovy/org/apache/ofbiz/bi/DimensionServices.groovy
+++ b/bi/src/main/groovy/org/apache/ofbiz/bi/DimensionServices.groovy
@@ -78,9 +78,7 @@ Map loadCurrencyDimension() {
 
 Map prepareProductDimensionData() {
     GenericValue product = from('Product').where(parameters).queryOne()
-    if (!product) {
-        return error(label('ProductUiLabels', 
'ProductProductNotFoundWithProduct'))
-    }
+    require(product as boolean, label('ProductUiLabels', 
'ProductProductNotFoundWithProduct'))
     GenericValue productDimension = makeValue('ProductDimension')
     productDimension.setNonPKFields(product)
     GenericValue productType = select('description').from('ProductType')
diff --git a/bi/src/main/groovy/org/apache/ofbiz/bi/FactServices.groovy 
b/bi/src/main/groovy/org/apache/ofbiz/bi/FactServices.groovy
index 6744e48ec..f97e54d6f 100644
--- a/bi/src/main/groovy/org/apache/ofbiz/bi/FactServices.groovy
+++ b/bi/src/main/groovy/org/apache/ofbiz/bi/FactServices.groovy
@@ -36,7 +36,7 @@ Map loadSalesInvoiceFact() {
     if (!invoice) {
         String errorMessage = UtilProperties.getMessage('AccountingUiLabels', 
'AccountingInvoiceDoesNotExists', parameters.locale)
         logError(errorMessage)
-        return error(errorMessage)
+        fail(errorMessage)
     }
     if (invoice.invoiceTypeId == 'SALES_INVOICE') {
         List invoiceItems = delegator.getRelated('InvoiceItem', null, null, 
invoice, false)
@@ -58,12 +58,12 @@ Map loadSalesInvoiceItemFact() {
     if (!invoice) {
         String errorMessage = UtilProperties.getMessage('AccountingUiLabels', 
'AccountingInvoiceDoesNotExists', parameters.locale)
         logError(errorMessage)
-        return error(errorMessage)
+        fail(errorMessage)
     }
     if (!invoiceItem) {
         String errorMessage = UtilProperties.getMessage('AccountingUiLabels', 
'AccountingInvoiceItemDoesNotExists', parameters.locale)
         logError(errorMessage)
-        return error(errorMessage)
+        fail(errorMessage)
     }
 
     if (invoice.invoiceTypeId == 'SALES_INVOICE') {
@@ -174,7 +174,7 @@ Map loadSalesOrderFact() {
     if (!orderHeader) {
         String errorMessage = UtilProperties.getMessage('OrderErrorUiLabels', 
'OrderOrderIdDoesNotExists', parameters.locale)
         logError(errorMessage)
-        return error(errorMessage)
+        fail(errorMessage)
     }
     if (orderHeader.orderTypeId == 'SALES_ORDER') {
         if (orderHeader.statusId == 'ORDER_APPROVED') {
@@ -213,12 +213,12 @@ Map loadSalesOrderItemFact() {
     if (!orderHeader) {
         String errorMessage = UtilProperties.getMessage('OrderErrorUiLabels', 
'OrderOrderIdDoesNotExists', parameters.locale)
         logError(errorMessage)
-        return error(errorMessage)
+        fail(errorMessage)
     }
     if (!orderItem) {
         String errorMessage = UtilProperties.getMessage('OrderErrorUiLabels', 
'OrderOrderItemIdDoesNotExists', parameters.locale)
         logError(errorMessage)
-        return error(errorMessage)
+        fail(errorMessage)
     }
 
     if (orderHeader.statusId == 'ORDER_APPROVED') {
diff --git 
a/example/src/main/groovy/org/apache/ofbiz/example/ExamplePermissionServices.groovy
 
b/example/src/main/groovy/org/apache/ofbiz/example/ExamplePermissionServices.groovy
index aab53000a..69895b031 100644
--- 
a/example/src/main/groovy/org/apache/ofbiz/example/ExamplePermissionServices.groovy
+++ 
b/example/src/main/groovy/org/apache/ofbiz/example/ExamplePermissionServices.groovy
@@ -24,9 +24,7 @@ Map exampleGenericPermission() {
     Map result = success()
     String mainAction = parameters.mainAction
 
-    if (!mainAction) {
-        return error(UtilProperties.getMessage('ExampleUiLabels', 
'ExamplePermissionMainActionAttributeMissing', locale))
-    }
+    require(mainAction as boolean, 'ExampleUiLabels', 
'ExamplePermissionMainActionAttributeMissing')
 
     if (security.hasEntityPermission('EXAMPLE', '_' + mainAction, userLogin) 
|| security.hasEntityPermission('EXAMPLE', '_ADMIN', userLogin)) {
         result.hasPermission = true
diff --git 
a/lucene/src/main/groovy/org/apache/ofbiz/lucene/content/IndexProducts.groovy 
b/lucene/src/main/groovy/org/apache/ofbiz/lucene/content/IndexProducts.groovy
index 444cf42b2..0f5f3b356 100644
--- 
a/lucene/src/main/groovy/org/apache/ofbiz/lucene/content/IndexProducts.groovy
+++ 
b/lucene/src/main/groovy/org/apache/ofbiz/lucene/content/IndexProducts.groovy
@@ -33,7 +33,7 @@ if (pi) {
         }
     } catch (Exception e) {
         TransactionUtil.rollback(beganTransaction, e.getMessage(), e)
-        return error(e.getMessage())
+        fail(e.getMessage())
     } finally {
         TransactionUtil.commit(beganTransaction)
     }
diff --git 
a/projectmgr/src/main/groovy/org/apache/ofbiz/projectmgr/ProjectServicesScript.groovy
 
b/projectmgr/src/main/groovy/org/apache/ofbiz/projectmgr/ProjectServicesScript.groovy
index bd597721e..aae568e54 100644
--- 
a/projectmgr/src/main/groovy/org/apache/ofbiz/projectmgr/ProjectServicesScript.groovy
+++ 
b/projectmgr/src/main/groovy/org/apache/ofbiz/projectmgr/ProjectServicesScript.groovy
@@ -57,10 +57,9 @@ Map createProject() {
 
     // create new work effort's e-mail address
     if (parameters.emailAddress) {
-        if (!UtilValidate.isEmail(parameters.emailAddress)) {
-            return error(label('PartyUiLabels', 
'PartyEmailAddressNotFormattedCorrectly'))
-        }
-        run service: 'createWorkEffortEmailAddress', with: serviceMap
+        require(UtilValidate.isEmail(parameters.emailAddress) as boolean,
+                label('PartyUiLabels', 
'PartyEmailAddressNotFormattedCorrectly'))
+        runAsync service: 'createWorkEffortEmailAddress', with: serviceMap
     }
     return success([projectId: serviceMap.workEffortId, workEffortId: 
serviceMap.workEffortId])
 }
@@ -86,19 +85,18 @@ Map updateProject() {
 
     // update new work effort's e-mail address
     if (parameters.emailAddress) {
-        if (!UtilValidate.isEmail(parameters.emailAddress)) {
-            return error(label('PartyUiLabels', 
'PartyEmailAddressNotFormattedCorrectly'))
-        }
+        require(UtilValidate.isEmail(parameters.emailAddress) as boolean,
+                label('PartyUiLabels', 
'PartyEmailAddressNotFormattedCorrectly'))
         GenericValue existEmailAddress = from('WorkEffortContactMechView')
                 .where(workEffortId: parameters.workEffortId,
                         contactMechTypeId: 'EMAIL_ADDRESS')
                 .filterByDate()
                 .queryFirst()
         if (existEmailAddress) {
-            run service: 'updateWorkEffortEmailAddress', with: [*: parameters,
+            runAsync service: 'updateWorkEffortEmailAddress', with: [*: 
parameters,
                                                                 
oldContactMechId: existEmailAddress.contactMechId]
         } else {
-            run service: 'createWorkEffortEmailAddress', with: parameters
+            runAsync service: 'createWorkEffortEmailAddress', with: parameters
         }
     }
     return success()
@@ -452,9 +450,7 @@ Map getProjectIdAndNameFromTask() {
  */
 Map copyProject() {
     GenericValue project = from('WorkEffort').where(workEffortId: 
parameters.projectId).queryOne()
-    if (!project) {
-        return error(label('ProjectMgrUiLabels', 
'ProjectMgrErrorProjectNotFound'))
-    }
+    require(project as boolean, label('ProjectMgrUiLabels', 
'ProjectMgrErrorProjectNotFound'))
     parameters.workEffortName = parameters.workEffortName ?: 
project.workEffortName
     parameters.description = parameters.description ?: project.description
     parameters.workEffortTypeId = parameters.toTemplate == 'Y' ? 
'PROJECT_TEMPLATE' : 'PROJECT'
@@ -538,9 +534,7 @@ Map getProject() {
  */
 Map getProjectPhaseList() {
     GenericValue project = from('WorkEffort').where(workEffortId: 
parameters.projectId).cache().queryOne()
-    if (!project) {
-        return error(label('ProjectMgrUiLabels', 
'ProjectMgrErrorProjectNotFound'))
-    }
+    require(project as boolean, label('ProjectMgrUiLabels', 
'ProjectMgrErrorProjectNotFound'))
 
     List phaseList = []
     from('WorkEffort')
@@ -567,9 +561,7 @@ Map getProjectPhaseList() {
  */
 Map getProjectTaskList() {
     GenericValue project = from('WorkEffort').where(workEffortId: 
parameters.projectId).cache().queryOne()
-    if (!project) {
-        return error(label('ProjectMgrUiLabels', 
'ProjectMgrErrorProjectNotFound'))
-    }
+    require(project as boolean, label('ProjectMgrUiLabels', 
'ProjectMgrErrorProjectNotFound'))
 
     List taskList = []
     from('ProjectAndPhaseAndTask')
@@ -707,9 +699,8 @@ Map createTimeEntryInTimesheet() {
     if (parameters.fromDate && !parameters.timesheetId) {
         GenericValue timesheet = from('Timesheet').where(partyId: 
parameters.partyId).filterByDate().queryFirst()
         if (timesheet) {
-            if (timesheet.statusId != 'TIMESHEET_IN_PROCESS') {
-                return error(label('ProjectMgrUiLabels', 
'ProjectMgrCannotAddToTimesheet'))
-            }
+            require(!(timesheet.statusId != 'TIMESHEET_IN_PROCESS'),
+                    label('ProjectMgrUiLabels', 
'ProjectMgrCannotAddToTimesheet'))
             timesheetId = timesheet.timesheetId
         } else {
             // create new timesheet
@@ -741,9 +732,7 @@ Map addProjectTimeToInvoice() {
     boolean createInvoice = !parameters.reCreate
     if (parameters.reCreate == 'Y') {
         GenericValue invoice = from('Invoice').where(parameters).queryOne()
-        if (!invoice) {
-            return error(label('WorkEffortUiLabels', 
'WorkEffortTimesheetCannotFindInvoice'))
-        }
+        require(invoice as boolean, label('WorkEffortUiLabels', 
'WorkEffortTimesheetCannotFindInvoice'))
         //FIXME <call-simple-method method-name="checkInvoiceStatusInProgress"
         // 
xml-resource="component://accounting/minilang/invoice/InvoiceServices.xml"/>
         EntityCondition removeCond = 
EntityCondition.makeCondition('invoiceId', parameters.invoiceId)
@@ -765,9 +754,7 @@ Map addProjectTimeToInvoice() {
             .where(condition)
             .orderBy('workEffortId')
             .queryList()
-    if (!tasks) {
-        return error(label('WorkEffortUiLabels', 
'ProjectMgrNoTimeentryItemsFound'))
-    }
+    require(tasks as boolean, label('WorkEffortUiLabels', 
'ProjectMgrNoTimeentryItemsFound'))
     String invoiceId = parameters.invoiceId
     if (createInvoice) {
         Map serviceResult = run service: 'addWorkEffortTimeToNewInvoice', 
with: [*: parameters,

Reply via email to