Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/packing/PackingSession.java Mon Nov 10 18:20:53 2008 @@ -178,10 +178,9 @@ } if (qtyRemain == 0) { - Iterator<GenericValue> x = toCreateMap.keySet().iterator(); - while (x.hasNext()) { - GenericValue res = x.next(); - Double qty = toCreateMap.get(res); + for (Map.Entry<GenericValue, Double> entry: toCreateMap.entrySet()) { + GenericValue res = entry.getKey(); + Double qty = entry.getValue(); this.createPackLineItem(2, res, orderId, orderItemSeqId, shipGroupSeqId, productId, qty.doubleValue(), weight, packageSeqId); } } else { @@ -202,10 +201,7 @@ } public PackingSessionLine findLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, int packageSeq) { - List<PackingSessionLine> lines = this.getLines(); - Iterator<PackingSessionLine> i = lines.iterator(); - while (i.hasNext()) { - PackingSessionLine line = i.next(); + for (PackingSessionLine line: this.getLines()) { if (orderId.equals(line.getOrderId()) && orderItemSeqId.equals(line.getOrderItemSeqId()) && shipGroupSeqId.equals(line.getShipGroupSeqId()) && @@ -255,19 +251,14 @@ String orderItemSeqId = null; if (orderItems != null) { - Iterator<GenericValue> i = orderItems.iterator(); - while (i.hasNext()) { - GenericValue item = i.next(); - + for (GenericValue item: orderItems) { // get the reservations for the item Map<String, Object> invLookup = FastMap.newInstance(); invLookup.put("orderId", orderId); invLookup.put("orderItemSeqId", item.getString("orderItemSeqId")); invLookup.put("shipGroupSeqId", shipGroupSeqId); List<GenericValue> reservations = this.getDelegator().findByAnd("OrderItemShipGrpInvRes", invLookup); - Iterator<GenericValue> resIter = reservations.iterator(); - while (resIter.hasNext()) { - GenericValue res = resIter.next(); + for (GenericValue res: reservations) { Double qty = res.getDouble("quantity"); if (quantity <= qty.doubleValue()) { orderItemSeqId = item.getString("orderItemSeqId"); @@ -314,9 +305,7 @@ } public void addItemInfo(List<GenericValue> infos) { - Iterator<GenericValue> i = infos.iterator(); - while (i.hasNext()) { - GenericValue v = i.next(); + for (GenericValue v: infos) { ItemDisplay newItem = new ItemDisplay(v); int currentIdx = itemInfos.indexOf(newItem); if (currentIdx != -1) { @@ -362,10 +351,7 @@ public double getPackedQuantity(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, int packageSeq) { double total = 0.0; - List<PackingSessionLine> lines = this.getLines(); - Iterator<PackingSessionLine> i = lines.iterator(); - while (i.hasNext()) { - PackingSessionLine line = i.next(); + for (PackingSessionLine line: this.getLines()) { if (orderId.equals(line.getOrderId()) && orderItemSeqId.equals(line.getOrderItemSeqId()) && shipGroupSeqId.equals(line.getShipGroupSeqId()) && productId.equals(line.getProductId())) { if (inventoryItemId == null || inventoryItemId.equals(line.getInventoryItemId())) { @@ -389,10 +375,7 @@ double total = 0.0; if (productId != null ) { - List<PackingSessionLine> lines = this.getLines(); - Iterator<PackingSessionLine> i = lines.iterator(); - while (i.hasNext()) { - PackingSessionLine line = i.next(); + for (PackingSessionLine line: this.getLines()) { if (productId.equals(line.getProductId())) { if (packageSeq == -1 || packageSeq == line.getPackageSeq()) { total += line.getQuantity(); @@ -405,10 +388,7 @@ public double getPackedQuantity(int packageSeq) { double total = 0.0; - List<PackingSessionLine> lines = this.getLines(); - Iterator<PackingSessionLine> i = lines.iterator(); - while (i.hasNext()) { - PackingSessionLine line = i.next(); + for (PackingSessionLine line: this.getLines()) { if (packageSeq == -1 || packageSeq == line.getPackageSeq()) { total += line.getQuantity(); } @@ -440,9 +420,7 @@ double shipped = 0.0; List<GenericValue> issues = this.getItemIssuances(orderId, orderItemSeqId, shipGroupSeqId); if (issues != null) { - Iterator<GenericValue> i = issues.iterator(); - while (i.hasNext()) { - GenericValue v = i.next(); + for (GenericValue v: issues) { Double qty = v.getDouble("quantity"); if (qty == null) qty = Double.valueOf(0); shipped += qty.doubleValue(); @@ -457,9 +435,7 @@ List<GenericValue> issues = this.getItemIssuances(orderId, orderItemSeqId, shipGroupSeqId); if (issues != null) { - Iterator<GenericValue> i = issues.iterator(); - while (i.hasNext()) { - GenericValue v = i.next(); + for (GenericValue v: issues) { shipmentIds.add(v.getString("shipmentId")); } } @@ -555,9 +531,7 @@ } List<PackingSessionLine> currentLines = UtilMisc.makeListWritable(this.packLines); - Iterator<PackingSessionLine> i = currentLines.iterator(); - while (i.hasNext()) { - PackingSessionLine line = i.next(); + for (PackingSessionLine line: currentLines) { if (line.getPackageSeq() == packageSeq) { this.clearLine(line); } @@ -623,9 +597,7 @@ protected void checkReservations(boolean ignore) throws GeneralException { List<String> errors = FastList.newInstance(); - Iterator<PackingSessionLine> i = this.getLines().iterator(); - while (i.hasNext()) { - PackingSessionLine line = i.next(); + for (PackingSessionLine line: this.getLines()) { double reservedQty = this.getCurrentReservedQuantity(line.getOrderId(), line.getOrderItemSeqId(), line.getShipGroupSeqId(), line.getProductId()); double packedQty = this.getPackedQuantity(line.getOrderId(), line.getOrderItemSeqId(), line.getShipGroupSeqId(), line.getProductId()); @@ -646,9 +618,7 @@ protected void checkEmptyLines() throws GeneralException { List<PackingSessionLine> lines = FastList.newInstance(); lines.addAll(this.getLines()); - Iterator<PackingSessionLine> i = lines.iterator(); - while (i.hasNext()) { - PackingSessionLine l = i.next(); + for (PackingSessionLine l: lines) { if (l.getQuantity() == 0) { this.packLines.remove(l); } @@ -657,9 +627,7 @@ protected void runEvents(int eventCode) { if (this.packEvents.size() > 0) { - Iterator<PackingEvent> i = this.packEvents.iterator(); - while (i.hasNext()) { - PackingEvent event = i.next(); + for (PackingEvent event: this.packEvents) { event.runEvent(this, eventCode); } } @@ -711,10 +679,7 @@ protected void issueItemsToShipment() throws GeneralException { List<PackingSessionLine> processedLines = FastList.newInstance(); - List<PackingSessionLine> lines = this.getLines(); - Iterator<PackingSessionLine> i = lines.iterator(); - while (i.hasNext()) { - PackingSessionLine line = i.next(); + for (PackingSessionLine line: this.getLines()) { if (this.checkLine(processedLines, line)) { double totalPacked = this.getPackedQuantity(line.getOrderId(), line.getOrderItemSeqId(), line.getShipGroupSeqId(), line.getProductId(), line.getInventoryItemId(), -1); @@ -726,9 +691,7 @@ } protected boolean checkLine(List<PackingSessionLine> processedLines, PackingSessionLine line) { - Iterator<PackingSessionLine> i = processedLines.iterator(); - while (i.hasNext()) { - PackingSessionLine l = i.next(); + for (PackingSessionLine l: processedLines) { if (line.isSameItem(l)) { line.setShipmentItemSeqId(l.getShipmentItemSeqId()); return false; @@ -758,10 +721,7 @@ } protected void applyItemsToPackages() throws GeneralException { - List<PackingSessionLine> lines = this.getLines(); - Iterator<PackingSessionLine> i = lines.iterator(); - while (i.hasNext()) { - PackingSessionLine line = i.next(); + for (PackingSessionLine line: this.getLines()) { line.applyLineToPackage(shipmentId, userLogin, getDispatcher()); } } @@ -771,9 +731,7 @@ if (shipmentWeight.doubleValue() <= 0) return; List<GenericValue> shipmentRouteSegments = getDelegator().findByAnd("ShipmentRouteSegment", UtilMisc.toMap("shipmentId", this.getShipmentId())); if (! UtilValidate.isEmpty(shipmentRouteSegments)) { - Iterator<GenericValue> srit = shipmentRouteSegments.iterator(); - while (srit.hasNext()) { - GenericValue shipmentRouteSegment = srit.next(); + for (GenericValue shipmentRouteSegment: shipmentRouteSegments) { shipmentRouteSegment.set("billingWeight", shipmentWeight); shipmentRouteSegment.set("billingWeightUomId", getWeightUomId()); } @@ -860,9 +818,7 @@ if (UtilValidate.isEmpty(shippableItemInfo)) { shippableItemInfo = FastList.newInstance(); - Iterator<PackingSessionLine> lit = getLines().iterator(); - while (lit.hasNext()) { - PackingSessionLine line = lit.next(); + for (PackingSessionLine line: getLines()) { List<GenericValue> oiasgas = getDelegator().findByAnd("OrderItemAndShipGroupAssoc", UtilMisc.toMap("orderId", line.getOrderId(), "orderItemSeqId", line.getOrderItemSeqId(), "shipGroupSeqId", line.getShipGroupSeqId())); shippableItemInfo.addAll(oiasgas); } @@ -910,9 +866,7 @@ public List<Integer> getPackageSeqIds() { Set<Integer> packageSeqIds = new TreeSet<Integer>(); if (! UtilValidate.isEmpty(this.getLines())) { - Iterator<PackingSessionLine> lit = this.getLines().iterator(); - while (lit.hasNext()) { - PackingSessionLine line = lit.next(); + for (PackingSessionLine line: this.getLines()) { packageSeqIds.add(Integer.valueOf(line.getPackageSeq())); } } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/picklist/PickListServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/picklist/PickListServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/picklist/PickListServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/picklist/PickListServices.java Mon Nov 10 18:20:53 2008 @@ -20,7 +20,6 @@ import java.util.Map; import java.util.List; -import java.util.Iterator; import javolution.util.FastList; @@ -61,9 +60,7 @@ conditionList2.add(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER")); // build the expression list from the IDs - Iterator<String> i = orderIdList.iterator(); - while (i.hasNext()) { - String orderId = i.next(); + for (String orderId: orderIdList) { conditionList1.add(EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderId)); } @@ -101,9 +98,7 @@ } if (!UtilValidate.isEmpty(items)) { - Iterator<GenericValue> i = items.iterator(); - while (i.hasNext()) { - GenericValue v = i.next(); + for (GenericValue v: items) { String itemStatus = v.getString("itemStatusId"); if (itemStatus != null) { if (!"PICKITEM_COMPLETED".equals(itemStatus)) { Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Mon Nov 10 18:20:53 2008 @@ -281,10 +281,8 @@ } // Get the possible estimates. List<GenericValue> estimateList = FastList.newInstance(); - Iterator<GenericValue> i = estimates.iterator(); - while (i.hasNext()) { - GenericValue thisEstimate = i.next(); + for (GenericValue thisEstimate: estimates) { String toGeo = thisEstimate.getString("geoIdTo"); if(UtilValidate.isNotEmpty(toGeo) && shipAddress ==null){ // This estimate requires shipping address details. We don't have it so we cannot use this estimate. @@ -385,10 +383,7 @@ List<Double> shippableItemSizes = FastList.newInstance(); Map<String, Double> shippableFeatureMap = FastMap.newInstance(); if (shippableItemInfo != null) { - Iterator<Map<String, Object>> sii = shippableItemInfo.iterator(); - while (sii.hasNext()) { - Map<String, Object> itemMap = sii.next(); - + for (Map<String, Object> itemMap: shippableItemInfo) { // add the item sizes Double itemSize = (Double) itemMap.get("size"); if (itemSize != null) { @@ -399,9 +394,7 @@ Double quantity = (Double) itemMap.get("quantity"); Set<String> featureSet = UtilGenerics.checkSet(itemMap.get("featureSet")); if (UtilValidate.isNotEmpty(featureSet)) { - Iterator<String> fi = featureSet.iterator(); - while (fi.hasNext()) { - String featureId = fi.next(); + for (String featureId: featureSet) { Double featureQuantity = shippableFeatureMap.get(featureId); if (featureQuantity == null) { featureQuantity = Double.valueOf(0.00); @@ -428,9 +421,7 @@ TreeMap<Integer, GenericValue> estimatePriority = new TreeMap<Integer, GenericValue>(); //int estimatePriority[] = new int[estimateList.size()]; - for (int x = 0; x < estimateList.size(); x++) { - GenericValue currentEstimate = estimateList.get(x); - + for (GenericValue currentEstimate: estimateList) { int prioritySum = 0; if (UtilValidate.isNotEmpty(currentEstimate.getString("partyId"))) prioritySum += PRIORITY_PARTY; @@ -511,10 +502,9 @@ } if (featureGroupId != null && featureGroupId.length() > 0 && shippableFeatureMap != null) { - Iterator<String> fii = shippableFeatureMap.keySet().iterator(); - while (fii.hasNext()) { - String featureId = fii.next(); - Double quantity = shippableFeatureMap.get(featureId); + for (Map.Entry<String, Double> entry: shippableFeatureMap.entrySet()) { + String featureId = entry.getKey(); + Double quantity = entry.getValue(); GenericValue appl = null; Map<String, String> fields = UtilMisc.toMap("productFeatureGroupId", featureGroupId, "productFeatureId", featureId); try { @@ -537,9 +527,7 @@ Double sizePrice = estimate.getDouble("oversizePrice"); if (sizeUnit != null && sizeUnit.doubleValue() > 0) { if (shippableItemSizes != null) { - Iterator<Double> isi = shippableItemSizes.iterator(); - while (isi.hasNext()) { - Double size = isi.next(); + for (Double size: shippableItemSizes) { if (size != null && size.doubleValue() >= sizeUnit.doubleValue()) { sizeSurcharge += sizePrice.doubleValue(); } @@ -646,9 +634,7 @@ toStore.add(stageShip); - Iterator<GenericValue> p = packages.iterator(); - while (p.hasNext()) { - GenericValue shipmentPkg = p.next(); + for (GenericValue shipmentPkg: packages) { GenericValue stagePkg = delegator.makeValue("OdbcPackageOut"); stagePkg.set("shipmentId", shipmentPkg.get("shipmentId")); stagePkg.set("shipmentPackageSeqId", shipmentPkg.get("shipmentPackageSeqId")); @@ -796,10 +782,9 @@ } // update the status of each shipment - Iterator<String> i = shipmentMap.keySet().iterator(); - while (i.hasNext()) { - String shipmentId = i.next(); - String voidInd = shipmentMap.get(shipmentId); + for (Map.Entry<String, String> entry: shipmentMap.entrySet()) { + String shipmentId = entry.getKey(); + String voidInd = entry.getValue(); Map<String, Object> shipCtx = FastMap.newInstance(); shipCtx.put("shipmentId", shipmentId); if ("Y".equals(voidInd)) { @@ -878,9 +863,7 @@ // store the quanitity of each product shipped in a hashmap keyed to productId Map<String, Double> shippedCountMap = FastMap.newInstance(); - Iterator<GenericValue> iter = shipmentAndItems.iterator(); - while (iter.hasNext()) { - GenericValue item = iter.next(); + for (GenericValue item: shipmentAndItems) { double shippedQuantity = item.getDouble("quantity").doubleValue(); Double quantity = shippedCountMap.get(item.getString("productId")); quantity = Double.valueOf(quantity == null ? shippedQuantity : shippedQuantity + quantity.doubleValue()); @@ -889,9 +872,7 @@ // store the quanitity of each product received in a hashmap keyed to productId Map<String, Double> receivedCountMap = FastMap.newInstance(); - iter = shipmentReceipts.iterator(); - while (iter.hasNext()) { - GenericValue item = iter.next(); + for (GenericValue item: shipmentAndItems) { double receivedQuantity = item.getDouble("quantityAccepted").doubleValue(); Double quantity = receivedCountMap.get(item.getString("productId")); quantity = Double.valueOf(quantity == null ? receivedQuantity : receivedQuantity + quantity.doubleValue()); @@ -1034,9 +1015,7 @@ } List<GenericValue> packageContents = delegator.findByAnd("PackedQtyVsOrderItemQuantity", UtilMisc.toMap("shipmentId", shipmentId, "shipmentPackageSeqId", shipmentPackageSeqId)); - Iterator<GenericValue> packageContentsIt = packageContents.iterator(); - while (packageContentsIt.hasNext()) { - GenericValue packageContent = packageContentsIt.next(); + for (GenericValue packageContent: packageContents) { String orderId = packageContent.getString("orderId"); String orderItemSeqId = packageContent.getString("orderItemSeqId"); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java Mon Nov 10 18:20:53 2008 @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.StringWriter; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -344,10 +343,9 @@ List<Map<String, String>> chargeList = FastList.newInstance(); if (UtilValidate.isNotEmpty(chargeNodeList)) { - for (int i = 0; chargeNodeList.size() > i; i++) { + for (Element responseChargeElement: chargeNodeList) { Map<String, String> charge = FastMap.newInstance(); - Element responseChargeElement = chargeNodeList.get(i); Element responseChargeTypeElement = UtilXml.firstChildElement( responseChargeElement, "Type"); @@ -612,9 +610,7 @@ String width = null; String height = null; Double packageWeight = null; - Iterator<GenericValue> shipmentPackageRouteSegIter = shipmentPackageRouteSegs.iterator(); - while (shipmentPackageRouteSegIter.hasNext()) { - GenericValue shipmentPackageRouteSeg = shipmentPackageRouteSegIter.next(); + for (GenericValue shipmentPackageRouteSeg: shipmentPackageRouteSegs) { GenericValue shipmentPackage = shipmentPackageRouteSeg.getRelatedOne("ShipmentPackage"); GenericValue shipmentBoxType = shipmentPackage.getRelatedOne("ShipmentBoxType"); List<GenericValue> carrierShipmentBoxTypes = shipmentPackage.getRelated("CarrierShipmentBoxType", UtilMisc.toMap("partyId", "DHL"), null); @@ -845,9 +841,7 @@ private static double getWeight(List<Map<String, Object>> shippableItemInfo) { double totalWeight = 0; if (shippableItemInfo != null) { - Iterator<Map<String, Object>> sii = shippableItemInfo.iterator(); - while (sii.hasNext()) { - Map<String, Object> itemInfo = sii.next(); + for (Map<String, Object> itemInfo: shippableItemInfo) { double weight = ((Double) itemInfo.get("weight")).doubleValue(); totalWeight = totalWeight + weight; } @@ -888,10 +882,8 @@ "Faults"); List<? extends Element> faultElements = UtilXml.childElementList(faultsElement, "Fault"); if (UtilValidate.isNotEmpty(faultElements)) { - Iterator<? extends Element> errorElementIter = faultElements.iterator(); - while (errorElementIter.hasNext()) { + for (Element errorElement: faultElements) { StringBuilder errorMessageBuf = new StringBuilder(); - Element errorElement = errorElementIter.next(); String errorCode = UtilXml.childElementValue(errorElement, "Code"); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/fedex/FedexServices.java Mon Nov 10 18:20:53 2008 @@ -23,7 +23,6 @@ import java.io.StringWriter; import java.math.BigDecimal; import java.sql.Timestamp; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -686,10 +685,7 @@ } // Loop through Shipment segments (NOTE: only one supported, loop is here for future refactoring reference) - Iterator<GenericValue> shipmentPackageRouteSegIter = shipmentPackageRouteSegs.iterator(); - while (shipmentPackageRouteSegIter.hasNext()) { - - GenericValue shipmentPackageRouteSeg = shipmentPackageRouteSegIter.next(); + for (GenericValue shipmentPackageRouteSeg: shipmentPackageRouteSegs) { GenericValue shipmentPackage = shipmentPackageRouteSeg.getRelatedOne("ShipmentPackage"); GenericValue shipmentBoxType = shipmentPackage.getRelatedOne("ShipmentBoxType"); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/ups/UpsServices.java Mon Nov 10 18:20:53 2008 @@ -76,9 +76,7 @@ unitsUpsToOfbiz.put("LBS", "WT_lb"); unitsUpsToOfbiz.put("KGS", "WT_kg"); - Iterator<Map.Entry<String, String>> unitsUpsToOfbizIter = unitsUpsToOfbiz.entrySet().iterator(); - while (unitsUpsToOfbizIter.hasNext()) { - Map.Entry<String, String> entry = unitsUpsToOfbizIter.next(); + for (Map.Entry<String, String> entry: unitsUpsToOfbiz.entrySet()) { unitsOfbizToUps.put(entry.getValue(), entry.getKey()); } } @@ -190,21 +188,17 @@ List<GenericValue> itemIssuances = shipment.getRelated("ItemIssuance"); Set<String> orderIdSet = new TreeSet<String>(); - Iterator<GenericValue> itemIssuanceIter = itemIssuances.iterator(); - while (itemIssuanceIter.hasNext()) { - GenericValue itemIssuance = itemIssuanceIter.next(); + for (GenericValue itemIssuance: itemIssuances) { orderIdSet.add(itemIssuance.getString("orderId")); } String ordersDescription = ""; if (orderIdSet.size() > 1) { StringBuilder odBuf = new StringBuilder("Orders "); - Iterator<String> orderIdIter = orderIdSet.iterator(); - while (orderIdIter.hasNext()) { - String orderId = orderIdIter.next(); - odBuf.append(orderId); - if (orderIdIter.hasNext()) { + for (String orderId: orderIdSet) { + if (odBuf.length() > 0) { odBuf.append(", "); } + odBuf.append(orderId); } ordersDescription = odBuf.toString(); } else if (orderIdSet.size() > 0) { @@ -964,9 +958,7 @@ // now process the PackageResults elements List<? extends Element> packageResultsElements = UtilXml.childElementList(shipmentResultsElement, "PackageResults"); Iterator<GenericValue> shipmentPackageRouteSegIter = shipmentPackageRouteSegs.iterator(); - Iterator<? extends Element> packageResultsElementIter = packageResultsElements.iterator(); - while (packageResultsElementIter.hasNext()) { - Element packageResultsElement = packageResultsElementIter.next(); + for (Element packageResultsElement: packageResultsElements) { String trackingNumber = UtilXml.childElementValue(packageResultsElement, "TrackingNumber"); @@ -1437,9 +1429,7 @@ String shipmentIdentificationNumber = UtilXml.childElementValue(shipmentElement, "ShipmentIdentificationNumber"); List<? extends Element> packageElements = UtilXml.childElementList(shipmentElement, "Package"); - Iterator<? extends Element> packageElementIter = packageElements.iterator(); - while (packageElementIter.hasNext()) { - Element packageElement = packageElementIter.next(); + for (Element packageElement: packageElements) { } /* <Package> @@ -1562,9 +1552,7 @@ private static void splitEstimatePackages(Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo, double maxWeight, double minWeight) { List<Map<String, Double>> packages = getPackageSplit(shippableItemInfo, maxWeight); if (UtilValidate.isNotEmpty(packages)) { - Iterator<Map<String, Double>> i = packages.iterator(); - while (i.hasNext()) { - Map<String, Double> packageMap = i.next(); + for (Map<String, Double> packageMap: packages) { addPackageElement(requestDoc, shipmentElement, shippableItemInfo, packageMap, minWeight); } } else { @@ -1630,9 +1618,7 @@ List<Map<String, Double>> packages = FastList.newInstance(); if (shippableItemInfo != null) { - Iterator<Map<String, Object>> sii = shippableItemInfo.iterator(); - while (sii.hasNext()) { - Map<String, Object> itemInfo = sii.next(); + for (Map<String, Object> itemInfo: shippableItemInfo) { long pieces = ((Long) itemInfo.get("piecesIncluded")).longValue(); double totalQuantity = ((Double) itemInfo.get("quantity")).doubleValue(); double totalWeight = ((Double) itemInfo.get("weight")).doubleValue(); @@ -1664,9 +1650,8 @@ // package loop int packageSize = packages.size(); boolean addedToPackage = false; - for (int pi = 0; pi < packageSize; pi++) { + for (Map<String, Double> packageMap: packages) { if (!addedToPackage) { - Map<String, Double> packageMap = packages.get(pi); double packageWeight = calcPackageWeight(packageMap, shippableItemInfo, weight); if (packageWeight <= maxWeight) { Double qtyD = (Double) packageMap.get(productId); @@ -1691,12 +1676,11 @@ private static double calcPackageWeight(Map<String, Double> packageMap, List<Map<String, Object>> shippableItemInfo, double additionalWeight) { double totalWeight = 0.00; - Iterator<String> i = packageMap.keySet().iterator(); - while (i.hasNext()) { - String productId = i.next(); + for (Map.Entry<String, Double> entry: packageMap.entrySet()) { + String productId = entry.getKey(); Map<String, Object> productInfo = getProductItemInfo(shippableItemInfo, productId); double productWeight = ((Double) productInfo.get("weight")).doubleValue(); - double quantity = packageMap.get(productId).doubleValue(); + double quantity = entry.getValue().doubleValue(); totalWeight += (productWeight * quantity); } return totalWeight + additionalWeight; @@ -1704,9 +1688,7 @@ private static Map<String, Object> getProductItemInfo(List<Map<String, Object>> shippableItemInfo, String productId) { if (shippableItemInfo != null) { - Iterator<Map<String, Object>> i = shippableItemInfo.iterator(); - while (i.hasNext()) { - Map<String, Object> testMap = i.next(); + for (Map<String, Object> testMap: shippableItemInfo) { String id = (String) testMap.get("productId"); if (productId.equals(id)) { return testMap; @@ -1738,10 +1720,7 @@ if (rates == null || rates.size() == 0) { return ServiceUtil.returnError("No rates available at this time"); } else { - Iterator<? extends Element> i = rates.iterator(); - while (i.hasNext()) { - Element element = i.next(); - + for (Element element: rates) { // get service Element service = UtilXml.firstChildElement(element, "Service"); String serviceCode = UtilXml.childElementValue(service, "Code"); @@ -1784,10 +1763,8 @@ public static void handleErrors(Element responseElement, List<Object> errorList) { List<? extends Element> errorElements = UtilXml.childElementList(responseElement, "Error"); - Iterator<? extends Element> errorElementIter = errorElements.iterator(); - while (errorElementIter.hasNext()) { + for (Element errorElement: errorElements) { StringBuilder errorMessageBuf = new StringBuilder(); - Element errorElement = errorElementIter.next(); String errorSeverity = UtilXml.childElementValue(errorElement, "ErrorSeverity"); String errorCode = UtilXml.childElementValue(errorElement, "ErrorCode"); @@ -1809,9 +1786,7 @@ } List<? extends Element> errorLocationElements = UtilXml.childElementList(errorElement, "ErrorLocation"); - Iterator<? extends Element> errorLocationElementIter = errorLocationElements.iterator(); - while (errorLocationElementIter.hasNext()) { - Element errorLocationElement = errorLocationElementIter.next(); + for (Element errorLocationElement: errorLocationElements) { String errorLocationElementName = UtilXml.childElementValue(errorLocationElement, "ErrorLocationElementName"); String errorLocationAttributeName = UtilXml.childElementValue(errorLocationElement, "ErrorLocationAttributeName"); @@ -1826,9 +1801,7 @@ } List<? extends Element> errorDigestElements = UtilXml.childElementList(errorLocationElement, "ErrorDigest"); - Iterator<? extends Element> errorDigestElementIter = errorDigestElements.iterator(); - while (errorDigestElementIter.hasNext()) { - Element errorDigestElement = errorDigestElementIter.next(); + for (Element errorDigestElement: errorDigestElements) { errorMessageBuf.append(" full text: ["); errorMessageBuf.append(UtilXml.elementValue(errorDigestElement)); errorMessageBuf.append("]"); @@ -2053,9 +2026,7 @@ splitEstimatePackages(rateRequestDoc, shipmentElement, shippableItemInfo, maxWeight, minWeight); } else { - Iterator<Double> i = packageWeights.iterator(); - while (i.hasNext()) { - Double packageWeight = i.next(); + for (Double packageWeight: packageWeights) { addPackageElement(rateRequestDoc, shipmentElement, packageWeight); } } @@ -2228,10 +2199,7 @@ List<? extends Element> avResultList = UtilXml.childElementList(avResponseElement, "AddressValidationResult"); // TODO: return error if there are no matches? if (UtilValidate.isNotEmpty(avResultList)) { - Iterator<? extends Element> i = avResultList.iterator(); - while (i.hasNext()) { - Element avResultElement = i.next(); - + for (Element avResultElement: avResultList) { Map<String, String> match = FastMap.newInstance(); match.put("Rank", UtilXml.childElementValue(avResultElement, "Rank")); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsMockApiServlet.java Mon Nov 10 18:20:53 2008 @@ -22,7 +22,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.Iterator; import java.util.List; import javax.servlet.ServletConfig; @@ -95,9 +94,7 @@ if (UtilValidate.isNotEmpty(packageElementList)) { Document responseDocument = UtilXml.makeEmptyXmlDocument("RateResponse"); - for (Iterator<? extends Element> i = packageElementList.iterator(); i.hasNext();) { - Element packageElement = i.next(); - + for (Element packageElement: packageElementList) { Element responsePackageElement = UtilXml.addChildElement(responseDocument.getDocumentElement(), "Package", responseDocument); responsePackageElement.setAttribute("ID", packageElement.getAttribute("ID")); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java?rev=712919&r1=712918&r2=712919&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/usps/UspsServices.java Mon Nov 10 18:20:53 2008 @@ -201,8 +201,7 @@ } double estimateAmount = 0.00; - for (Iterator<? extends Element> i = rates.iterator(); i.hasNext();) { - Element packageElement = i.next(); + for (Element packageElement: rates) { try { Element postageElement = UtilXml.firstChildElement(packageElement, "Postage"); double packageAmount = Double.parseDouble(UtilXml.childElementValue(postageElement, "Rate")); @@ -222,9 +221,7 @@ List<Map<String, Double>> packages = FastList.newInstance(); if (shippableItemInfo != null) { - Iterator<Map<String, Object>> sii = shippableItemInfo.iterator(); - while (sii.hasNext()) { - Map<String, Object> itemInfo = sii.next(); + for (Map<String, Object> itemInfo: shippableItemInfo) { long pieces = ((Long) itemInfo.get("piecesIncluded")).longValue(); double totalQuantity = ((Double) itemInfo.get("quantity")).doubleValue(); double totalWeight = ((Double) itemInfo.get("weight")).doubleValue(); @@ -250,11 +247,9 @@ } // package loop - int packageSize = packages.size(); boolean addedToPackage = false; - for (int pi = 0; pi < packageSize; pi++) { + for (Map<String, Double> packageMap: packages) { if (!addedToPackage) { - Map<String, Double> packageMap = packages.get(pi); double packageWeight = calcPackageWeight(dctx, packageMap, shippableItemInfo, weight); if (packageWeight <= maxWeight) { Double qtyD = (Double) packageMap.get(productId); @@ -287,12 +282,11 @@ defaultWeightUomId = "WT_oz"; } - Iterator<String> i = packageMap.keySet().iterator(); - while (i.hasNext()) { - String productId = i.next(); + for (Map.Entry<String, Double> entry: packageMap.entrySet()) { + String productId = entry.getKey(); Map<String, Object> productInfo = getProductItemInfo(shippableItemInfo, productId); double productWeight = ((Double) productInfo.get("weight")).doubleValue(); - double quantity = packageMap.get(productId).doubleValue(); + double quantity = entry.getValue().doubleValue(); // DLK - I'm not sure if this line is working. shipment_package seems to leave this value null so??? String weightUomId = (String) productInfo.get("weight_uom_id"); @@ -329,9 +323,7 @@ // lifted from UpsServices with no changes - 2004.09.06 JFE private static Map<String, Object> getProductItemInfo(List<Map<String, Object>> shippableItemInfo, String productId) { if (shippableItemInfo != null) { - Iterator<Map<String, Object>> i = shippableItemInfo.iterator(); - while (i.hasNext()) { - Map<String, Object> testMap = i.next(); + for (Map<String, Object> testMap: shippableItemInfo) { String id = (String) testMap.get("productId"); if (productId.equals(id)) { return testMap; @@ -389,8 +381,8 @@ List<? extends Element> detailElementList = UtilXml.childElementList(trackInfoElement, "TrackDetail"); if (UtilValidate.isNotEmpty(detailElementList)) { List<String> trackingDetailList = FastList.newInstance(); - for (Iterator<? extends Element> iter = detailElementList.iterator(); iter.hasNext();) { - trackingDetailList.add(UtilXml.elementValue(iter.next())); + for (Element detailElement: detailElementList) { + trackingDetailList.add(UtilXml.elementValue(detailElement)); } result.put("trackingDetailList", trackingDetailList); } @@ -1141,8 +1133,7 @@ return ServiceUtil.returnError("No packages found for ShipmentRouteSegment " + srsKeyString); } - for (Iterator<GenericValue> i = shipmentPackageRouteSegList.iterator(); i.hasNext();) { - + for (GenericValue shipmentPackageRouteSeg: shipmentPackageRouteSegList) { Document requestDocument = createUspsRequestDocument("DeliveryConfirmationV2.0Request"); Element requestElement = requestDocument.getDocumentElement(); @@ -1179,7 +1170,6 @@ UtilXml.addChildElementValue(requestElement, "ToZip5", destinationAddress.getString("postalCode"), requestDocument); UtilXml.addChildElement(requestElement, "ToZip4", requestDocument); - GenericValue shipmentPackageRouteSeg = i.next(); GenericValue shipmentPackage = shipmentPackageRouteSeg.getRelatedOne("ShipmentPackage"); String spKeyString = "[" + shipmentPackage.getString("shipmentId") + "," + shipmentPackage.getString("shipmentPackageSeqId") + "]"; @@ -1279,9 +1269,7 @@ List<GenericValue> shipmentPackageRouteSegList = shipmentRouteSegment.getRelated("ShipmentPackageRouteSeg", null, UtilMisc.toList("+shipmentPackageSeqId")); - for (Iterator<GenericValue> i = shipmentPackageRouteSegList.iterator(); i.hasNext();) { - GenericValue shipmentPackageRouteSeg = i.next(); - + for (GenericValue shipmentPackageRouteSeg: shipmentPackageRouteSegList) { byte[] labelImageBytes = shipmentPackageRouteSeg.getBytes("labelImage"); String outFileName = "UspsLabelImage" + shipmentRouteSegment.getString("shipmentId") + "_" + |
Free forum by Nabble | Edit this page |