Author: mrisaliti
Date: Sun Jan 30 17:25:13 2011 New Revision: 1065325 URL: http://svn.apache.org/viewvc?rev=1065325&view=rev Log: Remove java compilation warnings of ShoppingListServices/ShoppingListEvents (OFBIZ-4102) Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java?rev=1065325&r1=1065324&r2=1065325&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListEvents.java Sun Jan 30 17:25:13 2011 @@ -20,10 +20,7 @@ package org.ofbiz.order.shoppinglist; import java.math.BigDecimal; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -32,6 +29,9 @@ import javax.servlet.http.HttpServletReq import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javolution.util.FastList; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilDateTime; @@ -101,7 +101,7 @@ public class ShoppingListEvents { if (UtilValidate.isEmpty(shoppingListId)) { // create a new shopping list - Map newListResult = null; + Map<String, Object> newListResult = null; try { newListResult = dispatcher.runSync("createShoppingList", UtilMisc.<String, Object>toMap("userLogin", userLogin, "productStoreId", cart.getProductStoreId(), "partyId", cart.getOrderPartyId(), "shoppingListTypeId", shoppingListTypeId, "currencyUom", cart.getCurrency())); } catch (GenericServiceException e) { @@ -145,9 +145,9 @@ public class ShoppingListEvents { ShoppingCartItem item = cart.findCartItem(cartIdInt.intValue()); if (allowPromo || !item.getIsPromo()) { Debug.logInfo("Adding cart item to shopping list [" + shoppingListId + "], allowPromo=" + allowPromo + ", item.getIsPromo()=" + item.getIsPromo() + ", item.getProductId()=" + item.getProductId() + ", item.getQuantity()=" + item.getQuantity(), module); - Map serviceResult = null; + Map<String, Object> serviceResult = null; try { - Map ctx = UtilMisc.toMap("userLogin", userLogin, "shoppingListId", shoppingListId, "productId", item.getProductId(), "quantity", item.getQuantity()); + Map<String, Object> ctx = UtilMisc.<String, Object>toMap("userLogin", userLogin, "shoppingListId", shoppingListId, "productId", item.getProductId(), "quantity", item.getQuantity()); ctx.put("reservStart", item.getReservStart()); ctx.put("reservLength", item.getReservLength()); ctx.put("reservPersons", item.getReservPersons()); @@ -210,7 +210,7 @@ public class ShoppingListEvents { // get the shopping list GenericValue shoppingList = null; - List shoppingListItems = null; + List<GenericValue> shoppingListItems = null; try { shoppingList = delegator.findByPrimaryKey("ShoppingList", UtilMisc.toMap("shoppingListId", shoppingListId)); if (shoppingList == null) { @@ -220,16 +220,16 @@ public class ShoppingListEvents { shoppingListItems = shoppingList.getRelated("ShoppingListItem"); if (shoppingListItems == null) { - shoppingListItems = new LinkedList(); + shoppingListItems = FastList.newInstance(); } // include all items of child lists if flagged to do so if (includeChild) { - List childShoppingLists = shoppingList.getRelated("ChildShoppingList"); - Iterator ci = childShoppingLists.iterator(); + List<GenericValue> childShoppingLists = shoppingList.getRelated("ChildShoppingList"); + Iterator<GenericValue> ci = childShoppingLists.iterator(); while (ci.hasNext()) { - GenericValue v = (GenericValue) ci.next(); - List items = v.getRelated("ShoppingListItem"); + GenericValue v = ci.next(); + List<GenericValue> items = v.getRelated("ShoppingListItem"); shoppingListItems.addAll(items); } } @@ -252,13 +252,13 @@ public class ShoppingListEvents { } // get the survey info for all the items - Map shoppingListSurveyInfo = getItemSurveyInfos(shoppingListItems); + Map<String, List<String>> shoppingListSurveyInfo = getItemSurveyInfos(shoppingListItems); // add the items StringBuilder eventMessage = new StringBuilder(); - Iterator i = shoppingListItems.iterator(); + Iterator<GenericValue> i = shoppingListItems.iterator(); while (i.hasNext()) { - GenericValue shoppingListItem = (GenericValue) i.next(); + GenericValue shoppingListItem = i.next(); String productId = shoppingListItem.getString("productId"); BigDecimal quantity = shoppingListItem.getBigDecimal("quantity"); Timestamp reservStart = shoppingListItem.getTimestamp("reservStart"); @@ -271,7 +271,7 @@ public class ShoppingListEvents { String listId = shoppingListItem.getString("shoppingListId"); String itemId = shoppingListItem.getString("shoppingListItemSeqId"); - Map attributes = new HashMap(); + Map<String, Object> attributes = FastMap.newInstance(); // list items are noted in the shopping cart if (setAsListItem) { attributes.put("shoppingListId", listId); @@ -295,17 +295,17 @@ public class ShoppingListEvents { } else { cart.addOrIncreaseItem(productId, null, quantity, reservStart, reservLength, reservPersons, null, null, null, null, null, attributes, prodCatalogId, configWrapper, null, null, null, dispatcher); } - Map messageMap = UtilMisc.toMap("productId", productId); + Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productId", productId); errMsg = UtilProperties.getMessage(resource_error,"shoppinglistevents.added_product_to_cart", messageMap, cart.getLocale()); eventMessage.append(errMsg).append("\n"); } catch (CartItemModifyException e) { Debug.logWarning(e, UtilProperties.getMessage(resource_error,"OrderProblemsAddingItemFromListToCart", cart.getLocale())); - Map messageMap = UtilMisc.toMap("productId", productId); + Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productId", productId); errMsg = UtilProperties.getMessage(resource_error,"shoppinglistevents.problem_adding_product_to_cart", messageMap, cart.getLocale()); eventMessage.append(errMsg).append("\n"); } catch (ItemNotFoundException e) { Debug.logWarning(e, UtilProperties.getMessage(resource_error,"OrderProductNotFound", cart.getLocale())); - Map messageMap = UtilMisc.toMap("productId", productId); + Map<String, Object> messageMap = UtilMisc.<String, Object>toMap("productId", productId); errMsg = UtilProperties.getMessage(resource_error,"shoppinglistevents.problem_adding_product_to_cart", messageMap, cart.getLocale()); eventMessage.append(errMsg).append("\n"); } @@ -334,13 +334,13 @@ public class ShoppingListEvents { // do nothing, just won't pass to service if it is null } - Map serviceInMap = new HashMap(); + Map<String, Object> serviceInMap = FastMap.newInstance(); serviceInMap.put("shoppingListId", request.getParameter("shoppingListId")); serviceInMap.put("shoppingListItemSeqId", request.getParameter("shoppingListItemSeqId")); serviceInMap.put("productId", request.getParameter("add_product_id")); serviceInMap.put("userLogin", userLogin); if (quantity != null) serviceInMap.put("quantity", quantity); - Map result = null; + Map<String, Object> result = null; try { result = dispatcher.runSync("updateShoppingListItem", serviceInMap); } catch (GenericServiceException e) { @@ -369,8 +369,8 @@ public class ShoppingListEvents { String autoSaveListId = null; // TODO: add sorting, just in case there are multiple... - Map findMap = UtilMisc.toMap("partyId", partyId, "productStoreId", productStoreId, "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); - List existingLists = delegator.findByAnd("ShoppingList", findMap); + Map<String, Object> findMap = UtilMisc.<String, Object>toMap("partyId", partyId, "productStoreId", productStoreId, "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); + List<GenericValue> existingLists = delegator.findByAnd("ShoppingList", findMap); Debug.logInfo("Finding existing auto-save shopping list with: \nfindMap: " + findMap + "\nlists: " + existingLists, module); GenericValue list = null; @@ -380,8 +380,8 @@ public class ShoppingListEvents { } if (list == null && dispatcher != null && userLogin != null) { - Map listFields = UtilMisc.toMap("userLogin", userLogin, "productStoreId", productStoreId, "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); - Map newListResult = dispatcher.runSync("createShoppingList", listFields); + Map<String, Object> listFields = UtilMisc.<String, Object>toMap("userLogin", userLogin, "productStoreId", productStoreId, "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME); + Map<String, Object> newListResult = dispatcher.runSync("createShoppingList", listFields); if (newListResult != null) { autoSaveListId = (String) newListResult.get("shoppingListId"); @@ -522,12 +522,12 @@ public class ShoppingListEvents { /** * Creates records for survey responses on survey items */ - public static int makeListItemSurveyResp(Delegator delegator, GenericValue item, List surveyResps) throws GenericEntityException { + public static int makeListItemSurveyResp(Delegator delegator, GenericValue item, List<String> surveyResps) throws GenericEntityException { if (UtilValidate.isNotEmpty(surveyResps)) { - Iterator i = surveyResps.iterator(); + Iterator<String> i = surveyResps.iterator(); int count = 0; while (i.hasNext()) { - String responseId = (String) i.next(); + String responseId = i.next(); GenericValue listResp = delegator.makeValue("ShoppingListItemSurvey"); listResp.set("shoppingListId", item.getString("shoppingListId")); listResp.set("shoppingListItemSeqId", item.getString("shoppingListItemSeqId")); @@ -543,12 +543,12 @@ public class ShoppingListEvents { /** * Returns Map keyed on item sequence ID containing a list of survey response IDs */ - public static Map getItemSurveyInfos(List items) { - Map surveyInfos = new HashMap(); + public static Map<String, List<String>> getItemSurveyInfos(List<GenericValue> items) { + Map<String, List<String>> surveyInfos = FastMap.newInstance(); if (UtilValidate.isNotEmpty(items)) { - Iterator itemIt = items.iterator(); + Iterator<GenericValue> itemIt = items.iterator(); while (itemIt.hasNext()) { - GenericValue item = (GenericValue) itemIt.next(); + GenericValue item = itemIt.next(); String listId = item.getString("shoppingListId"); String itemId = item.getString("shoppingListItemSeqId"); surveyInfos.put(listId + "." + itemId, getItemSurveyInfo(item)); @@ -561,9 +561,9 @@ public class ShoppingListEvents { /** * Returns a list of survey response IDs for a shopping list item */ - public static List getItemSurveyInfo(GenericValue item) { - List responseIds = new ArrayList(); - List surveyResp = null; + public static List<String> getItemSurveyInfo(GenericValue item) { + List<String> responseIds = FastList.newInstance(); + List<GenericValue> surveyResp = null; try { surveyResp = item.getRelated("ShoppingListItemSurvey"); } catch (GenericEntityException e) { @@ -571,9 +571,9 @@ public class ShoppingListEvents { } if (UtilValidate.isNotEmpty(surveyResp)) { - Iterator respIt = surveyResp.iterator(); + Iterator<GenericValue> respIt = surveyResp.iterator(); while (respIt.hasNext()) { - GenericValue resp = (GenericValue) respIt.next(); + GenericValue resp = respIt.next(); responseIds.add(resp.getString("surveyResponseId")); } } Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java?rev=1065325&r1=1065324&r2=1065325&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java Sun Jan 30 17:25:13 2011 @@ -20,12 +20,13 @@ package org.ofbiz.order.shoppinglist; import java.math.BigDecimal; import java.sql.Timestamp; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilDateTime; @@ -36,6 +37,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.entity.util.EntityListIterator; @@ -64,7 +66,7 @@ public class ShoppingListServices { public static final String module = ShoppingListServices.class.getName(); public static final String resource_error = "OrderErrorUiLabels"; - public static Map setShoppingListRecurrence(DispatchContext dctx, Map context) { + public static Map<String, Object> setShoppingListRecurrence(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); Timestamp startDate = (Timestamp) context.get("startDateTime"); Timestamp endDate = (Timestamp) context.get("endDateTime"); @@ -108,13 +110,13 @@ public class ShoppingListServices { } Debug.log("Next Recurrence - " + UtilDateTime.getTimestamp(recInfo.next()), module); - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("recurrenceInfoId", recInfo.getID()); return result; } - public static Map createListReorders(DispatchContext dctx, Map context) { + public static Map<String, Object> createListReorders(DispatchContext dctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); @@ -125,10 +127,10 @@ public class ShoppingListServices { try { beganTransaction = TransactionUtil.begin(); - List exprs = UtilMisc.toList(EntityCondition.makeCondition("shoppingListTypeId", EntityOperator.EQUALS, "SLT_AUTO_REODR"), + List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("shoppingListTypeId", EntityOperator.EQUALS, "SLT_AUTO_REODR"), EntityCondition.makeCondition("isActive", EntityOperator.EQUALS, "Y")); EntityCondition cond = EntityCondition.makeCondition(exprs, EntityOperator.AND); - List order = UtilMisc.toList("-lastOrderedDate"); + List<String> order = UtilMisc.toList("-lastOrderedDate"); EntityListIterator eli = null; eli = delegator.find("ShoppingList", cond, null, null, order, null); @@ -167,14 +169,14 @@ public class ShoppingListServices { CheckOutHelper helper = new CheckOutHelper(dispatcher, delegator, listCart); // store the order - Map createResp = helper.createOrder(userLogin); + Map<String, Object> createResp = helper.createOrder(userLogin); if (createResp != null && ServiceUtil.isError(createResp)) { Debug.logError("Cannot create order for shopping list - " + shoppingList, module); } else { String orderId = (String) createResp.get("orderId"); // authorize the payments - Map payRes = null; + Map<String, Object> payRes = null; try { payRes = helper.processPayment(ProductStoreWorker.getProductStore(listCart.getProductStoreId(), delegator), userLogin); } catch (GeneralException e) { @@ -225,9 +227,9 @@ public class ShoppingListServices { } } - public static Map splitShipmentMethodString(DispatchContext dctx, Map context) { + public static Map<String, Object> splitShipmentMethodString(DispatchContext dctx, Map<String, ? extends Object> context) { String shipmentMethodString = (String) context.get("shippingMethodString"); - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); if (UtilValidate.isNotEmpty(shipmentMethodString)) { int delimiterPos = shipmentMethodString.indexOf('@'); @@ -244,7 +246,7 @@ public class ShoppingListServices { return result; } - public static Map makeListFromOrder(DispatchContext dctx, Map context) { + public static Map<String, Object> makeListFromOrder(DispatchContext dctx, Map<String, ? extends Object> context) { LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); @@ -279,14 +281,14 @@ public class ShoppingListServices { partyId = userLogin.getString("partyId"); } - Map serviceCtx = UtilMisc.toMap("userLogin", userLogin, "partyId", partyId, + Map<String, Object> serviceCtx = UtilMisc.<String, Object>toMap("userLogin", userLogin, "partyId", partyId, "productStoreId", productStoreId, "listName", "List Created From Order #" + orderId); if (UtilValidate.isNotEmpty(shoppingListTypeId)) { serviceCtx.put("shoppingListTypeId", shoppingListTypeId); } - Map newListResult = null; + Map<String, Object> newListResult = null; try { newListResult = dispatcher.runSync("createShoppingList", serviceCtx); @@ -319,14 +321,14 @@ public class ShoppingListServices { return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderUnableToLoadOrderReadHelper", UtilMisc.toMap("orderId",orderId), locale)); } - List orderItems = orh.getOrderItems(); - Iterator i = orderItems.iterator(); + List<GenericValue> orderItems = orh.getOrderItems(); + Iterator<GenericValue> i = orderItems.iterator(); String productId = null; while (i.hasNext()) { - GenericValue orderItem = (GenericValue) i.next(); + GenericValue orderItem = i.next(); productId = orderItem.getString("productId"); if (UtilValidate.isNotEmpty(productId)) { - Map ctx = UtilMisc.toMap("userLogin", userLogin, "shoppingListId", shoppingListId, "productId", + Map<String, Object> ctx = UtilMisc.<String, Object>toMap("userLogin", userLogin, "shoppingListId", shoppingListId, "productId", orderItem.get("productId"), "quantity", orderItem.get("quantity")); if ("AGGREGATED_CONF".equals(ProductWorker.getProductTypeId(delegator, productId))) { try { @@ -340,7 +342,7 @@ public class ShoppingListServices { Debug.logError(e, module); } } - Map serviceResult = null; + Map<String, Object> serviceResult = null; try { serviceResult = dispatcher.runSync("createShoppingListItem", ctx); } catch (GenericServiceException e) { @@ -356,7 +358,7 @@ public class ShoppingListServices { GenericValue paymentPref = EntityUtil.getFirst(orh.getPaymentPreferences()); GenericValue shipGroup = EntityUtil.getFirst(orh.getOrderItemShipGroups()); - Map slCtx = new HashMap(); + Map<String, Object> slCtx = FastMap.newInstance(); slCtx.put("shipmentMethodTypeId", shipGroup.get("shipmentMethodTypeId")); slCtx.put("carrierRoleTypeId", shipGroup.get("carrierRoleTypeId")); slCtx.put("carrierPartyId", shipGroup.get("carrierPartyId")); @@ -371,7 +373,7 @@ public class ShoppingListServices { slCtx.put("shoppingListId", shoppingListId); slCtx.put("userLogin", userLogin); - Map slUpResp = null; + Map<String, Object> slUpResp = null; try { slUpResp = dispatcher.runSync("updateShoppingList", slCtx); } catch (GenericServiceException e) { @@ -383,7 +385,7 @@ public class ShoppingListServices { } } - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("shoppingListId", shoppingListId); return result; @@ -442,7 +444,7 @@ public class ShoppingListServices { locale = Locale.getDefault(); } - List items = null; + List<GenericValue> items = null; try { items = shoppingList.getRelated("ShoppingListItem", UtilMisc.toList("shoppingListItemSeqId")); } catch (GenericEntityException e) { @@ -465,10 +467,10 @@ public class ShoppingListServices { } - Iterator i = items.iterator(); + Iterator<GenericValue> i = items.iterator(); ProductConfigWrapper configWrapper = null; while (i.hasNext()) { - GenericValue shoppingListItem = (GenericValue) i.next(); + GenericValue shoppingListItem = i.next(); String productId = shoppingListItem.getString("productId"); BigDecimal quantity = shoppingListItem.getBigDecimal("quantity"); Timestamp reservStart = shoppingListItem.getTimestamp("reservStart"); @@ -498,7 +500,7 @@ public class ShoppingListServices { // list items are noted in the shopping cart String listId = shoppingListItem.getString("shoppingListId"); String itemId = shoppingListItem.getString("shoppingListItemSeqId"); - Map attributes = UtilMisc.toMap("shoppingListId", listId, "shoppingListItemSeqId", itemId); + Map<String, Object> attributes = UtilMisc.<String, Object>toMap("shoppingListId", listId, "shoppingListItemSeqId", itemId); try { listCart.addOrIncreaseItem(productId, null, quantity, reservStart, reservLength, reservPersons, null, null, null, null, null, attributes, null, configWrapper, null, null, null, dispatcher); @@ -553,15 +555,15 @@ public class ShoppingListServices { * @param context - Map containing the input parameters * @return Map with the result of the service, the output parameters */ - public static Map updateShoppingListQuantitiesFromOrder(DispatchContext ctx, Map context) { - Map result = new HashMap(); + public static Map<String, Object> updateShoppingListQuantitiesFromOrder(DispatchContext ctx, Map<String, ? extends Object> context) { + Map<String, Object> result = FastMap.newInstance(); Delegator delegator = ctx.getDelegator(); String orderId = (String) context.get("orderId"); try { - List orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId)); - Iterator iter = orderItems.iterator(); + List<GenericValue> orderItems = delegator.findByAnd("OrderItem", UtilMisc.toMap("orderId", orderId)); + Iterator<GenericValue> iter = orderItems.iterator(); while (iter.hasNext()) { - GenericValue orderItem = (GenericValue) iter.next(); + GenericValue orderItem = iter.next(); String shoppingListId = orderItem.getString("shoppingListId"); String shoppingListItemSeqId = orderItem.getString("shoppingListItemSeqId"); if (UtilValidate.isNotEmpty(shoppingListId)) { |
Free forum by Nabble | Edit this page |