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


The following commit(s) were added to refs/heads/trunk by this push:
     new 23d80457db Improved: Convert RoutingSimpleServices.xml mini-lang to 
groovy (OFBIZ-13238)
23d80457db is described below

commit 23d80457dbc15974fcf7ecba8ccea556262386f8
Author: Nicolas Malin <[email protected]>
AuthorDate: Thu May 29 15:31:53 2025 +0200

    Improved: Convert RoutingSimpleServices.xml mini-lang to groovy 
(OFBIZ-13238)
    
    * move createCalendar and createCalendarWeek to entity-auto
    * move removeCalendar and removeCalendarWeek to groovy script
---
 .../minilang/techdata/RoutingSimpleServices.xml    | 125 ---------------------
 .../manufacturing/servicedef/services_calendar.xml |  46 ++++----
 .../routing/RoutingServicesScript.groovy           |  34 ++++++
 3 files changed, 58 insertions(+), 147 deletions(-)

diff --git 
a/applications/manufacturing/minilang/techdata/RoutingSimpleServices.xml 
b/applications/manufacturing/minilang/techdata/RoutingSimpleServices.xml
deleted file mode 100644
index 7a689dc24f..0000000000
--- a/applications/manufacturing/minilang/techdata/RoutingSimpleServices.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-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.
--->
-
-<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-        xmlns="http://ofbiz.apache.org/Simple-Method"; 
xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method 
http://ofbiz.apache.org/dtds/simple-methods.xsd";>
-    <simple-method method-name="createCalendar" short-description="Create 
Calendar">
-        <check-permission permission="MANUFACTURING" 
action="_CREATE"><fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarPermissionError"/></check-permission>
-        <check-errors/>
-        <make-value entity-name="TechDataCalendar" value-field="lookupPKMap"/>
-        <set-pk-fields map="parameters" value-field="lookupPKMap"/>
-        <find-by-primary-key entity-name="TechDataCalendar" map="lookupPKMap" 
value-field="newEntity"/>
-        <if-not-empty field="newEntity.calendarId">
-            <add-error>
-                <fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarIdAlreadyExist"/>
-            </add-error>
-            <check-errors/>
-        <else>
-            <make-value entity-name="TechDataCalendarWeek" 
value-field="lookupPKMap"/>
-            <set-pk-fields map="parameters" value-field="lookupPKMap"/>
-            <find-by-primary-key entity-name="TechDataCalendarWeek" 
map="lookupPKMap" value-field="newEntity"/>
-            <if-empty field="newEntity.calendarWeekId">
-                <add-error>
-                    <fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarWeekIdNotExisting"/>
-                </add-error>
-                <check-errors/>
-            <else>
-                <make-value entity-name="TechDataCalendar" 
value-field="newEntity"/>
-                <set-pk-fields map="parameters" value-field="newEntity"/>
-                <set-nonpk-fields map="parameters" value-field="newEntity"/>
-                <create-value value-field="newEntity"/>
-            </else>
-            </if-empty>
-        </else>
-        </if-not-empty>
-    </simple-method>
-    <simple-method method-name="removeCalendar" short-description="Remove 
Calendar">
-        <check-permission permission="MANUFACTURING" 
action="_DELETE"><fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarPermissionError"/></check-permission>
-        <check-errors/>
-        <make-value entity-name="TechDataCalendar" value-field="lookupPKMap"/>
-        <set-pk-fields map="parameters" value-field="lookupPKMap"/>
-        <get-related value-field="lookupPKMap" 
relation-name="TechDataCalendarExcDay" list="relatedResultList"/>
-        <first-from-list list="relatedResultList" entry="relatedResult"/>
-        <if-not-empty field="relatedResult">
-            <add-error>
-                <fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarExceptionDayUseCalendar"/>
-            </add-error>
-            <check-errors/>
-        </if-not-empty>
-        <get-related value-field="lookupPKMap" 
relation-name="TechDataCalendarExcWeek" list="relatedResultList"/>
-        <first-from-list list="relatedResultList" entry="relatedResult"/>
-        <if-not-empty field="relatedResult">
-            <add-error>
-                <fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarExceptionWeekUseCalendar"/>
-            </add-error>
-            <check-errors/>
-        </if-not-empty>
-        <find-by-primary-key entity-name="TechDataCalendar" map="lookupPKMap" 
value-field="lookedUpValue"/>
-        <if-not-empty field="lookedUpValue.calendarWeekId">
-            <remove-value value-field="lookedUpValue"/>
-        </if-not-empty>
-    </simple-method>
-
-    <simple-method method-name="createCalendarWeek" short-description="Create 
Calendar Week">
-        <check-permission permission="MANUFACTURING" 
action="_CREATE"><fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarPermissionError"/></check-permission>
-        <check-errors/>
-        <make-value entity-name="TechDataCalendarWeek" 
value-field="lookupPKMap"/>
-        <set-pk-fields map="parameters" value-field="lookupPKMap"/>
-        <find-by-primary-key entity-name="TechDataCalendarWeek" 
map="lookupPKMap" value-field="newEntity"/>
-        <if-not-empty field="newEntity.calendarWeekId">
-            <add-error>
-                <fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarWeekIdAlreadyExist"/>
-            </add-error>
-            <check-errors/>
-        <else>
-            <make-value entity-name="TechDataCalendarWeek" 
value-field="newEntity"/>
-            <set-pk-fields map="parameters" value-field="newEntity"/>
-            <set-nonpk-fields map="parameters" value-field="newEntity"/>
-            <create-value value-field="newEntity"/>
-        </else>
-        </if-not-empty>
-    </simple-method>
-    <simple-method method-name="removeCalendarWeek" short-description="Remove 
CalendarWeek">
-        <check-permission permission="MANUFACTURING" 
action="_DELETE"><fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarPermissionError"/></check-permission>
-        <check-errors/>
-        <make-value entity-name="TechDataCalendarWeek" 
value-field="lookupPKMap"/>
-        <set-pk-fields map="parameters" value-field="lookupPKMap"/>
-        <get-related value-field="lookupPKMap" 
relation-name="TechDataCalendar" list="relatedResultList"/>
-        <first-from-list list="relatedResultList" entry="relatedResult"/>
-        <if-not-empty field="relatedResult">
-            <add-error>
-                <fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarUseCalendarWeek"/>
-            </add-error>
-            <check-errors/>
-        </if-not-empty>
-        <get-related value-field="lookupPKMap" 
relation-name="TechDataCalendarExcWeek" list="relatedResultList"/>
-        <first-from-list list="relatedResultList" entry="relatedResult"/>
-        <if-not-empty field="relatedResult">
-            <add-error>
-                <fail-property resource="ManufacturingUiLabels" 
property="ManufacturingCalendarWeekExceptionUseCalendarWeek"/>
-            </add-error>
-            <check-errors/>
-        </if-not-empty>
-        <find-by-primary-key entity-name="TechDataCalendarWeek" 
map="lookupPKMap" value-field="lookedUpValue"/>
-        <if-not-empty field="lookedUpValue.calendarWeekId">
-            <remove-value value-field="lookedUpValue"/>
-        </if-not-empty>
-    </simple-method>
-</simple-methods>
diff --git a/applications/manufacturing/servicedef/services_calendar.xml 
b/applications/manufacturing/servicedef/services_calendar.xml
index 1577767d28..cfaa1a4dbd 100644
--- a/applications/manufacturing/servicedef/services_calendar.xml
+++ b/applications/manufacturing/servicedef/services_calendar.xml
@@ -24,44 +24,46 @@ under the License.
     <version>1.0</version>
 
     <!-- Routing services -->
-    <service name="createCalendar" engine="simple" 
default-entity-name="TechDataCalendar"
-            
location="component://manufacturing/minilang/techdata/RoutingSimpleServices.xml"
 invoke="createCalendar">
+    <service name="createCalendar" engine="entity-auto" 
default-entity-name="TechDataCalendar" invoke="create">
+        <permission-service service-name="manufacturingPermissionService" 
main-action="CREATE"/>
         <description>Create a calendar</description>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="updateCalendar" engine="entity-auto" 
default-entity-name="TechDataCalendar" invoke="update">
         <description>Update a calendar</description>
         <permission-service service-name="manufacturingPermissionService" 
main-action="UPDATE"/>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
-    <service name="removeCalendar" engine="simple" 
default-entity-name="TechDataCalendar"
-            
location="component://manufacturing/minilang/techdata/RoutingSimpleServices.xml"
 invoke="removeCalendar">
+    <service name="removeCalendar" engine="groovy" 
default-entity-name="TechDataCalendar"
+            
location="component://manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/routing/RoutingServicesScript.groovy"
 invoke="removeCalendar">
         <description>Remove a calendar</description>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <permission-service service-name="manufacturingPermissionService" 
main-action="DELETE"/>
+        <auto-attributes include="pk" mode="IN"/>
     </service>
     <!-- TechDataCalendarWeek services -->
-    <service name="createCalendarWeek" engine="simple" 
default-entity-name="TechDataCalendarWeek"
-            
location="component://manufacturing/minilang/techdata/RoutingSimpleServices.xml"
 invoke="createCalendarWeek">
+    <service name="createCalendarWeek" engine="entity-auto" 
default-entity-name="TechDataCalendarWeek" invoke="create">
         <description>Create a Calendar Week</description>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <permission-service service-name="manufacturingPermissionService" 
main-action="CREATE"/>
+        <auto-attributes include="pk" mode="IN"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="updateCalendarWeek" engine="entity-auto" 
default-entity-name="TechDataCalendarWeek" invoke="update">
         <description>Update a Calendar Week</description>
         <permission-service service-name="manufacturingPermissionService" 
main-action="UPDATE"/>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
-    <service name="removeCalendarWeek" engine="simple" 
default-entity-name="TechDataCalendarWeek"
-            
location="component://manufacturing/minilang/techdata/RoutingSimpleServices.xml"
 invoke="removeCalendarWeek">
+    <service name="removeCalendarWeek" engine="groovy" 
default-entity-name="TechDataCalendarWeek"
+            
location="component://manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/routing/RoutingServicesScript.groovy"
 invoke="removeCalendarWeek">
         <description>Remove a Calendar Week</description>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <permission-service service-name="manufacturingPermissionService" 
main-action="DELETE"/>
+        <auto-attributes include="pk" mode="IN"/>
     </service>
     <!-- manufacturing permission service -->
-    <service name="manufacturingPermissionService" engine="simple"
-             
location="component://common/minilang/permission/CommonPermissionServices.xml" 
invoke="genericBasePermissionCheck">
+    <service name="manufacturingPermissionService" engine="groovy"
+             
location="component://common/src/main/groovy/org/apache/ofbiz/common/permission/CommonPermissionServices.groovy"
 invoke="genericBasePermissionCheck">
         <implements service="permissionInterface"/>
         <attribute name="primaryPermission" type="String" mode="IN" 
optional="true" default-value="MANUFACTURING"/>
         <attribute name="altPermission" type="String" mode="IN" 
optional="true"/>
@@ -70,36 +72,36 @@ under the License.
     <service name="createCalendarExceptionDay" engine="entity-auto" 
default-entity-name="TechDataCalendarExcDay" invoke="create">
         <description>Create a calendar ExceptionDay</description>
         <permission-service service-name="manufacturingPermissionService" 
main-action="CREATE"/>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="updateCalendarExceptionDay" engine="entity-auto" 
default-entity-name="TechDataCalendarExcDay" invoke="update">
         <description>Update a calendar ExceptionDay</description>
         <permission-service service-name="manufacturingPermissionService" 
main-action="UPDATE"/>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="removeCalendarExceptionDay" engine="entity-auto" 
default-entity-name="TechDataCalendarExcDay" invoke="delete">
         <description>Delete a calendar ExceptionDay</description>
         <permission-service service-name="manufacturingPermissionService" 
main-action="DELETE"/>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN"/>
     </service>
     <!-- TechDataCalendarExcWeek services -->
     <service name="createCalendarExceptionWeek" engine="entity-auto" 
default-entity-name="TechDataCalendarExcWeek" invoke="create">
         <description>Create a Calendar Exception Week</description>
         <permission-service service-name="manufacturingPermissionService" 
main-action="CREATE"/>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="updateCalendarExceptionWeek" engine="entity-auto" 
default-entity-name="TechDataCalendarExcWeek" invoke="update">
         <description>Update a Calendar Exception Week</description>
         <permission-service service-name="manufacturingPermissionService" 
main-action="UPDATE"/>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="removeCalendarExceptionWeek" engine="entity-auto" 
default-entity-name="TechDataCalendarExcWeek" invoke="delete">
         <description>Delete a Calendar Exception Week</description>
         <permission-service service-name="manufacturingPermissionService" 
main-action="DELETE"/>
-        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="pk" mode="IN"/>
     </service>
 </services>
diff --git 
a/applications/manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/routing/RoutingServicesScript.groovy
 
b/applications/manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/routing/RoutingServicesScript.groovy
index d7b853aaca..78fa557457 100644
--- 
a/applications/manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/routing/RoutingServicesScript.groovy
+++ 
b/applications/manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/routing/RoutingServicesScript.groovy
@@ -125,3 +125,37 @@ Map getRoutingTaskAssocs() {
             .queryList()
     return result
 }
+
+/**
+ * Remove Calendar
+ */
+Map removeCalendar() {
+    GenericValue techDataCalendar = 
from('TechDataCalendar').where(parameters).queryOne()
+    if (techDataCalendar) {
+        if (techDataCalendar.getRelated('TechDataCalendarExcDay', null, null, 
false)) {
+            return error(label('ManufacturingUiLabels', 
'ManufacturingCalendarExceptionDayUseCalendar'))
+        }
+        if (techDataCalendar.getRelated('TechDataCalendarExcWeek', null, null, 
false)) {
+            return error(label('ManufacturingUiLabels', 
'ManufacturingCalendarExceptionWeekUseCalendar'))
+        }
+        techDataCalendar.remove()
+    }
+    return success()
+}
+
+/**
+ * Remove CalendarWeek
+ */
+Map removeCalendarWeek() {
+    GenericValue techDataCalendarWeek = 
from('TechDataCalendarWeek').where(parameters).queryOne()
+    if (techDataCalendarWeek) {
+        if (techDataCalendarWeek.getRelated('TechDataCalendar', null, null, 
false)) {
+            return error(label('ManufacturingUiLabels', 
'ManufacturingCalendarUseCalendarWeek'))
+        }
+        if (techDataCalendarWeek.getRelated('TechDataCalendarExcWeek', null, 
null, false)) {
+            return error(label('ManufacturingUiLabels', 
'ManufacturingCalendarWeekExceptionUseCalendarWeek'))
+        }
+        techDataCalendarWeek.remove()
+    }
+    return  success()
+}

Reply via email to