Author: mrisaliti
Date: Mon Sep 29 12:58:02 2008 New Revision: 700227 URL: http://svn.apache.org/viewvc?rev=700227&view=rev Log: Converted some bsh scripts to groovy Added: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy (contents, props changed) - copied, changed from r699860, ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/facilities.bsh ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy (contents, props changed) - copied, changed from r699860, ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productlist.bsh ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy (contents, props changed) - copied, changed from r699860, ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productstocktake.bsh Removed: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/facilities.bsh ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productlist.bsh ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productstocktake.bsh Modified: ofbiz/trunk/specialpurpose/hhfacility/widget/hhfacility/FacilityScreens.xml Copied: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy (from r699860, ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/facilities.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy?p2=ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy&p1=ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/facilities.bsh&r1=699860&r2=700227&rev=700227&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/facilities.bsh (original) +++ ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy Mon Sep 29 12:58:02 2008 @@ -17,10 +17,4 @@ * under the License. */ -import org.ofbiz.entity.*; - -delegator = request.getAttribute("delegator"); - -facilities = delegator.findList("Facility", null, null, null, null, false); - -context.put("facilities", facilities); \ No newline at end of file +context.facilities = delegator.findList("Facility", null, null, null, null, false); \ No newline at end of file Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Copied: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy (from r699860, ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productlist.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy?p2=ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy&p1=ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productlist.bsh&r1=699860&r2=700227&rev=700227&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productlist.bsh (original) +++ ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy Mon Sep 29 12:58:02 2008 @@ -17,12 +17,7 @@ * under the License. */ -import org.ofbiz.entity.*; - -delegator = request.getAttribute("delegator"); - productList = request.getAttribute("productList"); -if ( productList != null ) { - context.put("productList", productList); -} - +if (productList) { + context.productList = productList; +} \ No newline at end of file Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Copied: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy (from r699860, ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productstocktake.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy?p2=ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy&p1=ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productstocktake.bsh&r1=699860&r2=700227&rev=700227&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/productstocktake.bsh (original) +++ ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy Mon Sep 29 12:58:02 2008 @@ -18,68 +18,59 @@ */ import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; -import org.ofbiz.entity.util.EntityUtil; - +import org.ofbiz.entity.condition.*; import javolution.util.FastMap; -delegator = request.getAttribute("delegator"); - productId = request.getParameter("productId"); -if (productId == null) { +if (!productId) { productId = session.getAttribute("productId"); } -if (productId != null) { - product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId)); - context.put("product", product); +if (productId) { + product = delegator.findOne("Product", [productId : productId], true); + context.product = product; facilityId = request.getParameter("facilityId"); - contextInput = UtilMisc.toMap("productId",productId, "facilityId", facilityId); - resultOutput = dispatcher.runSync("getInventoryAvailableByFacility",contextInput); - quantitySummary = new HashMap(); - quantitySummary.put("facilityId", facilityId); - quantitySummary.put("atp_qoh", ((Double)resultOutput.get("availableToPromiseTotal")).intValue() + " / " + - ((Double)resultOutput.get("quantityOnHandTotal")).intValue()); - context.put("quantitySummary", quantitySummary); + resultOutput = dispatcher.runSync("getInventoryAvailableByFacility", [productId : productId, facilityId : facilityId]); + quantitySummary = FastMap.newInstance(); + quantitySummary.facilityId = facilityId; + quantitySummary.atp_qoh = ((Double)resultOutput.availableToPromiseTotal).intValue() + " / " + + ((Double)resultOutput.quantityOnHandTotal).intValue(); + context.quantitySummary = quantitySummary; // For now this just generates a visual list of locations set against the product for this facility. // todo: Will need to be able to edit and change these values at some point in the future. - productFacilityLocList = delegator.findByAnd("ProductFacilityLocation", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); - productFacilityLocListIter = productFacilityLocList.iterator(); + productFacilityLocList = delegator.findList("ProductFacilityLocation", + EntityCondition.makeCondition([productId : productId, facilityId : facilityId]), null, null, null, false); facStr = null; - - while (productFacilityLocListIter.hasNext()) { - facilityLoc = productFacilityLocListIter.next(); - if (UtilValidate.isEmpty(facStr)) { - facStr = facilityLoc.get("locationSeqId"); + productFacilityLocList.each { facilityLoc -> + if (!facStr) { + facStr = facilityLoc.locationSeqId; } else { - facStr = facStr + ", " + facilityLoc.get("locationSeqId"); + facStr = facStr + ", " + facilityLoc.locationSeqId; } } - context.put("productFacilityLocations", facStr); + context.productFacilityLocations = facStr; // Now we build a list of locations for inventory items against the facility. // todo: change this to a select from inv_items where productId and facilityId matches distinct (locationSeqId). - invItemList = delegator.findByAnd("InventoryItem", - UtilMisc.toMap("productId", productId, "facilityId", facilityId)); + invItemList = delegator.findList("InventoryItem", + EntityCondition.makeCondition([productId : productId, facilityId : facilityId]), null, null, null, false); - Map locations = new HashMap(); + locations = FastMap.newInstance(); boolean negativeQOH = false; - invItemListIter = invItemList.iterator(); - while (invItemListIter.hasNext()) { - invItem = invItemListIter.next(); - int qoh = ((Double)invItem.get("quantityOnHandTotal")).intValue(); + invItemList.each { invItem -> + int qoh = ((Double)invItem.quantityOnHandTotal).intValue(); if (qoh < 0) { negativeQOH = true; } - locationFound = (String)invItem.get("locationSeqId"); - if (locationFound == null) { + locationFound = (String)invItem.locationSeqId; + if (!locationFound) { locationFound = "nullField"; } - if (locations.get(locationFound) == null) { + if (!locations.get(locationFound)) { locations.put(locationFound, locationFound); } } @@ -89,23 +80,22 @@ locationsIter = locations.keySet().iterator(); while (locationsIter.hasNext()) { location = locationsIter.next(); - contextInput = UtilMisc.toMap("productId",productId, "facilityId", facilityId, "locationSeqId", location); - resultOutput = dispatcher.runSync("getInventoryAvailableByLocation",contextInput); - quantitySummary = new HashMap(); - quantitySummary.put("productId", productId); - quantitySummary.put("facilityId", facilityId); + resultOutput = dispatcher.runSync("getInventoryAvailableByLocation", [productId : productId, facilityId : facilityId, locationSeqId : location]); + quantitySummary = FastMap.newInstance(); + quantitySummary.productId = productId; + quantitySummary.facilityId = facilityId; if ("nullField".equals( location ) == true) { - quantitySummary.put("locationSeqId", ""); + quantitySummary.locationSeqId = ""; } else { - quantitySummary.put("locationSeqId", location); + quantitySummary.locationSeqId = location; } - quantitySummary.put("atp_qoh", ((Double)resultOutput.get("availableToPromiseTotal")).intValue() + " / " + - ((Double)resultOutput.get("quantityOnHandTotal")).intValue()); + quantitySummary.atp_qoh = ((Double)resultOutput.availableToPromiseTotal).intValue() + " / " + + ((Double)resultOutput.quantityOnHandTotal).intValue(); productFacilityLocations.add(quantitySummary); } - context.put("productQtyByLocations", productFacilityLocations); + context.productQtyByLocations = productFacilityLocations; if (negativeQOH) { - context.put("negativeQOH", "true"); + context.negativeQOH = "true"; } -} +} \ No newline at end of file Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/specialpurpose/hhfacility/widget/hhfacility/FacilityScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/hhfacility/widget/hhfacility/FacilityScreens.xml?rev=700227&r1=700226&r2=700227&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/hhfacility/widget/hhfacility/FacilityScreens.xml (original) +++ ofbiz/trunk/specialpurpose/hhfacility/widget/hhfacility/FacilityScreens.xml Mon Sep 29 12:58:02 2008 @@ -211,7 +211,7 @@ <section> <actions> <set field="idValue" from-field="parameters.idValue"/> - <script location="component://hhfacility/webapp/hhfacility/WEB-INF/actions/productlist.bsh"/> + <script location="component://hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy"/> </actions> <widgets> <decorator-screen name="FacilityDecorator"> @@ -230,7 +230,7 @@ <screen name="productstocktake"> <section> <actions> - <script location="component://hhfacility/webapp/hhfacility/WEB-INF/actions/productstocktake.bsh"/> + <script location="component://hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy"/> <set field="locationSeqId" from-field="productFacilityLocations"/> </actions> |
Free forum by Nabble | Edit this page |