svn commit: r1301945 - in /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing: bom/BOMHelper.java bom/BOMNode.java bom/BOMServices.java jobshopmgt/ProductionRunServices.java mrp/MrpServices.java techdata/TechDataServices.java

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

svn commit: r1301945 - in /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing: bom/BOMHelper.java bom/BOMNode.java bom/BOMServices.java jobshopmgt/ProductionRunServices.java mrp/MrpServices.java techdata/TechDataServices.java

erwan
Author: erwan
Date: Sat Mar 17 15:12:47 2012
New Revision: 1301945

URL: http://svn.apache.org/viewvc?rev=1301945&view=rev
Log:
Changes from while to for each loops in manufacturing component

Modified:
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java?rev=1301945&r1=1301944&r2=1301945&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java Sat Mar 17 15:12:47 2012
@@ -68,11 +68,8 @@ public class BOMHelper {
         List<GenericValue> productNodesList = delegator.findByAndCache("ProductAssoc",
                 UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", bomType));
         productNodesList = EntityUtil.filterByDate(productNodesList, inDate);
-        GenericValue oneNode = null;
-        Iterator<GenericValue> nodesIterator = productNodesList.iterator();
         int depth = 0;
-        while (nodesIterator.hasNext()) {
-            oneNode = nodesIterator.next();
+        for (GenericValue oneNode : productNodesList) {
             depth = 0;
             depth = getMaxDepth(oneNode.getString("productId"), bomType, inDate, delegator);
             depth++;
@@ -114,11 +111,9 @@ public class BOMHelper {
         List<GenericValue> productNodesList = delegator.findByAndCache("ProductAssoc",
                 UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", bomType));
         productNodesList = EntityUtil.filterByDate(productNodesList, inDate);
-        GenericValue oneNode = null;
         GenericValue duplicatedNode = null;
         Iterator<GenericValue> nodesIterator = productNodesList.iterator();
-        while (nodesIterator.hasNext()) {
-            oneNode = nodesIterator.next();
+        for(GenericValue oneNode : productNodesList) {
             for (int i = 0; i < productIdKeys.size(); i++) {
                 if (oneNode.getString("productId").equals(productIdKeys.get(i))) {
                     return oneNode;
@@ -141,9 +136,7 @@ public class BOMHelper {
 
         try {
         List<GenericValue> shipmentPlans = delegator.findByAnd("OrderShipment", UtilMisc.toMap("shipmentId", shipmentId));
-        Iterator<GenericValue> shipmentPlansIt = shipmentPlans.iterator();
-        while (shipmentPlansIt.hasNext()) {
-            GenericValue shipmentPlan = shipmentPlansIt.next();
+        for(GenericValue shipmentPlan : shipmentPlans) {
             GenericValue orderItem = shipmentPlan.getRelatedOne("OrderItem");
 
             List<GenericValue> productionRuns = delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId", shipmentPlan.getString("orderId"), "orderItemSeqId", shipmentPlan.getString("orderItemSeqId"), "shipGroupSeqId", shipmentPlan.getString("shipGroupSeqId")));

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java?rev=1301945&r1=1301944&r2=1301945&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java Sat Mar 17 15:12:47 2012
@@ -114,11 +114,8 @@ public class BOMNode {
         children = FastList.newInstance();
         children.addAll(rows);
         childrenNodes = FastList.newInstance();
-        Iterator<GenericValue> childrenIterator = children.iterator();
-        GenericValue oneChild = null;
         BOMNode oneChildNode = null;
-        while (childrenIterator.hasNext()) {
-            oneChild = childrenIterator.next();
+        for(GenericValue oneChild : children) {
             // Configurator
             oneChildNode = configurator(oneChild, productFeatures, getRootNode().getProductForRules(), inDate);
             // If the node is null this means that the node has been discarded by the rules.
@@ -340,13 +337,11 @@ public class BOMNode {
             rows = EntityUtil.filterByDate(rows, inDate);
         }
         children = FastList.newInstance();
-        children.addAll(rows);;
+        children.addAll(rows);
         childrenNodes = FastList.newInstance();
-        Iterator<GenericValue> childrenIterator = children.iterator();
-        GenericValue oneChild = null;
+
         BOMNode oneChildNode = null;
-        while (childrenIterator.hasNext()) {
-            oneChild = childrenIterator.next();
+        for(GenericValue oneChild : children) {
             oneChildNode = new BOMNode(oneChild.getString("productId"), delegator, dispatcher, userLogin);
             // Configurator
             //oneChildNode = configurator(oneChild, productFeatures, getRootNode().getProductForRules(), delegator);

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java?rev=1301945&r1=1301944&r2=1301945&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java Sat Mar 17 15:12:47 2012
@@ -84,9 +84,8 @@ public class BOMServices {
         if (bomType == null) {
             try {
                 List<GenericValue> bomTypesValues = delegator.findByAnd("ProductAssocType", UtilMisc.toMap("parentTypeId", "PRODUCT_COMPONENT"));
-                Iterator<GenericValue> bomTypesValuesIt = bomTypesValues.iterator();
-                while (bomTypesValuesIt.hasNext()) {
-                    bomTypes.add((bomTypesValuesIt.next()).getString("productAssocTypeId"));
+                for(GenericValue bomTypesValue : bomTypesValues) {
+                    bomTypes.add(bomTypesValue.getString("productAssocTypeId"));
                 }
             } catch (GenericEntityException gee) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingBomErrorRunningMaxDethAlgorithm", UtilMisc.toMap("errorString", gee.getMessage()), locale));
@@ -97,10 +96,8 @@ public class BOMServices {
 
         int depth = 0;
         int maxDepth = 0;
-        Iterator<String> bomTypesIt = bomTypes.iterator();
         try {
-            while (bomTypesIt.hasNext()) {
-                String oneBomType = bomTypesIt.next();
+            for(String oneBomType : bomTypes) {
                 depth = BOMHelper.getMaxDepth(productId, oneBomType, fromDate, delegator);
                 if (depth > maxDepth) {
                     maxDepth = depth;
@@ -149,10 +146,8 @@ public class BOMServices {
                     UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT"));
             virtualProducts = EntityUtil.filterByDate(virtualProducts);
             int virtualMaxDepth = 0;
-            Iterator<GenericValue> virtualProductsIt = virtualProducts.iterator();
-            while (virtualProductsIt.hasNext()) {
+            for(GenericValue oneVirtualProductAssoc : virtualProducts) {
                 int virtualDepth = 0;
-                GenericValue oneVirtualProductAssoc = virtualProductsIt.next();
                 GenericValue virtualProduct = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", oneVirtualProductAssoc.getString("productId")));
                 if (virtualProduct.get("billOfMaterialLevel") != null) {
                     virtualDepth = virtualProduct.getLong("billOfMaterialLevel").intValue();
@@ -190,9 +185,7 @@ public class BOMServices {
                 List<GenericValue> variantProducts = delegator.findByAnd("ProductAssoc",
                         UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"));
                 variantProducts = EntityUtil.filterByDate(variantProducts, true);
-                Iterator<GenericValue> variantProductsIt = variantProducts.iterator();
-                while (variantProductsIt.hasNext()) {
-                    GenericValue oneVariantProductAssoc = variantProductsIt.next();
+                for(GenericValue oneVariantProductAssoc : variantProducts) {
                     GenericValue variantProduct = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", oneVariantProductAssoc.getString("productId")));
                     variantProduct.set("billOfMaterialLevel", llc);
                     variantProduct.store();
@@ -220,20 +213,16 @@ public class BOMServices {
         try {
             List<GenericValue> products = delegator.findList("Product", null, null,
                     UtilMisc.toList("isVirtual DESC"), null, false);
-            Iterator<GenericValue> productsIt = products.iterator();
             Long zero = Long.valueOf(0);
             List<GenericValue> allProducts = FastList.newInstance();
-            while (productsIt.hasNext()) {
-                GenericValue product = productsIt.next();
+            for(GenericValue product : products) {
                 product.set("billOfMaterialLevel", zero);
                 allProducts.add(product);
             }
             delegator.storeAll(allProducts);
             Debug.logInfo("Low Level Code set to 0 for all the products", module);
 
-            productsIt = products.iterator();
-            while (productsIt.hasNext()) {
-                GenericValue product = productsIt.next();
+            for(GenericValue product : products) {
                 try {
                     Map<String, Object> depthResult = dispatcher.runSync("updateLowLevelCode", UtilMisc.<String, Object>toMap("productIdTo", product.getString("productId"), "alsoComponents", Boolean.valueOf(false), "alsoVariants", Boolean.valueOf(false)));
                     Debug.logInfo("Product [" + product.getString("productId") + "] Low Level Code [" + depthResult.get("lowLevelCode") + "]", module);
@@ -414,10 +403,8 @@ public class BOMServices {
 
         // also return a componentMap (useful in scripts and simple language code)
         List<Map<String, Object>> componentsMap = FastList.newInstance();
-        Iterator<BOMNode> componentsIt = components.iterator();
-        while (componentsIt.hasNext()) {
+        for(BOMNode node : components) {
             Map<String, Object> componentMap = FastMap.newInstance();
-            BOMNode node = componentsIt.next();
             componentMap.put("product", node.getProduct());
             componentMap.put("quantity", node.getQuantity());
             componentsMap.add(componentMap);
@@ -466,9 +453,7 @@ public class BOMServices {
         } catch (GenericEntityException gee) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingBomErrorCreatingBillOfMaterialsTree", UtilMisc.toMap("errorString", gee.getMessage()), locale));
         }
-        Iterator<BOMNode> componentsIt = components.iterator();
-        while (componentsIt.hasNext()) {
-            BOMNode oneComponent = componentsIt.next();
+        for(BOMNode oneComponent : components) {
             if (!oneComponent.isManufactured()) {
                 notAssembledComponents.add(oneComponent);
             }
@@ -503,11 +488,9 @@ public class BOMServices {
         } catch (GenericEntityException gee) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingBomErrorLoadingShipmentItems", locale));
         }
-        Iterator<GenericValue> shipmentItemsIt = shipmentItems.iterator();
         Map<String, Object> orderReadHelpers = FastMap.newInstance();
         Map<String, Object> partyOrderShipments = FastMap.newInstance();
-        while (shipmentItemsIt.hasNext()) {
-            GenericValue shipmentItem = shipmentItemsIt.next();
+        for(GenericValue shipmentItem : shipmentItems) {
             // Get the OrderShipments
             List<GenericValue> orderShipments = null;
             try {

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=1301945&r1=1301944&r2=1301945&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Sat Mar 17 15:12:47 2012
@@ -125,9 +125,7 @@ public class ProductionRunServices {
                         UtilMisc.toMap("workEffortId", productionRunId, "workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
                                 "statusId", "WEGS_CREATED"));
                 if (!UtilValidate.isEmpty(products)) {
-                    Iterator<GenericValue> productsIt = products.iterator();
-                    while (productsIt.hasNext()) {
-                        GenericValue product = productsIt.next();
+                    for(GenericValue product : products) {
                         product.set("statusId", "WEGS_CANCELLED");
                         product.store();
                     }
@@ -135,10 +133,8 @@ public class ProductionRunServices {
 
                 // change the tasks status to PRUN_CANCELLED
                 List<GenericValue> tasks = productionRun.getProductionRunRoutingTasks();
-                GenericValue oneTask = null;
                 String taskId = null;
-                for (int i = 0; i < tasks.size(); i++) {
-                    oneTask = tasks.get(i);
+                for(GenericValue oneTask : tasks) {
                     taskId = oneTask.getString("workEffortId");
                     serviceContext.clear();
                     serviceContext.put("workEffortId", taskId);
@@ -150,9 +146,7 @@ public class ProductionRunServices {
                             UtilMisc.toMap("workEffortId", taskId, "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED",
                                     "statusId", "WEGS_CREATED"));
                     if (!UtilValidate.isEmpty(components)) {
-                        Iterator<GenericValue> componentsIt = components.iterator();
-                        while (componentsIt.hasNext()) {
-                            GenericValue component = componentsIt.next();
+                        for(GenericValue component : components) {
                             component.set("statusId", "WEGS_CANCELLED");
                             component.store();
                         }
@@ -305,11 +299,8 @@ public class ProductionRunServices {
         }
 
         // Multi creation (like clone) ProductionRunTask and GoodAssoc
-        Iterator<GenericValue>  rt = routingTaskAssocs.iterator();
         boolean first = true;
-        while (rt.hasNext()) {
-            GenericValue routingTaskAssoc = rt.next();
-
+        for(GenericValue routingTaskAssoc : routingTaskAssocs) {
             if (EntityUtil.isValueActive(routingTaskAssoc, startDate)) {
                 GenericValue routingTask = null;
                 try {
@@ -368,11 +359,9 @@ public class ProductionRunServices {
                 // Now we iterate thru the components returned by the getManufacturingComponents service
                 // TODO: if in the BOM a routingWorkEffortId is specified, but the task is not in the routing
                 //       the component is not added to the production run.
-                Iterator<BOMNode>  pb = components.iterator();
-                while (pb.hasNext()) {
+                for(BOMNode node : components) {
                     // The components variable contains a list of BOMNodes:
                     // each node represents a product (component).
-                    BOMNode node = pb.next();
                     GenericValue productBom = node.getProductAssoc();
                     if ((productBom.getString("routingWorkEffortId") == null && first) || (productBom.getString("routingWorkEffortId") != null && productBom.getString("routingWorkEffortId").equals(routingTask.getString("workEffortId")))) {
                         serviceContext.clear();
@@ -433,9 +422,7 @@ public class ProductionRunServices {
         }
 
         if (workEffortPartyAssignments != null) {
-            Iterator<GenericValue> i = workEffortPartyAssignments.iterator();
-            while (i.hasNext()) {
-                GenericValue workEffortPartyAssignment = i.next();
+            for(GenericValue workEffortPartyAssignment : workEffortPartyAssignments) {
                 Map<String, Object> partyToWorkEffort = UtilMisc.<String, Object>toMap(
                         "workEffortId",  productionRunTaskId,
                         "partyId",  workEffortPartyAssignment.getString("partyId"),
@@ -600,9 +587,7 @@ public class ProductionRunServices {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale));
             }
             // change the production run tasks status to PRUN_SCHEDULED
-            Iterator<GenericValue> tasks = productionRun.getProductionRunRoutingTasks().iterator();
-            while (tasks.hasNext()) {
-                GenericValue task = tasks.next();
+            for(GenericValue task : productionRun.getProductionRunRoutingTasks()) {
                 serviceContext.clear();
                 serviceContext.put("workEffortId", task.getString("workEffortId"));
                 serviceContext.put("currentStatusId", statusId);
@@ -634,9 +619,7 @@ public class ProductionRunServices {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale));
             }
             // change the production run tasks status to PRUN_DOC_PRINTED
-            Iterator<GenericValue> tasks = productionRun.getProductionRunRoutingTasks().iterator();
-            while (tasks.hasNext()) {
-                GenericValue task = tasks.next();
+            for(GenericValue task : productionRun.getProductionRunRoutingTasks()) {
                 serviceContext.clear();
                 serviceContext.put("workEffortId", task.getString("workEffortId"));
                 serviceContext.put("currentStatusId", "PRUN_DOC_PRINTED");
@@ -726,9 +709,7 @@ public class ProductionRunServices {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale));
             }
             // change the production run tasks status to PRUN_CLOSED
-            Iterator<GenericValue> tasks = productionRun.getProductionRunRoutingTasks().iterator();
-            while (tasks.hasNext()) {
-                GenericValue task = tasks.next();
+            for(GenericValue task : productionRun.getProductionRunRoutingTasks()) {
                 serviceContext.clear();
                 serviceContext.put("workEffortId", task.getString("workEffortId"));
                 serviceContext.put("currentStatusId", "PRUN_CLOSED");
@@ -996,13 +977,11 @@ public class ProductionRunServices {
             List<GenericValue> costComponents = EntityUtil.filterByDate(delegator.findByAnd("CostComponent",
                     UtilMisc.toMap("workEffortId", workEffortId)));
             result.put("costComponents", costComponents);
-            Iterator<GenericValue> costComponentsIt = costComponents.iterator();
             // TODO: before doing these totals we should convert the cost components' costs to the
             //       base currency uom of the owner of the facility in which the task is running
             BigDecimal totalCost = ZERO;
             BigDecimal totalCostNoMaterials = ZERO;
-            while (costComponentsIt.hasNext()) {
-                GenericValue costComponent = costComponentsIt.next();
+            for(GenericValue costComponent : costComponents) {
                 BigDecimal cost = costComponent.getBigDecimal("cost");
                 totalCost = totalCost.add(cost);
                 if (!"ACTUAL_MAT_COST".equals(costComponent.getString("costComponentTypeId"))) {
@@ -1027,14 +1006,12 @@ public class ProductionRunServices {
         try {
             List<GenericValue> tasks = delegator.findByAnd("WorkEffort",
                     UtilMisc.toMap("workEffortParentId", workEffortId), UtilMisc.toList("workEffortId"));
-            Iterator<GenericValue> tasksIt = tasks.iterator();
             BigDecimal totalCost = ZERO;
             Map<String, Object> outputMap = dispatcher.runSync("getWorkEffortCosts",
                     UtilMisc.<String, Object>toMap("userLogin", userLogin, "workEffortId", workEffortId));
             BigDecimal productionRunHeaderCost = (BigDecimal)outputMap.get("totalCost");
             totalCost = totalCost.add(productionRunHeaderCost);
-            while (tasksIt.hasNext()) {
-                GenericValue task = tasksIt.next();
+            for(GenericValue task : tasks) {
                 outputMap = dispatcher.runSync("getWorkEffortCosts",
                         UtilMisc.<String, Object>toMap("userLogin", userLogin, "workEffortId", task.getString("workEffortId")));
                 BigDecimal taskCost = (BigDecimal)outputMap.get("totalCost");
@@ -1085,9 +1062,7 @@ public class ProductionRunServices {
                     UtilMisc.toMap("workEffortId", productionRunTaskId));
             workEffortCostCalcs = EntityUtil.filterByDate(workEffortCostCalcs);
 
-            Iterator<GenericValue> workEffortCostCalcsIt = workEffortCostCalcs.iterator();
-            while (workEffortCostCalcsIt.hasNext()) {
-                GenericValue workEffortCostCalc = workEffortCostCalcsIt.next();
+            for (GenericValue workEffortCostCalc : workEffortCostCalcs) {
                 GenericValue costComponentCalc = workEffortCostCalc.getRelatedOne("CostComponentCalc");
                 GenericValue customMethod = costComponentCalc.getRelatedOne("CustomMethod");
                 if (UtilValidate.isEmpty(customMethod) || UtilValidate.isEmpty(customMethod.getString("customMethodName"))) {
@@ -1164,11 +1139,9 @@ public class ProductionRunServices {
         }
         // materials costs: these are the costs derived from the materials used by the production run task
         try {
-            Iterator<GenericValue> inventoryAssignIt = delegator.findByAnd("WorkEffortAndInventoryAssign",
-                    UtilMisc.toMap("workEffortId", productionRunTaskId)).iterator();
             Map<String, BigDecimal> materialsCostByCurrency = FastMap.newInstance();
-            while (inventoryAssignIt.hasNext()) {
-                GenericValue inventoryConsumed = inventoryAssignIt.next();
+            for(GenericValue inventoryConsumed : delegator.findByAnd("WorkEffortAndInventoryAssign",
+                                UtilMisc.toMap("workEffortId", productionRunTaskId))) {
                 BigDecimal quantity = inventoryConsumed.getBigDecimal("quantity");
                 BigDecimal unitCost = inventoryConsumed.getBigDecimal("unitCost");
                 if (UtilValidate.isEmpty(unitCost) || UtilValidate.isEmpty(quantity)) {
@@ -1182,9 +1155,7 @@ public class ProductionRunServices {
                 materialsCost = materialsCost.add(unitCost.multiply(quantity)).setScale(decimals, rounding);
                 materialsCostByCurrency.put(currencyUomId, materialsCost);
             }
-            Iterator<String> currencyIt = materialsCostByCurrency.keySet().iterator();
-            while (currencyIt.hasNext()) {
-                String currencyUomId = currencyIt.next();
+            for(String currencyUomId : materialsCostByCurrency.keySet()) {
                 BigDecimal materialsCost = materialsCostByCurrency.get(currencyUomId);
                 Map<String, Object> inMap = UtilMisc.<String, Object>toMap("userLogin", userLogin,
                         "workEffortId", productionRunTaskId);
@@ -1539,9 +1510,7 @@ public class ProductionRunServices {
             Debug.logError(e.getMessage(),  module);
         }
         if (workEffortPartyAssignments != null) {
-            Iterator<GenericValue> i = workEffortPartyAssignments.iterator();
-            while (i.hasNext()) {
-                GenericValue workEffortPartyAssignment = i.next();
+            for(GenericValue workEffortPartyAssignment : workEffortPartyAssignments) {
                 Map<String, Object> partyToWorkEffort = UtilMisc.<String, Object>toMap(
                         "workEffortId",  productionRunTaskId,
                         "partyId",  workEffortPartyAssignment.getString("partyId"),
@@ -1980,21 +1949,17 @@ public class ProductionRunServices {
         // are currently assigned to this task.
         // If less than passed quantity then return an error message.
         try {
-            Iterator<GenericValue> issuances = (delegator.findByAnd("WorkEffortAndInventoryAssign",
-                    UtilMisc.toMap("workEffortId", productionRunTaskId, "productId", productId))).iterator();
             BigDecimal totalIssued = BigDecimal.ZERO;
-            while (issuances.hasNext()) {
-                GenericValue issuance = issuances.next();
+            for(GenericValue issuance : delegator.findByAnd("WorkEffortAndInventoryAssign",
+                            UtilMisc.toMap("workEffortId", productionRunTaskId, "productId", productId))) {
                 BigDecimal issued = issuance.getBigDecimal("quantity");
                 if (issued != null) {
                     totalIssued = totalIssued.add(issued);
                 }
             }
-            Iterator<GenericValue> returns = (delegator.findByAnd("WorkEffortAndInventoryProduced",
-                    UtilMisc.toMap("workEffortId", productionRunTaskId, "productId", productId))).iterator();
             BigDecimal totalReturned = BigDecimal.ZERO;
-            while (returns.hasNext()) {
-                GenericValue returned = returns.next();
+            for(GenericValue returned : delegator.findByAnd("WorkEffortAndInventoryProduced",
+                            UtilMisc.toMap("workEffortId", productionRunTaskId, "productId", productId))) {
                 GenericValue returnDetail = EntityUtil.getFirst(delegator.findByAnd("InventoryItemDetail", UtilMisc.toMap("inventoryItemId", returned.getString("inventoryItemId")), UtilMisc.toList("inventoryItemDetailSeqId")));
                 if (returnDetail != null) {
                     BigDecimal qtyReturned = returnDetail.getBigDecimal("quantityOnHandDiff");
@@ -2342,15 +2307,11 @@ public class ProductionRunServices {
         String productionRunId = (String)resultService.get("productionRunId");
         result.put("productionRunId", productionRunId);
 
-        Iterator<ConfigOption> options = config.getSelectedOptions().iterator();
         Map<String, BigDecimal> components = FastMap.newInstance();
-        while (options.hasNext()) {
-            ConfigOption co = options.next();
+        for(ConfigOption co : config.getSelectedOptions()) {
             //components.addAll(co.getComponents());
-            Iterator<GenericValue> selComponents = co.getComponents().iterator();
-            while (selComponents.hasNext()) {
+            for(GenericValue selComponent : co.getComponents()) {
                 BigDecimal componentQuantity = null;
-                GenericValue selComponent = selComponents.next();
                 if (selComponent.get("quantity") != null) {
                     componentQuantity = selComponent.getBigDecimal("quantity");
                 }
@@ -3073,9 +3034,7 @@ public class ProductionRunServices {
             if (UtilValidate.isEmpty(components)) {
                 return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunCannotDecomposingInventoryItemNoComponentsFound", UtilMisc.toMap("productId", inventoryItem.getString("productId")), locale));
             }
-            Iterator<Map<String, Object>> componentsIt = components.iterator();
-            while (componentsIt.hasNext()) {
-                Map<String, Object> component = componentsIt.next();
+            for(Map<String, Object> component : components) {
                 // get the component's standard cost
                 serviceContext.clear();
                 serviceContext = UtilMisc.toMap("productId", ((GenericValue)component.get("product")).getString("productId"),
@@ -3120,9 +3079,7 @@ public class ProductionRunServices {
             List<GenericValue> resultList = delegator.findByAnd("WorkEffortAndGoods",
                     UtilMisc.toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
                             "statusId", "WEGS_CREATED", "workEffortTypeId", "PROD_ORDER_HEADER"));
-            Iterator<GenericValue> iteratorResult = resultList.iterator();
-            while (iteratorResult.hasNext()) {
-                GenericValue genericResult = iteratorResult.next();
+            for(GenericValue genericResult : resultList) {
                 if ("PRUN_CLOSED".equals(genericResult.getString("currentStatusId")) ||
                     "PRUN_CREATED".equals(genericResult.getString("currentStatusId"))) {
                     continue;
@@ -3163,11 +3120,9 @@ public class ProductionRunServices {
             resultList = delegator.findByAnd("OrderHeaderAndItems",
                     UtilMisc.toMap("orderTypeId", "PURCHASE_ORDER",
                             "itemStatusId", "ITEM_APPROVED"), UtilMisc.toList("orderId"));
-            iteratorResult = resultList.iterator();
             String orderId = null;
             GenericValue orderDeliverySchedule = null;
-            while (iteratorResult.hasNext()) {
-                GenericValue genericResult = iteratorResult.next();
+            for(GenericValue genericResult : resultList) {
                 String newOrderId =  genericResult.getString("orderId");
                 if (!newOrderId.equals(orderId)) {
                     orderDeliverySchedule = null;
@@ -3218,9 +3173,7 @@ public class ProductionRunServices {
             List<GenericValue> backorders = delegator.findList("OrderItemAndShipGrpInvResAndItem",
                     EntityCondition.makeCondition(backordersCondList, EntityOperator.AND), null,
                     UtilMisc.toList("shipBeforeDate"), null, false);
-            Iterator<GenericValue> backordersIt = backorders.iterator();
-            while (backordersIt.hasNext()) {
-                GenericValue genericResult = backordersIt.next();
+            for(GenericValue genericResult : backorders) {
                 String productId = genericResult.getString("productId");
                 GenericValue orderItemShipGroup = delegator.findByPrimaryKey("OrderItemShipGroup", UtilMisc.toMap("orderId", genericResult.get("orderId"),
                                                                                                                   "shipGroupSeqId", genericResult.get("shipGroupSeqId")));
@@ -3238,9 +3191,7 @@ public class ProductionRunServices {
                 TreeMap<Timestamp, Object> productMap = products.get(productId);
                 SortedMap<Timestamp, Object> subsetMap = productMap.headMap(requiredByDate);
                 // iterate and 'reserve'
-                Iterator<Timestamp> subsetMapKeysIt = subsetMap.keySet().iterator();
-                while (subsetMapKeysIt.hasNext()) {
-                    Timestamp currentDate = subsetMapKeysIt.next();
+                for(Timestamp currentDate : subsetMap.keySet()) {
                     Map<String, Object> currentDateMap = UtilGenerics.checkMap(subsetMap.get(currentDate));
                     //List reservations = (List)currentDateMap.get("reservations");
                     BigDecimal remainingQty = (BigDecimal)currentDateMap.get("remainingQty");

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java?rev=1301945&r1=1301944&r2=1301945&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java Sat Mar 17 15:12:47 2012
@@ -103,9 +103,7 @@ public class MrpServices {
         }
         if (listResult != null) {
             try {
-                Iterator<GenericValue> listResultIt = listResult.iterator();
-                while (listResultIt.hasNext()) {
-                    GenericValue tmpRequirement = listResultIt.next();
+                for(GenericValue tmpRequirement : listResult) {
                     listResultRoles.addAll(tmpRequirement.getRelated("RequirementRole"));
                     //int numOfRecordsRemoved = delegator.removeRelated("RequirementRole", tmpRequirement);
                 }
@@ -129,10 +127,8 @@ public class MrpServices {
             }
         }
 
-        GenericValue genericResult = null;
         Map<String, Object> parameters = null;
         List<GenericValue> resultList = null;
-        Iterator<GenericValue> iteratorResult = null;
         // ----------------------------------------
         // Loads all the approved sales order items and purchase order items
         // ----------------------------------------
@@ -147,7 +143,6 @@ public class MrpServices {
             notAssignedDate = new Timestamp(calendar.getTimeInMillis());
         }
         resultList = null;
-        iteratorResult = null;
         parameters = UtilMisc.<String, Object>toMap("orderTypeId", "SALES_ORDER", "oiStatusId", "ITEM_APPROVED");
         parameters.put("facilityId", facilityId);
         try {
@@ -157,9 +152,7 @@ public class MrpServices {
             Debug.logError(e, "Error : parameters = "+parameters,module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventFindError", locale));
         }
-        iteratorResult = resultList.iterator();
-        while (iteratorResult.hasNext()) {
-            genericResult = iteratorResult.next();
+        for(GenericValue genericResult : resultList) {
             String productId =  genericResult.getString("productId");
             BigDecimal reservedQuantity = genericResult.getBigDecimal("reservedQuantity");
             BigDecimal shipGroupQuantity = genericResult.getBigDecimal("quantity");
@@ -211,7 +204,6 @@ public class MrpServices {
         // Loads all the approved product requirements (po requirements)
         // ----------------------------------------
         resultList = null;
-        iteratorResult = null;
         parameters = UtilMisc.<String, Object>toMap("requirementTypeId", "PRODUCT_REQUIREMENT",
                 "statusId", "REQ_APPROVED", "facilityId", facilityId);
         try {
@@ -219,9 +211,7 @@ public class MrpServices {
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventFindError", locale));
         }
-        iteratorResult = resultList.iterator();
-        while (iteratorResult.hasNext()) {
-            genericResult = iteratorResult.next();
+        for(GenericValue genericResult : resultList) {
             String productId =  genericResult.getString("productId");
             BigDecimal eventQuantityTmp = genericResult.getBigDecimal("quantity");
             if (productId == null || eventQuantityTmp == null) {
@@ -244,7 +234,6 @@ public class MrpServices {
         // Loads all the approved purchase order items
         // ----------------------------------------
         resultList = null;
-        iteratorResult = null;
         String orderId = null;
         GenericValue orderDeliverySchedule = null;
         try {
@@ -259,9 +248,7 @@ public class MrpServices {
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventFindError", locale));
         }
-        iteratorResult = resultList.iterator();
-        while (iteratorResult.hasNext()) {
-            genericResult = iteratorResult.next();
+        for(GenericValue genericResult : resultList) {
             String newOrderId =  genericResult.getString("orderId");
             if (!newOrderId.equals(orderId)) {
                 orderDeliverySchedule = null;
@@ -321,14 +308,11 @@ public class MrpServices {
         // PRODUCTION Run: components
         // ----------------------------------------
         resultList = null;
-        iteratorResult = null;
         parameters = UtilMisc.<String, Object>toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED",
                    "statusId", "WEGS_CREATED", "facilityId", facilityId);
         try {
             resultList = delegator.findByAnd("WorkEffortAndGoods", parameters);
-            iteratorResult = resultList.iterator();
-            while (iteratorResult.hasNext()) {
-                genericResult = iteratorResult.next();
+            for(GenericValue genericResult : resultList) {
                 if ("PRUN_CLOSED".equals(genericResult.getString("currentStatusId")) ||
                     "PRUN_COMPLETED".equals(genericResult.getString("currentStatusId")) ||
                     "PRUN_CANCELLED".equals(genericResult.getString("currentStatusId"))) {
@@ -359,14 +343,11 @@ public class MrpServices {
         // PRODUCTION Run: product produced
         // ----------------------------------------
         resultList = null;
-        iteratorResult = null;
         parameters = UtilMisc.<String, Object>toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
                 "statusId", "WEGS_CREATED", "workEffortTypeId", "PROD_ORDER_HEADER", "facilityId", facilityId);
         try {
             resultList = delegator.findByAnd("WorkEffortAndGoods", parameters);
-            iteratorResult = resultList.iterator();
-            while (iteratorResult.hasNext()) {
-                genericResult = iteratorResult.next();
+            for(GenericValue genericResult : resultList) {
                 if ("PRUN_CLOSED".equals(genericResult.getString("currentStatusId")) ||
                     "PRUN_COMPLETED".equals(genericResult.getString("currentStatusId")) ||
                     "PRUN_CANCELLED".equals(genericResult.getString("currentStatusId"))) {
@@ -402,7 +383,6 @@ public class MrpServices {
         // Products without upcoming events but that are already under minimum quantity in warehouse
         // ----------------------------------------
         resultList = null;
-        iteratorResult = null;
         parameters = UtilMisc.<String, Object>toMap("facilityId", facilityId);
         try {
             resultList = delegator.findByAnd("ProductFacility", parameters);
@@ -410,9 +390,7 @@ public class MrpServices {
             Debug.logError(e, "Unable to retrieve ProductFacility records.", module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpCannotFindProductFacility", locale));
         }
-        iteratorResult = resultList.iterator();
-        while (iteratorResult.hasNext()) {
-            genericResult = iteratorResult.next();
+        for(GenericValue genericResult : resultList) {
             String productId = genericResult.getString("productId");
             BigDecimal minimumStock = genericResult.getBigDecimal("minimumStock");
             if (minimumStock == null) {
@@ -444,7 +422,6 @@ public class MrpServices {
         // SALES FORECASTS
         // ----------------------------------------
         resultList = null;
-        iteratorResult = null;
         GenericValue facility = null;
         try {
             facility = delegator.findOne("Facility", UtilMisc.toMap("facilityId", facilityId), false);
@@ -457,9 +434,7 @@ public class MrpServices {
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpCannotFindSalesForecasts", locale));
         }
-        iteratorResult = resultList.iterator();
-        while (iteratorResult.hasNext()) {
-            genericResult = iteratorResult.next();
+        for(GenericValue genericResult : resultList) {
             String customTimePeriodId =  genericResult.getString("customTimePeriodId");
             GenericValue customTimePeriod = null;
             try {
@@ -472,24 +447,21 @@ public class MrpServices {
                     continue;
                 } else {
                     List<GenericValue> salesForecastDetails = null;
-                    Iterator<GenericValue> sfdIter = null;
                     try {
                         salesForecastDetails = delegator.findByAnd("SalesForecastDetail", UtilMisc.toMap("salesForecastId", genericResult.getString("salesForecastId")));
                     } catch (GenericEntityException e) {
                         return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpCannotFindSalesForecastDetails", locale));
                     }
-                    sfdIter = salesForecastDetails.iterator();
-                    while (sfdIter.hasNext()) {
-                        genericResult = sfdIter.next();
-                        String productId =  genericResult.getString("productId");
-                        BigDecimal eventQuantityTmp = genericResult.getBigDecimal("quantity");
+                    for(GenericValue sfd : salesForecastDetails) {
+                        String productId =  sfd.getString("productId");
+                        BigDecimal eventQuantityTmp = sfd.getBigDecimal("quantity");
                         if (productId == null || eventQuantityTmp == null) {
                             continue;
                         }
                         eventQuantityTmp = eventQuantityTmp.negate();
                         parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", customTimePeriod.getDate("fromDate"), "mrpEventTypeId", "SALES_FORECAST");
                         try {
-                            InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("salesForecastDetailId"), false, delegator);
+                            InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, sfd.getString("salesForecastDetailId"), false, delegator);
                         } catch (GenericEntityException e) {
                             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap("mrpEventTypeId", "SALES_FORECAST"), locale));
                         }
@@ -564,9 +536,7 @@ public class MrpServices {
         Delegator delegator = product.getDelegator();
 
         if (UtilValidate.isNotEmpty(listComponent)) {
-            Iterator<BOMNode> listComponentIter = listComponent.iterator();
-            while (listComponentIter.hasNext()) {
-                BOMNode node = listComponentIter.next();
+            for(BOMNode node : listComponent) {
                 GenericValue productComponent = node.getProductAssoc();
                 // read the startDate for the component
                 String routingTask = node.getProductAssoc().getString("routingWorkEffortId");
@@ -629,9 +599,7 @@ public class MrpServices {
                 if (UtilValidate.isEmpty(facilities)) {
                     return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpFacilityGroupIsNotAssociatedToFacility", UtilMisc.toMap("facilityGroupId", facilityGroupId), locale));
                 }
-                Iterator<GenericValue> facilitiesIt = facilities.iterator();
-                while (facilitiesIt.hasNext()) {
-                    GenericValue facilityMember = facilitiesIt.next();
+                for(GenericValue facilityMember : facilities) {
                     GenericValue facility = facilityMember.getRelatedOne("Facility");
                     if ("WAREHOUSE".equals(facility.getString("facilityTypeId")) && UtilValidate.isEmpty(facilityId)) {
                         facilityId = facility.getString("facilityId");
@@ -672,7 +640,6 @@ public class MrpServices {
         Map<String, Object> parameters = null;
         List<GenericValue> listInventoryEventForMRP = null;
         ListIterator<GenericValue> iteratorListInventoryEventForMRP = null;
-        GenericValue inventoryEventForMRP = null;
 
         // Initialization of the MrpEvent table, This table will contain the products we want to buy or build.
         parameters = UtilMisc.<String, Object>toMap("mrpId", mrpId, "reInitialize", Boolean.TRUE, "defaultYearsOffset", defaultYearsOffset, "userLogin", userLogin);
@@ -703,11 +670,9 @@ public class MrpServices {
 
             if (UtilValidate.isNotEmpty(listInventoryEventForMRP)) {
                 bomLevelWithNoEvent = 0;
-                iteratorListInventoryEventForMRP = listInventoryEventForMRP.listIterator();
 
                 oldProductId = "";
-                while (iteratorListInventoryEventForMRP.hasNext()) {
-                    inventoryEventForMRP = iteratorListInventoryEventForMRP.next();
+                for(GenericValue inventoryEventForMRP : listInventoryEventForMRP) {
                     productId = inventoryEventForMRP.getString("productId");
                     eventQuantity = inventoryEventForMRP.getBigDecimal("quantity");
 

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java?rev=1301945&r1=1301944&r2=1301945&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java Sat Mar 17 15:12:47 2012
@@ -132,9 +132,7 @@ public class TechDataServices {
         }
 
         if (listRoutingTaskAssoc != null) {
-            Iterator<GenericValue> i = listRoutingTaskAssoc.iterator();
-            while (i.hasNext()) {
-                GenericValue routingTaskAssoc = i.next();
+            for(GenericValue routingTaskAssoc : listRoutingTaskAssoc) {
                 if (! workEffortIdFrom.equals(routingTaskAssoc.getString("workEffortIdFrom")) ||
                 ! workEffortIdTo.equals(routingTaskAssoc.getString("workEffortIdTo")) ||
                 ! workEffortAssocTypeId.equals(routingTaskAssoc.getString("workEffortAssocTypeId")) ||