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

mridulpathak 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 ce8cfadfe3 Fixed: Mini-lang to Groovy regressions in 
CommonServicesScript (OFBIZ-13570)
ce8cfadfe3 is described below

commit ce8cfadfe3a5b3d01e9a2f4ae3f46facfc14bbaf
Author: Mridul Pathak <[email protected]>
AuthorDate: Fri Sep 11 17:17:42 2026 +0530

    Fixed: Mini-lang to Groovy regressions in CommonServicesScript (OFBIZ-13570)
    
    - convertUom: query UomConversion using explicit PK fields (uomId, uomIdTo) 
instead of entire parameters map, and move verbose conversion factor log after 
null check.
    - getVisualThemeResources: accumulate resourceValue Strings into a List per 
resourceTypeEnumId, fixing single map overwrite and resouceTypeEnumId typo.
    - linkGeos: guard against NullPointerException when geoIds parameter is 
null or omitted.
    - checkUomConversion: check queryCount() > 0 instead of == 1.
    - checkUomConversionDated: query UomConversionDated instead of 
UomConversion entity, and check queryCount() > 0 instead of == 1.
---
 .../org/apache/ofbiz/common/CommonServicesScript.groovy | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git 
a/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
 
b/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
index a7c51a7032..2838add480 100644
--- 
a/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
+++ 
b/framework/common/src/main/groovy/org/apache/ofbiz/common/CommonServicesScript.groovy
@@ -88,13 +88,17 @@ Map convertUom() {
     }
 
     // if not found, try the uom conversion entity
-    uomConversion = uomConversion ?: 
from('UomConversion').where(parameters).cache().queryOne()
-    logVerbose("using conversion factor=${uomConversion.conversionFactor}")
+    uomConversion = uomConversion ?: from('UomConversion')
+            .where(uomId: parameters.uomId,
+                    uomIdTo: parameters.uomIdTo)
+            .cache()
+            .queryOne()
 
     if (!uomConversion) {
         // if still no uom conversion entity, then no conversion is possible
         return error(UtilProperties.getMessage('CommonUiLabels', 
'CommonNoUomConversionFound', parameters.locale))
     }
+    logVerbose("using conversion factor=${uomConversion.conversionFactor}")
     // Do custom conversion, if we have customMethodId
     if (uomConversion.customMethodId) { //custom conversion?
         logVerbose("using custom conversion 
customMethodId=${uomConversion.customMethodId}")
@@ -201,7 +205,8 @@ Map getVisualThemeResources() {
         String resourceTypeEnumId = resourceRecord.resourceTypeEnumId
         String resourceValue = resourceRecord.resourceValue
         if (resourceValue) {
-            themeResources[resourceTypeEnumId] = [resouceTypeEnumId: 
resourceValue]
+            themeResources[resourceTypeEnumId] = 
themeResources[resourceTypeEnumId] ?: []
+            themeResources[resourceTypeEnumId] << resourceValue
         } else {
             logWarning(UtilProperties.getMessage('CommonUiLabels', 
'CommonVisualThemeInvalidRecord', parameters.locale))
         }
@@ -253,7 +258,7 @@ Map linkGeos() {
             .cache()
             .getFieldList('geoIdTo')
     // Old list contains current values
-    for (String geoIdTo : parameters.geoIds) {
+    for (String geoIdTo : parameters.geoIds ?: []) {
         if (!oldGeoIds?.contains(geoIdTo)) {
             // If it already exist, nothing to do and we keep it
             GenericValue oldGeoAssoc = from('GeoAssoc').where(geoId: 
parameters.geoId, geoIdTo: geoIdTo).queryOne()
@@ -290,7 +295,7 @@ Map getRelatedGeos() {
  */
 Map checkUomConversion() {
     Map result = success()
-    result.exist = from('UomConversion').where(uomId: parameters.uomId, 
uomIdTo: parameters.uomIdTo).queryCount() == 1
+    result.exist = from('UomConversion').where(uomId: parameters.uomId, 
uomIdTo: parameters.uomIdTo).queryCount() > 0
     return result
 }
 
@@ -306,7 +311,7 @@ Map checkUomConversionDated() {
     if (parameters.purposeEnumId) {
         condition.purposeEnumId = parameters.purposeEnumId
     }
-    result.exist = 
from('UomConversion').where(condition).filterByDate().queryCount() == 1
+    result.exist = 
from('UomConversionDated').where(condition).filterByDate().queryCount() > 0
     return result
 }
 

Reply via email to