Author: jleroux
Date: Thu Apr 8 11:43:51 2010 New Revision: 931892 URL: http://svn.apache.org/viewvc?rev=931892&view=rev Log: A patch from Bob Morley "Resolve java warnings exposed in Eclipse (specialpurpose - hhfacility part of OFBIZ-3100)" https://issues.apache.org/jira/browse/OFBIZ-3598 - OFBIZ-3598 Modified: ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilitySession.java Modified: ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java?rev=931892&r1=931891&r2=931892&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java (original) +++ ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java Thu Apr 8 11:43:51 2010 @@ -19,16 +19,13 @@ package org.ofbiz.hhfacility; -import java.util.HashMap; -import java.util.Map; import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; +import java.util.Map; -import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.base.util.GeneralRuntimeException; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.GeneralRuntimeException; 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; @@ -42,11 +39,9 @@ public class FacilityServices { public static final String module = FacilityServices.class.getName(); - public static Map findProductsById(DispatchContext dctx, Map context) { + public static Map<String, Object> findProductsById(DispatchContext dctx, Map<String, Object> context) { Delegator delegator = dctx.getDelegator(); - String facilityId = (String) context.get("facilityId"); String idValue = (String) context.get("idValue"); - GenericValue product = null; List<GenericValue> productsFound = null; try { @@ -57,14 +52,14 @@ public class FacilityServices { } // Send back the results - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); if (UtilValidate.isNotEmpty(productsFound)) { result.put("productList", productsFound); } return result; } - public static Map fixProductNegativeQOH(DispatchContext dctx, Map context) { + public static Map<String, Object> fixProductNegativeQOH(DispatchContext dctx, Map<String, Object> context) { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); @@ -74,7 +69,7 @@ public class FacilityServices { // Now we build a list of inventory items against the facility and product. // todo: change this to a select from inv_items where productId and facilityId matches distinct (locationSeqId). - List invItemList = null; + List<GenericValue> invItemList = null; try { invItemList = delegator.findByAnd("InventoryItem", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); @@ -83,16 +78,13 @@ public class FacilityServices { throw new GeneralRuntimeException(e.getMessage()); } - Map locations = new HashMap(); - Iterator invItemListIter = invItemList.iterator(); - while (invItemListIter.hasNext()) { - GenericValue invItem = (GenericValue)invItemListIter.next(); + for (GenericValue invItem : invItemList) { if (invItem != null) { int qoh = ((Double)invItem.get("quantityOnHandTotal")).intValue(); if (qoh < 0) { // Got a negative qoh so lets balance if off to zero. - Map contextInput = UtilMisc.toMap("userLogin", userLogin, "inventoryItemId", invItem.get("inventoryItemId"), + Map<String, Object> contextInput = UtilMisc.toMap("userLogin", userLogin, "inventoryItemId", invItem.get("inventoryItemId"), "varianceReasonId", "VAR_LOST", "availableToPromiseVar", new Double(qoh*-1), "quantityOnHandVar", new Double(qoh*-1), "comments", "QOH < 0 stocktake correction"); try { @@ -104,18 +96,16 @@ public class FacilityServices { } } } - Map result = ServiceUtil.returnSuccess(); - return result; + return ServiceUtil.returnSuccess(); } - public static Map updateProductStocktake(DispatchContext dctx, Map context) { + public static Map<String, Object> updateProductStocktake(DispatchContext dctx, Map<String, Object> context) { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); String facilityId = (String) context.get("facilityId"); String productId = (String) context.get("productId"); String locationSeqId = (String) context.get("locationSeqId"); - String locationSeqIdNew = (String) context.get("locationSeqIdNew"); Double quantity = (Double) context.get("quantity"); if (UtilValidate.isEmpty(productId) || UtilValidate.isEmpty(facilityId)) { return ServiceUtil.returnError("productId or facilityId not found"); @@ -128,15 +118,14 @@ public class FacilityServices { } // Get the current atp/qoh values for the location(s). - Map contextInput = UtilMisc.toMap("productId",productId, "facilityId", facilityId, "locationSeqId", locationSeqId); - Map invAvailability = null; + Map<String, Object> contextInput = UtilMisc.toMap("productId", (Object) productId, "facilityId", facilityId, "locationSeqId", locationSeqId); + Map<String, Object> invAvailability = null; try { invAvailability = dispatcher.runSync("getInventoryAvailableByLocation",contextInput); } catch (GenericServiceException e) { Debug.logError(e, "updateProductStocktake failed getting inventory counts", module); return ServiceUtil.returnError("updateProductStocktake failed getting inventory counts"); } - int atp = ((Double)invAvailability.get("availableToPromiseTotal")).intValue(); int qoh = ((Double)invAvailability.get("quantityOnHandTotal")).intValue(); if (quantity.intValue() == qoh) { // No change required. @@ -145,7 +134,7 @@ public class FacilityServices { } // Now get the inventory items that are found for that location, facility and product - List invItemList = null; + List<GenericValue> invItemList = null; try { invItemList = delegator.findByAnd("InventoryItem", UtilMisc.toMap("productId", productId, "facilityId", facilityId, "locationSeqId", locationSeqId)); @@ -154,9 +143,7 @@ public class FacilityServices { return ServiceUtil.returnError("updateProductStocktake failed getting inventory items"); } - Iterator invItemListIter = invItemList.iterator(); - while (invItemListIter.hasNext()) { - GenericValue invItem = (GenericValue)invItemListIter.next(); + for (GenericValue invItem : invItemList) { String locationFound = invItem.getString("locationSeqId"); Debug.logInfo("updateProductStocktake: InvItemId("+invItem.getString("inventoryItemId")+")", module); if (locationFound == null) { @@ -164,9 +151,8 @@ public class FacilityServices { } } // Check if there is a request to change the locationSeqId - GenericValue product = null; try { - Map resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, + dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); } catch (GenericServiceException e) { Debug.logError(e, module); Modified: ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilitySession.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilitySession.java?rev=931892&r1=931891&r2=931892&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilitySession.java (original) +++ ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilitySession.java Thu Apr 8 11:43:51 2010 @@ -19,31 +19,30 @@ package org.ofbiz.hhfacility; -import java.util.Map; -import java.util.List; import java.io.IOException; +import java.util.List; +import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.webapp.control.RequestHandler; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ServiceUtil; +import org.ofbiz.webapp.control.RequestHandler; public class FacilitySession { public static final String module = FacilitySession.class.getName(); public static final String findProductsById(HttpServletRequest request, HttpServletResponse response) { - HttpSession session = request.getSession(); String idValueStr = request.getParameter("idValue"); String facilityIdStr = request.getParameter("facilityId"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); @@ -52,7 +51,7 @@ public class FacilitySession { return "success"; } - Map productsMap = null; + Map<String, Object> productsMap = null; try { productsMap = dispatcher.runSync("findProductsById", UtilMisc.toMap("idValue", idValueStr, "facilityId", facilityIdStr)); } catch (GenericServiceException e) { @@ -64,7 +63,7 @@ public class FacilitySession { return "error"; } - List productList = (List)productsMap.get("productList"); + List<GenericValue> productList = UtilGenerics.checkList(productsMap.get("productList"), GenericValue.class); if (productList != null && productList.size() == 1) { // Found only one product so go get it and redirect to the edit page ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); |
Free forum by Nabble | Edit this page |