Skip to content

Commit 23d8045

Browse files
committed
Improved: Convert RoutingSimpleServices.xml mini-lang to groovy (OFBIZ-13238)
* move createCalendar and createCalendarWeek to entity-auto * move removeCalendar and removeCalendarWeek to groovy script
1 parent 7f8e7ca commit 23d8045

3 files changed

Lines changed: 58 additions & 147 deletions

File tree

applications/manufacturing/minilang/techdata/RoutingSimpleServices.xml

Lines changed: 0 additions & 125 deletions
This file was deleted.

applications/manufacturing/servicedef/services_calendar.xml

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,46 @@ under the License.
2424
<version>1.0</version>
2525

2626
<!-- Routing services -->
27-
<service name="createCalendar" engine="simple" default-entity-name="TechDataCalendar"
28-
location="component://manufacturing/minilang/techdata/RoutingSimpleServices.xml" invoke="createCalendar">
27+
<service name="createCalendar" engine="entity-auto" default-entity-name="TechDataCalendar" invoke="create">
28+
<permission-service service-name="manufacturingPermissionService" main-action="CREATE"/>
2929
<description>Create a calendar</description>
30-
<auto-attributes include="pk" mode="IN" optional="false"/>
30+
<auto-attributes include="pk" mode="IN"/>
3131
<auto-attributes include="nonpk" mode="IN" optional="true"/>
3232
</service>
3333
<service name="updateCalendar" engine="entity-auto" default-entity-name="TechDataCalendar" invoke="update">
3434
<description>Update a calendar</description>
3535
<permission-service service-name="manufacturingPermissionService" main-action="UPDATE"/>
36-
<auto-attributes include="pk" mode="IN" optional="false"/>
36+
<auto-attributes include="pk" mode="IN"/>
3737
<auto-attributes include="nonpk" mode="IN" optional="true"/>
3838
</service>
39-
<service name="removeCalendar" engine="simple" default-entity-name="TechDataCalendar"
40-
location="component://manufacturing/minilang/techdata/RoutingSimpleServices.xml" invoke="removeCalendar">
39+
<service name="removeCalendar" engine="groovy" default-entity-name="TechDataCalendar"
40+
location="component://manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/routing/RoutingServicesScript.groovy" invoke="removeCalendar">
4141
<description>Remove a calendar</description>
42-
<auto-attributes include="pk" mode="IN" optional="false"/>
42+
<permission-service service-name="manufacturingPermissionService" main-action="DELETE"/>
43+
<auto-attributes include="pk" mode="IN"/>
4344
</service>
4445
<!-- TechDataCalendarWeek services -->
45-
<service name="createCalendarWeek" engine="simple" default-entity-name="TechDataCalendarWeek"
46-
location="component://manufacturing/minilang/techdata/RoutingSimpleServices.xml" invoke="createCalendarWeek">
46+
<service name="createCalendarWeek" engine="entity-auto" default-entity-name="TechDataCalendarWeek" invoke="create">
4747
<description>Create a Calendar Week</description>
48-
<auto-attributes include="pk" mode="IN" optional="false"/>
48+
<permission-service service-name="manufacturingPermissionService" main-action="CREATE"/>
49+
<auto-attributes include="pk" mode="IN"/>
4950
<auto-attributes include="nonpk" mode="IN" optional="true"/>
5051
</service>
5152
<service name="updateCalendarWeek" engine="entity-auto" default-entity-name="TechDataCalendarWeek" invoke="update">
5253
<description>Update a Calendar Week</description>
5354
<permission-service service-name="manufacturingPermissionService" main-action="UPDATE"/>
54-
<auto-attributes include="pk" mode="IN" optional="false"/>
55+
<auto-attributes include="pk" mode="IN"/>
5556
<auto-attributes include="nonpk" mode="IN" optional="true"/>
5657
</service>
57-
<service name="removeCalendarWeek" engine="simple" default-entity-name="TechDataCalendarWeek"
58-
location="component://manufacturing/minilang/techdata/RoutingSimpleServices.xml" invoke="removeCalendarWeek">
58+
<service name="removeCalendarWeek" engine="groovy" default-entity-name="TechDataCalendarWeek"
59+
location="component://manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/routing/RoutingServicesScript.groovy" invoke="removeCalendarWeek">
5960
<description>Remove a Calendar Week</description>
60-
<auto-attributes include="pk" mode="IN" optional="false"/>
61+
<permission-service service-name="manufacturingPermissionService" main-action="DELETE"/>
62+
<auto-attributes include="pk" mode="IN"/>
6163
</service>
6264
<!-- manufacturing permission service -->
63-
<service name="manufacturingPermissionService" engine="simple"
64-
location="component://common/minilang/permission/CommonPermissionServices.xml" invoke="genericBasePermissionCheck">
65+
<service name="manufacturingPermissionService" engine="groovy"
66+
location="component://common/src/main/groovy/org/apache/ofbiz/common/permission/CommonPermissionServices.groovy" invoke="genericBasePermissionCheck">
6567
<implements service="permissionInterface"/>
6668
<attribute name="primaryPermission" type="String" mode="IN" optional="true" default-value="MANUFACTURING"/>
6769
<attribute name="altPermission" type="String" mode="IN" optional="true"/>
@@ -70,36 +72,36 @@ under the License.
7072
<service name="createCalendarExceptionDay" engine="entity-auto" default-entity-name="TechDataCalendarExcDay" invoke="create">
7173
<description>Create a calendar ExceptionDay</description>
7274
<permission-service service-name="manufacturingPermissionService" main-action="CREATE"/>
73-
<auto-attributes include="pk" mode="IN" optional="false"/>
75+
<auto-attributes include="pk" mode="IN"/>
7476
<auto-attributes include="nonpk" mode="IN" optional="true"/>
7577
</service>
7678
<service name="updateCalendarExceptionDay" engine="entity-auto" default-entity-name="TechDataCalendarExcDay" invoke="update">
7779
<description>Update a calendar ExceptionDay</description>
7880
<permission-service service-name="manufacturingPermissionService" main-action="UPDATE"/>
79-
<auto-attributes include="pk" mode="IN" optional="false"/>
81+
<auto-attributes include="pk" mode="IN"/>
8082
<auto-attributes include="nonpk" mode="IN" optional="true"/>
8183
</service>
8284
<service name="removeCalendarExceptionDay" engine="entity-auto" default-entity-name="TechDataCalendarExcDay" invoke="delete">
8385
<description>Delete a calendar ExceptionDay</description>
8486
<permission-service service-name="manufacturingPermissionService" main-action="DELETE"/>
85-
<auto-attributes include="pk" mode="IN" optional="false"/>
87+
<auto-attributes include="pk" mode="IN"/>
8688
</service>
8789
<!-- TechDataCalendarExcWeek services -->
8890
<service name="createCalendarExceptionWeek" engine="entity-auto" default-entity-name="TechDataCalendarExcWeek" invoke="create">
8991
<description>Create a Calendar Exception Week</description>
9092
<permission-service service-name="manufacturingPermissionService" main-action="CREATE"/>
91-
<auto-attributes include="pk" mode="IN" optional="false"/>
93+
<auto-attributes include="pk" mode="IN"/>
9294
<auto-attributes include="nonpk" mode="IN" optional="true"/>
9395
</service>
9496
<service name="updateCalendarExceptionWeek" engine="entity-auto" default-entity-name="TechDataCalendarExcWeek" invoke="update">
9597
<description>Update a Calendar Exception Week</description>
9698
<permission-service service-name="manufacturingPermissionService" main-action="UPDATE"/>
97-
<auto-attributes include="pk" mode="IN" optional="false"/>
99+
<auto-attributes include="pk" mode="IN"/>
98100
<auto-attributes include="nonpk" mode="IN" optional="true"/>
99101
</service>
100102
<service name="removeCalendarExceptionWeek" engine="entity-auto" default-entity-name="TechDataCalendarExcWeek" invoke="delete">
101103
<description>Delete a Calendar Exception Week</description>
102104
<permission-service service-name="manufacturingPermissionService" main-action="DELETE"/>
103-
<auto-attributes include="pk" mode="IN" optional="false"/>
105+
<auto-attributes include="pk" mode="IN"/>
104106
</service>
105107
</services>

applications/manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/routing/RoutingServicesScript.groovy

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,37 @@ Map getRoutingTaskAssocs() {
125125
.queryList()
126126
return result
127127
}
128+
129+
/**
130+
* Remove Calendar
131+
*/
132+
Map removeCalendar() {
133+
GenericValue techDataCalendar = from('TechDataCalendar').where(parameters).queryOne()
134+
if (techDataCalendar) {
135+
if (techDataCalendar.getRelated('TechDataCalendarExcDay', null, null, false)) {
136+
return error(label('ManufacturingUiLabels', 'ManufacturingCalendarExceptionDayUseCalendar'))
137+
}
138+
if (techDataCalendar.getRelated('TechDataCalendarExcWeek', null, null, false)) {
139+
return error(label('ManufacturingUiLabels', 'ManufacturingCalendarExceptionWeekUseCalendar'))
140+
}
141+
techDataCalendar.remove()
142+
}
143+
return success()
144+
}
145+
146+
/**
147+
* Remove CalendarWeek
148+
*/
149+
Map removeCalendarWeek() {
150+
GenericValue techDataCalendarWeek = from('TechDataCalendarWeek').where(parameters).queryOne()
151+
if (techDataCalendarWeek) {
152+
if (techDataCalendarWeek.getRelated('TechDataCalendar', null, null, false)) {
153+
return error(label('ManufacturingUiLabels', 'ManufacturingCalendarUseCalendarWeek'))
154+
}
155+
if (techDataCalendarWeek.getRelated('TechDataCalendarExcWeek', null, null, false)) {
156+
return error(label('ManufacturingUiLabels', 'ManufacturingCalendarWeekExceptionUseCalendarWeek'))
157+
}
158+
techDataCalendarWeek.remove()
159+
}
160+
return success()
161+
}

0 commit comments

Comments
 (0)