This is an automated email from the ASF dual-hosted git repository.
mbrohl pushed a commit to branch release18.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/release18.12 by this push: new 90faad2 Revert "Improved: Remove unused services from party/services_view.xml and PartyServices.java/.xml. (OFBIZ-9988)" 90faad2 is described below commit 90faad2046ea5ca403b95fb8364fa6f7555151f8 Author: Michael Brohl <[hidden email]> AuthorDate: Sun Feb 9 15:46:50 2020 +0100 Revert "Improved: Remove unused services from party/services_view.xml and PartyServices.java/.xml. (OFBIZ-9988)" This reverts commit 00a5d3413a238e0d2b18f2e076cd90670a2e5f71. --- .../party/minilang/party/PartyServices.xml | 21 ++ applications/party/servicedef/services_view.xml | 70 ++++++ .../apache/ofbiz/party/party/PartyServices.java | 270 +++++++++++++++++++++ 3 files changed, 361 insertions(+) diff --git a/applications/party/minilang/party/PartyServices.xml b/applications/party/minilang/party/PartyServices.xml index 57b2621..fcdebf7 100644 --- a/applications/party/minilang/party/PartyServices.xml +++ b/applications/party/minilang/party/PartyServices.xml @@ -375,6 +375,27 @@ under the License. <field-to-result field="parameters.contentId" result-name="contentId"/> </simple-method> + <!-- get parties based on PartyRelationship --> + <simple-method method-name="getPartiesByRelationship" + short-description="Gets all parties related to partyIdFrom using the PartyRelationship entity" login-required="false"> + <set from-field="parameters.partyIdFrom" field="lookupMap.partyIdFrom"/> + <set from-field="parameters.partyIdTo" field="lookupMap.partyIdTo"/> + <set from-field="parameters.roleTypeIdFrom" field="lookupMap.roleTypeIdFrom"/> + <set from-field="parameters.roleTypeIdTo" field="lookupMap.roleTypeIdTo"/> + <set from-field="parameters.statusId" field="lookupMap.statusId"/> + <set from-field="parameters.priorityTypeId" field="lookupMap.priorityTypeId"/> + <set from-field="parameters.partyRelationshipTypeId" field="lookupMap.partyRelationshipTypeId"/> + + <find-by-and entity-name="PartyRelationship" map="lookupMap" list="partyRelationships"/> + <iterate list="partyRelationships" entry="partyRelationship"> + <get-related-one value-field="partyRelationship" relation-name="ToParty" to-value-field="party"/> + <field-to-list field="party" list="parties"/> + </iterate> + <if-not-empty field="parties"> + <field-to-result field="parties"/> + </if-not-empty> + </simple-method> + <simple-method method-name="getParentOrganizations" short-description="Gets Parent Organizations for an Organization Party"> <set from-field="parameters.organizationPartyId" field="relatedPartyIdList[]"/> <set from-field="parameters.getParentsOfParents" field="recurse"/> diff --git a/applications/party/servicedef/services_view.xml b/applications/party/servicedef/services_view.xml index e36dbf1..d0d2793 100644 --- a/applications/party/servicedef/services_view.xml +++ b/applications/party/servicedef/services_view.xml @@ -126,6 +126,76 @@ under the License. <attribute name="lookupPerson" type="org.apache.ofbiz.entity.GenericValue" mode="OUT"/> </service> + <service name="getPartiesFromExactEmail" engine="java" + location="org.apache.ofbiz.party.party.PartyServices" invoke="getPartiesFromExactEmail"> + <description>Gets a collection of parties from an exact email address, uses SQL EQUALS</description> + <attribute name="email" type="String" mode="IN"/> + <attribute name="parties" type="java.util.Collection" mode="OUT" optional="true"/> + </service> + + <service name="getPartiesFromPartOfEmail" engine="java" + location="org.apache.ofbiz.party.party.PartyServices" invoke="getPartiesFromPartOfEmail"> + <description>Gets a collection of parties from a part of an email address, uses SQL LIKE</description> + <attribute name="email" type="String" mode="IN"/> + <attribute name="parties" type="java.util.Collection" mode="OUT" optional="true"/> + </service> + + <service name="getPartiesFromPartOfUserloginId" engine="java" + location="org.apache.ofbiz.party.party.PartyServices" invoke="getPartiesFromPartOfUserloginId"> + <description>Gets a collection of parties from a part of an UserloginId, uses SQL LIKE</description> + <attribute name="userLoginId" type="String" mode="IN"/> + <attribute name="parties" type="java.util.Collection" mode="OUT" optional="true"/> + </service> + + <service name="getPartiesFromName" engine="java" + location="org.apache.ofbiz.party.party.PartyServices" invoke="getPartiesFromPerson"> + <description>Gets a collection of parties from a first/last name, uses SQL LIKE</description> + <attribute name="firstName" type="String" mode="IN" optional="true"/> + <attribute name="lastName" type="String" mode="IN" optional="true"/> + <attribute name="parties" type="java.util.Collection" mode="OUT" optional="true"/> + </service> + + <service name="getPartiesFromGroupName" engine="java" + location="org.apache.ofbiz.party.party.PartyServices" invoke="getPartiesFromPartyGroup"> + <description>Gets a collection of parties from a group name, uses SQL LIKE</description> + <attribute name="groupName" type="String" mode="IN" optional="false"/> + <attribute name="parties" type="java.util.Collection" mode="OUT" optional="true"/> + </service> + + <service name="getPartiesFromExternalId" engine="java" + location="org.apache.ofbiz.party.party.PartyServices" invoke="getPartiesFromExternalId"> + <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/minilang/party/PartyServices.xml" invoke="getPartiesByRelationship"> + <description>Gets all parties related to partyIdFrom through the PartyRelationship entity</description> + <auto-attributes mode="IN" include="all" optional="true" entity-name="PartyRelationship"/> + <attribute name="parties" type="java.util.Collection" mode="OUT" optional="true"/> + <override name="partyIdFrom" optional="false"/> + </service> + <service name="getRelatedParties" engine="simple" + location="component://party/minilang/party/PartyServices.xml" invoke="getRelatedParties"> + <description> + Get Parties Related to a Party + - The relatedPartyIdList coming out will include the original partyIdFrom + - The includeFromToSwitched and recurse attributes should by "Y" or "N" and default to N. + - The useCache attribute should be "true" or "false", defaults to "false" + </description> + <attribute name="partyIdFrom" type="String" mode="IN" optional="false"/> + <attribute name="partyRelationshipTypeId" type="String" mode="IN" optional="true"/> + <attribute name="roleTypeIdFrom" type="String" mode="IN" optional="true"/> + <attribute name="roleTypeIdFromInclueAllChildTypes" type="String" mode="IN" optional="true"/> + <attribute name="roleTypeIdTo" type="String" mode="IN" optional="true"/> + <attribute name="roleTypeIdToIncludeAllChildTypes" type="String" mode="IN" optional="true"/> + <attribute name="includeFromToSwitched" type="String" mode="IN" optional="true"/> + <attribute name="recurse" type="String" mode="IN" optional="true"/> + <attribute name="useCache" type="String" mode="IN" optional="true"/> + <attribute name="relatedPartyIdList" type="List" mode="OUT" optional="false"/> + </service> + <service name="getParentOrganizations" engine="simple" location="component://party/minilang/party/PartyServices.xml" invoke="getParentOrganizations"> <description> 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 e2d171f..ea574ca 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 @@ -26,6 +26,7 @@ import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -45,6 +46,8 @@ import org.apache.ofbiz.entity.GenericEntity; import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.condition.EntityCondition; +import org.apache.ofbiz.entity.condition.EntityConditionList; +import org.apache.ofbiz.entity.condition.EntityExpr; import org.apache.ofbiz.entity.condition.EntityFunction; import org.apache.ofbiz.entity.condition.EntityOperator; import org.apache.ofbiz.entity.model.DynamicViewEntity; @@ -702,6 +705,273 @@ public class PartyServices { return result; } + /** + * Get the party object(s) from an e-mail address + * @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> getPartiesFromExactEmail(DispatchContext dctx, Map<String, ? extends Object> context) { + Map<String, Object> result = new HashMap<>(); + Delegator delegator = dctx.getDelegator(); + Collection<Map<String, GenericValue>> parties = new LinkedList<>(); + String email = (String) context.get("email"); + Locale locale = (Locale) context.get("locale"); + + if (email.length() == 0) { + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "partyservices.required_parameter_email_cannot_be_empty", locale)); + } + + try { + List<GenericValue> c = EntityQuery.use(delegator).from("PartyAndContactMech") + .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.EQUALS, EntityFunction.UPPER(email.toUpperCase(Locale.getDefault())))) + .orderBy("infoString") + .filterByDate() + .queryList(); + + if (Debug.verboseOn()) { + Debug.logVerbose("List: " + c, module); + } + if (Debug.infoOn()) { + Debug.logInfo("PartyFromEmail number found: " + c.size(), module); + } + if (c != null) { + for (GenericValue pacm: c) { + GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", pacm.get("partyId"), "partyTypeId", pacm.get("partyTypeId"))); + + parties.add(UtilMisc.<String, GenericValue>toMap("party", party)); + } + } + } catch (GenericEntityException e) { + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "partyservices.cannot_get_party_entities_read", + UtilMisc.toMap("errMessage", e.getMessage()), locale)); + } + if (parties.size() > 0) { + result.put("parties", parties); + } + return result; + } + + public static Map<String, Object> getPartiesFromPartOfEmail(DispatchContext dctx, Map<String, ? extends Object> context) { + Map<String, Object> result = new HashMap<>(); + Delegator delegator = dctx.getDelegator(); + Collection<Map<String, GenericValue>> parties = new LinkedList<>(); + String email = (String) context.get("email"); + Locale locale = (Locale) context.get("locale"); + + if (email.length() == 0) { + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "partyservices.required_parameter_email_cannot_be_empty", locale)); + } + + try { + List<GenericValue> c = EntityQuery.use(delegator).from("PartyAndContactMech") + .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER(("%" + email.toUpperCase(Locale.getDefault())) + "%"))) + .orderBy("infoString") + .filterByDate() + .queryList(); + + if (Debug.verboseOn()) { + Debug.logVerbose("List: " + c, module); + } + if (Debug.infoOn()) { + Debug.logInfo("PartyFromEmail number found: " + c.size(), module); + } + if (c != null) { + for (GenericValue pacm: c) { + GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", pacm.get("partyId"), "partyTypeId", pacm.get("partyTypeId"))); + + parties.add(UtilMisc.<String, GenericValue>toMap("party", party)); + } + } + } catch (GenericEntityException e) { + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "partyservices.cannot_get_party_entities_read", + UtilMisc.toMap("errMessage", e.getMessage()), locale)); + } + if (parties.size() > 0) { + result.put("parties", parties); + } + return result; + } + + /** + * Get the party object(s) from a user login ID + * @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> getPartiesFromPartOfUserloginId(DispatchContext dctx, Map<String, ? extends Object> context) { + Debug.logWarning("Running the getPartiesFromPartOfUserloginId Service...", module); + Map<String, Object> result = new HashMap<>(); + Delegator delegator = dctx.getDelegator(); + Collection<Map<String, GenericValue>> parties = new LinkedList<>(); + String userLoginId = (String) context.get("userLoginId"); + Locale locale = (Locale) context.get("locale"); + + if (userLoginId.length() == 0) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "PartyCannotGetUserLoginFromParty", locale)); + } + + try { + Collection<GenericValue> ulc = EntityQuery.use(delegator).from("PartyAndUserLogin") + .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + userLoginId.toUpperCase(Locale.getDefault()) + "%"))) + .orderBy("userLoginId") + .queryList(); + + if (Debug.verboseOn()) { + Debug.logVerbose("Collection: " + ulc, module); + } + if (Debug.infoOn()) { + Debug.logInfo("PartyFromUserLogin number found: " + ulc.size(), module); + } + if (ulc != null) { + for (GenericValue ul: ulc) { + GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", ul.get("partyId"), "partyTypeId", ul.get("partyTypeId"))); + + parties.add(UtilMisc.<String, GenericValue>toMap("party", party)); + } + } + } catch (GenericEntityException e) { + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "partyservices.cannot_get_party_entities_read", + UtilMisc.toMap("errMessage", e.getMessage()), locale)); + } + if (UtilValidate.isNotEmpty(parties)) { + result.put("parties", parties); + } + return result; + } + + /** + * Get the party object(s) from person information + * @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> getPartiesFromPerson(DispatchContext dctx, Map<String, ? extends Object> context) { + Map<String, Object> result = new HashMap<>(); + Delegator delegator = dctx.getDelegator(); + Collection<Map<String, GenericValue>> parties = new LinkedList<>(); + String firstName = (String) context.get("firstName"); + String lastName = (String) context.get("lastName"); + Locale locale = (Locale) context.get("locale"); + + if (firstName == null) { + firstName = ""; + } + if (lastName == null) { + lastName = ""; + } + if (firstName.length() == 0 && lastName.length() == 0) { + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "partyservices.both_names_cannot_be_empty", locale)); + } + + try { + EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(EntityOperator.AND, + EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE, + EntityFunction.UPPER("%" + firstName.toUpperCase(Locale.getDefault()) + "%")), + EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE, + EntityFunction.UPPER("%" + lastName.toUpperCase(Locale.getDefault()) + "%"))); + Collection<GenericValue> pc = EntityQuery.use(delegator).from("Person").where(ecl).orderBy("lastName", "firstName", "partyId").queryList(); + + if (Debug.infoOn()) { + Debug.logInfo("PartyFromPerson number found: " + pc.size(), module); + } + if (pc != null) { + for (GenericValue person: pc) { + GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", person.get("partyId"), "partyTypeId", "PERSON")); + + parties.add(UtilMisc.<String, GenericValue>toMap("person", person, "party", party)); + } + } + } catch (GenericEntityException e) { + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "partyservices.cannot_get_party_entities_read", + UtilMisc.toMap("errMessage", e.getMessage()), locale)); + } + if (parties.size() > 0) { + result.put("parties", parties); + } + return result; + } + + /** + * Get the party object(s) from party group name. + * @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> getPartiesFromPartyGroup(DispatchContext dctx, Map<String, ? extends Object> context) { + Map<String, Object> result = new HashMap<>(); + Delegator delegator = dctx.getDelegator(); + Collection<Map<String, GenericValue>> parties = new LinkedList<>(); + String groupName = (String) context.get("groupName"); + Locale locale = (Locale) context.get("locale"); + + if (groupName.length() == 0) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "PartyCannotgetPartiesFromPartyGroup", locale)); + } + + try { + Collection<GenericValue> pc = EntityQuery.use(delegator).from("PartyGroup") + .where(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + groupName.toUpperCase(Locale.getDefault()) + "%"))) + .orderBy("groupName", "partyId") + .queryList(); + + if (Debug.infoOn()) { + Debug.logInfo("PartyFromGroup number found: " + pc.size(), module); + } + if (pc != null) { + for (GenericValue group: pc) { + GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", group.get("partyId"), "partyTypeId", "PARTY_GROUP")); + + parties.add(UtilMisc.<String, GenericValue>toMap("partyGroup", group, "party", party)); + } + } + } catch (GenericEntityException e) { + return ServiceUtil.returnError(UtilProperties.getMessage(resourceError, + "partyservices.cannot_get_party_entities_read", + UtilMisc.toMap("errMessage", e.getMessage()), locale)); + } + if (parties.size() > 0) { + result.put("parties", parties); + } + 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> getPartiesFromExternalId(DispatchContext dctx, Map<String, ? extends Object> context) { + Map<String, Object> result = ServiceUtil.returnSuccess(); + Delegator delegator = dctx.getDelegator(); + List<GenericValue> parties; + 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<>(); Delegator delegator = dctx.getDelegator(); |
Free forum by Nabble | Edit this page |