svn commit: r1059536 - in /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing: mrp/InventoryEventPlannedServices.java mrp/MrpServices.java mrp/ProposedOrder.java routing/RoutingServices.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: r1059536 - in /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing: mrp/InventoryEventPlannedServices.java mrp/MrpServices.java mrp/ProposedOrder.java routing/RoutingServices.java techdata/TechDataServices.java

mrisaliti
Author: mrisaliti
Date: Sun Jan 16 11:23:59 2011
New Revision: 1059536

URL: http://svn.apache.org/viewvc?rev=1059536&view=rev
Log:
Remove most of the java compilation warning (generics markup, unused code/import) (OFBIZ-4102)
Please advice if you see some issues, I have tested but it could be some errors due to the migration.

Modified:
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java?rev=1059536&r1=1059535&r2=1059536&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java Sun Jan 16 11:23:59 2011
@@ -44,14 +44,13 @@ public class InventoryEventPlannedServic
      * @param context: a map containing the parameters used to create an MrpEvent
      * @return result: a map with service status
      */
-    public static Map createMrpEvent(DispatchContext ctx, Map context) {
+    public static Map<String, Object> createMrpEvent(DispatchContext ctx, Map<String, ? extends Object> context) {
         Delegator delegator = ctx.getDelegator();
-        Map parameters = UtilMisc.toMap("mrpId", context.get("mrpId"),
+        Map<String, Object> parameters = UtilMisc.<String, Object>toMap("mrpId", context.get("mrpId"),
                                         "productId", context.get("productId"),
                                         "eventDate", context.get("eventDate"),
                                         "mrpEventTypeId", context.get("mrpEventTypeId"));
         BigDecimal quantity = (BigDecimal)context.get("quantity");
-        GenericValue mrpEvent = null;
         try {
             createOrUpdateMrpEvent(parameters, quantity, (String)context.get("facilityId"), (String)context.get("eventName"), false, delegator);
         } catch (GenericEntityException e) {
@@ -61,7 +60,8 @@ public class InventoryEventPlannedServic
         return ServiceUtil.returnSuccess();
     }
 
-    public static void createOrUpdateMrpEvent(Map mrpEventKeyMap, BigDecimal newQuantity, String facilityId, String eventName, boolean isLate, Delegator delegator) throws GenericEntityException {
+    public static void createOrUpdateMrpEvent(Map<String, Object> mrpEventKeyMap, BigDecimal newQuantity, String facilityId,
+            String eventName, boolean isLate, Delegator delegator) throws GenericEntityException {
         GenericValue mrpEvent = null;
         mrpEvent = delegator.findByPrimaryKey("MrpEvent", mrpEventKeyMap);
         if (mrpEvent == null) {

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=1059536&r1=1059535&r2=1059536&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 Sun Jan 16 11:23:59 2011
@@ -21,23 +21,25 @@ package org.ofbiz.manufacturing.mrp;
 
 import java.math.BigDecimal;
 import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
 
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityFieldMap;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.util.EntityUtil;
@@ -60,20 +62,19 @@ public class MrpServices {
     public static final String module = MrpServices.class.getName();
     public static final String resource = "ManufacturingUiLabels";
 
-    public static Map initMrpEvents(DispatchContext ctx, Map context) {
+    public static Map<String, Object> initMrpEvents(DispatchContext ctx, Map<String, ? extends Object> context) {
         Delegator delegator = ctx.getDelegator();
         LocalDispatcher dispatcher = ctx.getDispatcher();
         Timestamp now = UtilDateTime.nowTimestamp();
 
         String facilityId = (String)context.get("facilityId");
-        String manufacturingFacilityId = (String)context.get("manufacturingFacilityId");
         Integer defaultYearsOffset = (Integer)context.get("defaultYearsOffset");
         String mrpId = (String)context.get("mrpId");
 
         //Erases the old table for the moment and initializes it with the new orders,
         //Does not modify the old one now.
 
-        List listResult = null;
+        List<GenericValue> listResult = null;
         try {
             listResult = delegator.findList("MrpEvent", null, null, null, null, false);
             //int numOfRecordsRemoved = delegator.removeByCondition("MrpEvent", null);
@@ -92,7 +93,7 @@ public class MrpServices {
 
         // Proposed requirements are deleted
         listResult = null;
-        List listResultRoles = new ArrayList();
+        List<GenericValue> listResultRoles = FastList.newInstance();
         try {
             listResult = delegator.findByAnd("Requirement", UtilMisc.toMap("requirementTypeId", "PRODUCT_REQUIREMENT", "statusId", "REQ_PROPOSED"));
         } catch (GenericEntityException e) {
@@ -100,7 +101,7 @@ public class MrpServices {
         }
         if (listResult != null) {
             try {
-                Iterator listResultIt = listResult.iterator();
+                Iterator<GenericValue> listResultIt = listResult.iterator();
                 while (listResultIt.hasNext()) {
                     GenericValue tmpRequirement = (GenericValue)listResultIt.next();
                     listResultRoles.addAll(tmpRequirement.getRelated("RequirementRole"));
@@ -127,9 +128,9 @@ public class MrpServices {
         }
 
         GenericValue genericResult = null;
-        Map parameters = null;
-        List resultList = null;
-        Iterator iteratorResult = 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
         // ----------------------------------------
@@ -145,7 +146,7 @@ public class MrpServices {
         }
         resultList = null;
         iteratorResult = null;
-        parameters = UtilMisc.toMap("orderTypeId", "SALES_ORDER", "oiStatusId", "ITEM_APPROVED");
+        parameters = UtilMisc.<String, Object>toMap("orderTypeId", "SALES_ORDER", "oiStatusId", "ITEM_APPROVED");
         parameters.put("facilityId", facilityId);
         try {
             resultList = delegator.findByAnd("OrderHeaderItemAndShipGroup", parameters, UtilMisc.toList("orderId"));
@@ -209,7 +210,8 @@ public class MrpServices {
         // ----------------------------------------
         resultList = null;
         iteratorResult = null;
-        parameters = UtilMisc.toMap("requirementTypeId", "PRODUCT_REQUIREMENT", "statusId", "REQ_APPROVED", "facilityId", facilityId);
+        parameters = UtilMisc.<String, Object>toMap("requirementTypeId", "PRODUCT_REQUIREMENT",
+                "statusId", "REQ_APPROVED", "facilityId", facilityId);
         try {
             resultList = delegator.findByAnd("Requirement", parameters);
         } catch (GenericEntityException e) {
@@ -244,12 +246,12 @@ public class MrpServices {
         String orderId = null;
         GenericValue orderDeliverySchedule = null;
         try {
-            List facilityContactMechs = EntityUtil.filterByDate(delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId)));
-            List facilityContactMechIds = EntityUtil.getFieldListFromEntityList(facilityContactMechs, "contactMechId", true);
-            List searchConditions = UtilMisc.toList(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER"),
+            List<GenericValue> facilityContactMechs = EntityUtil.filterByDate(delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId)));
+            List<GenericValue> facilityContactMechIds = EntityUtil.getFieldListFromEntityList(facilityContactMechs, "contactMechId", true);
+            List<EntityExpr> searchConditions = UtilMisc.toList(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER"),
                                                     EntityCondition.makeCondition("oiStatusId", EntityOperator.EQUALS, "ITEM_APPROVED"),
                                                     EntityCondition.makeCondition("contactMechId", EntityOperator.IN, facilityContactMechIds));
-            Set fieldsToSelect = UtilMisc.toSet("orderId", "orderItemSeqId", "productId", "quantity", "cancelQuantity", "oiEstimatedDeliveryDate");
+            Set<String> fieldsToSelect = UtilMisc.toSet("orderId", "orderItemSeqId", "productId", "quantity", "cancelQuantity", "oiEstimatedDeliveryDate");
             resultList = delegator.findList("OrderHeaderItemAndShipGroup", EntityCondition.makeCondition(searchConditions, EntityOperator.AND), fieldsToSelect, UtilMisc.toList("orderDate"), null, false);
 
         } catch (GenericEntityException e) {
@@ -318,7 +320,8 @@ public class MrpServices {
         // ----------------------------------------
         resultList = null;
         iteratorResult = null;
-        parameters = UtilMisc.toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED", "statusId", "WEGS_CREATED", "facilityId", facilityId);
+        parameters = UtilMisc.<String, Object>toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED",
+                   "statusId", "WEGS_CREATED", "facilityId", facilityId);
         try {
             resultList = delegator.findByAnd("WorkEffortAndGoods", parameters);
             iteratorResult = resultList.iterator();
@@ -355,7 +358,8 @@ public class MrpServices {
         // ----------------------------------------
         resultList = null;
         iteratorResult = null;
-        parameters = UtilMisc.toMap("workEffortGoodStdTypeId", "PRUN_PROD_DELIV", "statusId", "WEGS_CREATED", "workEffortTypeId", "PROD_ORDER_HEADER", "facilityId", facilityId);
+        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();
@@ -397,7 +401,7 @@ public class MrpServices {
         // ----------------------------------------
         resultList = null;
         iteratorResult = null;
-        parameters = UtilMisc.toMap("facilityId", facilityId);
+        parameters = UtilMisc.<String, Object>toMap("facilityId", facilityId);
         try {
             resultList = delegator.findByAnd("ProductFacility", parameters);
         } catch (GenericEntityException e) {
@@ -465,8 +469,8 @@ public class MrpServices {
                 if (customTimePeriod.getDate("thruDate") != null && customTimePeriod.getDate("thruDate").before(UtilDateTime.nowDate())) {
                     continue;
                 } else {
-                    List salesForecastDetails = null;
-                    Iterator sfdIter = null;
+                    List<GenericValue> salesForecastDetails = null;
+                    Iterator<GenericValue> sfdIter = null;
                     try {
                         salesForecastDetails = delegator.findByAnd("SalesForecastDetail", UtilMisc.toMap("salesForecastId", genericResult.getString("salesForecastId")));
                     } catch (GenericEntityException e) {
@@ -491,7 +495,7 @@ public class MrpServices {
                 }
             }
         }
-        Map result = new HashMap();
+        Map<String, Object> result = FastMap.newInstance();
         result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
         Debug.logInfo("return from initMrpEvent", module);
         return result;
@@ -509,7 +513,7 @@ public class MrpServices {
         return findProductMrpQoh(mrpId, product.getString("productId"), facilityId, dispatcher, delegator);
     }
     public static BigDecimal findProductMrpQoh(String mrpId, String productId, String facilityId, LocalDispatcher dispatcher, Delegator delegator) {
-        Map resultMap = null;
+        Map<String, Object> resultMap = null;
         try {
             if (facilityId == null) {
                 resultMap = dispatcher.runSync("getProductInventoryAvailable", UtilMisc.toMap("productId", productId));
@@ -553,12 +557,12 @@ public class MrpServices {
      * @return None
      */
 
-    public static void processBomComponent(String mrpId, GenericValue product, BigDecimal eventQuantity, Timestamp startDate, Map routingTaskStartDate, List listComponent) {
+    public static void processBomComponent(String mrpId, GenericValue product, BigDecimal eventQuantity, Timestamp startDate, Map<String, Object> routingTaskStartDate, List<BOMNode> listComponent) {
         // TODO : change the return type to boolean to be able to test if all is ok or if it have had a exception
         Delegator delegator = product.getDelegator();
 
         if (UtilValidate.isNotEmpty(listComponent)) {
-            Iterator listComponentIter = listComponent.iterator();
+            Iterator<BOMNode> listComponentIter = listComponent.iterator();
             while (listComponentIter.hasNext()) {
                 BOMNode node = (BOMNode) listComponentIter.next();
                 GenericValue productComponent = node.getProductAssoc();
@@ -568,7 +572,7 @@ public class MrpServices {
                 // if the components is valid at the event Date create the Mrp requirement in the M entity
                 if (EntityUtil.isValueActive(productComponent, eventDate)) {
                     //Map parameters = UtilMisc.toMap("productId", productComponent.getString("productIdTo"));
-                    Map parameters = UtilMisc.toMap("productId", node.getProduct().getString("productId"));
+                    Map<String, Object> parameters = UtilMisc.<String, Object>toMap("productId", node.getProduct().getString("productId"));
                     parameters.put("mrpId", mrpId);
                     parameters.put("eventDate", eventDate);
                     parameters.put("mrpEventTypeId", "MRP_REQUIREMENT");
@@ -598,7 +602,7 @@ public class MrpServices {
      * @param context Map containing the input parameters, productId routingId, quantity, startDate.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map executeMrp(DispatchContext ctx, Map context) {
+    public static Map<String, Object> executeMrp(DispatchContext ctx, Map<String, ? extends Object> context) {
         Debug.logInfo("executeMrp called", module);
 
         Delegator delegator = ctx.getDelegator();
@@ -620,11 +624,11 @@ public class MrpServices {
                 if (UtilValidate.isEmpty(facilityGroup)) {
                     return ServiceUtil.returnError("facilityGroupId [" + facilityGroupId + "] is not valid");
                 }
-                List facilities = facilityGroup.getRelated("FacilityGroupMember", UtilMisc.toList("sequenceNum"));
+                List<GenericValue> facilities = facilityGroup.getRelated("FacilityGroupMember", UtilMisc.toList("sequenceNum"));
                 if (UtilValidate.isEmpty(facilities)) {
                     return ServiceUtil.returnError("No facility associated to facilityGroupId [" + facilityGroupId + "]");
                 }
-                Iterator facilitiesIt = facilities.iterator();
+                Iterator<GenericValue> facilitiesIt = facilities.iterator();
                 while (facilitiesIt.hasNext()) {
                     GenericValue facilityMember = (GenericValue)facilitiesIt.next();
                     GenericValue facility = facilityMember.getRelatedOne("Facility");
@@ -654,25 +658,23 @@ public class MrpServices {
         GenericValue productFacility = null;
         BigDecimal eventQuantity = BigDecimal.ZERO;
         Timestamp eventDate = null;
-        boolean isNegative = false;
-        BigDecimal quantityNeeded = BigDecimal.ZERO;
         BigDecimal reorderQuantity = BigDecimal.ZERO;
         BigDecimal minimumStock = BigDecimal.ZERO;
         int daysToShip = 0;
-        List components = null;
+        List<BOMNode> components = null;
         boolean isBuilt = false;
         GenericValue routing = null;
 
         String mrpId = delegator.getNextSeqId("MrpEvent");
 
-        Map result = null;
-        Map parameters = null;
-        List listInventoryEventForMRP = null;
-        ListIterator iteratorListInventoryEventForMRP = null;
+        Map<String, Object> result = null;
+        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.toMap("mrpId", mrpId, "reInitialize", Boolean.TRUE, "defaultYearsOffset", defaultYearsOffset, "userLogin", userLogin);
+        parameters = UtilMisc.<String, Object>toMap("mrpId", mrpId, "reInitialize", Boolean.TRUE, "defaultYearsOffset", defaultYearsOffset, "userLogin", userLogin);
         parameters.put("facilityId", facilityId);
         parameters.put("manufacturingFacilityId", manufacturingFacilityId);
         try {
@@ -718,9 +720,10 @@ public class MrpServices {
                         }
                         stockTmp = findProductMrpQoh(mrpId, product, facilityId, dispatcher, delegator);
                         try {
-                            InventoryEventPlannedServices.createOrUpdateMrpEvent(UtilMisc.toMap("mrpId", mrpId, "productId", product.getString("productId"), "mrpEventTypeId", "INITIAL_QOH", "eventDate", now),
-                                                                                              stockTmp, facilityId, null, false,
-                                                                                              delegator);
+                            InventoryEventPlannedServices.createOrUpdateMrpEvent(UtilMisc.<String, Object>toMap("mrpId", mrpId,
+                                    "productId", product.getString("productId"),
+                                    "mrpEventTypeId", "INITIAL_QOH", "eventDate", now),
+                                    stockTmp, facilityId, null, false, delegator);
                         } catch (GenericEntityException e) {
                             return ServiceUtil.returnError("Problem running createOrUpdateMrpEvent");
                         }
@@ -739,13 +742,13 @@ public class MrpServices {
                         }
                         // -----------------------------------------------------
                         // The components are also loaded thru the configurator
-                        Map serviceResponse = null;
+                        Map<String, Object> serviceResponse = null;
                         try {
                             serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "quantity", positiveEventQuantity, "excludeWIPs", Boolean.FALSE, "userLogin", userLogin));
                         } catch (Exception e) {
                             return ServiceUtil.returnError("An error occurred exploding the product [" + product.getString("productId") + "]");
                         }
-                        components = (List)serviceResponse.get("components");
+                        components = UtilGenerics.checkList(serviceResponse.get("components"));
                         if (UtilValidate.isNotEmpty(components)) {
                             BOMNode node = ((BOMNode)components.get(0)).getParentNode();
                             isBuilt = node.isManufactured();
@@ -771,13 +774,13 @@ public class MrpServices {
 
                         // -----------------------------------------------------
                         // The components are also loaded thru the configurator
-                        Map serviceResponse = null;
+                        Map<String, Object> serviceResponse = null;
                         try {
                             serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "quantity", proposedOrder.getQuantity(), "excludeWIPs", Boolean.FALSE, "userLogin", userLogin));
                         } catch (Exception e) {
                             return ServiceUtil.returnError("An error occurred exploding the product [" + product.getString("productId") + "]");
                         }
-                        components = (List)serviceResponse.get("components");
+                        components = UtilGenerics.checkList(serviceResponse.get("components"));
                         String routingId = (String)serviceResponse.get("workEffortId");
                         if (routingId != null) {
                             try {
@@ -797,7 +800,7 @@ public class MrpServices {
                         // #####################################################
 
                         // calculate the ProposedOrder requirementStartDate and update the requirementStartDate object property.
-                        Map routingTaskStartDate = proposedOrder.calculateStartDate(daysToShip, routing, delegator, dispatcher, userLogin);
+                        Map<String, Object> routingTaskStartDate = proposedOrder.calculateStartDate(daysToShip, routing, delegator, dispatcher, userLogin);
                         if (isBuilt) {
                             // process the product components
                             processBomComponent(mrpId, product, proposedOrder.getQuantity(), proposedOrder.getRequirementStartDate(), routingTaskStartDate, components);
@@ -814,7 +817,7 @@ public class MrpServices {
                         if (UtilValidate.isNotEmpty(requirementId)) {
                             eventName = "*" + requirementId + " (" + proposedOrder.getRequirementStartDate() + ")*";
                         }
-                        Map eventMap = UtilMisc.toMap("productId", product.getString("productId"),
+                        Map<String, Object> eventMap = UtilMisc.<String, Object>toMap("productId", product.getString("productId"),
                                                       "mrpId", mrpId,
                                                       "eventDate", eventDate,
                                                       "mrpEventTypeId", (isBuilt? "PROP_MANUF_O_RECP" : "PROP_PUR_O_RECP"));
@@ -835,9 +838,9 @@ public class MrpServices {
             // if there are 3 levels with no inventoryEvenPanned we stop
         } while (bomLevelWithNoEvent < 3);
 
-        result =  new HashMap();
-        List msgResult = new LinkedList();
-        result.put("msgResult",msgResult);
+        result = FastMap.newInstance();
+        List<Object> msgResult = FastList.newInstance();
+        result.put("msgResult", msgResult);
         result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
         Debug.logInfo("return from executeMrp", module);
         return result;

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java?rev=1059536&r1=1059535&r2=1059536&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java Sun Jan 16 11:23:59 2011
@@ -21,18 +21,21 @@ package org.ofbiz.manufacturing.mrp;
 
 import java.math.BigDecimal;
 import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
 
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.manufacturing.bom.BOMNode;
 import org.ofbiz.manufacturing.bom.BOMTree;
 import org.ofbiz.manufacturing.jobshopmgt.ProductionRun;
 import org.ofbiz.manufacturing.techdata.TechDataServices;
@@ -95,23 +98,24 @@ public class ProposedOrder {
      * <li>if ProposedOrder.isBuild a Map with all the routingTaskId as keys and estimatedStartDate as value.
      * <li>else null.
      **/
-    public Map calculateStartDate(int daysToShip, GenericValue routing, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) {
-        Map result = null;
+    public Map<String, Object> calculateStartDate(int daysToShip, GenericValue routing, Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) {
+        Map<String, Object> result = null;
         Timestamp endDate = (Timestamp)requiredByDate.clone();
         Timestamp startDate = endDate;
         long timeToShip = daysToShip * 8 * 60 * 60 * 1000;
         if (isBuilt) {
-            List listRoutingTaskAssoc = null;
+            List<GenericValue> listRoutingTaskAssoc = null;
             if (routing == null) {
                 try {
-                    Map routingInMap = UtilMisc.toMap("productId", product.getString("productId"), "ignoreDefaultRouting", "Y", "userLogin", userLogin);
-                    Map routingOutMap = dispatcher.runSync("getProductRouting", routingInMap);
+                    Map<String, Object> routingInMap = UtilMisc.<String, Object>toMap("productId", product.getString("productId"),
+                            "ignoreDefaultRouting", "Y", "userLogin", userLogin);
+                    Map<String, Object> routingOutMap = dispatcher.runSync("getProductRouting", routingInMap);
                     routing = (GenericValue)routingOutMap.get("routing");
-                    listRoutingTaskAssoc = (List)routingOutMap.get("tasks");
+                    listRoutingTaskAssoc = UtilGenerics.checkList(routingOutMap.get("tasks"));
                     if (routing == null) {
                         // try to find a routing linked to the virtual product
                         BOMTree tree = null;
-                        ArrayList components = new ArrayList();
+                        List<BOMNode> components = FastList.newInstance();
                         try {
                             tree = new BOMTree(product.getString("productId"), "MANUF_COMPONENT", requiredByDate, BOMTree.EXPLOSION_SINGLE_LEVEL, delegator, dispatcher, userLogin);
                             tree.setRootQuantity(quantity);
@@ -132,13 +136,14 @@ public class ProposedOrder {
                 }
             }
             if (routing != null) {
-                result = new HashMap();
+                result = FastMap.newInstance();
                 //Looks for all the routingTask (ordered by inversed (begin from the end) sequence number)
                 if (listRoutingTaskAssoc == null) {
                     try {
-                        Map routingTasksInMap = UtilMisc.toMap("workEffortId", routing.getString("workEffortId"), "userLogin", userLogin);
-                        Map routingTasksOutMap = dispatcher.runSync("getRoutingTaskAssocs", routingTasksInMap);
-                        listRoutingTaskAssoc = (List)routingTasksOutMap.get("routingTaskAssocs");
+                        Map<String, Object> routingTasksInMap = UtilMisc.<String, Object>toMap("workEffortId", routing.getString("workEffortId"),
+                                "userLogin", userLogin);
+                        Map<String, Object> routingTasksOutMap = dispatcher.runSync("getRoutingTaskAssocs", routingTasksInMap);
+                        listRoutingTaskAssoc = UtilGenerics.checkList(routingTasksOutMap.get("routingTaskAssocs"));
                     } catch (GenericServiceException gse) {
                         Debug.logWarning(gse.getMessage(), module);
                     }
@@ -201,7 +206,7 @@ public class ProposedOrder {
      * Read the first ProductFacility.reorderQuantity and calculate the quantity : if (quantity < reorderQuantity) quantity = reorderQuantity;
      **/
     // FIXME: facilityId
-    public void calculateQuantityToSupply(BigDecimal reorderQuantity, BigDecimal minimumStock, ListIterator  listIterIEP) {
+    public void calculateQuantityToSupply(BigDecimal reorderQuantity, BigDecimal minimumStock, ListIterator<GenericValue>  listIterIEP) {
         //      TODO : use a better algorithm using Order management cost et Product Stock cost to calculate the re-order quantity
         //                     the variable listIterIEP will be used for that
         if (quantity.compareTo(reorderQuantity) < 0) {
@@ -226,12 +231,13 @@ public class ProposedOrder {
         }
         LocalDispatcher dispatcher = ctx.getDispatcher();
         Delegator delegator = ctx.getDelegator();
-        Map parameters = UtilMisc.toMap("userLogin", userLogin);
+        Map<String, Object> parameters = UtilMisc.<String, Object>toMap("userLogin", userLogin);
         if (isBuilt) {
             try {
+                List<BOMNode> bom = FastList.newInstance();
                 BOMTree tree = new BOMTree(productId, "MANUF_COMPONENT", null, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin);
                 tree.setRootQuantity(quantity);
-                tree.print(new ArrayList());
+                tree.print(bom);
                 requirementStartDate = tree.getRoot().getStartDate(manufacturingFacilityId, requiredByDate, true);
             } catch (Exception e) {
                 Debug.logError(e,"Error : computing the requirement start date. " + e.getMessage(), module);
@@ -250,7 +256,7 @@ public class ProposedOrder {
             parameters.put("description", "Automatically generated by MRP");
         }
         try {
-            Map result = dispatcher.runSync("createRequirement", parameters);
+            Map<String, Object> result = dispatcher.runSync("createRequirement", parameters);
             return (String) result.get("requirementId");
         } catch (GenericServiceException e) {
             Debug.logError(e,"Error : createRequirement with parameters = "+parameters+"--"+e.getMessage(), module);

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java?rev=1059536&r1=1059535&r2=1059536&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java Sun Jan 16 11:23:59 2011
@@ -19,19 +19,19 @@
 package org.ofbiz.manufacturing.routing;
 
 import java.math.BigDecimal;
-import java.util.HashMap;
 import java.util.Map;
 
+import javolution.util.FastMap;
+
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.manufacturing.jobshopmgt.ProductionRun;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
 
-import org.ofbiz.manufacturing.jobshopmgt.ProductionRun;
-
 /**
  * Routing related services
  *
@@ -47,8 +47,8 @@ public class RoutingServices {
      * @param context Map containing the input parameters.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map getEstimatedTaskTime(DispatchContext ctx, Map context) {
-        Map result = new HashMap();
+    public static Map<String, Object> getEstimatedTaskTime(DispatchContext ctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
         Delegator delegator = ctx.getDelegator();
         LocalDispatcher dispatcher = ctx.getDispatcher();
 

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=1059536&r1=1059535&r2=1059536&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 Sun Jan 16 11:23:59 2011
@@ -20,13 +20,13 @@ package org.ofbiz.manufacturing.techdata
 
 import java.sql.Time;
 import java.sql.Timestamp;
-import com.ibm.icu.util.Calendar;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilMisc;
@@ -42,6 +42,8 @@ import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.ServiceUtil;
 
+import com.ibm.icu.util.Calendar;
+
 /**
  * TechDataServices - TechData related Services
  *
@@ -52,27 +54,28 @@ public class TechDataServices {
 
     /**
      *
-     * Used to retreive some RoutingTasks (WorkEffort) selected by Name or MachineGroup ordered by Name
+     * Used to retrieve some RoutingTasks (WorkEffort) selected by Name or MachineGroup ordered by Name
      *
      * @param ctx
      * @param context: a map containing workEffortName (routingTaskName) and fixedAssetId (MachineGroup or ANY)
      * @return result: a map containing lookupResult (list of RoutingTask <=> workEffortId with currentStatusId = "ROU_ACTIVE" and workEffortTypeId = "ROU_TASK"
      */
-    public static Map lookupRoutingTask(DispatchContext ctx, Map context) {
+    public static Map<String, Object> lookupRoutingTask(DispatchContext ctx, Map<String, ? extends Object> context) {
         Delegator delegator = ctx.getDelegator();
-        Map result = new HashMap();
+        Map<String, Object> result = FastMap.newInstance();
 
         String workEffortName = (String) context.get("workEffortName");
         String fixedAssetId = (String) context.get("fixedAssetId");
 
-        List listRoutingTask = null;
-        List constraints = new LinkedList();
+        List<GenericValue> listRoutingTask = null;
+        List<EntityExpr> constraints = FastList.newInstance();
 
-        if (UtilValidate.isNotEmpty(workEffortName))
+        if (UtilValidate.isNotEmpty(workEffortName)) {
             constraints.add(EntityCondition.makeCondition("workEffortName", EntityOperator.GREATER_THAN_EQUAL_TO, workEffortName));
-        if (UtilValidate.isNotEmpty(fixedAssetId) && ! "ANY".equals(fixedAssetId))
+        }
+        if (UtilValidate.isNotEmpty(fixedAssetId) && ! "ANY".equals(fixedAssetId)) {
             constraints.add(EntityCondition.makeCondition("fixedAssetId", EntityOperator.EQUALS, fixedAssetId));
-
+        }
         constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "ROU_ACTIVE"));
         constraints.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "ROU_TASK"));
 
@@ -83,11 +86,17 @@ public class TechDataServices {
             Debug.logWarning(e, module);
             return ServiceUtil.returnError("Error finding desired WorkEffort records: " + e.toString());
         }
-        if (listRoutingTask == null) listRoutingTask = new LinkedList();
-        if (listRoutingTask.size() == 0) listRoutingTask.add(UtilMisc.toMap("label","no Match","value","NO_MATCH"));
+        if (listRoutingTask == null) {
+            listRoutingTask = FastList.newInstance();
+        }
+        if (listRoutingTask.size() == 0) {
+            //FIXME is it correct ?
+            // listRoutingTask.add(UtilMisc.toMap("label","no Match","value","NO_MATCH"));
+        }
         result.put("lookupResult", listRoutingTask);
         return result;
     }
+    
     /**
      *
      * Used to check if there is not two routing task with the same SeqId valid at the same period
@@ -96,9 +105,9 @@ public class TechDataServices {
      * @param context    a map containing workEffortIdFrom (routing) and SeqId, fromDate thruDate
      * @return result      a map containing sequenceNumNotOk which is equal to "Y" if it's not Ok
      */
-    public static Map checkRoutingTaskAssoc(DispatchContext ctx, Map context) {
+    public static Map<String, Object> checkRoutingTaskAssoc(DispatchContext ctx, Map<String, ? extends Object> context) {
         Delegator delegator = ctx.getDelegator();
-        Map result = new HashMap();
+        Map<String, Object> result = FastMap.newInstance();
         String sequenceNumNotOk = "N";
 
         String workEffortIdFrom = (String) context.get("workEffortIdFrom");
@@ -110,7 +119,7 @@ public class TechDataServices {
         String create = (String) context.get("create");
 
         boolean createProcess = (create !=null && create.equals("Y")) ? true : false;
-        List listRoutingTaskAssoc = null;
+        List<GenericValue> listRoutingTaskAssoc = null;
 
         try {
             listRoutingTaskAssoc = delegator.findByAnd("WorkEffortAssoc",UtilMisc.toMap("workEffortIdFrom", workEffortIdFrom,"sequenceNum",sequenceNum), UtilMisc.toList("fromDate"));
@@ -120,7 +129,7 @@ public class TechDataServices {
         }
 
         if (listRoutingTaskAssoc != null) {
-            Iterator  i = listRoutingTaskAssoc.iterator();
+            Iterator<GenericValue> i = listRoutingTaskAssoc.iterator();
             while (i.hasNext()) {
                 GenericValue routingTaskAssoc = (GenericValue) i.next();
                 if (! workEffortIdFrom.equals(routingTaskAssoc.getString("workEffortIdFrom")) ||
@@ -175,7 +184,7 @@ public class TechDataServices {
                 }
             } else {
                 try {
-                    List  machines = machineGroup.getRelatedCache("ChildFixedAsset");
+                    List<GenericValue> machines = machineGroup.getRelatedCache("ChildFixedAsset");
                     if (machines != null && machines.size()>0) {
                         GenericValue machine = EntityUtil.getFirst(machines);
                         techDataCalendar = machine.getRelatedOneCache("TechDataCalendar");
@@ -202,8 +211,8 @@ public class TechDataServices {
      * @param dayStart
      * @return a map with the  capacity (Double) available and moveDay (int): the number of day it's necessary to move to have capacity available
      */
-    public static Map dayStartCapacityAvailable(GenericValue techDataCalendarWeek,  int  dayStart) {
-        Map result = new HashMap();
+    public static Map<String, Object> dayStartCapacityAvailable(GenericValue techDataCalendarWeek,  int  dayStart) {
+        Map<String, Object> result = FastMap.newInstance();
         int moveDay = 0;
         Double capacity = null;
         Time startTime = null;
@@ -268,7 +277,7 @@ public class TechDataServices {
         // TODO read TechDataCalendarExcDay to manage execption day
         Calendar cDateTrav =  Calendar.getInstance();
         cDateTrav.setTime(dateFrom);
-        Map position = dayStartCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
+        Map<String, Object> position = dayStartCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
         int moveDay = ((Integer) position.get("moveDay")).intValue();
         if (moveDay != 0) return 0;
         Time startTime = (Time) position.get("startTime");
@@ -286,8 +295,8 @@ public class TechDataServices {
      * @param dateFrom                        the date
      * @return a map with Timestamp dateTo, Double nextCapacity
      */
-    public static Map startNextDay(GenericValue techDataCalendar,  Timestamp  dateFrom) {
-        Map result = new HashMap();
+    public static Map<String, Object> startNextDay(GenericValue techDataCalendar,  Timestamp  dateFrom) {
+        Map<String, Object> result = FastMap.newInstance();
         Timestamp dateTo = null;
         GenericValue techDataCalendarWeek = null;
         // TODO read TechDataCalendarExcWeek to manage execption week (maybe it's needed to refactor the entity definition
@@ -300,7 +309,7 @@ public class TechDataServices {
         // TODO read TechDataCalendarExcDay to manage execption day
         Calendar cDateTrav =  Calendar.getInstance();
         cDateTrav.setTime(dateFrom);
-        Map position = dayStartCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
+        Map<String, Object> position = dayStartCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
         Time startTime = (Time) position.get("startTime");
         int moveDay = ((Integer) position.get("moveDay")).intValue();
         dateTo = (moveDay == 0) ? dateFrom : UtilDateTime.getDayStart(dateFrom,moveDay);
@@ -337,7 +346,7 @@ public class TechDataServices {
             amount = 0;
         } else amount -= nextCapacity;
 
-        Map result = new HashMap();
+        Map<String, Object> result = FastMap.newInstance();
         while (amount > 0)  {
             result = startNextDay(techDataCalendar, dateTo);
             dateTo = (Timestamp) result.get("dateTo");
@@ -357,8 +366,8 @@ public class TechDataServices {
      * @param dayEnd
      * @return a map with the  capacity (Double) available, the startTime and  moveDay (int): the number of day it's necessary to move to have capacity available
      */
-    public static Map dayEndCapacityAvailable(GenericValue techDataCalendarWeek,  int  dayEnd) {
-        Map result = new HashMap();
+    public static Map<String, Object> dayEndCapacityAvailable(GenericValue techDataCalendarWeek, int dayEnd) {
+        Map<String, Object> result = FastMap.newInstance();
         int moveDay = 0;
         Double capacity = null;
         Time startTime = null;
@@ -422,7 +431,7 @@ public class TechDataServices {
         // TODO read TechDataCalendarExcDay to manage execption day
         Calendar cDateTrav =  Calendar.getInstance();
         cDateTrav.setTime(dateFrom);
-        Map position = dayEndCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
+        Map<String, Object> position = dayEndCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
         int moveDay = ((Integer) position.get("moveDay")).intValue();
         if (moveDay != 0) return 0;
         Time startTime = (Time) position.get("startTime");
@@ -440,8 +449,8 @@ public class TechDataServices {
      * @param dateFrom                        the date
      * @return a map with Timestamp dateTo, Double previousCapacity
      */
-    public static Map endPreviousDay(GenericValue techDataCalendar,  Timestamp  dateFrom) {
-        Map result = new HashMap();
+    public static Map<String, Object> endPreviousDay(GenericValue techDataCalendar,  Timestamp  dateFrom) {
+        Map<String, Object> result = FastMap.newInstance();
         Timestamp dateTo = null;
         GenericValue techDataCalendarWeek = null;
         // TODO read TechDataCalendarExcWeek to manage exception week (maybe it's needed to refactor the entity definition
@@ -454,7 +463,7 @@ public class TechDataServices {
         // TODO read TechDataCalendarExcDay to manage execption day
         Calendar cDateTrav =  Calendar.getInstance();
         cDateTrav.setTime(dateFrom);
-        Map position = dayEndCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
+        Map<String, Object> position = dayEndCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
         Time startTime = (Time) position.get("startTime");
         int moveDay = ((Integer) position.get("moveDay")).intValue();
         Double capacity = (Double) position.get("capacity");
@@ -493,7 +502,7 @@ public class TechDataServices {
             amount = 0;
         } else amount -= previousCapacity;
 
-        Map result = new HashMap();
+        Map<String, Object> result = FastMap.newInstance();
         while (amount > 0)  {
             result = endPreviousDay(techDataCalendar, dateTo);
             dateTo = (Timestamp) result.get("dateTo");