Modified: ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1818329&r1=1818328&r2=1818329&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java Fri Dec 15 20:33:56 2017 @@ -127,37 +127,37 @@ public class ShoppingCart implements Ite private String autoSaveListId = null; /** Holds value of order adjustments. */ - private List<GenericValue> adjustments = new LinkedList<GenericValue>(); + private List<GenericValue> adjustments = new LinkedList<>(); // OrderTerms private boolean orderTermSet = false; - private List<GenericValue> orderTerms = new LinkedList<GenericValue>(); + private List<GenericValue> orderTerms = new LinkedList<>(); - private List<ShoppingCartItem> cartLines = new LinkedList<ShoppingCartItem>(); - private Map<String, ShoppingCartItemGroup> itemGroupByNumberMap = new HashMap<String, ShoppingCartItemGroup>(); + private List<ShoppingCartItem> cartLines = new LinkedList<>(); + private Map<String, ShoppingCartItemGroup> itemGroupByNumberMap = new HashMap<>(); protected long nextGroupNumber = 1; - protected List<CartPaymentInfo> paymentInfo = new LinkedList<ShoppingCart.CartPaymentInfo>(); - private List<CartShipInfo> shipInfo = new LinkedList<ShoppingCart.CartShipInfo>(); - private Map<String, String> contactMechIdsMap = new HashMap<String, String>(); - private Map<String, String> orderAttributes = new HashMap<String, String>(); - private Map<String, Object> attributes = new HashMap<String, Object>(); // user defined attributes + protected List<CartPaymentInfo> paymentInfo = new LinkedList<>(); + private List<CartShipInfo> shipInfo = new LinkedList<>(); + private Map<String, String> contactMechIdsMap = new HashMap<>(); + private Map<String, String> orderAttributes = new HashMap<>(); + private Map<String, Object> attributes = new HashMap<>(); // user defined attributes // Lists of internal/public notes: when the order is stored they are transformed into OrderHeaderNotes - private List<String> internalOrderNotes = new LinkedList<String>(); // internal notes - private List<String> orderNotes = new LinkedList<String>(); // public notes (printed on documents etc.) + private List<String> internalOrderNotes = new LinkedList<>(); // internal notes + private List<String> orderNotes = new LinkedList<>(); // public notes (printed on documents etc.) /** contains a list of partyId for each roleTypeId (key) */ - private Map<String, List<String>> additionalPartyRole = new HashMap<String, List<String>>(); + private Map<String, List<String>> additionalPartyRole = new HashMap<>(); /** these are defaults for all ship groups */ private Timestamp defaultShipAfterDate = null; private Timestamp defaultShipBeforeDate = null; /** Contains a List for each productPromoId (key) containing a productPromoCodeId (or empty string for no code) for each use of the productPromoId */ - private List<ProductPromoUseInfo> productPromoUseInfoList = new LinkedList<ShoppingCart.ProductPromoUseInfo>(); + private List<ProductPromoUseInfo> productPromoUseInfoList = new LinkedList<>(); /** Contains the promo codes entered */ - private Set<String> productPromoCodes = new HashSet<String>(); - private List<GenericValue> freeShippingProductPromoActions = new ArrayList<GenericValue>(); + private Set<String> productPromoCodes = new HashSet<>(); + private List<GenericValue> freeShippingProductPromoActions = new ArrayList<>(); /** Note that even though this is promotion info, it should NOT be cleared when the promos are cleared, it is a preference that will be used in the next promo calculation */ - private Map<GenericPK, String> desiredAlternateGiftByAction = new HashMap<GenericPK, String>(); + private Map<GenericPK, String> desiredAlternateGiftByAction = new HashMap<>(); private Timestamp cartCreatedTs = UtilDateTime.nowTimestamp(); private transient Delegator delegator = null; @@ -213,11 +213,11 @@ public class ShoppingCart implements Ite this.quoteId = cart.getQuoteId(); this.orderAdditionalEmails = cart.getOrderAdditionalEmails(); this.adjustments.addAll(cart.getAdjustments()); - this.contactMechIdsMap = new HashMap<String, String>(cart.getOrderContactMechIds()); - this.freeShippingProductPromoActions = new ArrayList<GenericValue>(cart.getFreeShippingProductPromoActions()); + this.contactMechIdsMap = new HashMap<>(cart.getOrderContactMechIds()); + this.freeShippingProductPromoActions = new ArrayList<>(cart.getFreeShippingProductPromoActions()); this.desiredAlternateGiftByAction = cart.getAllDesiredAlternateGiftByActionCopy(); this.productPromoUseInfoList.addAll(cart.productPromoUseInfoList); - this.productPromoCodes = new HashSet<String>(cart.productPromoCodes); + this.productPromoCodes = new HashSet<>(cart.productPromoCodes); this.locale = cart.getLocale(); this.currencyUom = cart.getCurrency(); this.externalId = cart.getExternalId(); @@ -232,16 +232,18 @@ public class ShoppingCart implements Ite this.autoOrderShoppingListId = cart.getAutoOrderShoppingListId(); // clone the additionalPartyRoleMap - this.additionalPartyRole = new HashMap<String, List<String>>(); + this.additionalPartyRole = new HashMap<>(); for (Map.Entry<String, List<String>> me : cart.additionalPartyRole.entrySet()) { - this.additionalPartyRole.put(me.getKey(), new LinkedList<String>(me.getValue())); + this.additionalPartyRole.put(me.getKey(), new LinkedList<>(me.getValue())); } // clone the groups for (ShoppingCartItemGroup itemGroup : cart.itemGroupByNumberMap.values()) { // get the new parent group by number from the existing set; as before the parent must come before all children to work... ShoppingCartItemGroup parentGroup = null; - if (itemGroup.getParentGroup() != null) parentGroup = this.getItemGroupByNumber(itemGroup.getParentGroup().getGroupNumber()); + if (itemGroup.getParentGroup() != null) { + parentGroup = this.getItemGroupByNumber(itemGroup.getParentGroup().getGroupNumber()); + } ShoppingCartItemGroup newGroup = new ShoppingCartItemGroup(itemGroup, parentGroup); itemGroupByNumberMap.put(newGroup.getGroupNumber(), newGroup); } @@ -458,10 +460,11 @@ public class ShoppingCart implements Ite public String getCurrency() { if (this.currencyUom != null) { return this.currencyUom; - } else { - // uh oh, not good, should always be passed in on init, we can't really do anything without it, so throw an exception - throw new IllegalStateException("The Currency UOM is not set in the shopping cart, this is not a valid state, it should always be passed in when the cart is created."); } + // uh oh, not good, should always be passed in on init, we can't really do + // anything without it, so throw an exception + throw new IllegalStateException( + "The Currency UOM is not set in the shopping cart, this is not a valid state, it should always be passed in when the cart is created."); } public Timestamp getCartCreatedTime() { @@ -480,9 +483,7 @@ public class ShoppingCart implements Ite if ((productSuppliers != null) && (productSuppliers.size() > 0)) { supplierProduct = productSuppliers.get(0); } - } catch (GenericServiceException e) { - Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderRunServiceGetSuppliersForProductError", locale) + e.getMessage(), module); - } catch (Exception e) { + } catch (GenericServiceException e) { Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderRunServiceGetSuppliersForProductError", locale) + e.getMessage(), module); } return supplierProduct; @@ -506,7 +507,7 @@ public class ShoppingCart implements Ite /** add rental (with accommodation) item to cart */ public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, - String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, + String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, Object> attributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException { return addOrIncreaseItem(productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, accommodationMapId, accommodationSpotId, shipBeforeDate, shipAfterDate, features, attributes, null, prodCatalogId, configWrapper, itemType, itemGroupNumber, parentProductId, dispatcher); } @@ -514,8 +515,8 @@ public class ShoppingCart implements Ite /** add rental (with accommodation) item to cart and order item attributes*/ // TODO change method signature, this one is really scary, above are not bad too :/ ! public int addOrIncreaseItem(String productId, BigDecimal selectedAmount, BigDecimal quantity, Timestamp reservStart, BigDecimal reservLength, BigDecimal reservPersons, - String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, - Object> attributes, Map<String, String> orderItemAttributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, + String accommodationMapId, String accommodationSpotId, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map<String, GenericValue> features, Map<String, + Object> attributes, Map<String, String> orderItemAttributes, String prodCatalogId, ProductConfigWrapper configWrapper, String itemType, String itemGroupNumber, String parentProductId, LocalDispatcher dispatcher) throws CartItemModifyException, ItemNotFoundException { if (isReadOnlyCart()) { throw new CartItemModifyException("Cart items cannot be changed"); @@ -553,7 +554,9 @@ public class ShoppingCart implements Ite } } - if (Debug.verboseOn()) Debug.logVerbose("Found a match for id " + productId + " on line " + i + ", updating quantity to " + newQuantity, module); + if (Debug.verboseOn()) { + Debug.logVerbose("Found a match for id " + productId + " on line " + i + ", updating quantity to " + newQuantity, module); + } sci.setQuantity(newQuantity, dispatcher, this); if ("PURCHASE_ORDER".equals(getOrderType())) { @@ -632,9 +635,8 @@ public class ShoppingCart implements Ite } cartLines.add(index, item); return index; - } else { - return this.getItemIndex(item); } + return this.getItemIndex(item); } /** Add an item to the shopping cart. */ @@ -706,9 +708,11 @@ public class ShoppingCart implements Ite } /** Get all ShoppingCartItems from the cart object with the given productId and optional groupNumber to limit it to a specific item group */ public List<ShoppingCartItem> findAllCartItems(String productId, String groupNumber) { - if (productId == null) return this.items(); + if (productId == null) { + return this.items(); + } - List<ShoppingCartItem> itemsToReturn = new LinkedList<ShoppingCartItem>(); + List<ShoppingCartItem> itemsToReturn = new LinkedList<>(); // Check for existing cart item. for (ShoppingCartItem cartItem : cartLines) { if (UtilValidate.isNotEmpty(groupNumber) && !cartItem.isInItemGroup(groupNumber)) { @@ -723,10 +727,12 @@ public class ShoppingCart implements Ite /** Get all ShoppingCartItems from the cart object with the given productCategoryId and optional groupNumber to limit it to a specific item group */ public List<ShoppingCartItem> findAllCartItemsInCategory(String productCategoryId, String groupNumber) { - if (productCategoryId == null) return this.items(); + if (productCategoryId == null) { + return this.items(); + } Delegator delegator = this.getDelegator(); - List<ShoppingCartItem> itemsToReturn = new LinkedList<ShoppingCartItem>(); + List<ShoppingCartItem> itemsToReturn = new LinkedList<>(); try { // Check for existing cart item for (ShoppingCartItem cartItem : cartLines) { @@ -763,13 +769,17 @@ public class ShoppingCart implements Ite // =============== some misc utility methods, mostly for dealing with lists of items ================= public void removeExtraItems(List<ShoppingCartItem> multipleItems, LocalDispatcher dispatcher, int maxItems) throws CartItemModifyException { // if 1 or 0 items, do nothing - if (multipleItems.size() <= maxItems) return; + if (multipleItems.size() <= maxItems) { + return; + } // remove all except first <maxItems> in list from the cart, first because new cart items are added to the beginning... - List<ShoppingCartItem> localList = new LinkedList<ShoppingCartItem>(); + List<ShoppingCartItem> localList = new LinkedList<>(); localList.addAll(multipleItems); // the ones to keep... - for (int i=0; i<maxItems; i++) localList.remove(0); + for (int i=0; i<maxItems; i++) { + localList.remove(0); + } for (ShoppingCartItem item : localList) { this.removeCartItem(item, dispatcher); } @@ -784,7 +794,7 @@ public class ShoppingCart implements Ite } public static List<GenericValue> getItemsProducts(List<ShoppingCartItem> cartItems) { - List<GenericValue> productList = new LinkedList<GenericValue>(); + List<GenericValue> productList = new LinkedList<>(); for (ShoppingCartItem item : cartItems) { GenericValue product = item.getProduct(); if (product != null) { @@ -919,7 +929,9 @@ public class ShoppingCart implements Ite } public void removeCartItem(ShoppingCartItem item, LocalDispatcher dispatcher) throws CartItemModifyException { - if (item == null) return; + if (item == null) { + return; + } this.removeCartItem(this.getItemIndex(item), dispatcher); } @@ -928,8 +940,12 @@ public class ShoppingCart implements Ite if (isReadOnlyCart()) { throw new CartItemModifyException("Cart items cannot be changed"); } - if (index < 0) return; - if (cartLines.size() <= index) return; + if (index < 0) { + return; + } + if (cartLines.size() <= index) { + return; + } ShoppingCartItem item = cartLines.remove(index); // set quantity to 0 to trigger necessary events, but skip price calc and inventory checks @@ -952,7 +968,7 @@ public class ShoppingCart implements Ite /** Returns a Collection of items in the cart object. */ public List<ShoppingCartItem> items() { - List<ShoppingCartItem> result = new LinkedList<ShoppingCartItem>(); + List<ShoppingCartItem> result = new LinkedList<>(); result.addAll(cartLines); return result; } @@ -964,7 +980,9 @@ public class ShoppingCart implements Ite } public ShoppingCart.ShoppingCartItemGroup getItemGroupByNumber(String groupNumber) { - if (UtilValidate.isEmpty(groupNumber)) return null; + if (UtilValidate.isEmpty(groupNumber)) { + return null; + } return this.itemGroupByNumberMap.get(groupNumber); } @@ -996,7 +1014,7 @@ public class ShoppingCart implements Ite } public List<ShoppingCartItem> getCartItemsInNoGroup() { - List<ShoppingCartItem> cartItemList = new LinkedList<ShoppingCartItem>(); + List<ShoppingCartItem> cartItemList = new LinkedList<>(); for (ShoppingCartItem cartItem : cartLines) { if (cartItem.getItemGroup() == null) { cartItemList.add(cartItem); @@ -1006,7 +1024,7 @@ public class ShoppingCart implements Ite } public List<ShoppingCartItem> getCartItemsInGroup(String groupNumber) { - List<ShoppingCartItem> cartItemList = new LinkedList<ShoppingCartItem>(); + List<ShoppingCartItem> cartItemList = new LinkedList<>(); ShoppingCart.ShoppingCartItemGroup itemGroup = this.getItemGroupByNumber(groupNumber); if (itemGroup != null) { for (ShoppingCartItem cartItem : cartLines) { @@ -1238,7 +1256,9 @@ public class ShoppingCart implements Ite public void setPlacingCustomerPartyId(String placingCustomerPartyId) { this.placingCustomerPartyId = placingCustomerPartyId; - if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = placingCustomerPartyId; + if (UtilValidate.isEmpty(this.orderPartyId)) { + this.orderPartyId = placingCustomerPartyId; + } } public String getBillToCustomerPartyId() { @@ -1258,7 +1278,9 @@ public class ShoppingCart implements Ite public void setShipToCustomerPartyId(String shipToCustomerPartyId) { this.shipToCustomerPartyId = shipToCustomerPartyId; - if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = shipToCustomerPartyId; + if (UtilValidate.isEmpty(this.orderPartyId)) { + this.orderPartyId = shipToCustomerPartyId; + } } public String getEndUserCustomerPartyId() { @@ -1267,7 +1289,9 @@ public class ShoppingCart implements Ite public void setEndUserCustomerPartyId(String endUserCustomerPartyId) { this.endUserCustomerPartyId = endUserCustomerPartyId; - if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = endUserCustomerPartyId; + if (UtilValidate.isEmpty(this.orderPartyId)) { + this.orderPartyId = endUserCustomerPartyId; + } } public String getBillFromVendorPartyId() { @@ -1288,7 +1312,9 @@ public class ShoppingCart implements Ite public void setShipFromVendorPartyId(String shipFromVendorPartyId) { this.shipFromVendorPartyId = shipFromVendorPartyId; - if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = shipFromVendorPartyId; + if (UtilValidate.isEmpty(this.orderPartyId)) { + this.orderPartyId = shipFromVendorPartyId; + } } public String getSupplierAgentPartyId() { @@ -1297,7 +1323,9 @@ public class ShoppingCart implements Ite public void setSupplierAgentPartyId(String supplierAgentPartyId) { this.supplierAgentPartyId = supplierAgentPartyId; - if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = supplierAgentPartyId; + if (UtilValidate.isEmpty(this.orderPartyId)) { + this.orderPartyId = supplierAgentPartyId; + } } public String getPartyId() { @@ -1563,7 +1591,7 @@ public class ShoppingCart implements Ite /** Returns the CartPaymentInfo objects which have matching fields */ public List<CartPaymentInfo> getPaymentInfos(boolean isPaymentMethod, boolean isPaymentMethodType, boolean hasRefNum) { - List<CartPaymentInfo> foundRecords = new LinkedList<CartPaymentInfo>(); + List<CartPaymentInfo> foundRecords = new LinkedList<>(); for (CartPaymentInfo inf : paymentInfo) { if (isPaymentMethod && inf.paymentMethodId != null) { if (hasRefNum && inf.refNum != null) { @@ -1716,7 +1744,9 @@ public class ShoppingCart implements Ite /** remove all the paymentMethods based on the paymentMethodIds */ public void clearPaymentMethodsById(List<String> paymentMethodIdsToRemove) { - if (UtilValidate.isEmpty(paymentMethodIdsToRemove)) return; + if (UtilValidate.isEmpty(paymentMethodIdsToRemove)) { + return; + } for (Iterator<CartPaymentInfo> iter = paymentInfo.iterator(); iter.hasNext();) { CartPaymentInfo info = iter.next(); if (paymentMethodIdsToRemove.contains(info.paymentMethodId)) { @@ -1732,7 +1762,7 @@ public class ShoppingCart implements Ite try { List<GenericValue> declinedPaymentMethods = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderId", orderId, "statusId", "PAYMENT_DECLINED").queryList(); if (UtilValidate.isNotEmpty(declinedPaymentMethods)) { - List<String> paymentMethodIdsToRemove = new ArrayList<String>(); + List<String> paymentMethodIdsToRemove = new ArrayList<>(); for (GenericValue opp : declinedPaymentMethods) { paymentMethodIdsToRemove.add(opp.getString("paymentMethodId")); } @@ -1773,7 +1803,7 @@ public class ShoppingCart implements Ite /** Returns the Payment Method Ids */ public List<String> getPaymentMethodIds() { - List<String> pmi = new LinkedList<String>(); + List<String> pmi = new LinkedList<>(); for (CartPaymentInfo inf : paymentInfo) { if (inf.paymentMethodId != null) { pmi.add(inf.paymentMethodId); @@ -1784,7 +1814,7 @@ public class ShoppingCart implements Ite /** Returns the Payment Method Type Ids */ public List<String> getPaymentMethodTypeIds() { - List<String> pmt = new LinkedList<String>(); + List<String> pmt = new LinkedList<>(); for (CartPaymentInfo inf : paymentInfo) { if (inf.paymentMethodTypeId != null) { pmt.add(inf.paymentMethodTypeId); @@ -1795,7 +1825,7 @@ public class ShoppingCart implements Ite /** Returns a list of PaymentMethod value objects selected in the cart */ public List<GenericValue> getPaymentMethods() { - List<GenericValue> methods = new LinkedList<GenericValue>(); + List<GenericValue> methods = new LinkedList<>(); if (UtilValidate.isNotEmpty(paymentInfo)) { for (String paymentMethodId : getPaymentMethodIds()) { try { @@ -1816,7 +1846,7 @@ public class ShoppingCart implements Ite /** Returns a list of PaymentMethodType value objects selected in the cart */ public List<GenericValue> getPaymentMethodTypes() { - List<GenericValue> types = new LinkedList<GenericValue>(); + List<GenericValue> types = new LinkedList<>(); if (UtilValidate.isNotEmpty(paymentInfo)) { for (String id : getPaymentMethodTypeIds()) { try { @@ -1832,7 +1862,7 @@ public class ShoppingCart implements Ite public List<GenericValue> getCreditCards() { List<GenericValue> paymentMethods = this.getPaymentMethods(); - List<GenericValue> creditCards = new LinkedList<GenericValue>(); + List<GenericValue> creditCards = new LinkedList<>(); for (GenericValue pm : paymentMethods) { if ("CREDIT_CARD".equals(pm.getString("paymentMethodTypeId"))) { try { @@ -1849,7 +1879,7 @@ public class ShoppingCart implements Ite public List<GenericValue> getGiftCards() { List<GenericValue> paymentMethods = this.getPaymentMethods(); - List<GenericValue> giftCards = new LinkedList<GenericValue>(); + List<GenericValue> giftCards = new LinkedList<>(); for (GenericValue pm : paymentMethods) { if ("GIFT_CARD".equals(pm.getString("paymentMethodTypeId"))) { try { @@ -1874,9 +1904,8 @@ public class ShoppingCart implements Ite } if (paymentMethodType == null) { return false; - } else { - return true; } + return true; } public GenericValue getBillingAddress() { @@ -1893,7 +1922,7 @@ public class ShoppingCart implements Ite /** * Returns ProductStoreFinActSetting based on cart's productStoreId and FinAccountHelper's defined giftCertFinAcctTypeId * @param delegator the delegator - * @return returns ProductStoreFinActSetting based on cart's productStoreId + * @return returns ProductStoreFinActSetting based on cart's productStoreId * @throws GenericEntityException */ public GenericValue getGiftCertSettingFromStore(Delegator delegator) throws GenericEntityException { @@ -1911,13 +1940,12 @@ public class ShoppingCart implements Ite if (giftCertSettings != null) { if ("Y".equals(giftCertSettings.getString("requirePinCode"))) { return true; - } else { - return false; } - } else { - Debug.logWarning("No product store gift certificate settings found for store [" + getProductStoreId() + "]", module); - return true; + return false; } + Debug.logWarning("No product store gift certificate settings found for store [" + getProductStoreId() + "]", + module); + return true; } catch (GenericEntityException ex) { Debug.logError("Error checking if store requires pin number for GC: " + ex.getMessage(), module); return true; @@ -1935,13 +1963,12 @@ public class ShoppingCart implements Ite if (giftCertSettings != null) { if ("Y".equals(giftCertSettings.getString("validateGCFinAcct"))) { return true; - } else { - return false; } - } else { - Debug.logWarning("No product store gift certificate settings found for store [" + getProductStoreId() + "]", module); return false; } + Debug.logWarning("No product store gift certificate settings found for store [" + getProductStoreId() + "]", + module); + return false; } catch (GenericEntityException ex) { Debug.logError("Error checking if store requires pin number for GC: " + ex.getMessage(), module); return false; @@ -1993,7 +2020,7 @@ public class ShoppingCart implements Ite } public Map<Integer, BigDecimal> getShipGroups(ShoppingCartItem item) { - Map<Integer, BigDecimal> shipGroups = new LinkedHashMap<Integer, BigDecimal>(); + Map<Integer, BigDecimal> shipGroups = new LinkedHashMap<>(); if (item != null) { for (int i = 0; i < this.shipInfo.size(); i++) { CartShipInfo csi = shipInfo.get(i); @@ -2033,7 +2060,7 @@ public class ShoppingCart implements Ite /** Returns the ShoppingCartItem (key) and quantity (value) associated with the ship group */ public Map<ShoppingCartItem, BigDecimal> getShipGroupItems(int idx) { CartShipInfo csi = this.getShipInfo(idx); - Map<ShoppingCartItem, BigDecimal> qtyMap = new HashMap<ShoppingCartItem, BigDecimal>(); + Map<ShoppingCartItem, BigDecimal> qtyMap = new HashMap<>(); for (ShoppingCartItem item : csi.shipItemInfo.keySet()) { CartShipInfo.CartShipItemInfo csii = csi.shipItemInfo.get(item); qtyMap.put(item, csii.quantity); @@ -2260,7 +2287,7 @@ public class ShoppingCart implements Ite } csi.setContactMechId(shippingContactMechId); } - + /** * Sets @param shippingContactMechId in all ShipInfo(ShipGroups) associated * with this ShoppingCart @@ -2272,7 +2299,7 @@ public class ShoppingCart implements Ite this.setShippingContactMechId(x, shippingContactMechId); } } - + /** Returns the shipping contact mech id. */ public String getShippingContactMechId(int idx) { CartShipInfo csi = this.getShipInfo(idx); @@ -2288,7 +2315,7 @@ public class ShoppingCart implements Ite CartShipInfo csi = this.getShipInfo(idx); csi.shipmentMethodTypeId = shipmentMethodTypeId; } - + /** * Sets @param shipmentMethodTypeId in all ShipInfo(ShipGroups) associated * with this ShoppingCart @@ -2300,7 +2327,7 @@ public class ShoppingCart implements Ite this.setShipmentMethodTypeId(x, shipmentMethodTypeId); } } - + /** Returns the shipment method type ID */ public String getShipmentMethodTypeId(int idx) { CartShipInfo csi = this.getShipInfo(idx); @@ -2344,7 +2371,7 @@ public class ShoppingCart implements Ite CartShipInfo csi = this.getShipInfo(idx); csi.shippingInstructions = shippingInstructions; } - + /** * Sets @param shippingInstructions in all ShipInfo(ShipGroups) associated * with this ShoppingCart @@ -2373,7 +2400,7 @@ public class ShoppingCart implements Ite csi.setMaySplit(maySplit); } } - + /** * Sets @param maySplit in all ShipInfo(ShipGroups) associated * with this ShoppingCart @@ -2385,7 +2412,7 @@ public class ShoppingCart implements Ite this.setMaySplit(x, maySplit); } } - + /** Returns Boolean.TRUE if the order may be split (null if unspecified) */ public String getMaySplit(int idx) { @@ -2413,7 +2440,7 @@ public class ShoppingCart implements Ite this.setGiftMessage(x, giftMessage); } } - + public String getGiftMessage(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.giftMessage; @@ -2441,7 +2468,7 @@ public class ShoppingCart implements Ite this.setIsGift(x, isGift); } } - + public String getIsGift(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.isGift; @@ -2455,7 +2482,7 @@ public class ShoppingCart implements Ite CartShipInfo csi = this.getShipInfo(idx); csi.carrierPartyId = carrierPartyId; } - + /** * Sets @param carrierPartyId in all ShipInfo(ShipGroups) associated * with this ShoppingCart @@ -2467,7 +2494,7 @@ public class ShoppingCart implements Ite this.setCarrierPartyId(x, carrierPartyId); } } - + public String getCarrierPartyId(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.carrierPartyId; @@ -2490,7 +2517,7 @@ public class ShoppingCart implements Ite CartShipInfo csi = this.getShipInfo(idx); csi.productStoreShipMethId = productStoreShipMethId; } - + /** * Sets @param productStoreShipMethId in all ShipInfo(ShipGroups) associated * with this ShoppingCart @@ -2549,9 +2576,8 @@ public class ShoppingCart implements Ite Debug.logWarning(e.toString(), module); return null; } - } else { - return null; } + return null; } public GenericValue getShippingAddress() { @@ -2698,11 +2724,11 @@ public class ShoppingCart implements Ite } public BigDecimal getOrderGlobalAdjustments() { List<GenericValue> cartAdjustments = this.getAdjustments(); - List<GenericValue> tempAdjustmentsList = new LinkedList<GenericValue>(); + List<GenericValue> tempAdjustmentsList = new LinkedList<>(); if (cartAdjustments != null) { Iterator<GenericValue> cartAdjustmentIter = cartAdjustments.iterator(); while (cartAdjustmentIter.hasNext()) { - GenericValue checkOrderAdjustment = (GenericValue) cartAdjustmentIter.next(); + GenericValue checkOrderAdjustment = cartAdjustmentIter.next(); if (UtilValidate.isEmpty(checkOrderAdjustment.getString("shipGroupSeqId")) || DataModelConstants.SEQ_ID_NA.equals(checkOrderAdjustment.getString("shipGroupSeqId"))) { tempAdjustmentsList.add(checkOrderAdjustment); } @@ -2766,7 +2792,9 @@ public class ShoppingCart implements Ite BigDecimal total = BigDecimal.ZERO; String thisPaymentMethodTypeId = null; for (CartPaymentInfo payment : paymentInfo) { - if (payment.amount == null) continue; + if (payment.amount == null) { + continue; + } if (payment.paymentMethodId != null) { try { // need to determine the payment method type from the payment method @@ -2803,7 +2831,9 @@ public class ShoppingCart implements Ite /** Add a contact mech to this purpose; the contactMechPurposeTypeId is required */ public void addContactMech(String contactMechPurposeTypeId, String contactMechId) { - if (contactMechPurposeTypeId == null) throw new IllegalArgumentException("You must specify a contactMechPurposeTypeId to add a ContactMech"); + if (contactMechPurposeTypeId == null) { + throw new IllegalArgumentException("You must specify a contactMechPurposeTypeId to add a ContactMech"); + } contactMechIdsMap.put(contactMechPurposeTypeId, contactMechId); } @@ -2870,7 +2900,7 @@ public class ShoppingCart implements Ite orderTerm.put("textValue", textValue); return addOrderTerm(orderTerm); } - + public int addOrderTerm(String termTypeId, String orderItemSeqId,BigDecimal termValue, Long termDays, String textValue, String description) { GenericValue orderTerm = this.getDelegator().makeValue("OrderTerm"); orderTerm.put("termTypeId", termTypeId); @@ -2929,10 +2959,12 @@ public class ShoppingCart implements Ite /** go through the order adjustments and remove all adjustments with the given type */ public void removeAdjustmentByType(String orderAdjustmentTypeId) { - if (orderAdjustmentTypeId == null) return; + if (orderAdjustmentTypeId == null) { + return; + } // make a list of adjustment lists including the cart adjustments and the cartItem adjustments for each item - List<List<GenericValue>> adjsLists = new LinkedList<List<GenericValue>>(); + List<List<GenericValue>> adjsLists = new LinkedList<>(); adjsLists.add(this.getAdjustments()); @@ -3032,7 +3064,7 @@ public class ShoppingCart implements Ite /** Returns a List of shippable item's size for a specific ship group. */ public List<BigDecimal> getShippableSizes(int idx) { CartShipInfo info = this.getShipInfo(idx); - List<BigDecimal> shippableSizes = new LinkedList<BigDecimal>(); + List<BigDecimal> shippableSizes = new LinkedList<>(); for (ShoppingCartItem item : info.shipItemInfo.keySet()) { CartShipInfo.CartShipItemInfo csii = info.shipItemInfo.get(item); @@ -3049,7 +3081,7 @@ public class ShoppingCart implements Ite /** Returns a List of shippable item info (quantity, size, weight) for a specific ship group */ public List<Map<String, Object>> getShippableItemInfo(int idx) { CartShipInfo info = this.getShipInfo(idx); - List<Map<String, Object>> itemInfos = new LinkedList<Map<String,Object>>(); + List<Map<String, Object>> itemInfos = new LinkedList<>(); for (ShoppingCartItem item : info.shipItemInfo.keySet()) { CartShipInfo.CartShipItemInfo csii = info.shipItemInfo.get(item); @@ -3092,7 +3124,7 @@ public class ShoppingCart implements Ite /** Returns a Map of all features applied to products in the cart with quantities for a specific ship group. */ public Map<String, BigDecimal> getFeatureIdQtyMap(int idx) { CartShipInfo info = this.getShipInfo(idx); - Map<String, BigDecimal> featureMap = new HashMap<String, BigDecimal>(); + Map<String, BigDecimal> featureMap = new HashMap<>(); for (ShoppingCartItem item : info.shipItemInfo.keySet()) { CartShipInfo.CartShipItemInfo csii = info.shipItemInfo.get(item); @@ -3132,9 +3164,8 @@ public class ShoppingCart implements Ite public void setNextItemSeq(long seq) throws GeneralException { if (this.nextItemSeq != 1) { throw new GeneralException("Cannot set the item sequence once the sequence has been incremented!"); - } else { - this.nextItemSeq = seq; } + this.nextItemSeq = seq; } /** TODO: Sets the first attempt orderId for this cart. */ @@ -3147,7 +3178,9 @@ public class ShoppingCart implements Ite } /** Removes a free shipping ProductPromoAction by trying to find one in the list with the same primary key. */ public void removeFreeShippingProductPromoAction(GenericPK productPromoActionPK) { - if (productPromoActionPK == null) return; + if (productPromoActionPK == null) { + return; + } Iterator<GenericValue> fsppas = this.freeShippingProductPromoActions.iterator(); while (fsppas.hasNext()) { @@ -3158,9 +3191,14 @@ public class ShoppingCart implements Ite } /** Adds a ProductPromoAction to be used for free shipping (must be of type free shipping, or nothing will be done). */ public void addFreeShippingProductPromoAction(GenericValue productPromoAction) { - if (productPromoAction == null) return; + if (productPromoAction == null) { + return; + } // is this a free shipping action? - if (!"PROMO_FREE_SHIPPING".equals(productPromoAction.getString("productPromoActionEnumId"))) return; // Changed 1-5-04 by Si Chen + if (!"PROMO_FREE_SHIPPING".equals(productPromoAction.getString("productPromoActionEnumId"))) + { + return; // Changed 1-5-04 by Si Chen + } // to easily make sure that no duplicate exists, do a remove first this.removeFreeShippingProductPromoAction(productPromoAction.getPrimaryKey()); @@ -3180,14 +3218,16 @@ public class ShoppingCart implements Ite return this.desiredAlternateGiftByAction.get(productPromoActionPK); } public Map<GenericPK, String> getAllDesiredAlternateGiftByActionCopy() { - return new HashMap<GenericPK, String>(this.desiredAlternateGiftByAction); + return new HashMap<>(this.desiredAlternateGiftByAction); } public void addProductPromoUse(String productPromoId, String productPromoCodeId, BigDecimal totalDiscountAmount, BigDecimal quantityLeftInActions, Map<ShoppingCartItem,BigDecimal> usageInfoMap) { if (UtilValidate.isNotEmpty(productPromoCodeId) && !this.productPromoCodes.contains(productPromoCodeId)) { throw new IllegalStateException("Cannot add a use to a promo code use for a code that has not been entered."); } - if (Debug.verboseOn()) Debug.logVerbose("Used promotion [" + productPromoId + "] with code [" + productPromoCodeId + "] for total discount [" + totalDiscountAmount + "] and quantity left in actions [" + quantityLeftInActions + "]", module); + if (Debug.verboseOn()) { + Debug.logVerbose("Used promotion [" + productPromoId + "] with code [" + productPromoCodeId + "] for total discount [" + totalDiscountAmount + "] and quantity left in actions [" + quantityLeftInActions + "]", module); + } this.productPromoUseInfoList.add(new ProductPromoUseInfo(productPromoId, productPromoCodeId, totalDiscountAmount, quantityLeftInActions, usageInfoMap)); } @@ -3267,7 +3307,9 @@ public class ShoppingCart implements Ite } public int getProductPromoUseCount(String productPromoId) { - if (productPromoId == null) return 0; + if (productPromoId == null) { + return 0; + } int useCount = 0; for (ProductPromoUseInfo productPromoUseInfo: this.productPromoUseInfoList) { if (productPromoId.equals(productPromoUseInfo.productPromoId)) { @@ -3278,7 +3320,9 @@ public class ShoppingCart implements Ite } public int getProductPromoCodeUse(String productPromoCodeId) { - if (productPromoCodeId == null) return 0; + if (productPromoCodeId == null) { + return 0; + } int useCount = 0; for (ProductPromoUseInfo productPromoUseInfo: this.productPromoUseInfoList) { if (productPromoCodeId.equals(productPromoUseInfo.productPromoCodeId)) { @@ -3372,9 +3416,8 @@ public class ShoppingCart implements Ite // new promo code, re-evaluate promos ProductPromoWorker.doPromotions(this, dispatcher); return null; - } else { - return checkResult; } + return checkResult; } public Set<String> getProductPromoCodesEntered() { @@ -3408,7 +3451,7 @@ public class ShoppingCart implements Ite } } } else { - parties = new LinkedList<String>(); + parties = new LinkedList<>(); additionalPartyRole.put(roleTypeId, parties); } @@ -3471,7 +3514,7 @@ public class ShoppingCart implements Ite GenericValue product = item.getProduct(); String productName = product.getString("productName"); String description = product.getString("description"); - Map<String, Object> serviceContext = new HashMap<String, Object>(); + Map<String, Object> serviceContext = new HashMap<>(); GenericValue permUserLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").queryOne(); String internalName = item.getProductId() + "_" + configId; serviceContext.put("internalName", internalName); @@ -3529,15 +3572,12 @@ public class ShoppingCart implements Ite } } catch (GenericEntityException | GenericServiceException e) { Debug.logError(e, module); - } catch (Exception e) { - Debug.logError(e, module); - return null; } return newProductId; } public List<GenericValue> makeOrderItemGroups() { - List<GenericValue> result = new LinkedList<GenericValue>(); + List<GenericValue> result = new LinkedList<>(); for (ShoppingCart.ShoppingCartItemGroup itemGroup : this.itemGroupByNumberMap.values()) { result.add(itemGroup.makeOrderItemGroup(this.getDelegator())); } @@ -3545,9 +3585,11 @@ public class ShoppingCart implements Ite } private void explodeItems(LocalDispatcher dispatcher) { - if (dispatcher == null) return; + if (dispatcher == null) { + return; + } synchronized (cartLines) { - List<ShoppingCartItem> cartLineItems = new LinkedList<ShoppingCartItem>(cartLines); + List<ShoppingCartItem> cartLineItems = new LinkedList<>(cartLines); for (ShoppingCartItem item : cartLineItems) { try { int thisIndex = items().indexOf(item); @@ -3576,7 +3618,9 @@ public class ShoppingCart implements Ite * @param dispatcher */ public void explodeItems(List<ShoppingCartItem> shoppingCartItems, LocalDispatcher dispatcher) { - if (dispatcher == null) return; + if (dispatcher == null) { + return; + } synchronized (cartLines) { for (ShoppingCartItem item : shoppingCartItems) { try { @@ -3610,7 +3654,7 @@ public class ShoppingCart implements Ite // now build the lines synchronized (cartLines) { - List<GenericValue> result = new LinkedList<GenericValue>(); + List<GenericValue> result = new LinkedList<>(); for (ShoppingCartItem item : cartLines) { if (UtilValidate.isEmpty(item.getOrderItemSeqId())) { @@ -3644,7 +3688,9 @@ public class ShoppingCart implements Ite orderItem.set("orderItemSeqId", item.getOrderItemSeqId()); orderItem.set("externalId", item.getExternalId()); orderItem.set("orderItemTypeId", item.getItemType()); - if (item.getItemGroup() != null) orderItem.set("orderItemGroupSeqId", item.getItemGroup().getGroupNumber()); + if (item.getItemGroup() != null) { + orderItem.set("orderItemGroupSeqId", item.getItemGroup().getGroupNumber()); + } orderItem.set("productId", UtilValidate.isNotEmpty(aggregatedInstanceId) ? aggregatedInstanceId : item.getProductId()); orderItem.set("supplierProductId", item.getSupplierProductId()); orderItem.set("prodCatalogId", item.getProdCatalogId()); @@ -3689,7 +3735,7 @@ public class ShoppingCart implements Ite /** create WorkEfforts from the shoppingcart items when itemType = RENTAL_ORDER_ITEM */ public List<GenericValue> makeWorkEfforts() { - List<GenericValue> allWorkEfforts = new LinkedList<GenericValue>(); + List<GenericValue> allWorkEfforts = new LinkedList<>(); for (ShoppingCartItem item : cartLines) { if ("RENTAL_ORDER_ITEM".equals(item.getItemType())) { // prepare workeffort when the order item is a rental item GenericValue workEffort = getDelegator().makeValue("WorkEffort"); @@ -3709,7 +3755,7 @@ public class ShoppingCart implements Ite /** make a list of all adjustments including order adjustments, order line adjustments, and special adjustments (shipping and tax if applicable) */ public List<GenericValue> makeAllAdjustments() { - List<GenericValue> allAdjs = new LinkedList<GenericValue>(); + List<GenericValue> allAdjs = new LinkedList<>(); // before returning adjustments, go through them to find all that need counter adjustments (for instance: free shipping) for (GenericValue orderAdjustment: this.getAdjustments()) { @@ -3753,7 +3799,7 @@ public class ShoppingCart implements Ite * Internally, the quote adjustments are created from the order adjustments. */ public List<GenericValue> makeAllQuoteAdjustments() { - List<GenericValue> quoteAdjs = new LinkedList<GenericValue>(); + List<GenericValue> quoteAdjs = new LinkedList<>(); for (GenericValue orderAdj: makeAllAdjustments()) { GenericValue quoteAdj = this.getDelegator().makeValue("QuoteAdjustment"); @@ -3790,7 +3836,7 @@ public class ShoppingCart implements Ite /** make a list of all OrderPaymentPreferences and Billing info including all payment methods and types */ public List<GenericValue> makeAllOrderPaymentInfos(LocalDispatcher dispatcher) { Delegator delegator = this.getDelegator(); - List<GenericValue> allOpPrefs = new LinkedList<GenericValue>(); + List<GenericValue> allOpPrefs = new LinkedList<>(); BigDecimal remainingAmount = this.getGrandTotal().subtract(this.getPaymentTotal()); remainingAmount = remainingAmount.setScale(2, RoundingMode.HALF_UP); if (getBillingAccountId() != null && this.billingAccountAmt.compareTo(BigDecimal.ZERO) <= 0) { @@ -3817,7 +3863,7 @@ public class ShoppingCart implements Ite /** make a list of OrderItemPriceInfos from the ShoppingCartItems */ public List<GenericValue> makeAllOrderItemPriceInfos() { - List<GenericValue> allInfos = new LinkedList<GenericValue>(); + List<GenericValue> allInfos = new LinkedList<>(); // add all of the item adjustments to this list too for (ShoppingCartItem item : cartLines) { @@ -3835,7 +3881,7 @@ public class ShoppingCart implements Ite } public List<GenericValue> makeProductPromoUses() { - List<GenericValue> productPromoUses = new LinkedList<GenericValue>(); + List<GenericValue> productPromoUses = new LinkedList<>(); String partyId = this.getPartyId(); int sequenceValue = 0; for (ProductPromoUseInfo productPromoUseInfo: this.productPromoUseInfoList) { @@ -3854,7 +3900,7 @@ public class ShoppingCart implements Ite /** make a list of SurveyResponse object to update with order information set */ public List<GenericValue> makeAllOrderItemSurveyResponses() { - List<GenericValue> allInfos = new LinkedList<GenericValue>(); + List<GenericValue> allInfos = new LinkedList<>(); for (ShoppingCartItem item : this) { List<String> responses = UtilGenerics.checkList(item.getAttribute("surveyResponses")); GenericValue response = null; @@ -3885,7 +3931,7 @@ public class ShoppingCart implements Ite /** make a list of OrderContactMechs from the ShoppingCart and the ShoppingCartItems */ public List<GenericValue> makeAllOrderContactMechs() { - List<GenericValue> allOrderContactMechs = new LinkedList<GenericValue>(); + List<GenericValue> allOrderContactMechs = new LinkedList<>(); Map<String, String> contactMechIds = this.getOrderContactMechIds(); @@ -3903,7 +3949,7 @@ public class ShoppingCart implements Ite /** make a list of OrderContactMechs from the ShoppingCart and the ShoppingCartItems */ public List<GenericValue> makeAllOrderItemContactMechs() { - List<GenericValue> allOrderContactMechs = new LinkedList<GenericValue>(); + List<GenericValue> allOrderContactMechs = new LinkedList<>(); for (ShoppingCartItem item : cartLines) { Map<String, String> itemContactMechIds = item.getOrderItemContactMechIds(); @@ -3924,7 +3970,7 @@ public class ShoppingCart implements Ite } public List<GenericValue> makeAllShipGroupInfos() { - List<GenericValue> groups = new LinkedList<GenericValue>(); + List<GenericValue> groups = new LinkedList<>(); long seqId = 1; for (CartShipInfo csi : this.shipInfo) { String shipGroupSeqId = csi.shipGroupSeqId; @@ -3950,7 +3996,7 @@ public class ShoppingCart implements Ite // now build order item attributes synchronized (cartLines) { - List<GenericValue> result = new LinkedList<GenericValue>(); + List<GenericValue> result = new LinkedList<>(); for (ShoppingCartItem item : cartLines) { Map<String, String> orderItemAttributes = item.getOrderItemAttributes(); @@ -3984,7 +4030,7 @@ public class ShoppingCart implements Ite public List<GenericValue> makeAllOrderAttributes(String orderId, int mode) { - List<GenericValue> allOrderAttributes = new LinkedList<GenericValue>(); + List<GenericValue> allOrderAttributes = new LinkedList<>(); for (Map.Entry<String, String> entry: orderAttributes.entrySet()) { GenericValue orderAtt = this.getDelegator().makeValue("OrderAttribute"); @@ -4019,7 +4065,7 @@ public class ShoppingCart implements Ite } public List<GenericValue> makeAllOrderItemAssociations() { - List<GenericValue> allOrderItemAssociations = new LinkedList<GenericValue>(); + List<GenericValue> allOrderItemAssociations = new LinkedList<>(); for (CartShipInfo csi : shipInfo) { Set<ShoppingCartItem> items = csi.getShipItems(); @@ -4063,7 +4109,7 @@ public class ShoppingCart implements Ite /** Returns a Map of cart values to pass to the storeOrder service */ public Map<String, Object> makeCartMap(LocalDispatcher dispatcher, boolean explodeItems) { - Map<String, Object> result = new HashMap<String, Object>(); + Map<String, Object> result = new HashMap<>(); result.put("orderTypeId", this.getOrderType()); result.put("orderName", this.getOrderName()); @@ -4122,13 +4168,13 @@ public class ShoppingCart implements Ite } public List<ShoppingCartItem> getLineListOrderedByBasePrice(boolean ascending) { - List<ShoppingCartItem> result = new ArrayList<ShoppingCartItem>(this.cartLines); + List<ShoppingCartItem> result = new ArrayList<>(this.cartLines); Collections.sort(result, new BasePriceOrderComparator(ascending)); return result; } public TreeMap<Integer, CartShipInfo> getShipGroupsBySupplier(String supplierPartyId) { - TreeMap<Integer, CartShipInfo> shipGroups = new TreeMap<Integer, CartShipInfo>(); + TreeMap<Integer, CartShipInfo> shipGroups = new TreeMap<>(); for (int i = 0; i < this.shipInfo.size(); i++) { CartShipInfo csi = shipInfo.get(i); if ((csi.supplierPartyId == null && supplierPartyId == null) || @@ -4155,17 +4201,16 @@ public class ShoppingCart implements Ite } catch (GenericEntityException gee) { Debug.logError(UtilProperties.getMessage(resource_error,"OrderProblemGettingProductStoreRecords", locale) + gee.getMessage(), module); return; - } catch (Exception e) { - Debug.logError(UtilProperties.getMessage(resource_error,"OrderProblemGettingProductStoreRecords", locale) + e.getMessage(), module); - return; } } List<CartShipInfo> shipGroups = getShipGroups(); - if (shipGroups == null) return; + if (shipGroups == null) { + return; + } // Intermediate structure supplierPartyId -> { ShoppingCartItem = { originalShipGroupIndex = dropShipQuantity } } to collect drop-shippable items - Map<String, Map<ShoppingCartItem, Map<Integer, BigDecimal>>> dropShipItems = new HashMap<String, Map<ShoppingCartItem, Map<Integer, BigDecimal>>>(); + Map<String, Map<ShoppingCartItem, Map<Integer, BigDecimal>>> dropShipItems = new HashMap<>(); for (int shipGroupIndex = 0; shipGroupIndex < shipGroups.size(); shipGroupIndex++) { @@ -4179,7 +4224,9 @@ public class ShoppingCart implements Ite // Ignore empty ship groups Set<ShoppingCartItem> shipItems = shipInfo.getShipItems(); - if (UtilValidate.isEmpty(shipItems)) continue; + if (UtilValidate.isEmpty(shipItems)) { + continue; + } for (ShoppingCartItem cartItem : shipItems) { BigDecimal itemQuantity = cartItem.getQuantity(); @@ -4214,8 +4261,6 @@ public class ShoppingCart implements Ite } catch (GenericServiceException gee) { Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderRunServiceGetInventoryAvailableByFacilityError", locale) + gee.getMessage(), module); - } catch (Exception e) { - Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderRunServiceGetInventoryAvailableByFacilityError", locale) + e.getMessage(), module); } } else { @@ -4223,7 +4268,9 @@ public class ShoppingCart implements Ite dropShipQuantity = BigDecimal.ZERO; } - if (dropShipQuantity.compareTo(BigDecimal.ZERO) <= 0) continue; + if (dropShipQuantity.compareTo(BigDecimal.ZERO) <= 0) { + continue; + } // Find a supplier for the product String supplierPartyId = null; @@ -4242,12 +4289,18 @@ public class ShoppingCart implements Ite } // Leave the items untouched if we couldn't find a supplier - if (UtilValidate.isEmpty(supplierPartyId)) continue; + if (UtilValidate.isEmpty(supplierPartyId)) { + continue; + } - if (! dropShipItems.containsKey(supplierPartyId)) dropShipItems.put(supplierPartyId, new HashMap<ShoppingCartItem, Map<Integer, BigDecimal>>()); + if (! dropShipItems.containsKey(supplierPartyId)) { + dropShipItems.put(supplierPartyId, new HashMap<ShoppingCartItem, Map<Integer, BigDecimal>>()); + } Map<ShoppingCartItem, Map<Integer, BigDecimal>> supplierCartItems = UtilGenerics.checkMap(dropShipItems.get(supplierPartyId)); - if (! supplierCartItems.containsKey(cartItem)) supplierCartItems.put(cartItem, new HashMap<Integer, BigDecimal>()); + if (! supplierCartItems.containsKey(cartItem)) { + supplierCartItems.put(cartItem, new HashMap<Integer, BigDecimal>()); + } Map<Integer, BigDecimal> cartItemGroupQuantities = UtilGenerics.checkMap(supplierCartItems.get(cartItem)); cartItemGroupQuantities.put(Integer.valueOf(shipGroupIndex), dropShipQuantity); @@ -4271,7 +4324,7 @@ public class ShoppingCart implements Ite shipInfo = this.shipInfo.get(newShipGroupIndex); } shipInfo.supplierPartyId = supplierPartyId; - + Map<ShoppingCartItem, Map<Integer, BigDecimal>> supplierCartItems = UtilGenerics.checkMap(supplierPartyEntry.getValue()); for (Entry<ShoppingCartItem, Map<Integer, BigDecimal>> cartItemEntry : supplierCartItems.entrySet()) { ShoppingCartItem cartItem = cartItemEntry.getKey(); @@ -4310,12 +4363,12 @@ public class ShoppingCart implements Ite return result; } + @Override public boolean equals(java.lang.Object obj) { if (obj instanceof BasePriceOrderComparator) { return this.ascending == ((BasePriceOrderComparator) obj).ascending; - } else { - return false; } + return false; } } @@ -4432,9 +4485,8 @@ public class ShoppingCart implements Ite } if (totalAmount.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ZERO; - } else { - return getTotalDiscountAmount().negate().divide(totalAmount, scale, rounding); } + return getTotalDiscountAmount().negate().divide(totalAmount, scale, rounding); } @Override @@ -4456,45 +4508,58 @@ public class ShoppingCart implements Ite @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } ProductPromoUseInfo other = (ProductPromoUseInfo) obj; if (productPromoCodeId == null) { - if (other.productPromoCodeId != null) + if (other.productPromoCodeId != null) { return false; - } else if (!productPromoCodeId.equals(other.productPromoCodeId)) + } + } else if (!productPromoCodeId.equals(other.productPromoCodeId)) { return false; + } if (productPromoId == null) { - if (other.productPromoId != null) + if (other.productPromoId != null) { return false; - } else if (!productPromoId.equals(other.productPromoId)) + } + } else if (!productPromoId.equals(other.productPromoId)) { return false; + } if (quantityLeftInActions == null) { - if (other.quantityLeftInActions != null) + if (other.quantityLeftInActions != null) { return false; - } else if (!quantityLeftInActions.equals(other.quantityLeftInActions)) + } + } else if (!quantityLeftInActions.equals(other.quantityLeftInActions)) { return false; + } if (totalDiscountAmount == null) { - if (other.totalDiscountAmount != null) + if (other.totalDiscountAmount != null) { return false; - } else if (!totalDiscountAmount.equals(other.totalDiscountAmount)) + } + } else if (!totalDiscountAmount.equals(other.totalDiscountAmount)) { return false; + } if (usageInfoMap == null) { - if (other.usageInfoMap != null) + if (other.usageInfoMap != null) { return false; - } else if (!usageInfoMap.equals(other.usageInfoMap)) + } + } else if (!usageInfoMap.equals(other.usageInfoMap)) { return false; + } return true; } } public static class CartShipInfo implements Serializable { - public Map<ShoppingCartItem, CartShipItemInfo> shipItemInfo = new HashMap<ShoppingCartItem, CartShipItemInfo>(); - public List<GenericValue> shipTaxAdj = new LinkedList<GenericValue>(); + public Map<ShoppingCartItem, CartShipItemInfo> shipItemInfo = new HashMap<>(); + public List<GenericValue> shipTaxAdj = new LinkedList<>(); public String orderTypeId = null; private String internalContactMechId = null; public String telecomContactMechId = null; @@ -4514,7 +4579,7 @@ public class ShoppingCart implements Ite private String associatedShipGroupSeqId = null; public String vendorPartyId = null; public String productStoreShipMethId = null; - public Map<String, Object> attributes = new HashMap<String, Object>(); + public Map<String, Object> attributes = new HashMap<>(); public void setAttribute(String name, Object value) { this.attributes.put(name, value); @@ -4579,7 +4644,7 @@ public class ShoppingCart implements Ite } public List<GenericValue> makeItemShipGroupAndAssoc(Delegator delegator, ShoppingCart cart, String shipGroupSeqId, boolean newShipGroup) { - List<GenericValue> values = new LinkedList<GenericValue>(); + List<GenericValue> values = new LinkedList<>(); // create order contact mech for shipping address if (this.internalContactMechId != null) { @@ -4620,7 +4685,7 @@ public class ShoppingCart implements Ite values.add(shipGroup); //set estimated ship dates - LinkedList<Timestamp> estimatedShipDates = new LinkedList<Timestamp>(); + LinkedList<Timestamp> estimatedShipDates = new LinkedList<>(); for (ShoppingCartItem item : shipItemInfo.keySet()) { Timestamp estimatedShipDate = item.getEstimatedShipDate(); if (estimatedShipDate != null) { @@ -4634,7 +4699,7 @@ public class ShoppingCart implements Ite } //set estimated delivery dates - LinkedList<Timestamp> estimatedDeliveryDates = new LinkedList<Timestamp>(); + LinkedList<Timestamp> estimatedDeliveryDates = new LinkedList<>(); for (ShoppingCartItem item : shipItemInfo.keySet()) { Timestamp estimatedDeliveryDate = item.getDesiredDeliveryDate(); if (estimatedDeliveryDate != null) { @@ -4652,7 +4717,9 @@ public class ShoppingCart implements Ite GenericValue shipAdj = delegator.makeValue("OrderAdjustment"); shipAdj.set("orderAdjustmentTypeId", "SHIPPING_CHARGES"); shipAdj.set("amount", shipEstimate); - if("PURCHASE_ORDER".equals(cart.getOrderType())) shipAdj.set("isManual", "Y"); + if("PURCHASE_ORDER".equals(cart.getOrderType())) { + shipAdj.set("isManual", "Y"); + } shipAdj.set("shipGroupSeqId", shipGroupSeqId); values.add(shipAdj); } @@ -4766,7 +4833,7 @@ public class ShoppingCart implements Ite } public BigDecimal getTotalTax(ShoppingCart cart) { - List<GenericValue> taxAdjustments = new LinkedList<GenericValue>(); + List<GenericValue> taxAdjustments = new LinkedList<>(); taxAdjustments.addAll(shipTaxAdj); for (CartShipItemInfo info : shipItemInfo.values()) { taxAdjustments.addAll(info.itemTaxAdj); @@ -4786,7 +4853,7 @@ public class ShoppingCart implements Ite } public static class CartShipItemInfo implements Serializable { - public List<GenericValue> itemTaxAdj = new LinkedList<GenericValue>(); + public List<GenericValue> itemTaxAdj = new LinkedList<>(); public ShoppingCartItem item = null; public BigDecimal quantity = BigDecimal.ZERO; @@ -4889,7 +4956,7 @@ public class ShoppingCart implements Ite public List<GenericValue> makeOrderPaymentInfos(Delegator delegator, ShoppingCart cart) { BigDecimal maxAmount = ZERO; GenericValue valueObj = this.getValueObject(delegator); - List<GenericValue> values = new LinkedList<GenericValue>(); + List<GenericValue> values = new LinkedList<>(); if (valueObj != null) { // first create a BILLING_LOCATION for the payment method address if there is one if ("PaymentMethod".equals(valueObj.getEntityName())) { @@ -5024,50 +5091,40 @@ public class ShoppingCart implements Ite if (this.paymentMethodId != null) { if (that.paymentMethodId == null) { return 1; - } else { - int pmCmp = this.paymentMethodId.compareTo(that.paymentMethodId); - if (pmCmp == 0) { - if (this.refNum != null && this.refNum[0] != null) { - if (that.refNum != null && that.refNum[0] != null) { - return this.refNum[0].compareTo(that.refNum[0]); - } else { - return 1; - } - } else { - if (that.refNum != null && that.refNum[0] != null) { - return -1; - } else { - return 0; - } + } + int pmCmp = this.paymentMethodId.compareTo(that.paymentMethodId); + if (pmCmp == 0) { + if (this.refNum != null && this.refNum[0] != null) { + if (that.refNum != null && that.refNum[0] != null) { + return this.refNum[0].compareTo(that.refNum[0]); } - } else { - return pmCmp; + return 1; + } + if (that.refNum != null && that.refNum[0] != null) { + return -1; } + return 0; } - } else { - if (that.paymentMethodId != null) { - return -1; - } else { - int pmtCmp = this.paymentMethodTypeId.compareTo(that.paymentMethodTypeId); - if (pmtCmp == 0) { - if (this.refNum != null && this.refNum[0] != null) { - if (that.refNum != null && that.refNum[0] != null) { - return this.refNum[0].compareTo(that.refNum[0]); - } else { - return 1; - } - } else { - if (that.refNum != null && that.refNum[0] != null) { - return -1; - } else { - return 0; - } - } - } else { - return pmtCmp; + return pmCmp; + } + if (that.paymentMethodId != null) { + return -1; + } + + int pmtCmp = this.paymentMethodTypeId.compareTo(that.paymentMethodTypeId); + if (pmtCmp == 0) { + if (this.refNum != null && this.refNum[0] != null) { + if (that.refNum != null && that.refNum[0] != null) { + return this.refNum[0].compareTo(that.refNum[0]); } + return 1; } + if (that.refNum != null && that.refNum[0] != null) { + return -1; + } + return 0; } + return pmtCmp; } @Override @@ -5091,58 +5148,80 @@ public class ShoppingCart implements Ite @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } CartPaymentInfo other = (CartPaymentInfo) obj; if (amount == null) { - if (other.amount != null) + if (other.amount != null) { return false; - } else if (!amount.equals(other.amount)) + } + } else if (!amount.equals(other.amount)) { return false; + } if (finAccountId == null) { - if (other.finAccountId != null) + if (other.finAccountId != null) { return false; - } else if (!finAccountId.equals(other.finAccountId)) + } + } else if (!finAccountId.equals(other.finAccountId)) { return false; - if (isPresent != other.isPresent) + } + if (isPresent != other.isPresent) { return false; - if (isSwiped != other.isSwiped) + } + if (isSwiped != other.isSwiped) { return false; - if (overflow != other.overflow) + } + if (overflow != other.overflow) { return false; + } if (paymentMethodId == null) { - if (other.paymentMethodId != null) + if (other.paymentMethodId != null) { return false; - } else if (!paymentMethodId.equals(other.paymentMethodId)) + } + } else if (!paymentMethodId.equals(other.paymentMethodId)) { return false; + } if (paymentMethodTypeId == null) { - if (other.paymentMethodTypeId != null) + if (other.paymentMethodTypeId != null) { return false; - } else if (!paymentMethodTypeId.equals(other.paymentMethodTypeId)) + } + } else if (!paymentMethodTypeId.equals(other.paymentMethodTypeId)) { return false; + } if (postalCode == null) { - if (other.postalCode != null) + if (other.postalCode != null) { return false; - } else if (!postalCode.equals(other.postalCode)) + } + } else if (!postalCode.equals(other.postalCode)) { return false; - if (!Arrays.equals(refNum, other.refNum)) + } + if (!Arrays.equals(refNum, other.refNum)) { return false; + } if (securityCode == null) { - if (other.securityCode != null) + if (other.securityCode != null) { return false; - } else if (!securityCode.equals(other.securityCode)) + } + } else if (!securityCode.equals(other.securityCode)) { return false; - if (singleUse != other.singleUse) + } + if (singleUse != other.singleUse) { return false; + } if (track2 == null) { - if (other.track2 != null) + if (other.track2 != null) { return false; - } else if (!track2.equals(other.track2)) + } + } else if (!track2.equals(other.track2)) { return false; + } return true; } @@ -5178,7 +5257,7 @@ public class ShoppingCart implements Ite public static BigDecimal getMinimumOrderQuantity(Delegator delegator, BigDecimal itemBasePrice, String itemProductId) throws GenericEntityException { BigDecimal minQuantity = BigDecimal.ZERO; - BigDecimal minimumOrderPrice = BigDecimal.ZERO; + BigDecimal minimumOrderPrice = BigDecimal.ZERO; List<GenericValue> minimumOrderPriceList = EntityQuery.use(delegator).from("ProductPrice") .where("productId", itemProductId, "productPriceTypeId", "MINIMUM_ORDER_PRICE") @@ -5189,7 +5268,7 @@ public class ShoppingCart implements Ite .where("productId", itemProductId) .filterByDate() .queryList(); - Map<String, BigDecimal> productPriceMap = new HashMap<String, BigDecimal>(); + Map<String, BigDecimal> productPriceMap = new HashMap<>(); for (GenericValue productPrice : productPriceList) { productPriceMap.put(productPrice.getString("productPriceTypeId"), productPrice.getBigDecimal("price")); } |
Free forum by Nabble | Edit this page |