svn commit: r685936 [2/2] - in /ofbiz/trunk/applications/party/src/org/ofbiz/party: communication/ contact/ content/ party/

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

svn commit: r685936 [2/2] - in /ofbiz/trunk/applications/party/src/org/ofbiz/party: communication/ contact/ content/ party/

doogie-3
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=685936&r1=685935&r2=685936&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 Thu Aug 14 08:12:17 2008
@@ -21,14 +21,13 @@
 
 import java.sql.Timestamp;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
 import javolution.util.FastList;
+import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
@@ -70,7 +69,7 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map deleteParty(DispatchContext ctx, Map context) {
+    public static Map<String, Object> deleteParty(DispatchContext ctx, Map<String, ? extends Object> context) {
 
         Locale locale = (Locale) context.get("locale");
 
@@ -99,11 +98,11 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map createPerson(DispatchContext ctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> createPerson(DispatchContext ctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = ctx.getDelegator();
         Timestamp now = UtilDateTime.nowTimestamp();
-        List toBeStored = new LinkedList();
+        List<GenericValue> toBeStored = FastList.newInstance();
         Locale locale = (Locale) context.get("locale");
         // in most cases userLogin will be null, but get anyway so we can keep track of that info if it is available
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -144,7 +143,7 @@
             if (statusId == null) {
                 statusId = "PARTY_ENABLED";
             }
-            Map newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", "PERSON", "description", description, "createdDate", now, "lastModifiedDate", now, "statusId", statusId);
+            Map<String, Object> newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", "PERSON", "description", description, "createdDate", now, "lastModifiedDate", now, "statusId", statusId);
             String preferredCurrencyUomId = (String) context.get("preferredCurrencyUomId");
             if (!UtilValidate.isEmpty(preferredCurrencyUomId)) {
                 newPartyMap.put("preferredCurrencyUomId", preferredCurrencyUomId);
@@ -194,7 +193,7 @@
      * Sets a party status.
      * <b>security check</b>: the status change must be defined in StatusValidChange.
      */
-    public static Map setPartyStatus(DispatchContext ctx, Map context) {
+    public static Map<String, Object> setPartyStatus(DispatchContext ctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = ctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
 
@@ -225,7 +224,7 @@
             GenericValue partyStatus = delegator.makeValue("PartyStatus", UtilMisc.toMap("partyId", partyId, "statusId", statusId, "statusDate", statusDate));
             partyStatus.create();
 
-            Map results = ServiceUtil.returnSuccess();
+            Map<String, Object> results = ServiceUtil.returnSuccess();
             results.put("oldStatusId", oldStatusId);
             return results;
         } catch (GenericEntityException e) {
@@ -240,8 +239,8 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map updatePerson(DispatchContext ctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> updatePerson(DispatchContext ctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = ctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
 
@@ -288,8 +287,8 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map createPartyGroup(DispatchContext ctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> createPartyGroup(DispatchContext ctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = ctx.getDelegator();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Timestamp now = UtilDateTime.nowTimestamp();
@@ -344,7 +343,7 @@
                     }
                 }
 
-                Map newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", partyTypeId, "createdDate", now, "lastModifiedDate", now);
+                Map<String, Object> newPartyMap = UtilMisc.toMap("partyId", partyId, "partyTypeId", partyTypeId, "createdDate", now, "lastModifiedDate", now);
                 if (userLogin != null) {
                     newPartyMap.put("createdByUserLogin", userLogin.get("userLoginId"));
                     newPartyMap.put("lastModifiedByUserLogin", userLogin.get("userLoginId"));
@@ -377,7 +376,7 @@
             partyGroup.create();
         } catch (GenericEntityException e) {
             Debug.logWarning(e, module);
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             errMsg = UtilProperties.getMessage(resource,"partyservices.data_source_error_adding_party_group", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -393,8 +392,8 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map updatePartyGroup(DispatchContext ctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> updatePartyGroup(DispatchContext ctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = ctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
 
@@ -412,7 +411,7 @@
             party = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId));
         } catch (GenericEntityException e) {
             Debug.logWarning(e, module);
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             errMsg = UtilProperties.getMessage(resource,"partyservices.could_not_update_party_information_read", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -430,7 +429,7 @@
             party.store();
         } catch (GenericEntityException e) {
             Debug.logWarning(e.getMessage(), module);
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             errMsg = UtilProperties.getMessage(resource,"partyservices.could_not_update_party_information_write", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -445,8 +444,8 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map createAffiliate(DispatchContext ctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> createAffiliate(DispatchContext ctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = ctx.getDelegator();
         Timestamp now = UtilDateTime.nowTimestamp();
 
@@ -506,7 +505,7 @@
             delegator.create(affiliate);
         } catch (GenericEntityException e) {
             Debug.logWarning(e.getMessage(), module);
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             errMsg = UtilProperties.getMessage(resource,"partyservices.could_not_add_affiliate_info_write", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -522,7 +521,7 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map updateAffiliate(DispatchContext ctx, Map context) {
+    public static Map<String, Object> updateAffiliate(DispatchContext ctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = ctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
 
@@ -538,7 +537,7 @@
             affiliate = delegator.findByPrimaryKey("Affiliate", UtilMisc.toMap("partyId", partyId));
         } catch (GenericEntityException e) {
             Debug.logWarning(e, module);
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             errMsg = UtilProperties.getMessage(resource,"partyservices.could_not_update_affiliate_information_read", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -553,7 +552,7 @@
         try {
             affiliate.store();
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             errMsg = UtilProperties.getMessage(resource,"partyservices.could_not_update_affiliate_information_write", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -566,8 +565,8 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map createPartyNote(DispatchContext dctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> createPartyNote(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -596,7 +595,7 @@
 
         // if no noteId is specified, then create and associate the note with the userLogin
         if (noteId == null) {
-            Map noteRes = null;
+            Map<String, Object> noteRes = null;
             try {
                 noteRes = dispatcher.runSync("createNote", UtilMisc.toMap("partyId", userLogin.getString("partyId"),
                          "note", noteString, "userLogin", userLogin, "locale", locale, "noteName", noteName));
@@ -619,13 +618,13 @@
 
         // Set the party info
         try {
-            Map fields = UtilMisc.toMap("partyId", partyId, "noteId", noteId);
+            Map<String, String> fields = UtilMisc.toMap("partyId", partyId, "noteId", noteId);
             GenericValue v = delegator.makeValue("PartyNote", fields);
 
             delegator.create(v);
         } catch (GenericEntityException ee) {
             Debug.logError(ee, module);
-            Map messageMap = UtilMisc.toMap("errMessage", ee.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", ee.getMessage());
             errMsg = UtilProperties.getMessage(resource,"partyservices.problem_associating_note_with_party", messageMap, locale);
             result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
             result.put(ModelService.ERROR_MESSAGE, errMsg);
@@ -639,10 +638,10 @@
      * @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();
+    public static Map<String, Object> getPartyFromExactEmail(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
-        Collection parties = new LinkedList();
+        Collection<Map<String, GenericValue>> parties = FastList.newInstance();
         String email = (String) context.get("email");
         Locale locale = (Locale) context.get("locale");
         String errMsg = null;
@@ -654,22 +653,19 @@
 
         try {
             EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.EQUALS, EntityFunction.UPPER(email.toUpperCase()));
-            List c = EntityUtil.filterByDate(delegator.findList("PartyAndContactMech", ee, null, UtilMisc.toList("infoString"), null, false), true);
+            List<GenericValue> c = EntityUtil.filterByDate(delegator.findList("PartyAndContactMech", ee, null, UtilMisc.toList("infoString"), null, false), 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();
+                for (GenericValue pacm: c) {
                     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());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -678,10 +674,10 @@
         return result;
     }
 
-    public static Map getPartyFromEmail(DispatchContext dctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> getPartyFromEmail(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
-        Collection parties = new LinkedList();
+        Collection<Map<String, GenericValue>> parties = FastList.newInstance();
         String email = (String) context.get("email");
         Locale locale = (Locale) context.get("locale");
         String errMsg = null;
@@ -693,22 +689,19 @@
 
         try {
             EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("infoString"), EntityOperator.LIKE, EntityFunction.UPPER(("%" + email.toUpperCase()) + "%"));
-            List c = EntityUtil.filterByDate(delegator.findList("PartyAndContactMech", ee, null, UtilMisc.toList("infoString"), null, false), true);
+            List<GenericValue> c = EntityUtil.filterByDate(delegator.findList("PartyAndContactMech", ee, null, UtilMisc.toList("infoString"), null, false), 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();
+                for (GenericValue pacm: c) {
                     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());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -723,11 +716,11 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map getPartyFromUserLogin(DispatchContext dctx, Map context) {
+    public static Map<String, Object> getPartyFromUserLogin(DispatchContext dctx, Map<String, ? extends Object> context) {
         Debug.logWarning("Running the getPartyFromUserLogin Service...", module);
-        Map result = new HashMap();
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
-        Collection parties = new LinkedList();
+        Collection<Map<String, GenericValue>> parties = FastList.newInstance();
         String userLoginId = (String) context.get("userLoginId");
         Locale locale = (Locale) context.get("locale");
 
@@ -736,22 +729,19 @@
 
         try {
             EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("userLoginId"), EntityOperator.LIKE, EntityFunction.UPPER("%" + userLoginId.toUpperCase() + "%"));
-            Collection ulc = delegator.findList("PartyAndUserLogin", ee, null, UtilMisc.toList("userloginId"), null, false);
+            Collection<GenericValue> ulc = delegator.findList("PartyAndUserLogin", ee, null, UtilMisc.toList("userloginId"), null, false);
 
             if (Debug.verboseOn()) Debug.logVerbose("Collection: " + ulc, module);
             if (Debug.infoOn()) Debug.logInfo("PartyFromUserLogin number found: " + ulc.size(), module);
             if (ulc != null) {
-                Iterator i = ulc.iterator();
-
-                while (i.hasNext()) {
-                    GenericValue ul = (GenericValue) i.next();
+                for (GenericValue ul: ulc) {
                     GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", ul.get("partyId"), "partyTypeId", ul.get("partyTypeId")));
 
                     parties.add(UtilMisc.toMap("party", party));
                 }
             }
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             String errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -767,10 +757,10 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map getPartyFromPerson(DispatchContext dctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> getPartyFromPerson(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
-        Collection parties = new LinkedList();
+        Collection<Map<String, GenericValue>> parties = FastList.newInstance();
         String firstName = (String) context.get("firstName");
         String lastName = (String) context.get("lastName");
         Locale locale = (Locale) context.get("locale");
@@ -790,21 +780,18 @@
             EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(EntityOperator.AND,
                     EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + firstName.toUpperCase() + "%")),
                     EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + lastName.toUpperCase() + "%")));
-            Collection pc = delegator.findList("Person", ecl, null, UtilMisc.toList("lastName", "firstName", "partyId"), null, false);
+            Collection<GenericValue> pc = delegator.findList("Person", ecl, null, UtilMisc.toList("lastName", "firstName", "partyId"), null, false);
 
             if (Debug.infoOn()) Debug.logInfo("PartyFromPerson number found: " + pc.size(), module);
             if (pc != null) {
-                Iterator i = pc.iterator();
-
-                while (i.hasNext()) {
-                    GenericValue person = (GenericValue) i.next();
+                for (GenericValue person: pc) {
                     GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", person.get("partyId"), "partyTypeId", "PERSON"));
 
                     parties.add(UtilMisc.toMap("person", person, "party", party));
                 }
             }
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             String errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -820,10 +807,10 @@
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map getPartyFromPartyGroup(DispatchContext dctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> getPartyFromPartyGroup(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
-        Collection parties = new LinkedList();
+        Collection<Map<String, GenericValue>> parties = FastList.newInstance();
         String groupName = (String) context.get("groupName");
         Locale locale = (Locale) context.get("locale");
 
@@ -833,21 +820,18 @@
 
         try {
             EntityExpr ee = EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("groupName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + groupName.toUpperCase() + "%"));
-            Collection pc = delegator.findList("PartyGroup", ee, null, UtilMisc.toList("groupName", "partyId"), null, false);
+            Collection<GenericValue> pc = delegator.findList("PartyGroup", ee, null, UtilMisc.toList("groupName", "partyId"), null, false);
 
             if (Debug.infoOn()) Debug.logInfo("PartyFromGroup number found: " + pc.size(), module);
             if (pc != null) {
-                Iterator i = pc.iterator();
-
-                while (i.hasNext()) {
-                    GenericValue group = (GenericValue) i.next();
+                for (GenericValue group: pc) {
                     GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", group.get("partyId"), "partyTypeId", "PARTY_GROUP"));
 
                     parties.add(UtilMisc.toMap("partyGroup", group, "party", party));
                 }
             }
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage());
             String errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);
             return ServiceUtil.returnError(errMsg);
         }
@@ -857,8 +841,8 @@
         return result;
     }
 
-    public static Map getPerson(DispatchContext dctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> getPerson(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
         String partyId = (String) context.get("partyId");
         GenericValue person = null;
@@ -874,8 +858,8 @@
         return result;
     }
 
-    public static Map createRoleType(DispatchContext dctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> createRoleType(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         GenericDelegator delegator = dctx.getDelegator();
         GenericValue roleType = null;
 
@@ -894,7 +878,7 @@
         return result;
     }
 
-    public static Map createPartyDataSource(DispatchContext ctx, Map context) {
+    public static Map<String, Object> createPartyDataSource(DispatchContext ctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = ctx.getDelegator();
 
         // input data
@@ -908,7 +892,7 @@
             GenericValue party = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId));
             GenericValue dataSource = delegator.findByPrimaryKey("DataSource", UtilMisc.toMap("dataSourceId", dataSourceId));
             if (party == null || dataSource == null) {
-                List errorList = UtilMisc.toList("Cannot create PartyDataSource");
+                List<String> errorList = UtilMisc.toList("Cannot create PartyDataSource");
                 if (party == null) errorList.add("party with ID [" + partyId + "] was not found ");
                 if (dataSource == null) errorList.add("data source with ID [" + dataSourceId + "] was not found ");
                 return ServiceUtil.returnError(errorList);
@@ -925,8 +909,8 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public static Map findParty(DispatchContext dctx, Map context) {
-        Map result = ServiceUtil.returnSuccess();
+    public static Map<String, Object> findParty(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = ServiceUtil.returnSuccess();
         GenericDelegator delegator = dctx.getDelegator();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
 
@@ -934,7 +918,7 @@
 
         // get the role types
         try {
-            List roleTypes = delegator.findList("RoleType", null, null, UtilMisc.toList("description"), null, false);
+            List<GenericValue> roleTypes = delegator.findList("RoleType", null, null, UtilMisc.toList("description"), null, false);
             result.put("roleTypes", roleTypes);
         } catch (GenericEntityException e) {
             String errMsg = "Error looking up RoleTypes: " + e.toString();
@@ -958,7 +942,7 @@
         
         //get party types
         try {
-            List partyTypes = delegator.findList("PartyType", null, null, UtilMisc.toList("description"), null, false);
+            List<GenericValue> partyTypes = delegator.findList("PartyType", null, null, UtilMisc.toList("description"), null, false);
             result.put("partyTypes", partyTypes);
         } catch (GenericEntityException e) {
             String errMsg = "Error looking up PartyTypes: " + e.toString();
@@ -1001,7 +985,7 @@
         } catch (Exception e) {
             viewIndex = 0;
         }
-        result.put("viewIndex", new Integer(viewIndex));
+        result.put("viewIndex", Integer.valueOf(viewIndex));
 
         int viewSize = 20;
         try {
@@ -1009,7 +993,7 @@
         } catch (Exception e) {
             viewSize = 20;
         }
-        result.put("viewSize", new Integer(viewSize));
+        result.put("viewSize", Integer.valueOf(viewSize));
 
         // get the lookup flag
         String lookupFlag = (String) context.get("lookupFlag");
@@ -1017,7 +1001,7 @@
         // blank param list
         String paramList = "";
 
-        List partyList = null;
+        List<GenericValue> partyList = null;
         int partyListSize = 0;
         int lowIndex = 0;
         int highIndex = 0;
@@ -1038,11 +1022,11 @@
             dynamicView.addRelation("many", "", "UserLogin", ModelKeyMap.makeKeyMapList("partyId"));
 
             // define the main condition & expression list
-            List andExprs = FastList.newInstance();
+            List<EntityCondition> andExprs = FastList.newInstance();
             EntityCondition mainCond = null;
 
-            List orderBy = FastList.newInstance();
-            List fieldsToSelect = FastList.newInstance();
+            List<String> orderBy = FastList.newInstance();
+            List<String> fieldsToSelect = FastList.newInstance();
             // fields we need to select; will be used to set distinct
             fieldsToSelect.add("partyId");
             fieldsToSelect.add("statusId");
@@ -1384,10 +1368,10 @@
 
         if (partyList == null) partyList = FastList.newInstance();
         result.put("partyList", partyList);
-        result.put("partyListSize", new Integer(partyListSize));
+        result.put("partyListSize", Integer.valueOf(partyListSize));
         result.put("paramList", paramList);
-        result.put("highIndex", new Integer(highIndex));
-        result.put("lowIndex", new Integer(lowIndex));
+        result.put("highIndex", Integer.valueOf(highIndex));
+        result.put("lowIndex", Integer.valueOf(lowIndex));
 
         return result;
     }
@@ -1401,7 +1385,7 @@
      * @param context
      * @return
      */
-    public static Map linkParty(DispatchContext dctx, Map context) {
+    public static Map<String, Object> linkParty(DispatchContext dctx, Map<String, ? extends Object> context) {
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericDelegator _delegator = dctx.getDelegator();
         GenericDelegator delegator = _delegator.cloneDelegator();
@@ -1497,7 +1481,7 @@
         }
 
         // update the non-existing party roles
-        List rolesToMove;
+        List<GenericValue> rolesToMove;
         try {
             rolesToMove = delegator.findByAnd("PartyRole", UtilMisc.toMap("partyId", partyId));
         } catch (GenericEntityException e) {
@@ -1505,9 +1489,7 @@
             return ServiceUtil.returnError(e.getMessage());
         }
 
-        Iterator rtmi = rolesToMove.iterator();
-        while (rtmi.hasNext()) {
-            GenericValue attr = (GenericValue) rtmi.next();
+        for (GenericValue attr: rolesToMove) {
             attr.set("partyId", partyIdTo);
             try {
                 if (delegator.findByPrimaryKey("PartyRole", attr.getPrimaryKey()) == null) {
@@ -1575,7 +1557,7 @@
         }
 
         // update the non-existing attributes
-        List attrsToMove;
+        List<GenericValue> attrsToMove;
         try {
             attrsToMove = delegator.findByAnd("PartyAttribute", UtilMisc.toMap("partyId", partyId));
         } catch (GenericEntityException e) {
@@ -1583,9 +1565,7 @@
             return ServiceUtil.returnError(e.getMessage());
         }
 
-        Iterator atmi = attrsToMove.iterator();
-        while (atmi.hasNext()) {
-            GenericValue attr = (GenericValue) atmi.next();
+        for (GenericValue attr: attrsToMove) {
             attr.set("partyId", partyIdTo);
             try {
                 if (delegator.findByPrimaryKey("PartyAttribute", attr.getPrimaryKey()) == null) {
@@ -1628,12 +1608,12 @@
             }
         }
                 
-        Map resp = ServiceUtil.returnSuccess();
+        Map<String, Object> resp = ServiceUtil.returnSuccess();
         resp.put("partyId", partyIdTo);
         return resp;
     }
 
-    public static Map importAddressMatchMapCsv(DispatchContext dctx, Map context) {
+    public static Map<String, Object> importAddressMatchMapCsv(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         byte[] fileBytes = (byte[]) context.get("uploadedFile");
         String csvFile = new String(fileBytes);
@@ -1654,8 +1634,8 @@
                     if (map.length == 3) {
                         char[] chars = map[2].toCharArray();
                         boolean isNumber = true;
-                        for (int c = 0; c < chars.length; c++) {
-                            if (!Character.isDigit(chars[c])) {
+                        for (char c: chars) {
+                            if (!Character.isDigit(c)) {
                                 isNumber = false;
                             }
                         }
@@ -1668,7 +1648,7 @@
                         }
                     }
 
-                    addrMap.put("sequenceNum", new Long(seq));
+                    addrMap.put("sequenceNum", Long.valueOf(seq));
                     Debug.log("Creating map entry: " + addrMap, module);
                     try {
                         delegator.create(addrMap);

Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyWorker.java?rev=685936&r1=685935&r2=685936&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyWorker.java (original)
+++ ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyWorker.java Thu Aug 14 08:12:17 2008
@@ -20,7 +20,6 @@
 package org.ofbiz.party.party;
 
 import java.sql.Timestamp;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -30,6 +29,7 @@
 import javax.servlet.jsp.PageContext;
 
 import javolution.util.FastList;
+import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
@@ -52,9 +52,9 @@
     
     public static String module = PartyWorker.class.getName();
     
-    public static Map getPartyOtherValues(ServletRequest request, String partyId, String partyAttr, String personAttr, String partyGroupAttr) {
+    public static Map<String, GenericValue> getPartyOtherValues(ServletRequest request, String partyId, String partyAttr, String personAttr, String partyGroupAttr) {
         GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
-        Map result = new HashMap();
+        Map<String, GenericValue> result = FastMap.newInstance();
         try {
             GenericValue party = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId));
 
@@ -85,11 +85,9 @@
     }              
     
     public static void getPartyOtherValues(PageContext pageContext, String partyId, String partyAttr, String personAttr, String partyGroupAttr) {
-        Map partyMap = getPartyOtherValues(pageContext.getRequest(), partyId, partyAttr, personAttr, partyGroupAttr);
-        Iterator i = partyMap.entrySet().iterator();
-        while (i.hasNext()) {
-            Map.Entry e = (Map.Entry) i.next();
-            pageContext.setAttribute((String) e.getKey(), e.getValue());
+        Map<String, GenericValue> partyMap = getPartyOtherValues(pageContext.getRequest(), partyId, partyAttr, personAttr, partyGroupAttr);
+        for (Map.Entry<String, GenericValue> e: partyMap.entrySet()) {
+            pageContext.setAttribute(e.getKey(), e.getValue());
             
         }      
     }
@@ -118,7 +116,7 @@
 
     public static GenericValue findPartyLatestContactMech(String partyId, String contactMechTypeId, GenericDelegator delegator) {
         try {
-            List cmList = delegator.findByAnd("PartyAndContactMech", UtilMisc.toMap("partyId", partyId, "contactMechTypeId", contactMechTypeId), UtilMisc.toList("-fromDate"));
+            List<GenericValue> cmList = delegator.findByAnd("PartyAndContactMech", UtilMisc.toMap("partyId", partyId, "contactMechTypeId", contactMechTypeId), UtilMisc.toList("-fromDate"));
             cmList = EntityUtil.filterByDate(cmList);
             return EntityUtil.getFirst(cmList);
         } catch (GenericEntityException e) {
@@ -153,7 +151,7 @@
 
     public static GenericValue findPartyLatestUserLogin(String partyId, GenericDelegator delegator) {
         try {
-            List userLoginList = delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId), UtilMisc.toList("-" + ModelEntity.STAMP_FIELD));
+            List<GenericValue> userLoginList = delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId), UtilMisc.toList("-" + ModelEntity.STAMP_FIELD));
             return EntityUtil.getFirst(userLoginList);
         } catch (GenericEntityException e) {
             Debug.logError(e, "Error while finding latest UserLogin for party with ID [" + partyId + "]: " + e.toString(), module);
@@ -163,7 +161,7 @@
 
     public static Timestamp findPartyLastLoginTime(String partyId, GenericDelegator delegator) {
         try {
-            List loginHistory = delegator.findByAnd("UserLoginHistory", UtilMisc.toMap("partyId", partyId), UtilMisc.toList("-fromDate"));
+            List<GenericValue> loginHistory = delegator.findByAnd("UserLoginHistory", UtilMisc.toMap("partyId", partyId), UtilMisc.toList("-fromDate"));
             GenericValue v = EntityUtil.getFirst(loginHistory);
             if (v != null) {
                 return v.getTimestamp("fromDate");
@@ -207,7 +205,7 @@
             String stateProvinceGeoId, String postalCode, String postalCodeExt, String countryGeoId,
             String firstName, String middleName, String lastName) throws GeneralException {
 
-        List matching = findMatchingPartyAndPostalAddress(delegator, address1, address2, city, stateProvinceGeoId, postalCode,
+        List<GenericValue> matching = findMatchingPartyAndPostalAddress(delegator, address1, address2, city, stateProvinceGeoId, postalCode,
             postalCodeExt, countryGeoId, firstName, middleName, lastName);
         GenericValue v = EntityUtil.getFirst(matching);
         if (v != null) {
@@ -216,19 +214,19 @@
         return null;
     }
 
-    public static List findMatchingPartyAndPostalAddress(GenericDelegator delegator, String address1, String address2, String city,
+    public static List<GenericValue> findMatchingPartyAndPostalAddress(GenericDelegator delegator, String address1, String address2, String city,
                             String stateProvinceGeoId, String postalCode, String postalCodeExt, String countryGeoId,
                             String firstName, String middleName, String lastName) throws GeneralException {
 
         // return list
-        List returnList = FastList.newInstance();
+        List<GenericValue> returnList = FastList.newInstance();
 
         // address information
         if (firstName == null || lastName == null || address1 == null || city == null || postalCode == null) {
             throw new IllegalArgumentException();
         }
 
-        List addrExprs = FastList.newInstance();
+        List<EntityCondition> addrExprs = FastList.newInstance();
         if (stateProvinceGeoId != null) {
             if ("**".equals(stateProvinceGeoId)) {
                 Debug.logWarning("Illegal state code passed!", module);
@@ -263,18 +261,15 @@
         addrExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, null),
                 EntityOperator.OR, EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED")));
 
-        List sort = UtilMisc.toList("-fromDate");
+        List<String> sort = UtilMisc.toList("-fromDate");
         EntityCondition addrCond = EntityCondition.makeCondition(addrExprs, EntityOperator.AND);
-        List addresses = EntityUtil.filterByDate(delegator.findList("PartyAndPostalAddress", addrCond, null, sort, null, false));
+        List<GenericValue> addresses = EntityUtil.filterByDate(delegator.findList("PartyAndPostalAddress", addrCond, null, sort, null, false));
         //Debug.log("Checking for matching address: " + addrCond.toString() + "[" + addresses.size() + "]", module);
 
-        List validFound = FastList.newInstance();
+        List<GenericValue> validFound = FastList.newInstance();
         if (UtilValidate.isNotEmpty(addresses)) {
             // check the address line
-            Iterator v = addresses.iterator();
-            while (v.hasNext()) {
-                GenericValue address = (GenericValue) v.next();
-
+            for (GenericValue address: addresses) {
                 // address 1 field
                 String addr1Source = PartyWorker.makeMatchingString(delegator, address1);
                 String addr1Target = PartyWorker.makeMatchingString(delegator, address.getString("address1"));
@@ -308,9 +303,7 @@
             }
 
             if (validFound != null && validFound.size() > 0) {
-                Iterator a = validFound.iterator();
-                while (a.hasNext()) {
-                    GenericValue partyAndAddr = (GenericValue) a.next();
+                for (GenericValue partyAndAddr: validFound) {
                     String partyId = partyAndAddr.getString("partyId");
                     String cmId = partyAndAddr.getString("contactMechId");
                     if (UtilValidate.isNotEmpty(partyId)) {
@@ -350,7 +343,7 @@
         String str = address.trim().toUpperCase();
 
         // replace mapped words
-        List addressMap = null;
+        List<GenericValue> addressMap = null;
         try {
             addressMap = delegator.findList("AddressMatchMap", null, null, UtilMisc.toList("sequenceNum"), null, false);
         } catch (GenericEntityException e) {
@@ -358,9 +351,7 @@
         }
 
         if (addressMap != null) {
-            Iterator i = addressMap.iterator();
-            while (i.hasNext()) {
-                GenericValue v = (GenericValue) i.next();
+            for (GenericValue v: addressMap) {
                 str = str.replaceAll(v.getString("mapKey").toUpperCase(), v.getString("mapValue").toUpperCase());
             }
         }