You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by de...@apache.org on 2016/06/08 13:58:51 UTC

svn commit: r1747398 - in /ofbiz/trunk/applications/party: servicedef/services_view.xml src/org/ofbiz/party/party/PartyServices.java widget/partymgr/PartyForms.xml

Author: deepak
Date: Wed Jun  8 13:58:51 2016
New Revision: 1747398

URL: http://svn.apache.org/viewvc?rev=1747398&view=rev
Log:
(OFBIZ-382) Applied slightly modified patch from jira ticket
=======================================
Implement Party lookup by External Id
=======================================
Thanks  John Martin for reporting the issue and Renuka for providing the patch.

Modified:
    ofbiz/trunk/applications/party/servicedef/services_view.xml
    ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java
    ofbiz/trunk/applications/party/widget/partymgr/PartyForms.xml

Modified: ofbiz/trunk/applications/party/servicedef/services_view.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/servicedef/services_view.xml?rev=1747398&r1=1747397&r2=1747398&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/servicedef/services_view.xml (original)
+++ ofbiz/trunk/applications/party/servicedef/services_view.xml Wed Jun  8 13:58:51 2016
@@ -83,6 +83,7 @@ under the License.
         <attribute name="partyId" type="String" mode="IN" optional="true"/> <!-- does a LIKE compare on this, can do partial, case insensitive, etc -->
         <attribute name="partyTypeId" type="String" mode="IN" optional="true"/>
         <attribute name="userLoginId" type="String" mode="IN" optional="true"/> <!-- does a LIKE compare on this, can do partial, case insensitive, etc -->
+        <attribute name="externalId" type="String" mode="IN" optional="true"/>
         <attribute name="groupName" type="String" mode="IN" optional="true"/>
         <attribute name="firstName" type="String" mode="IN" optional="true"/>
         <attribute name="lastName" type="String" mode="IN" optional="true"/>
@@ -153,6 +154,13 @@ under the License.
         <attribute name="parties" type="java.util.Collection" mode="OUT" optional="true"/>
     </service>
 
+	<service name="getPartyFromExternalId" engine="java"
+            location="org.ofbiz.party.party.PartyServices" invoke="getPartyFromExternalId">
+        <description>Gets a list of parties from a party externalId </description>
+        <attribute name="externalId" type="String" mode="IN" optional="false"/>
+        <attribute name="parties" type="java.util.List" mode="OUT" optional="true"/>
+    </service>
+    
     <service name="getPartiesByRelationship" engine="simple"
         location="component://party/script/org/ofbiz/party/party/PartyServices.xml" invoke="getPartiesByRelationship">
         <description>Gets all parties related to partyIdFrom through the PartyRelationship entity</description>

Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java?rev=1747398&r1=1747397&r2=1747398&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java (original)
+++ ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java Wed Jun  8 13:58:51 2016
@@ -928,6 +928,33 @@ public class PartyServices {
         return result;
     }
 
+    /**
+     * Get the party object(s) from party externalId.
+     * @param dctx The DispatchContext that this service is operating in.
+     * @param context Map containing the input parameters.
+     * @return Map with the result of the service, the output parameters.
+     */
+    public static Map<String, Object> getPartyFromExternalId(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = ServiceUtil.returnSuccess();
+        Delegator delegator = dctx.getDelegator();
+        List<GenericValue> parties = new ArrayList<>();
+        String externalId = (String) context.get("externalId");
+        Locale locale = (Locale) context.get("locale");
+
+        try {
+        	parties = EntityQuery.use(delegator).from("Party")
+                    .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("externalId"), EntityOperator.EQUALS, EntityFunction.UPPER(externalId)))
+                    .orderBy("externalId", "partyId")
+                    .queryList();
+        } catch (GenericEntityException e) {
+            return ServiceUtil.returnError(UtilProperties.getMessage(resourceError,
+                    "partyservices.cannot_get_party_entities_read",
+                    UtilMisc.toMap("errMessage", e.getMessage()), locale));
+        }
+        result.put("parties", parties);
+        return result;
+    }
+
     public static Map<String, Object> getPerson(DispatchContext dctx, Map<String, ? extends Object> context) {
         Map<String, Object> result = new HashMap<String, Object>();
         Delegator delegator = dctx.getDelegator();
@@ -1532,6 +1559,7 @@ public class PartyServices {
         dynamicView.addAlias("PT", "partyId");
         dynamicView.addAlias("PT", "statusId");
         dynamicView.addAlias("PT", "partyTypeId");
+        dynamicView.addAlias("PT", "externalId");
         dynamicView.addAlias("PT", "createdDate");
         dynamicView.addAlias("PT", "lastModifiedDate");
         dynamicView.addRelation("one-nofk", "", "PartyType", ModelKeyMap.makeKeyMapList("partyTypeId"));
@@ -1551,6 +1579,7 @@ public class PartyServices {
         fieldsToSelect.add("partyId");
         fieldsToSelect.add("statusId");
         fieldsToSelect.add("partyTypeId");
+        fieldsToSelect.add("externalId");
         fieldsToSelect.add("createdDate");
         fieldsToSelect.add("lastModifiedDate");
 
@@ -1584,6 +1613,7 @@ public class PartyServices {
         String roleTypeId = (String) context.get("roleTypeId");
         String statusId = (String) context.get("statusId");
         String userLoginId = (String) context.get("userLoginId");
+        String externalId = (String) context.get("externalId");
         String firstName = (String) context.get("firstName");
         String lastName = (String) context.get("lastName");
         String groupName = (String) context.get("groupName");
@@ -1605,6 +1635,9 @@ public class PartyServices {
             andExprs.add(EntityCondition.makeCondition("partyTypeId", partyTypeId));
         }
 
+        if (UtilValidate.isNotEmpty(externalId)) {
+            andExprs.add(EntityCondition.makeCondition("externalId", externalId));
+        }
         // ----
         // UserLogin Fields
         // ----

Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyForms.xml?rev=1747398&r1=1747397&r2=1747398&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/widget/partymgr/PartyForms.xml (original)
+++ ofbiz/trunk/applications/party/widget/partymgr/PartyForms.xml Wed Jun  8 13:58:51 2016
@@ -41,6 +41,7 @@ under the License.
         <field name="hideFields"><hidden value="Y"/></field>
         <field name="partyId"><text size="15" /></field>
         <field name="userLoginId"><text size="15" /></field>
+        <field name="externalId"><text size="15" /></field>
         <field name="lastName"><text size="15"/></field>
         <field name="firstName"><text size="15"/></field>
         <field name="groupName" title="${uiLabelMap.PartyGroupName}"><text size="15"/></field>
@@ -92,6 +93,7 @@ under the License.
             <sort-field name="extInfo"/>
             <sort-field name="partyId"/>
             <sort-field name="userLoginId"/>
+            <sort-field name="externalId"/>
             <sort-field name="lastName"/>
             <sort-field name="firstName"/>
             <sort-field name="groupName"/>
@@ -148,6 +150,7 @@ under the License.
         <field name="userLoginId" use-when="userLoginSize > 1"><include-grid name="ListPartyUserLogin" location="component://party/widget/partymgr/PartyForms.xml"/></field>
         <field name="userLoginId" use-when="userLoginSize == 1"><display description="${logins[0].userLoginId}"/></field>
         <field name="userLoginId" use-when="userLoginSize == 0"><display description="(${uiLabelMap.CommonNone})"/></field>
+        <field name="externalId"><display description="${externalId}"/></field>
         <field name="name"><display description="${groovy:org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, true)}"/></field>
         <field name="partyTypeId" title="${uiLabelMap.CommonType}"><display-entity entity-name="PartyType"/></field>
         <field name="mainRole" title="${uiLabelMap.PartyMainRole}"><display description="${mainRole.description}"/></field>