Re: svn commit: r443465 - /incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java

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

Re: svn commit: r443465 - /incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java

Jacques Le Roux
Administrator
Sorry, of course the real methods names are respectively getPartiesFromExactEmail ans getPartiesFromEmail

Jacques

----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Sent: Thursday, September 14, 2006 10:50 PM
Subject: svn commit: r443465 - /incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java


> Author: jleroux
> Date: Thu Sep 14 13:50:55 2006
> New Revision: 443465
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=443465
> Log:
> Used EQUALS in place of LIKE in getPartiesByEmail.
> Added a new method matchPartiesByEmail wich as the same behaviour has had getPartiesByEmail before.
>
> After some thoughts I wondered if nobody was not already using getPartiesByEmail with its ancient behaviour.
> In that perspective I respectively changed the name of :
>
> getPartiesByEmail (using EQUALS) to getPartiesByExactEmail
> And reversed matchPartiesByEmail to getPartiesByEmail (ancient behaviour)
>
> What do you think ?
>
> Modified:
>     incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java
>
> Modified: incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java
> URL:
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java?view=diff&rev=443465&r1=443464&r2=443465

> ==============================================================================
> --- incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java (original)
> +++ incubator/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java Thu Sep 14 13:50:55 2006
> @@ -647,6 +647,47 @@
>       * @param context Map containing the input parameters.
>       * @return Map with the result of the service, the output parameters.
>       */
> +    public static Map getPartyFromExactEmail(DispatchContext dctx, Map context) {
> +        Map result = new HashMap();
> +        GenericDelegator delegator = dctx.getDelegator();
> +        Collection parties = new LinkedList();
> +        String email = (String) context.get("email");
> +        Locale locale = (Locale) context.get("locale");
> +        String errMsg = null;
> +
> +        if (email.length() == 0){
> +            errMsg = UtilProperties.getMessage(resource,"partyservices.required_parameter_email_cannot_be_empty", locale);
> +            return ServiceUtil.returnError(errMsg);
> +        }
> +
> +        try {
> +            List exprs = new LinkedList();
> +
> +            exprs.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("infoString")), EntityOperator.EQUALS, new
EntityFunction.UPPER(email.toUpperCase())));
> +            List c = EntityUtil.filterByDate(delegator.findByAnd("PartyAndContactMech", exprs, UtilMisc.toList("infoString")),
true);
> +
> +            if (Debug.verboseOn()) Debug.logVerbose("List: " + c, module);
> +            if (Debug.infoOn()) Debug.logInfo("PartyFromEmail number found: " + c.size(), module);
> +            if (c != null) {
> +                Iterator i = c.iterator();
> +
> +                while (i.hasNext()) {
> +                    GenericValue pacm = (GenericValue) i.next();
> +                    GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", pacm.get("partyId"),
"partyTypeId", pacm.get("partyTypeId")));

> +
> +                    parties.add(UtilMisc.toMap("party", party));
> +                }
> +            }
> +        } catch (GenericEntityException e) {
> +            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
> +            errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);
> +            return ServiceUtil.returnError(errMsg);
> +        }
> +        if (parties.size() > 0)
> +            result.put("parties", parties);
> +        return result;
> +    }
> +
>      public static Map getPartyFromEmail(DispatchContext dctx, Map context) {
>          Map result = new HashMap();
>          GenericDelegator delegator = dctx.getDelegator();
> @@ -663,7 +704,7 @@
>          try {
>              List exprs = new LinkedList();
>
> -            exprs.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("infoString")), EntityOperator.LIKE, new
EntityFunction.UPPER(email.toUpperCase())));
> +            exprs.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("infoString")), EntityOperator.LIKE, new
EntityFunction.UPPER(("%" + email.toUpperCase()) + "%")));
>              List c = EntityUtil.filterByDate(delegator.findByAnd("PartyAndContactMech", exprs, UtilMisc.toList("infoString")),
true);
>
>              if (Debug.verboseOn()) Debug.logVerbose("List: " + c, module);
>