[ofbiz-framework] branch trunk updated: Improved: Converted all RequirementRole related CRUD services from simple to entity-auto (#105)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Improved: Converted all RequirementRole related CRUD services from simple to entity-auto (#105)

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

surajk 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 ffd6686  Improved: Converted all RequirementRole related CRUD services from simple to entity-auto (#105)
ffd6686 is described below

commit ffd66862205bd7f8b16a0e6292ba1e1ce98020f4
Author: Suraj Khurana <[hidden email]>
AuthorDate: Fri May 8 09:31:53 2020 +0530

    Improved: Converted all RequirementRole related CRUD services from simple to entity-auto (#105)
   
    (OFBIZ-11641)
    It was using same permission for all CRUD operation, updated logical permissions corresponding to each action.
---
 .../minilang/requirement/RequirementServices.xml   | 58 ----------------------
 applications/order/servicedef/secas.xml            |  5 +-
 .../order/servicedef/services_requirement.xml      | 22 +++++---
 3 files changed, 18 insertions(+), 67 deletions(-)

diff --git a/applications/order/minilang/requirement/RequirementServices.xml b/applications/order/minilang/requirement/RequirementServices.xml
index 861c9ae..ec650b5 100644
--- a/applications/order/minilang/requirement/RequirementServices.xml
+++ b/applications/order/minilang/requirement/RequirementServices.xml
@@ -55,63 +55,6 @@ under the License.
             </if-not-empty>
         </if-compare>
     </simple-method>
-
-    <!-- create a new RequirementRole -->
-    <simple-method method-name="createRequirementRole" short-description="Create a RequirementRole">
-        <check-permission permission="ORDERMGR" action="_CREATE">
-            <fail-property resource="OrderErrorUiLabels" property="OrderErrorCreatePermissionError"/>
-        </check-permission>
-        <check-errors/>
-        <set from-field="parameters.partyId" field="lookupPKMap.partyId"/>
-        <set from-field="parameters.roleTypeId" field="lookupPKMap.roleTypeId"/>
-        <find-by-primary-key entity-name="PartyRole" map="lookupPKMap" value-field="partyRole"/>
-        <if-empty field="partyRole.partyId">
-            <check-permission permission="PARTYMGR" action="_CREATE">
-                <fail-property resource="OrderErrorUiLabels" property="OrderErrorCreatePermissionError"/>
-            </check-permission>
-            <check-permission permission="PARTYMGR" action="_UPDATE">
-                <fail-property resource="OrderErrorUiLabels" property="OrderErrorCreatePermissionError"/>
-            </check-permission>
-            <check-errors/>
-            <make-value entity-name="PartyRole" value-field="partyRole"/>
-            <set-pk-fields map="lookupPKMap" value-field="partyRole"/>
-            <create-value value-field="partyRole"/>
-        </if-empty>
-        <!-- create new entity and create all the fields -->
-        <make-value entity-name="RequirementRole" value-field="newEntity"/>
-        <set-pk-fields map="parameters" value-field="newEntity"/>
-        <set-nonpk-fields map="parameters" value-field="newEntity"/>
-        <if-empty field="newEntity.fromDate">
-            <now-timestamp field="newEntity.fromDate"/>
-        </if-empty>
-        <create-value value-field="newEntity"/>
-        <check-errors/>
-    </simple-method>
-
-    <!-- update an existing RequirementRole -->
-    <simple-method method-name="updateRequirementRole" short-description="Update an existing RequirementRole">
-        <check-permission permission="ORDERMGR" action="_CREATE">
-            <fail-property resource="OrderErrorUiLabels" property="OrderErrorCreatePermissionError"/></check-permission>
-        <check-errors/>
-        <entity-one entity-name="RequirementRole" value-field="requirementRole" auto-field-map="true"/>
-        <check-errors/>
-        <set-nonpk-fields map="parameters" value-field="requirementRole"/>
-        <store-value value-field="requirementRole"/>
-        <check-errors/>
-    </simple-method>
-
-    <!-- remove an existing RequirementRole -->
-    <simple-method method-name="removeRequirementRole" short-description="Remove an existing RequirementRole">
-        <check-permission permission="ORDERMGR" action="_CREATE">
-            <fail-property resource="OrderErrorUiLabels" property="OrderErrorCreatePermissionError"/>
-        </check-permission>
-        <check-errors/>
-        <entity-one entity-name="RequirementRole" value-field="requirementRole" auto-field-map="true"/>
-        <check-errors/>
-        <remove-value value-field="requirementRole"/>
-        <check-errors/>
-    </simple-method>
-
     <simple-method method-name="createTransferFromRequirement" short-description="Create the inventory transfers required to fulfill the requirement.">
         <check-permission permission="ORDERMGR" action="_CREATE">
             <fail-property resource="OrderErrorUiLabels" property="OrderErrorCreatePermissionError"/>
@@ -142,5 +85,4 @@ under the License.
         <set field="inputMap.statusId" value="REQ_ORDERED"/>
         <call-service service-name="updateRequirement" in-map-name="inputMap"/>
     </simple-method>
-
 </simple-methods>
diff --git a/applications/order/servicedef/secas.xml b/applications/order/servicedef/secas.xml
index 50c4e9d..978c210 100644
--- a/applications/order/servicedef/secas.xml
+++ b/applications/order/servicedef/secas.xml
@@ -497,7 +497,10 @@ under the License.
         <condition field-name="statusId" operator="equals" value="ALLOC_PLAN_CANCELLED"/>
         <action service="cancelAllocationPlanItems" mode="sync"/>
     </eca>
-
+    <!-- RequirementRole eca -->
+    <eca service="createRequirementRole" event="invoke">
+        <action service="ensurePartyRole" mode="sync"/>
+    </eca>
     <!-- CustRequestParty eca -->
     <eca service="createCustRequestParty" event="invoke">
         <action service="checkStatusCustRequest" mode="sync"/>
diff --git a/applications/order/servicedef/services_requirement.xml b/applications/order/servicedef/services_requirement.xml
index 07cb297..a35edb6 100644
--- a/applications/order/servicedef/services_requirement.xml
+++ b/applications/order/servicedef/services_requirement.xml
@@ -47,26 +47,32 @@ under the License.
         <description>Delete a requirement after deleting related entity records.</description>
         <attribute name="requirementId" type="String" mode="IN" optional="false"/>
     </service>
-
-    <service name="createRequirementRole" default-entity-name="RequirementRole" engine="simple" auth="true"
-            location="component://order/minilang/requirement/RequirementServices.xml" invoke="createRequirementRole">
+    <!-- RequirementRole services -->
+    <service name="createRequirementRole" default-entity-name="RequirementRole" engine="entity-auto" invoke="create" auth="true">
         <description>Creates a new party role for the requirement</description>
+        <required-permissions join-type="AND">
+            <check-permission permission="ORDERMGR" action="_CREATE"/>
+        </required-permissions>
         <auto-attributes mode="IN" include="pk" optional="false"/>
         <auto-attributes mode="IN" include="nonpk" optional="true"/>
         <override name="fromDate" optional="true"/>
     </service>
-    <service name="updateRequirementRole" default-entity-name="RequirementRole" engine="simple"
-                location="component://order/minilang/requirement/RequirementServices.xml" invoke="updateRequirementRole" auth="true">
+    <service name="updateRequirementRole" default-entity-name="RequirementRole" engine="entity-auto" invoke="update" auth="true">
         <description>Update a RequirementRole</description>
+        <required-permissions join-type="AND">
+            <check-permission permission="ORDERMGR" action="_UPDATE"/>
+        </required-permissions>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
-    <service name="removeRequirementRole" engine="simple" default-entity-name="RequirementRole"
-                location="component://order/minilang/requirement/RequirementServices.xml" invoke="removeRequirementRole" auth="true">
+    <service name="removeRequirementRole" default-entity-name="RequirementRole" engine="entity-auto" invoke="delete" auth="true">
         <description>Remove a RequirementRole</description>
+        <required-permissions join-type="AND">
+            <check-permission permission="ORDERMGR" action="_DELETE"/>
+        </required-permissions>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
-
+    <!-- RequirementStatus services -->
     <service name="createRequirementStatus" engine="entity-auto" default-entity-name="RequirementStatus" auth="true" invoke="create">
         <description>Create Requirement Status </description>
         <auto-attributes mode="IN" include="pk" optional="false"/>