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

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 RequirementCustRequest related CRUD services from simple to entity-auto (#102)

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 112a592  Improved: Converted all RequirementCustRequest related CRUD services from simple to entity-auto (#102)
112a592 is described below

commit 112a5929e91ae85b34ac017dfa5420ee67c0f27a
Author: Suraj Khurana <[hidden email]>
AuthorDate: Thu May 7 11:09:34 2020 +0530

    Improved: Converted all RequirementCustRequest related CRUD services from simple to entity-auto (#102)
   
    (OFBIZ-11638)
    Also, renamed associatedRequirementWithRequestItem to proper name and corrected occurences including tests.
---
 .../order/minilang/requirement/RequirementServices.xml     |  8 --------
 applications/order/servicedef/secas.xml                    |  2 +-
 applications/order/servicedef/services_requirement.xml     | 14 +++++---------
 .../org/apache/ofbiz/order/OrderRequirementTests.groovy    |  5 ++---
 4 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/applications/order/minilang/requirement/RequirementServices.xml b/applications/order/minilang/requirement/RequirementServices.xml
index 0720f80..861c9ae 100644
--- a/applications/order/minilang/requirement/RequirementServices.xml
+++ b/applications/order/minilang/requirement/RequirementServices.xml
@@ -27,14 +27,6 @@ under the License.
         <remove-related value-field="requirement" relation-name="RequirementCustRequest"/>
         <remove-value value-field="requirement"/>
     </simple-method>
-
-    <simple-method method-name="associateRequirementWithRequestItem" short-description="Associate a requirement and CustRequestItem">
-        <make-value entity-name="RequirementCustRequest" value-field="newEntity"/>
-        <set-pk-fields map="parameters" value-field="newEntity"/>
-        <set-nonpk-fields map="parameters" value-field="newEntity"/>
-        <create-value value-field="newEntity"/>
-    </simple-method>
-
     <simple-method method-name="autoAssignRequirementToSupplier" short-description="If the requirement is a product requirement (purchasing) try to assign it to the primary supplier">
         <entity-one entity-name="Requirement" value-field="requirement" auto-field-map="true"/>
         <check-errors/>
diff --git a/applications/order/servicedef/secas.xml b/applications/order/servicedef/secas.xml
index e241170..50c4e9d 100644
--- a/applications/order/servicedef/secas.xml
+++ b/applications/order/servicedef/secas.xml
@@ -347,7 +347,7 @@ under the License.
     <eca service="createRequirement" event="commit">
         <condition field-name="custRequestId" operator="is-not-empty"/>
         <condition field-name="custRequestItemSeqId" operator="is-not-empty"/>
-        <action service="associatedRequirementWithRequestItem" mode="sync"/>
+        <action service="createRequirementCustRequest" mode="sync"/>
     </eca>
     <eca service="createRequirement" event="commit" run-on-error="false">
         <condition field-name="statusId" operator="is-not-empty" />
diff --git a/applications/order/servicedef/services_requirement.xml b/applications/order/servicedef/services_requirement.xml
index 642941a..07cb297 100644
--- a/applications/order/servicedef/services_requirement.xml
+++ b/applications/order/servicedef/services_requirement.xml
@@ -77,14 +77,6 @@ under the License.
         <auto-attributes include="pk" mode="IN"/>
     </service>
 
-    <service name="associatedRequirementWithRequestItem" engine="simple"
-            location="component://order/minilang/requirement/RequirementServices.xml" invoke="associateRequirementWithRequestItem">
-        <description>Creates a CustRequestItem/Requirement association</description>
-        <attribute name="requirementId" type="String" mode="IN" optional="false"/>
-        <attribute name="custRequestId" type="String" mode="IN" optional="false"/>
-        <attribute name="custRequestItemSeqId" type="String" mode="IN" optional="false"/>
-    </service>
-
     <service name="addRequirementTask" engine="entity-auto" invoke="create" default-entity-name="WorkRequirementFulfillment">
         <description>Associate an existing task w/ a requirement</description>
         <deprecated use-instead="createWorkRequirementFulfillment" since="Upcoming Branch">
@@ -279,8 +271,12 @@ under the License.
         <description>Delete a RequirementTypeAttr record</description>
         <auto-attributes mode="IN" include="pk"/>
     </service>
-
     <!-- RequirementCustRequest services -->
+    <service name="createRequirementCustRequest" default-entity-name="RequirementCustRequest" engine="entity-auto" invoke="create" auth="true">
+        <description>Create a RequirementCustRequest record</description>
+        <auto-attributes mode="IN" include="pk"/>
+        <auto-attributes mode="IN" include="nonpk" optional="true"/>
+    </service>
     <service name="deleteRequirementCustRequest" default-entity-name="RequirementCustRequest" engine="entity-auto" invoke="delete" auth="true">
         <description>Delete a RequirementCustRequest record</description>
         <auto-attributes mode="IN" include="pk"/>
diff --git a/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy b/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy
index a050a86..85420a8 100644
--- a/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy
+++ b/applications/order/src/main/groovy/org/apache/ofbiz/order/OrderRequirementTests.groovy
@@ -72,14 +72,14 @@ class OrderRequirementTests extends OFBizTestCase {
         Map serviceResult = dispatcher.runSync('autoAssignRequirementToSupplier', serviceCtx)
         assert ServiceUtil.isSuccess(serviceResult)
     }
-    void testAssociatedRequirementWithRequestItem() {
+    void testCreateRequirementCustRequest() {
         Map serviceCtx = [
             requirementId: '1000',
             custRequestId: '9000',
             custRequestItemSeqId: '00001',
             userLogin: userLogin
         ]
-        Map serviceResult = dispatcher.runSync('associatedRequirementWithRequestItem', serviceCtx)
+        Map serviceResult = dispatcher.runSync('createRequirementCustRequest', serviceCtx)
         assert ServiceUtil.isSuccess(serviceResult)
     }
     void testAddRequirementTask() {
@@ -91,5 +91,4 @@ class OrderRequirementTests extends OFBizTestCase {
         Map serviceResult = dispatcher.runSync("addRequirementTask", serviceCtx)
         assert ServiceUtil.isSuccess(serviceResult)
     }
-
 }