Author: doogie
Date: Thu Aug 14 08:12:17 2008 New Revision: 685936 URL: http://svn.apache.org/viewvc?rev=685936&view=rev Log: Generics, StringBuilder, for-loop, Number.valueOf. Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactHelper.java ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyHelper.java ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyRelationshipServices.java ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyServices.java ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyWorker.java Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java?rev=685936&r1=685935&r2=685936&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java Thu Aug 14 08:12:17 2008 @@ -22,6 +22,7 @@ import java.util.*; import javolution.util.FastList; +import javolution.util.FastMap; import org.ofbiz.base.util.*; import org.ofbiz.entity.GenericDelegator; @@ -43,7 +44,7 @@ public static final String module = CommunicationEventServices.class.getName(); public static final String resource = "PartyUiLabels"; - public static Map sendCommEventAsEmail(DispatchContext ctx, Map context) { + public static Map<String, Object> sendCommEventAsEmail(DispatchContext ctx, Map<String, ? extends Object> context) { GenericDelegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -51,8 +52,8 @@ String communicationEventId = (String) context.get("communicationEventId"); - Map result = ServiceUtil.returnSuccess(); - List errorMessages = FastList.newInstance(); // used to keep a list of all error messages returned from sending emails to contact list + Map<String, Object> result = ServiceUtil.returnSuccess(); + List<Object> errorMessages = FastList.newInstance(); // used to keep a list of all error messages returned from sending emails to contact list try { // find the communication event and make sure that it is actually an email @@ -84,7 +85,7 @@ } // prepare the email - Map sendMailParams = new HashMap(); + Map<String, Object> sendMailParams = FastMap.newInstance(); sendMailParams.put("sendFrom", communicationEvent.getRelatedOne("FromContactMech").getString("infoString")); sendMailParams.put("subject", communicationEvent.getString("subject")); sendMailParams.put("body", communicationEvent.getString("content")); @@ -112,7 +113,7 @@ sendMailParams.put("partyId", communicationEvent.getString("partyIdTo")); // who it's going to // send it - Map tmpResult = dispatcher.runSync("sendMail", sendMailParams); + Map<String, Object> tmpResult = dispatcher.runSync("sendMail", sendMailParams); if (ServiceUtil.isError(tmpResult)) { errorMessages.add(ServiceUtil.getErrorMessage(tmpResult)); } else { @@ -126,7 +127,7 @@ return ServiceUtil.returnError(e.getMessage()); } - Map completeResult = dispatcher.runSync("setCommEventComplete", UtilMisc.<String, Object>toMap("communicationEventId", communicationEventId, "userLogin", userLogin)); + Map<String, Object> completeResult = dispatcher.runSync("setCommEventComplete", UtilMisc.<String, Object>toMap("communicationEventId", communicationEventId, "userLogin", userLogin)); if (ServiceUtil.isError(completeResult)) { errorMessages.add(ServiceUtil.getErrorMessage(completeResult)); } @@ -134,7 +135,7 @@ } else { // Call the sendEmailToContactList service if there's a contactListId present - Map sendEmailToContactListContext = new HashMap(); + Map<String, Object> sendEmailToContactListContext = FastMap.newInstance(); sendEmailToContactListContext.put("contactListId", communicationEvent.getString("contactListId")); sendEmailToContactListContext.put("communicationEventId", communicationEventId); sendEmailToContactListContext.put("userLogin", userLogin); @@ -160,13 +161,13 @@ return result; } - public static Map sendEmailToContactList(DispatchContext ctx, Map context) { + public static Map<String, Object> sendEmailToContactList(DispatchContext ctx, Map<String, ? extends Object> context) { GenericDelegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Locale locale = (Locale) context.get("locale"); - List errorMessages = new ArrayList(); + List<Object> errorMessages = FastList.newInstance(); String errorCallingUpdateContactListPartyService = UtilProperties.getMessage(resource, "commeventservices.errorCallingUpdateContactListPartyService", locale); String errorCallingSendMailService = UtilProperties.getMessage(resource, "commeventservices.errorCallingSendMailService", locale); String errorInSendEmailToContactListService = UtilProperties.getMessage(resource, "commeventservices.errorInSendEmailToContactListService", locale); @@ -181,7 +182,7 @@ GenericValue communicationEvent = delegator.findByPrimaryKey("CommunicationEvent", UtilMisc.toMap("communicationEventId", communicationEventId)); GenericValue contactList = delegator.findByPrimaryKey("ContactList", UtilMisc.toMap("contactListId", contactListId)); - Map sendMailParams = new HashMap(); + Map<String, Object> sendMailParams = FastMap.newInstance(); sendMailParams.put("sendFrom", communicationEvent.getRelatedOne("FromContactMech").getString("infoString")); sendMailParams.put("subject", communicationEvent.getString("subject")); sendMailParams.put("body", communicationEvent.getString("content")); @@ -199,17 +200,13 @@ EntityConditionList<EntityCondition> conditions = EntityCondition.makeCondition(conditionList, EntityOperator.AND); Set<String> fieldsToSelect = UtilMisc.toSet("infoString"); - List sendToEmails = delegator.findList("ContactListPartyAndContactMech", conditions, fieldsToSelect, null, + List<GenericValue> sendToEmails = delegator.findList("ContactListPartyAndContactMech", conditions, fieldsToSelect, null, new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true), false); // Send an email to each contact list member // TODO: Contact lists for emails really should be written as an EntityListIterator for very large lists! - List orderBy = UtilMisc.toList("-fromDate"); - Iterator sendToEmailsIt = sendToEmails.iterator(); - while (sendToEmailsIt.hasNext()) { - - GenericValue contactListPartyAndContactMech = (GenericValue) sendToEmailsIt.next(); - + List<String> orderBy = UtilMisc.toList("-fromDate"); + for (GenericValue contactListPartyAndContactMech: sendToEmails) { // Any exceptions thrown in this inner block will only relate to a single email of the list, so should // only be logged and not cause the service to return an error try { @@ -229,11 +226,11 @@ // Because we're retrieving infoString only above (so as not to pollute the distinctness), we // need to retrieve the partyId it's related to. Since this could be multiple parties, get // only the most recent valid one via ContactListPartyAndContactMech. - List clpConditionList = new ArrayList(conditionList); + List<EntityCondition> clpConditionList = UtilMisc.makeListWritable(conditionList); clpConditionList.add(EntityCondition.makeCondition("infoString", EntityOperator.EQUALS, emailAddress)); EntityConditionList clpConditions = EntityCondition.makeCondition(clpConditionList, EntityOperator.AND); - List emailCLPaCMs = delegator.findList("ContactListPartyAndContactMech", clpConditions, null, orderBy, null, true); + List<GenericValue> emailCLPaCMs = delegator.findList("ContactListPartyAndContactMech", clpConditions, null, orderBy, null, true); GenericValue lastContactListPartyACM = EntityUtil.getFirst(emailCLPaCMs); if (lastContactListPartyACM == null) continue; @@ -248,13 +245,13 @@ } // Retrieve a record for this contactMechId from ContactListCommStatus - Map contactListCommStatusRecordMap = UtilMisc.toMap("contactListId", contactListId, "communicationEventId", communicationEventId, "contactMechId", lastContactListPartyACM.getString("preferredContactMechId")); + Map<String, String> contactListCommStatusRecordMap = UtilMisc.toMap("contactListId", contactListId, "communicationEventId", communicationEventId, "contactMechId", lastContactListPartyACM.getString("preferredContactMechId")); GenericValue contactListCommStatusRecord = delegator.findByPrimaryKey("ContactListCommStatus", contactListCommStatusRecordMap); if (contactListCommStatusRecord == null) { // No attempt has been made previously to send to this address, so create a record to reflect // the beginning of the current attempt - Map newContactListCommStatusRecordMap = new HashMap(contactListCommStatusRecordMap); + Map<String, String> newContactListCommStatusRecordMap = UtilMisc.makeMapWritable(contactListCommStatusRecordMap); newContactListCommStatusRecordMap.put("statusId", "COM_IN_PROGRESS"); contactListCommStatusRecord = delegator.create("ContactListCommStatus", newContactListCommStatusRecordMap); } else if (contactListCommStatusRecord.get("statusId") != null && contactListCommStatusRecord.getString("statusId").equals("COM_COMPLETE")) { @@ -263,7 +260,7 @@ continue; } - Map tmpResult = null; + Map<String, Object> tmpResult = null; // Make the attempt to send the email to the address tmpResult = dispatcher.runSync("sendMail", sendMailParams); Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactHelper.java?rev=685936&r1=685935&r2=685936&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactHelper.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactHelper.java Thu Aug 14 08:12:17 2008 @@ -36,27 +36,27 @@ public static final String module = ContactHelper.class.getName(); - public static Collection getContactMech(GenericValue party, boolean includeOld) { + public static Collection<GenericValue> getContactMech(GenericValue party, boolean includeOld) { return getContactMech(party, null, null, includeOld); } - public static Collection getContactMechByType(GenericValue party, String contactMechTypeId, boolean includeOld) { + public static Collection<GenericValue> getContactMechByType(GenericValue party, String contactMechTypeId, boolean includeOld) { return getContactMech(party, null, contactMechTypeId, includeOld); } - public static Collection getContactMechByPurpose(GenericValue party, String contactMechPurposeTypeId, boolean includeOld) { + public static Collection<GenericValue> getContactMechByPurpose(GenericValue party, String contactMechPurposeTypeId, boolean includeOld) { return getContactMech(party, contactMechPurposeTypeId, null, includeOld); } - public static Collection getContactMech(GenericValue party, String contactMechPurposeTypeId, String contactMechTypeId, boolean includeOld) { + public static Collection<GenericValue> getContactMech(GenericValue party, String contactMechPurposeTypeId, String contactMechTypeId, boolean includeOld) { if (party == null) return null; try { - List partyContactMechList; + List<GenericValue> partyContactMechList; if (contactMechPurposeTypeId == null) { partyContactMechList = party.getRelated("PartyContactMech"); } else { - List list; + List<GenericValue> list; list = party.getRelatedByAnd("PartyContactMechPurpose", UtilMisc.toMap("contactMechPurposeTypeId", contactMechPurposeTypeId)); if (!includeOld) { @@ -75,12 +75,12 @@ } } catch (GenericEntityException gee) { Debug.logWarning(gee, module); - return Collections.EMPTY_LIST; + return Collections.emptyList(); } } public static String formatCreditCard(GenericValue creditCardInfo) { - StringBuffer result = new StringBuffer(16); + StringBuilder result = new StringBuilder(16); result.append(creditCardInfo.getString("cardType")); String cardNumber = creditCardInfo.getString("cardNumber"); Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java?rev=685936&r1=685935&r2=685936&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java Thu Aug 14 08:12:17 2008 @@ -23,15 +23,17 @@ import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; -import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Locale; +import javolution.util.FastList; +import javolution.util.FastMap; + import org.ofbiz.base.crypto.HashCrypt; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; @@ -63,13 +65,13 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map createContactMech(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> createContactMech(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Timestamp now = UtilDateTime.nowTimestamp(); - List toBeStored = new LinkedList(); + List<GenericValue> toBeStored = FastList.newInstance(); String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_CREATE"); String errMsg = null; @@ -111,7 +113,7 @@ delegator.storeAll(toBeStored); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_create_contact_info_write", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -128,13 +130,13 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map updateContactMech(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> updateContactMech(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Timestamp now = UtilDateTime.nowTimestamp(); - List toBeStored = new LinkedList(); + List<GenericValue> toBeStored = FastList.newInstance(); boolean isModified = false; String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_UPDATE"); @@ -166,7 +168,7 @@ if (!partyId.equals("_NA_")) { // try to find a PartyContactMech with a valid date range try { - List partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate")), true); + List<GenericValue> partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate")), true); partyContactMech = EntityUtil.getFirst(partyContactMechs); if (partyContactMech == null) { errMsg = UtilProperties.getMessage(resource,"contactmechservices.cannot_update_specified_contact_info_not_corresponds", locale); @@ -219,17 +221,17 @@ newPartyContactMech.set("thruDate", null); try { - Iterator partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose")); + Iterator<GenericValue> partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose")); while (partyContactMechPurposes != null && partyContactMechPurposes.hasNext()) { - GenericValue tempVal = GenericValue.create((GenericValue) partyContactMechPurposes.next()); + GenericValue tempVal = GenericValue.create(partyContactMechPurposes.next()); tempVal.set("contactMechId", newCmId); toBeStored.add(tempVal); } } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_change_contact_info_read", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -239,7 +241,7 @@ delegator.storeAll(toBeStored); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_change_contact_info_write", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -263,8 +265,8 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map deleteContactMech(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> deleteContactMech(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -282,12 +284,12 @@ try { // try to find a PartyContactMech with a valid date range - List partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate")), true); + List<GenericValue> partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate")), true); partyContactMech = EntityUtil.getFirst(partyContactMechs); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_delete_contact_info_read", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -320,13 +322,13 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map createPostalAddress(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> createPostalAddress(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Timestamp now = UtilDateTime.nowTimestamp(); - List toBeStored = new LinkedList(); + List<GenericValue> toBeStored = FastList.newInstance(); String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_CREATE"); String errMsg = null; @@ -376,7 +378,7 @@ delegator.storeAll(toBeStored); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_create_contact_info_write", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -393,13 +395,13 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map updatePostalAddress(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> updatePostalAddress(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Timestamp now = UtilDateTime.nowTimestamp(); - List toBeStored = new LinkedList(); + List<GenericValue> toBeStored = FastList.newInstance(); boolean isModified = false; String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_UPDATE"); @@ -433,7 +435,7 @@ if (!partyId.equals("_NA_")) { // try to find a PartyContactMech with a valid date range try { - List partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate")), true); + List<GenericValue> partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate")), true); partyContactMech = EntityUtil.getFirst(partyContactMechs); if (partyContactMech == null) { errMsg = UtilProperties.getMessage(resource,"contactmechservices.cannot_update_specified_contact_info_not_corresponds", locale); @@ -484,7 +486,7 @@ } relatedEntityToSet.set("contactMechId", newCmId); } else { - Map messageMap = UtilMisc.toMap("contactMechTypeId", contactMech.getString("contactMechTypeId")); + Map<String, String> messageMap = UtilMisc.toMap("contactMechTypeId", contactMech.getString("contactMechTypeId")); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_update_contact_as_POSTAL_ADDRESS_specified", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -511,17 +513,17 @@ newPartyContactMech.set("thruDate", null); try { - Iterator partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose")); + Iterator<GenericValue> partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose")); while (partyContactMechPurposes != null && partyContactMechPurposes.hasNext()) { - GenericValue tempVal = GenericValue.create((GenericValue) partyContactMechPurposes.next()); + GenericValue tempVal = GenericValue.create(partyContactMechPurposes.next()); tempVal.set("contactMechId", newCmId); toBeStored.add(tempVal); } } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_change_contact_info_read", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -533,7 +535,7 @@ delegator.storeAll(toBeStored); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_change_contact_info_write", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -560,13 +562,13 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map createTelecomNumber(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> createTelecomNumber(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Timestamp now = UtilDateTime.nowTimestamp(); - List toBeStored = new LinkedList(); + List<GenericValue> toBeStored = FastList.newInstance(); String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_CREATE"); String errMsg = null; @@ -598,7 +600,7 @@ delegator.storeAll(toBeStored); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_create_contact_info_write", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -615,13 +617,13 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map updateTelecomNumber(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> updateTelecomNumber(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Timestamp now = UtilDateTime.nowTimestamp(); - List toBeStored = new LinkedList(); + List<GenericValue> toBeStored = FastList.newInstance(); boolean isModified = false; String partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_PCM_UPDATE"); @@ -646,7 +648,7 @@ try { contactMech = delegator.findByPrimaryKey("ContactMech", UtilMisc.toMap("contactMechId", contactMechId)); // try to find a PartyContactMech with a valid date range - List partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate")), true); + List<GenericValue> partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId), UtilMisc.toList("fromDate")), true); partyContactMech = EntityUtil.getFirst(partyContactMechs); } catch (GenericEntityException e) { @@ -689,7 +691,7 @@ relatedEntityToSet.set("contactMechId", newCmId); newPartyContactMech.set("extension", context.get("extension")); } else { - Map messageMap = UtilMisc.toMap("contactMechTypeId", contactMech.getString("contactMechTypeId")); + Map<String, String> messageMap = UtilMisc.toMap("contactMechTypeId", contactMech.getString("contactMechTypeId")); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_update_contact_as_TELECOM_NUMBER_specified", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -712,17 +714,17 @@ newPartyContactMech.set("thruDate", null); try { - Iterator partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose")); + Iterator<GenericValue> partyContactMechPurposes = UtilMisc.toIterator(partyContactMech.getRelated("PartyContactMechPurpose")); while (partyContactMechPurposes != null && partyContactMechPurposes.hasNext()) { - GenericValue tempVal = GenericValue.create((GenericValue) partyContactMechPurposes.next()); + GenericValue tempVal = GenericValue.create(partyContactMechPurposes.next()); tempVal.set("contactMechId", newCmId); toBeStored.add(tempVal); } } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_change_contact_info_read", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -732,7 +734,7 @@ delegator.storeAll(toBeStored); } catch (GenericEntityException e) { Debug.logWarning(e.toString(), module); - Map messageMap = UtilMisc.toMap("errMessage", e.getMessage()); + Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.getMessage()); errMsg = UtilProperties.getMessage(resource,"contactmechservices.could_not_change_contact_info_write", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -759,8 +761,8 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map createEmailAddress(DispatchContext ctx, Map context) { - Map newContext = new HashMap(context); + public static Map<String, Object> createEmailAddress(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> newContext = UtilMisc.makeMapWritable(context); newContext.put("infoString", newContext.get("emailAddress")); newContext.remove("emailAddress"); @@ -776,8 +778,8 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map updateEmailAddress(DispatchContext ctx, Map context) { - Map newContext = new HashMap(context); + public static Map<String, Object> updateEmailAddress(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> newContext = UtilMisc.makeMapWritable(context); newContext.put("infoString", newContext.get("emailAddress")); newContext.remove("emailAddress"); @@ -794,9 +796,9 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map createPartyContactMechPurpose(DispatchContext ctx, Map context) { + public static Map<String, Object> createPartyContactMechPurpose(DispatchContext ctx, Map<String, ? extends Object> context) { //Debug.logInfo(new Exception(), "In createPartyContactMechPurpose context: " + context, module); - Map result = new HashMap(); + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -815,9 +817,9 @@ GenericValue tempVal = null; try { - Map pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId); + Map<String, String> pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId); //Debug.logInfo("pcmpFindMap = " + pcmpFindMap, module); - List allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", pcmpFindMap), true); + List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", pcmpFindMap), true); tempVal = EntityUtil.getFirst(allPCMPs); } catch (GenericEntityException e) { @@ -842,7 +844,7 @@ delegator.create(newPartyContactMechPurpose); } 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,"contactmechservices.could_not_add_purpose_write", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -853,9 +855,9 @@ return result; } - public static Map deletePartyContactMechPurposeIfExists(DispatchContext ctx, Map context) { + public static Map<String, Object> deletePartyContactMechPurposeIfExists(DispatchContext ctx, Map<String, ? extends Object> context) { //Debug.logInfo(new Exception(), "In createPartyContactMechPurpose context: " + context, module); - Map result = new HashMap(); + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -874,9 +876,9 @@ GenericValue tempVal = null; try { - Map pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId); + Map<String, String> pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId); //Debug.logInfo("pcmpFindMap = " + pcmpFindMap, module); - List allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", pcmpFindMap), true); + List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", pcmpFindMap), true); tempVal = EntityUtil.getFirst(allPCMPs); } catch (GenericEntityException e) { @@ -884,18 +886,18 @@ tempVal = null; } if (tempVal != null) { - Map deletePcmCtx = UtilMisc.toMap("contactMechId", context.get("contactMechId")); + Map<String, Object> deletePcmCtx = UtilMisc.toMap("contactMechId", context.get("contactMechId")); deletePcmCtx.put("contactMechPurposeTypeId", context.get("contactMechPurposeTypeId")); deletePcmCtx.put("fromDate", tempVal.get("fromDate")); deletePcmCtx.put("userLogin", context.get("userLogin")); try { - Map deletePcmResult = ctx.getDispatcher().runSync("deletePartyContactMechPurpose", deletePcmCtx); + Map<String, Object> deletePcmResult = ctx.getDispatcher().runSync("deletePartyContactMechPurpose", deletePcmCtx); if(ServiceUtil.isError(deletePcmResult)){ return deletePcmResult; } } catch (GenericServiceException 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,"contactmechservices.could_not_delete_purpose_from_contact_mechanism_read", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -911,8 +913,8 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map deletePartyContactMechPurpose(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> deletePartyContactMechPurpose(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -939,7 +941,7 @@ } } 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,"contactmechservices.could_not_delete_purpose_from_contact_mechanism_read", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -949,7 +951,7 @@ pcmp.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,"contactmechservices.could_not_delete_purpose_from_contact_mechanism_write", messageMap, locale); return ServiceUtil.returnError(errMsg); } @@ -965,8 +967,8 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map getPartyContactMechValueMaps(DispatchContext ctx, Map context) { - Map result = ServiceUtil.returnSuccess(); + public static Map<String, Object> getPartyContactMechValueMaps(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = ServiceUtil.returnSuccess(); GenericDelegator delegator = ctx.getDelegator(); GenericValue userLogin = (GenericValue) context.get("userLogin"); String partyId = (String)context.get("partyId"); @@ -980,7 +982,7 @@ Boolean bShowOld = (Boolean)context.get("showOld"); boolean showOld = (bShowOld != null && bShowOld.booleanValue()) ? true : false; String contactMechTypeId = (String)context.get("contactMechTypeId"); - List valueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, partyId, showOld, contactMechTypeId); + List<Map<String, Object>> valueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, partyId, showOld, contactMechTypeId); result.put("valueMaps", valueMaps ); return result; } @@ -998,20 +1000,19 @@ try { // grab all of the non-expired contact mechs using this party worker method - List valueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, partyIdFrom, false); + List<Map<String, Object>> valueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, partyIdFrom, false); // loop through results - for (Iterator iter = valueMaps.iterator(); iter.hasNext(); ) { - Map thisMap = (Map) iter.next(); + for (Map<String, Object> thisMap: valueMaps) { GenericValue contactMech = (GenericValue) thisMap.get("contactMech"); GenericValue partyContactMech = (GenericValue) thisMap.get("partyContactMech"); - List partyContactMechPurposes = (List) thisMap.get("partyContactMechPurposes"); + List<GenericValue> partyContactMechPurposes = UtilGenerics.checkList(thisMap.get("partyContactMechPurposes")); // get the contactMechId String contactMechId = contactMech.getString("contactMechId"); // create a new party contact mech for the partyIdTo - Map serviceResults = dispatcher.runSync("createPartyContactMech", UtilMisc.<String, Object>toMap("partyId", partyIdTo, "userLogin", userLogin, + Map<String, Object> serviceResults = dispatcher.runSync("createPartyContactMech", UtilMisc.<String, Object>toMap("partyId", partyIdTo, "userLogin", userLogin, "contactMechId", contactMechId, "fromDate", UtilDateTime.nowTimestamp(), "allowSolicitation", partyContactMech.getString("allowSolicitation"), "extension", partyContactMech.getString("extension"))); if (ServiceUtil.isError(serviceResults)) { @@ -1019,9 +1020,8 @@ } // loop through purposes and copy each as a new purpose for the partyIdTo - for (Iterator piter = partyContactMechPurposes.iterator(); piter.hasNext(); ) { - GenericValue purpose = (GenericValue) piter.next(); - Map input = UtilMisc.toMap("partyId", partyIdTo, "contactMechId", contactMechId, "userLogin", userLogin); + for (GenericValue purpose: partyContactMechPurposes) { + Map<String, Object> input = UtilMisc.toMap("partyId", partyIdTo, "contactMechId", contactMechId, "userLogin", userLogin); input.put("contactMechPurposeTypeId", purpose.getString("contactMechPurposeTypeId")); serviceResults = dispatcher.runSync("createPartyContactMechPurpose", input); if (ServiceUtil.isError(serviceResults)) { @@ -1058,7 +1058,7 @@ while(true){ Long random = secureRandom.nextLong(); verifyHash = HashCrypt.getDigestHash(Long.toString(random), "MD5"); - List emailAddVerifications = null; + List<GenericValue> emailAddVerifications = null; try { emailAddVerifications = delegator.findByAnd("EmailAddressVerification", UtilMisc.toMap("verifyHash", verifyHash)); } catch (GenericEntityException e) { @@ -1081,7 +1081,7 @@ } } - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("verifyHash", verifyHash); return result; } Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java?rev=685936&r1=685935&r2=685936&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java Thu Aug 14 08:12:17 2008 @@ -52,27 +52,26 @@ public static void getPartyContactMechValueMaps(PageContext pageContext, String partyId, boolean showOld, String partyContactMechValueMapsAttr) { GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator"); - List partyContactMechValueMaps = getPartyContactMechValueMaps(delegator, partyId, showOld); + List<Map<String, Object>> partyContactMechValueMaps = getPartyContactMechValueMaps(delegator, partyId, showOld); if (partyContactMechValueMaps.size() > 0) { pageContext.setAttribute(partyContactMechValueMapsAttr, partyContactMechValueMaps); } } - public static List getPartyContactMechValueMaps(GenericDelegator delegator, String partyId, boolean showOld) { + public static List<Map<String, Object>> getPartyContactMechValueMaps(GenericDelegator delegator, String partyId, boolean showOld) { return getPartyContactMechValueMaps(delegator, partyId, showOld, null); } - public static List getPartyContactMechValueMaps(GenericDelegator delegator, String partyId, boolean showOld, String contactMechTypeId) { - List partyContactMechValueMaps = FastList.newInstance(); + public static List<Map<String, Object>> getPartyContactMechValueMaps(GenericDelegator delegator, String partyId, boolean showOld, String contactMechTypeId) { + List<Map<String, Object>> partyContactMechValueMaps = FastList.newInstance(); - Iterator allPartyContactMechs = null; + List<GenericValue> allPartyContactMechs = null; try { - List tempCol = delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId)); + List<GenericValue> tempCol = delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId)); if(contactMechTypeId != null) { - List tempColTemp = FastList.newInstance(); - for(Iterator iterator = tempCol.iterator(); iterator.hasNext();) { - GenericValue partyContactMech = (GenericValue) iterator.next(); + List<GenericValue> tempColTemp = FastList.newInstance(); + for (GenericValue partyContactMech: tempCol) { GenericValue contactMech = delegator.getRelatedOne("ContactMech", partyContactMech); if(contactMech != null && contactMechTypeId.equals(contactMech.getString("contactMechTypeId"))) { tempColTemp.add(partyContactMech); @@ -82,13 +81,14 @@ tempCol = tempColTemp; } if (!showOld) tempCol = EntityUtil.filterByDate(tempCol, true); - allPartyContactMechs = UtilMisc.toIterator(tempCol); + allPartyContactMechs = tempCol; } catch (GenericEntityException e) { Debug.logWarning(e, module); } - while (allPartyContactMechs != null && allPartyContactMechs.hasNext()) { - GenericValue partyContactMech = (GenericValue) allPartyContactMechs.next(); + if (allPartyContactMechs == null) return partyContactMechValueMaps; + + for (GenericValue partyContactMech: allPartyContactMechs) { GenericValue contactMech = null; try { @@ -97,7 +97,7 @@ Debug.logWarning(e, module); } if (contactMech != null) { - Map partyContactMechValueMap = FastMap.newInstance(); + Map<String, Object> partyContactMechValueMap = FastMap.newInstance(); partyContactMechValueMaps.add(partyContactMechValueMap); partyContactMechValueMap.put("contactMech", contactMech); @@ -110,7 +110,7 @@ } try { - List partyContactMechPurposes = partyContactMech.getRelated("PartyContactMechPurpose"); + List<GenericValue> partyContactMechPurposes = partyContactMech.getRelated("PartyContactMechPurpose"); if (!showOld) partyContactMechPurposes = EntityUtil.filterByDate(partyContactMechPurposes, true); partyContactMechValueMap.put("partyContactMechPurposes", partyContactMechPurposes); @@ -133,17 +133,16 @@ return partyContactMechValueMaps; } - public static List getFacilityContactMechValueMaps(GenericDelegator delegator, String facilityId, boolean showOld, String contactMechTypeId) { - List facilityContactMechValueMaps = FastList.newInstance(); + public static List<Map<String, Object>> getFacilityContactMechValueMaps(GenericDelegator delegator, String facilityId, boolean showOld, String contactMechTypeId) { + List<Map<String, Object>> facilityContactMechValueMaps = FastList.newInstance(); - Iterator allFacilityContactMechs = null; + List<GenericValue> allFacilityContactMechs = null; try { - List tempCol = delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId)); + List<GenericValue> tempCol = delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId)); if(contactMechTypeId != null) { - List tempColTemp = FastList.newInstance(); - for(Iterator iterator = tempCol.iterator(); iterator.hasNext();) { - GenericValue partyContactMech = (GenericValue) iterator.next(); + List<GenericValue> tempColTemp = FastList.newInstance(); + for (GenericValue partyContactMech: tempCol) { GenericValue contactMech = delegator.getRelatedOne("ContactMech", partyContactMech); if(contactMech != null && contactMechTypeId.equals(contactMech.getString("contactMechTypeId"))) { tempColTemp.add(partyContactMech); @@ -153,13 +152,14 @@ tempCol = tempColTemp; } if (!showOld) tempCol = EntityUtil.filterByDate(tempCol, true); - allFacilityContactMechs = UtilMisc.toIterator(tempCol); + allFacilityContactMechs = tempCol; } catch (GenericEntityException e) { Debug.logWarning(e, module); } - while (allFacilityContactMechs != null && allFacilityContactMechs.hasNext()) { - GenericValue facilityContactMech = (GenericValue) allFacilityContactMechs.next(); + if (allFacilityContactMechs == null) return facilityContactMechValueMaps; + + for (GenericValue facilityContactMech: allFacilityContactMechs) { GenericValue contactMech = null; try { @@ -168,7 +168,7 @@ Debug.logWarning(e, module); } if (contactMech != null) { - Map facilityContactMechValueMap = FastMap.newInstance(); + Map<String, Object> facilityContactMechValueMap = FastMap.newInstance(); facilityContactMechValueMaps.add(facilityContactMechValueMap); facilityContactMechValueMap.put("contactMech", contactMech); @@ -181,7 +181,7 @@ } try { - List facilityContactMechPurposes = facilityContactMech.getRelated("FacilityContactMechPurpose"); + List<GenericValue> facilityContactMechPurposes = facilityContactMech.getRelated("FacilityContactMechPurpose"); if (!showOld) facilityContactMechPurposes = EntityUtil.filterByDate(facilityContactMechPurposes, true); facilityContactMechValueMap.put("facilityContactMechPurposes", facilityContactMechPurposes); @@ -207,26 +207,25 @@ public static void getOrderContactMechValueMaps(PageContext pageContext, String orderId, String orderContactMechValueMapsAttr) { GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator"); - List maps = getOrderContactMechValueMaps(delegator, orderId); + List<Map<String, GenericValue>> maps = getOrderContactMechValueMaps(delegator, orderId); if (maps != null && maps.size() > 0) { pageContext.setAttribute(orderContactMechValueMapsAttr, maps); } } - public static List getOrderContactMechValueMaps(GenericDelegator delegator, String orderId) { - List orderContactMechValueMaps = FastList.newInstance(); + public static List<Map<String, GenericValue>> getOrderContactMechValueMaps(GenericDelegator delegator, String orderId) { + List<Map<String, GenericValue>> orderContactMechValueMaps = FastList.newInstance(); - Iterator allOrderContactMechs = null; + List<GenericValue> allOrderContactMechs = null; try { - Collection tempCol = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId), UtilMisc.toList("contactMechPurposeTypeId")); - - allOrderContactMechs = UtilMisc.toIterator(tempCol); + allOrderContactMechs = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId), UtilMisc.toList("contactMechPurposeTypeId")); } catch (GenericEntityException e) { Debug.logWarning(e, module); } - while (allOrderContactMechs != null && allOrderContactMechs.hasNext()) { - GenericValue orderContactMech = (GenericValue) allOrderContactMechs.next(); + if (allOrderContactMechs == null) return orderContactMechValueMaps; + + for (GenericValue orderContactMech: allOrderContactMechs) { GenericValue contactMech = null; try { @@ -235,7 +234,7 @@ Debug.logWarning(e, module); } if (contactMech != null) { - Map orderContactMechValueMap = FastMap.newInstance(); + Map<String, GenericValue> orderContactMechValueMap = FastMap.newInstance(); orderContactMechValueMaps.add(orderContactMechValueMap); orderContactMechValueMap.put("contactMech", contactMech); @@ -270,20 +269,20 @@ return orderContactMechValueMaps; } - public static Collection getWorkEffortContactMechValueMaps(GenericDelegator delegator, String workEffortId) { - Collection workEffortContactMechValueMaps = FastList.newInstance(); + public static Collection<Map<String, GenericValue>> getWorkEffortContactMechValueMaps(GenericDelegator delegator, String workEffortId) { + Collection<Map<String, GenericValue>> workEffortContactMechValueMaps = FastList.newInstance(); - Iterator allWorkEffortContactMechs = null; + List<GenericValue> allWorkEffortContactMechs = null; try { - Collection tempCol = delegator.findByAnd("WorkEffortContactMech", UtilMisc.toMap("workEffortId", workEffortId)); - allWorkEffortContactMechs = UtilMisc.toIterator(tempCol); + allWorkEffortContactMechs = delegator.findByAnd("WorkEffortContactMech", UtilMisc.toMap("workEffortId", workEffortId)); } catch (GenericEntityException e) { Debug.logWarning(e, module); } - while (allWorkEffortContactMechs != null && allWorkEffortContactMechs.hasNext()) { - GenericValue workEffortContactMech = (GenericValue) allWorkEffortContactMechs.next(); + if (allWorkEffortContactMechs == null) return null; + + for (GenericValue workEffortContactMech: allWorkEffortContactMechs) { GenericValue contactMech = null; try { @@ -292,7 +291,7 @@ Debug.logWarning(e, module); } if (contactMech != null) { - Map workEffortContactMechValueMap = FastMap.newInstance(); + Map<String, GenericValue> workEffortContactMechValueMap = FastMap.newInstance(); workEffortContactMechValueMaps.add(workEffortContactMechValueMap); workEffortContactMechValueMap.put("contactMech", contactMech); @@ -319,7 +318,7 @@ return workEffortContactMechValueMaps.size() > 0 ? workEffortContactMechValueMaps : null; } - public static void getContactMechAndRelated(ServletRequest request, String partyId, Map target) { + public static void getContactMechAndRelated(ServletRequest request, String partyId, Map<String, Object> target) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); boolean tryEntity = true; @@ -348,7 +347,7 @@ target.put("contactMechId", contactMechId); // try to find a PartyContactMech with a valid date range - List partyContactMechs = null; + List<GenericValue> partyContactMechs = null; try { partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId)), true); @@ -361,7 +360,7 @@ if (partyContactMech != null) { target.put("partyContactMech", partyContactMech); - Collection partyContactMechPurposes = null; + Collection<GenericValue> partyContactMechPurposes = null; try { partyContactMechPurposes = EntityUtil.filterByDate(partyContactMech.getRelated("PartyContactMechPurpose"), true); @@ -396,8 +395,8 @@ Debug.logWarning(e, module); } - Collection purposeTypes = FastList.newInstance(); - Iterator typePurposes = null; + Collection<GenericValue> purposeTypes = FastList.newInstance(); + Iterator<GenericValue> typePurposes = null; try { typePurposes = UtilMisc.toIterator(delegator.findByAnd("ContactMechTypePurpose", UtilMisc.toMap("contactMechTypeId", contactMechTypeId))); @@ -405,7 +404,7 @@ Debug.logWarning(e, module); } while (typePurposes != null && typePurposes.hasNext()) { - GenericValue contactMechTypePurpose = (GenericValue) typePurposes.next(); + GenericValue contactMechTypePurpose = typePurposes.next(); GenericValue contactMechPurposeType = null; try { @@ -473,10 +472,10 @@ } if ("true".equals(request.getParameter("useValues"))) tryEntity = true; - target.put("tryEntity", new Boolean(tryEntity)); + target.put("tryEntity", Boolean.valueOf(tryEntity)); try { - Collection contactMechTypes = delegator.findList("ContactMechType", null, null, null, null, true); + Collection<GenericValue> contactMechTypes = delegator.findList("ContactMechType", null, null, null, null, true); if (contactMechTypes != null) { target.put("contactMechTypes", contactMechTypes); @@ -492,16 +491,13 @@ * @param purposeTypes A List of ContactMechPurposeType ids which will be checked one at a time until a valid contact mech is found * @return */ - public static GenericValue getFacilityContactMechByPurpose(GenericDelegator delegator, String facilityId, List purposeTypes) { + public static GenericValue getFacilityContactMechByPurpose(GenericDelegator delegator, String facilityId, List<String> purposeTypes) { if (UtilValidate.isEmpty(facilityId)) return null; if (UtilValidate.isEmpty(purposeTypes)) return null; - Iterator ptIt = purposeTypes.iterator(); - while (ptIt.hasNext()) { - String purposeType = (String) ptIt.next(); - - List facilityContactMechPurposes = null; - List conditionList = FastList.newInstance(); + for (String purposeType: purposeTypes) { + List<GenericValue> facilityContactMechPurposes = null; + List<EntityCondition> conditionList = FastList.newInstance(); conditionList.add(EntityCondition.makeCondition("facilityId", facilityId)); conditionList.add(EntityCondition.makeCondition("contactMechPurposeTypeId", purposeType)); conditionList.add(EntityCondition.makeConditionDate("fromDate", "thruDate")); @@ -511,11 +507,9 @@ } catch (GenericEntityException e) { Debug.logWarning(e, module); } - Iterator fcmpIt = facilityContactMechPurposes.iterator(); - while (fcmpIt.hasNext()) { - GenericValue facilityContactMechPurpose = (GenericValue) fcmpIt.next(); + for (GenericValue facilityContactMechPurpose: facilityContactMechPurposes) { String contactMechId = facilityContactMechPurpose.getString("contactMechId"); - List facilityContactMechs = null; + List<GenericValue> facilityContactMechs = null; conditionList = FastList.newInstance(); conditionList.add(EntityCondition.makeCondition("facilityId", facilityId)); conditionList.add(EntityCondition.makeCondition("contactMechId", contactMechId)); @@ -535,7 +529,7 @@ return null; } - public static void getFacilityContactMechAndRelated(ServletRequest request, String facilityId, Map target) { + public static void getFacilityContactMechAndRelated(ServletRequest request, String facilityId, Map<String, Object> target) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); boolean tryEntity = true; @@ -564,7 +558,7 @@ target.put("contactMechId", contactMechId); // try to find a PartyContactMech with a valid date range - List facilityContactMechs = null; + List<GenericValue> facilityContactMechs = null; try { facilityContactMechs = EntityUtil.filterByDate(delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId, "contactMechId", contactMechId)), true); @@ -577,7 +571,7 @@ if (facilityContactMech != null) { target.put("facilityContactMech", facilityContactMech); - Collection facilityContactMechPurposes = null; + Collection<GenericValue> facilityContactMechPurposes = null; try { facilityContactMechPurposes = EntityUtil.filterByDate(facilityContactMech.getRelated("FacilityContactMechPurpose"), true); @@ -612,8 +606,8 @@ Debug.logWarning(e, module); } - Collection purposeTypes = FastList.newInstance(); - Iterator typePurposes = null; + Collection<GenericValue> purposeTypes = FastList.newInstance(); + Iterator<GenericValue> typePurposes = null; try { typePurposes = UtilMisc.toIterator(delegator.findByAnd("ContactMechTypePurpose", UtilMisc.toMap("contactMechTypeId", contactMechTypeId))); @@ -621,7 +615,7 @@ Debug.logWarning(e, module); } while (typePurposes != null && typePurposes.hasNext()) { - GenericValue contactMechTypePurpose = (GenericValue) typePurposes.next(); + GenericValue contactMechTypePurpose = typePurposes.next(); GenericValue contactMechPurposeType = null; try { @@ -689,7 +683,7 @@ } if ("true".equals(request.getParameter("useValues"))) tryEntity = true; - target.put("tryEntity", new Boolean(tryEntity)); + target.put("tryEntity", Boolean.valueOf(tryEntity)); try { Collection contactMechTypes = delegator.findList("ContactMechType", null, null, null, null, true); @@ -702,19 +696,21 @@ } } - public static List getPartyPostalAddresses(ServletRequest request, String partyId, String curContactMechId) { + public static List<Map<String, Object>> getPartyPostalAddresses(ServletRequest request, String partyId, String curContactMechId) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); - List postalAddressInfos = FastList.newInstance(); + List<Map<String, Object>> postalAddressInfos = FastList.newInstance(); - Iterator allPartyContactMechs = null; + List<GenericValue> allPartyContactMechs = null; try { - allPartyContactMechs = UtilMisc.toIterator(EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId)), true)); + allPartyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId)), true); } catch (GenericEntityException e) { Debug.logWarning(e, module); } - while (allPartyContactMechs != null && allPartyContactMechs.hasNext()) { - GenericValue partyContactMech = (GenericValue) allPartyContactMechs.next(); + + if (allPartyContactMechs == null) return postalAddressInfos; + + for (GenericValue partyContactMech: allPartyContactMechs) { GenericValue contactMech = null; try { @@ -723,7 +719,7 @@ Debug.logWarning(e, module); } if (contactMech != null && "POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId")) && !contactMech.getString("contactMechId").equals(curContactMechId)) { - Map postalAddressInfo = FastMap.newInstance(); + Map<String, Object> postalAddressInfo = FastMap.newInstance(); postalAddressInfos.add(postalAddressInfo); postalAddressInfo.put("contactMech", contactMech); @@ -737,7 +733,7 @@ } try { - List partyContactMechPurposes = EntityUtil.filterByDate(partyContactMech.getRelated("PartyContactMechPurpose"), true); + List<GenericValue> partyContactMechPurposes = EntityUtil.filterByDate(partyContactMech.getRelated("PartyContactMechPurpose"), true); postalAddressInfo.put("partyContactMechPurposes", partyContactMechPurposes); } catch (GenericEntityException e) { Debug.logWarning(e, module); @@ -748,12 +744,12 @@ return postalAddressInfos; } - public static Map getCurrentPostalAddress(ServletRequest request, String partyId, String curContactMechId) { + public static Map<String, Object> getCurrentPostalAddress(ServletRequest request, String partyId, String curContactMechId) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); - Map results = FastMap.newInstance(); + Map<String, Object> results = FastMap.newInstance(); if (curContactMechId != null) { - List partyContactMechs = null; + List<GenericValue> partyContactMechs = null; try { partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", curContactMechId)), true); @@ -771,7 +767,7 @@ Debug.logWarning(e, module); } - Collection curPartyContactMechPurposes = null; + Collection<GenericValue> curPartyContactMechPurposes = null; try { curPartyContactMechPurposes = EntityUtil.filterByDate(curPartyContactMech.getRelated("PartyContactMechPurpose"), true); } catch (GenericEntityException e) { @@ -858,14 +854,12 @@ // get all company addresses GenericDelegator delegator = postalAddress.getDelegator(); - List postalAddresses = FastList.newInstance(); + List<GenericValue> postalAddresses = FastList.newInstance(); try { - List partyContactMechs = delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", companyPartyId)); + List<GenericValue> partyContactMechs = delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", companyPartyId)); partyContactMechs = EntityUtil.filterByDate(partyContactMechs); if (partyContactMechs != null) { - Iterator pci = partyContactMechs.iterator(); - while (pci.hasNext()) { - GenericValue pcm = (GenericValue) pci.next(); + for (GenericValue pcm: partyContactMechs) { GenericValue addr = pcm.getRelatedOne("PostalAddress"); if (addr != null) { postalAddresses.add(addr); @@ -877,9 +871,7 @@ } if (postalAddresses != null) { - Iterator pai = postalAddresses.iterator(); - while (pai.hasNext()) { - GenericValue addr = (GenericValue) pai.next(); + for (GenericValue addr: postalAddresses) { String thisAddr1 = addr.getString("address1"); String thisAddr2 = addr.getString("address2"); String thisState = addr.getString("stateProvinceGeoId"); @@ -940,7 +932,7 @@ } // no shortcut, try the longcut to see if there is something with a geoCode associated to the countryGeoId - List geoAssocAndGeoToList = delegator.findByAndCache("GeoAssocAndGeoTo", + List<GenericValue> geoAssocAndGeoToList = delegator.findByAndCache("GeoAssocAndGeoTo", UtilMisc.toMap("geoIdFrom", postalAddress.getString("countryGeoId"), "geoCode", postalAddress.getString("postalCode"), "geoAssocTypeId", "REGIONS")); GenericValue geoAssocAndGeoTo = EntityUtil.getFirst(geoAssocAndGeoToList); if (geoAssocAndGeoTo != null) { Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java?rev=685936&r1=685935&r2=685936&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/content/PartyContentWrapper.java Thu Aug 14 08:12:17 2008 @@ -47,7 +47,7 @@ public static final String module = PartyContentWrapper.class.getName(); public static final String CACHE_KEY_SEPARATOR = "::"; - public static UtilCache partyContentCache = new UtilCache("party.content.rendered", true); + public static UtilCache<String, String> partyContentCache = new UtilCache<String, String>("party.content.rendered", true); protected LocalDispatcher dispatcher; protected GenericValue party; @@ -86,7 +86,7 @@ } } - public List getList(String contentTypeId) { + public List<String> getList(String contentTypeId) { try { return getPartyContentTextList(party, contentTypeId, locale, mimeTypeId, party.getDelegator(), dispatcher); } catch (Exception e) { @@ -136,7 +136,7 @@ try { if (useCache && partyContentCache.get(cacheKey) != null) { - return (String) partyContentCache.get(cacheKey); + return partyContentCache.get(cacheKey); } Writer outWriter = new StringWriter(); @@ -223,24 +223,22 @@ } if (partyContent != null) { // when rendering the product content, always include the Product and ProductContent records that this comes from - Map inContext = FastMap.newInstance(); + Map<String, GenericValue> inContext = FastMap.newInstance(); inContext.put("party", party); inContext.put("partyContent", partyContent); ContentWorker.renderContentAsText(dispatcher, delegator, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); } } - public static List getPartyContentTextList(GenericValue party, String partyContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { - List partyContentList = delegator.findByAndCache("PartyContent", UtilMisc.toMap("partyId", party.getString("partyId"), "partyContentTypeId", partyContentTypeId), UtilMisc.toList("-fromDate")); + public static List<String> getPartyContentTextList(GenericValue party, String partyContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { + List<GenericValue> partyContentList = delegator.findByAndCache("PartyContent", UtilMisc.toMap("partyId", party.getString("partyId"), "partyContentTypeId", partyContentTypeId), UtilMisc.toList("-fromDate")); partyContentList = EntityUtil.filterByDate(partyContentList); - List contentList = FastList.newInstance(); + List<String> contentList = FastList.newInstance(); if (partyContentList != null) { - Iterator i = partyContentList.iterator(); - while (i.hasNext()) { - GenericValue partyContent = (GenericValue) i.next(); + for (GenericValue partyContent: partyContentList) { StringWriter outWriter = new StringWriter(); - Map inContext = FastMap.newInstance(); + Map<String, GenericValue> inContext = FastMap.newInstance(); inContext.put("party", party); inContext.put("partyContent", partyContent); ContentWorker.renderContentAsText(dispatcher, delegator, partyContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); @@ -264,7 +262,7 @@ throw new IllegalArgumentException("GenericDelegator missing"); } - List partyContentList = null; + List<GenericValue> partyContentList = null; try { partyContentList = delegator.findByAndCache("PartyContent", UtilMisc.toMap("partyId", partyId, "partyContentTypeId", partyContentTypeId), UtilMisc.toList("-fromDate")); } catch (GeneralException e) { Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyHelper.java?rev=685936&r1=685935&r2=685936&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyHelper.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyHelper.java Thu Aug 14 08:12:17 2008 @@ -86,7 +86,7 @@ if (partyValue == null) { return ""; } - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); ModelEntity modelEntity = partyValue.getModelEntity(); if (modelEntity.isField("firstName") && modelEntity.isField("middleName") && modelEntity.isField("lastName")) { if (lastNameFirst) { Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyRelationshipServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyRelationshipServices.java?rev=685936&r1=685935&r2=685936&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyRelationshipServices.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/party/PartyRelationshipServices.java Thu Aug 14 08:12:17 2008 @@ -19,9 +19,10 @@ package org.ofbiz.party.party; -import java.util.HashMap; import java.util.Map; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericDelegator; @@ -45,8 +46,8 @@ *@param context Map containing the input parameters *@return Map with the result of the service, the output parameters */ - public static Map createPartyRelationshipType(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> createPartyRelationshipType(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); GenericDelegator delegator = ctx.getDelegator(); Security security = ctx.getSecurity(); GenericValue userLogin = (GenericValue) context.get("userLogin"); |
Free forum by Nabble | Edit this page |