[ofbiz-framework] branch trunk updated: Improved : Convert createRoleType service to entity-auto from Java and update its service calls (OFBIZ-11894) (#215)

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 : Convert createRoleType service to entity-auto from Java and update its service calls (OFBIZ-11894) (#215)

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 679b288  Improved : Convert createRoleType service to entity-auto from Java and update its service calls (OFBIZ-11894) (#215)
679b288 is described below

commit 679b2883e143105f35313807b4fc028b65c1e092
Author: Priya Sharma <[hidden email]>
AuthorDate: Wed Jul 22 11:21:16 2020 +0530

    Improved : Convert createRoleType service to entity-auto from Java and update its service calls (OFBIZ-11894) (#215)
   
    (OFBIZ-11894)
    * Improved: Convert createRoleType service to entity-auto from Java and update its service calls
    - Removed the java implementation
    - Converted the service to entity-auto
    - updated the service call in Party tests where this service was used.
    * Improved: Removed the testCreateRoleType test, as the base service is now converted to entity-auto and will be handled in entity-auto tests. (OFBIZ-11984)
   
    Co-authored-by: Priya Sharma <[hidden email]>
   
    Thanks: Pawan Verma for review.
---
 applications/party/minilang/test/PartyTests.xml    | 18 -----------------
 applications/party/servicedef/services.xml         | 10 ++++------
 .../apache/ofbiz/party/party/PartyServices.java    | 23 ----------------------
 3 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/applications/party/minilang/test/PartyTests.xml b/applications/party/minilang/test/PartyTests.xml
index 58bc404..9563f6a 100644
--- a/applications/party/minilang/test/PartyTests.xml
+++ b/applications/party/minilang/test/PartyTests.xml
@@ -755,24 +755,6 @@ under the License.
         <check-errors/>
     </simple-method>
 
-    <simple-method method-name="testCreateRoleType" short-description="Test the service createRoleType" login-required="false">
-        <set field="serviceCtx.roleTypeId" value="TEST_ROLE"/>
-        <set field="serviceCtx.description" value="Test Role to test service createRoleType"/>
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-        <set field="serviceCtx.userLogin" from-field="userLogin"/>
-        <call-service service-name="createRoleType" in-map-name="serviceCtx">
-            <result-to-field result-name="roleType"/>
-        </call-service>
-        <assert>
-            <not><if-empty field="roleType"/></not>
-            <if-compare field="roleType.roleTypeId" operator="equals" value="TEST_ROLE"/>
-            <if-compare field="roleType.description" operator="equals" value="Test Role to test service createRoleType"/>
-        </assert>
-        <check-errors/>
-    </simple-method>
-
     <simple-method method-name="testCreateTelecomNumber" short-description="Test the service createTelecomNumber" login-required="false">
         <set field="serviceCtx.contactMechId" value="TestTelecomNumber"/>
         <set field="serviceCtx.areaCode" value="801"/>
diff --git a/applications/party/servicedef/services.xml b/applications/party/servicedef/services.xml
index 4d90401..8a1f8ad 100644
--- a/applications/party/servicedef/services.xml
+++ b/applications/party/servicedef/services.xml
@@ -246,13 +246,11 @@ under the License.
         <attribute name="note" type="String" mode="IN" optional="true"/>
     </service>
 
-    <service name="createRoleType" engine="java"
-            location="org.apache.ofbiz.party.party.PartyServices" invoke="createRoleType" auth="true">
+    <service name="createRoleType" default-entity-name="RoleType" engine="entity-auto" invoke="create" auth="true">
         <description>Create a new role type</description>
-        <attribute name="roleTypeId" type="String" mode="IN"/>
-        <attribute name="parentTypeId" type="String" mode="IN" optional="true"/>
-        <attribute name="description" type="String" mode="IN"/>
-        <attribute name="roleType" type="org.apache.ofbiz.entity.GenericValue" mode="OUT"/>
+        <auto-attributes include="pk" mode="INOUT" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <override name="description" optional="false"/>
     </service>
 
     <service name="setPartyProfileDefaults" engine="groovy"
diff --git a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
index aaf2515..fabb6d4 100644
--- a/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
+++ b/applications/party/src/main/java/org/apache/ofbiz/party/party/PartyServices.java
@@ -992,29 +992,6 @@ public class PartyServices {
         return result;
     }
 
-    public static Map<String, Object> createRoleType(DispatchContext dctx, Map<String, ? extends Object> context) {
-        Map<String, Object> result = new HashMap<>();
-        Delegator delegator = dctx.getDelegator();
-        Locale locale = (Locale) context.get("locale");
-        GenericValue roleType = null;
-
-        try {
-            roleType = delegator.makeValue("RoleType");
-            roleType.setPKFields(context);
-            roleType.setNonPKFields(context);
-            roleType = delegator.create(roleType);
-        } catch (GenericEntityException e) {
-            Debug.logError(e, MODULE);
-            return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE,
-                    "PartyCannotCreateRoleTypeEntity",
-                    UtilMisc.toMap("errMessage", e.getMessage()), locale));
-        }
-        if (roleType != null) {
-            result.put("roleType", roleType);
-        }
-        return result;
-    }
-
     @Deprecated // migration from ftl to widget in process.
     public static Map<String, Object> findParty(DispatchContext dctx, Map<String, ? extends Object> context) {
         Map<String, Object> result = ServiceUtil.returnSuccess();