Author: mrisaliti
Date: Fri Jun 13 13:27:17 2008 New Revision: 667640 URL: http://svn.apache.org/viewvc?rev=667640&view=rev Log: Converted some facility bsh scripts to groovy (Part of issue OFBIZ-1801) Added: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/QuickShipOrder.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/QuickShipOrder.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ShipmentManifest.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ShipmentManifest.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ViewShipment.groovy - copied, changed from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ViewShipment.bsh Removed: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackOrder.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/PackingSlip.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/QuickShipOrder.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ShipmentManifest.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ViewShipment.bsh Modified: ofbiz/trunk/applications/product/widget/facility/ShipmentScreens.xml Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.groovy (from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.bsh&r1=667620&r2=667640&rev=667640&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/AddItemsFromOrder.groovy Fri Jun 13 13:27:17 2008 @@ -17,140 +17,124 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.util.*; -import org.ofbiz.base.util.*; - -delegator = request.getAttribute("delegator"); +import org.ofbiz.entity.* +import org.ofbiz.entity.util.* shipmentId = request.getParameter("shipmentId"); orderId = request.getParameter("orderId"); shipGroupSeqId = request.getParameter("shipGroupSeqId"); selectFromShipmentPlan = request.getParameter("selectFromShipmentPlan"); -shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); +shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false); -if (shipment != null) { - context.put("originFacility", shipment.getRelatedOne("OriginFacility")); - context.put("destinationFacility", shipment.getRelatedOne("DestinationFacility")); +if (shipment) { + context.originFacility = shipment.getRelatedOne("OriginFacility"); + context.destinationFacility = shipment.getRelatedOne("DestinationFacility"); } -if (UtilValidate.isEmpty(orderId) && shipment != null && selectFromShipmentPlan == null) { - orderId = shipment.get("primaryOrderId"); +if (!orderId && shipment && !selectFromShipmentPlan) { + orderId = shipment.primaryOrderId; } -if (UtilValidate.isEmpty(shipGroupSeqId) && shipment != null) { - shipGroupSeqId = shipment.get("primaryShipGroupSeqId"); +if (!shipGroupSeqId && shipment) { + shipGroupSeqId = shipment.primaryShipGroupSeqId; } -if (UtilValidate.isNotEmpty(orderId) && shipment != null) { - orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); - context.put("orderHeader", orderHeader); +if (orderId && shipment) { + orderHeader = delegator.findOne("OrderHeader", [orderId : orderId], false); + context.orderHeader = orderHeader; - if (orderHeader != null) { - context.put("orderHeaderStatus", orderHeader.getRelatedOne("StatusItem")); - context.put("orderType", orderHeader.getRelatedOne("OrderType")); + if (orderHeader) { + context.orderHeaderStatus = orderHeader.getRelatedOne("StatusItem"); + context.orderType = orderHeader.getRelatedOne("OrderType"); - isSalesOrder = "SALES_ORDER".equals(orderHeader.getString("orderTypeId")); - context.put("isSalesOrder", isSalesOrder); + isSalesOrder = "SALES_ORDER".equals(orderHeader.orderTypeId); + context.isSalesOrder = isSalesOrder; orderItemShipGroup = null; - if (UtilValidate.isNotEmpty(shipGroupSeqId)) { - orderItemShipGroup = delegator.findByPrimaryKey("OrderItemShipGroup", UtilMisc.toMap("orderId", orderId, "shipGroupSeqId", shipGroupSeqId)); - context.put("orderItemShipGroup", orderItemShipGroup); + if (shipGroupSeqId) { + orderItemShipGroup = delegator.findOne("OrderItemShipGroup", [orderId : orderId, shipGroupSeqId : shipGroupSeqId], false); + context.orderItemShipGroup = orderItemShipGroup; } oiasgaLimitMap = null; - if (orderItemShipGroup != null) { - oiasgaLimitMap = UtilMisc.toMap("shipGroupSeqId", shipGroupSeqId); + if (orderItemShipGroup) { + oiasgaLimitMap = [shipGroupSeqId : shipGroupSeqId]; } - orderItems = orderHeader.getRelated("OrderItemAndShipGroupAssoc", oiasgaLimitMap, UtilMisc.toList("shipGroupSeqId", "orderItemSeqId")); - orderItemDatas = new LinkedList(); - orderItemIter = orderItems.iterator(); - while (orderItemIter.hasNext()) { - orderItemData = new HashMap(); - orderItemAndShipGroupAssoc = orderItemIter.next(); + orderItems = orderHeader.getRelated("OrderItemAndShipGroupAssoc", oiasgaLimitMap, ['shipGroupSeqId', 'orderItemSeqId']); + orderItemDatas = [] as LinkedList; + orderItems.each { orderItemAndShipGroupAssoc -> + orderItemData = [:]; product = orderItemAndShipGroupAssoc.getRelatedOne("Product"); itemIssuances = orderItemAndShipGroupAssoc.getRelated("ItemIssuance"); totalQuantityIssued = 0; - itemIssuanceIter = itemIssuances.iterator(); - while (itemIssuanceIter.hasNext()) { - itemIssuance = itemIssuanceIter.next(); - if (itemIssuance.get("quantity") != null) { + itemIssuances.each { itemIssuance -> + if (itemIssuance.quantity) { totalQuantityIssued += itemIssuance.getDouble("quantity"); } - if (itemIssuance.get("cancelQuantity") != null) { + if (itemIssuance.cancelQuantity) { totalQuantityIssued -= itemIssuance.getDouble("cancelQuantity"); - } + } } if (isSalesOrder) { oisgirLimitMap = null; - if (orderItemShipGroup != null) { - oisgirLimitMap = UtilMisc.toMap("shipGroupSeqId", shipGroupSeqId); + if (orderItemShipGroup) { + oisgirLimitMap = [shipGroupSeqId : shipGroupSeqId]; } - orderItemShipGrpInvResList = orderItemAndShipGroupAssoc.getRelated("OrderItemShipGrpInvRes", oisgirLimitMap, UtilMisc.toList("reservedDatetime")); - orderItemShipGrpInvResDatas = new LinkedList(); + orderItemShipGrpInvResList = orderItemAndShipGroupAssoc.getRelated("OrderItemShipGrpInvRes", oisgirLimitMap, ['reservedDatetime']); + orderItemShipGrpInvResDatas = [] as LinkedList; totalQuantityReserved = 0; - orderItemShipGrpInvResIter = orderItemShipGrpInvResList.iterator(); - while (orderItemShipGrpInvResIter.hasNext()) { - orderItemShipGrpInvRes = orderItemShipGrpInvResIter.next(); + orderItemShipGrpInvResList.each { orderItemShipGrpInvRes -> inventoryItem = orderItemShipGrpInvRes.getRelatedOne("InventoryItem"); - orderItemShipGrpInvResData = new HashMap(); - orderItemShipGrpInvResData.put("orderItemShipGrpInvRes", orderItemShipGrpInvRes); - orderItemShipGrpInvResData.put("inventoryItem", inventoryItem); - orderItemShipGrpInvResData.put("inventoryItemFacility", inventoryItem.getRelatedOne("Facility")); + orderItemShipGrpInvResData = [:]; + orderItemShipGrpInvResData.orderItemShipGrpInvRes = orderItemShipGrpInvRes; + orderItemShipGrpInvResData.inventoryItem = inventoryItem; + orderItemShipGrpInvResData.inventoryItemFacility = inventoryItem.getRelatedOne("Facility"); orderItemShipGrpInvResDatas.add(orderItemShipGrpInvResData); - if (orderItemShipGrpInvRes.get("quantity") != null) { + if (orderItemShipGrpInvRes.quantity) { totalQuantityReserved += orderItemShipGrpInvRes.getDouble("quantity"); } } - orderItemData.put("orderItemShipGrpInvResDatas", orderItemShipGrpInvResDatas); - orderItemData.put("totalQuantityReserved", totalQuantityReserved); - orderItemData.put("totalQuantityIssuedAndReserved", totalQuantityReserved + totalQuantityIssued); + orderItemData.orderItemShipGrpInvResDatas = orderItemShipGrpInvResDatas; + orderItemData.totalQuantityReserved = totalQuantityReserved; + orderItemData.totalQuantityIssuedAndReserved = totalQuantityReserved + totalQuantityIssued; } - orderItemData.put("orderItemAndShipGroupAssoc", orderItemAndShipGroupAssoc); - orderItemData.put("product", product); - orderItemData.put("itemIssuances", itemIssuances); - orderItemData.put("totalQuantityIssued", totalQuantityIssued); + orderItemData.orderItemAndShipGroupAssoc = orderItemAndShipGroupAssoc; + orderItemData.product = product; + orderItemData.itemIssuances = itemIssuances; + orderItemData.totalQuantityIssued = totalQuantityIssued; orderItemDatas.add(orderItemData); } - context.put("orderItemDatas", orderItemDatas); + context.orderItemDatas = orderItemDatas; } } -if (shipment != null && selectFromShipmentPlan != null) { - - shipmentPlans = delegator.findByAnd("OrderShipment", UtilMisc.toMap("shipmentId", shipment.getString("shipmentId")), UtilMisc.toList("orderId", "orderItemSeqId")); - orderItemDatas = new LinkedList(); - - context.put("isSalesOrder", true); - - shipmentPlansIt = shipmentPlans.iterator(); - - while (shipmentPlansIt.hasNext()) { - orderItemData = new HashMap(); - - shipmentPlan = shipmentPlansIt.next(); +if (shipment && selectFromShipmentPlan) { + shipmentPlans = delegator.findList("OrderShipment", EntityCondition.makeCondition([shipmentId : shipment.shipmentId]), null, ['orderId', 'orderItemSeqId'], null, false); + orderItemDatas = [] as LinkedList; + + context.isSalesOrder = true; + shipmentPlans.each { shipmentPlan -> + orderItemData = [:]; orderItem = shipmentPlan.getRelatedOne("OrderItem"); orderItemShipGroup = null; - if (UtilValidate.isNotEmpty(shipGroupSeqId)) { - orderItemShipGroup = delegator.findByPrimaryKey("OrderItemShipGroup", UtilMisc.toMap("orderId", orderItem.getString("orderId"), "shipGroupSeqId", shipGroupSeqId)); - context.put("orderItemShipGroup", orderItemShipGroup); + if (shipGroupSeqId) { + orderItemShipGroup = delegator.findOne("OrderItemShipGroup", [orderId : orderItem.orderId, shipGroupSeqId : shipGroupSeqId], false); + context.orderItemShipGroup = orderItemShipGroup; } oiasgaLimitMap = null; - if (orderItemShipGroup != null) { - oiasgaLimitMap = UtilMisc.toMap("shipGroupSeqId", shipGroupSeqId); + if (orderItemShipGroup) { + oiasgaLimitMap = [shipGroupSeqId : shipGroupSeqId]; } orderItemShipGroupAssoc = null; orderItemShipGroupAssocs = orderItem.getRelatedByAnd("OrderItemShipGroupAssoc", oiasgaLimitMap); - if (UtilValidate.isNotEmpty(orderItemShipGroupAssocs)) { + if (orderItemShipGroupAssocs) { orderItemShipGroupAssoc = EntityUtil.getFirst(orderItemShipGroupAssocs); } plannedQuantity = shipmentPlan.getDouble("quantity"); @@ -161,45 +145,40 @@ itemIssuances = orderItem.getRelated("ItemIssuance"); totalQuantityIssued = 0; totalQuantityIssuedInShipment = 0; - itemIssuanceIter = itemIssuances.iterator(); - while (itemIssuanceIter.hasNext()) { - itemIssuance = itemIssuanceIter.next(); - if (itemIssuance.get("quantity") != null) { + itemIssuances.each { itemIssuance -> + if (itemIssuance.quantity) { totalQuantityIssued += itemIssuance.getDouble("quantity"); } - if (itemIssuance.get("cancelQuantity") != null) { + if (itemIssuance.cancelQuantity) { totalQuantityIssued -= itemIssuance.getDouble("cancelQuantity"); } - if (itemIssuance.get("shipmentId") != null && itemIssuance.getString("shipmentId").equals(shipmentId)) { + if (itemIssuance.shipmentId && itemIssuance.shipmentId.equals(shipmentId)) { totalQuantityIssuedInShipment += itemIssuance.getDouble("quantity"); - if (itemIssuance.get("cancelQuantity") != null) { + if (itemIssuance.cancelQuantity) { totalQuantityIssuedInShipment -= itemIssuance.getDouble("cancelQuantity"); } } } - orderItemShipGrpInvResList = orderItem.getRelated("OrderItemShipGrpInvRes", null, UtilMisc.toList("reservedDatetime")); - orderItemShipGrpInvResDatas = new LinkedList(); + orderItemShipGrpInvResList = orderItem.getRelated("OrderItemShipGrpInvRes", null, ['reservedDatetime']); + orderItemShipGrpInvResDatas = [] as LinkedList; totalQuantityReserved = 0; - orderItemShipGrpInvResIter = orderItemShipGrpInvResList.iterator(); - - while (orderItemShipGrpInvResIter.hasNext()) { - orderItemShipGrpInvRes = orderItemShipGrpInvResIter.next(); + orderItemShipGrpInvResList.each { orderItemShipGrpInvRes -> inventoryItem = orderItemShipGrpInvRes.getRelatedOne("InventoryItem"); - orderItemShipGrpInvResData = new HashMap(); - orderItemShipGrpInvResData.put("orderItemShipGrpInvRes", orderItemShipGrpInvRes); - orderItemShipGrpInvResData.put("inventoryItem", inventoryItem); - orderItemShipGrpInvResData.put("inventoryItemFacility", inventoryItem.getRelatedOne("Facility")); + orderItemShipGrpInvResData = [:]; + orderItemShipGrpInvResData.orderItemShipGrpInvRes = orderItemShipGrpInvRes; + orderItemShipGrpInvResData.inventoryItem = inventoryItem; + orderItemShipGrpInvResData.inventoryItemFacility = inventoryItem.getRelatedOne("Facility"); orderItemShipGrpInvResDatas.add(orderItemShipGrpInvResData); reservedQuantity = 0.0; quantityNotAvailable = 0.0; proposedQuantity = 0.0; - if (orderItemShipGrpInvRes.get("quantity") != null) { + if (orderItemShipGrpInvRes.quantity) { reservedQuantity = orderItemShipGrpInvRes.getDouble("quantity"); totalQuantityReserved += reservedQuantity; } - if (orderItemShipGrpInvRes.get("quantityNotAvailable") != null) { + if (orderItemShipGrpInvRes.quantityNotAvailable) { quantityNotAvailable = orderItemShipGrpInvRes.getDouble("quantityNotAvailable"); } proposedQuantity = reservedQuantity - quantityNotAvailable; @@ -210,27 +189,24 @@ proposedQuantity = 0.0; } totalProposedQuantity += proposedQuantity; - orderItemShipGrpInvResData.put("shipmentPlanQuantity", proposedQuantity); + orderItemShipGrpInvResData.shipmentPlanQuantity = proposedQuantity; } - Map orderItemShipGroupAssocMap = new HashMap(orderItemShipGroupAssoc); - orderItemShipGroupAssocMap.put("quantity", orderItemShipGroupAssoc.getDouble("quantity")); - orderItemData.put("orderItemAndShipGroupAssoc", orderItemShipGroupAssocMap); - orderItemData.put("orderItemShipGrpInvResDatas", orderItemShipGrpInvResDatas); - orderItemData.put("totalQuantityReserved", totalQuantityReserved); - orderItemData.put("totalQuantityIssuedAndReserved", totalQuantityReserved + totalQuantityIssued); - - orderItemData.put("orderItem", orderItem); - orderItemData.put("product", product); - orderItemData.put("itemIssuances", itemIssuances); - orderItemData.put("totalQuantityIssued", totalQuantityIssued); + orderItemShipGroupAssocMap = new HashMap(orderItemShipGroupAssoc); + orderItemShipGroupAssocMap.quantity = orderItemShipGroupAssoc.getDouble("quantity"); + orderItemData.orderItemAndShipGroupAssoc = orderItemShipGroupAssocMap; + orderItemData.orderItemShipGrpInvResDatas = orderItemShipGrpInvResDatas; + orderItemData.totalQuantityReserved = totalQuantityReserved; + orderItemData.totalQuantityIssuedAndReserved = totalQuantityReserved + totalQuantityIssued; + orderItemData.orderItem = orderItem; + orderItemData.product = product; + orderItemData.itemIssuances = itemIssuances; + orderItemData.totalQuantityIssued = totalQuantityIssued; orderItemDatas.add(orderItemData); - } - context.put("orderItemDatas", orderItemDatas); + context.orderItemDatas = orderItemDatas; } -context.put("shipmentId", shipmentId); -context.put("shipment", shipment); -context.put("orderId", orderId); -context.put("shipGroupSeqId", shipGroupSeqId); - +context.shipmentId = shipmentId; +context.shipment = shipment; +context.orderId = orderId; +context.shipGroupSeqId = shipGroupSeqId; \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.groovy (from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.bsh&r1=667620&r2=667640&rev=667640&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipment.groovy Fri Jun 13 13:27:17 2008 @@ -17,46 +17,45 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; -import org.ofbiz.widget.html.*; - -delegator = request.getAttribute("delegator"); +import org.ofbiz.entity.condition.* +import org.ofbiz.widget.html.HtmlFormWrapper shipmentId = request.getParameter("shipmentId"); -if (UtilValidate.isEmpty(shipmentId)) shipmentId = request.getAttribute("shipmentId"); -shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); +if (!shipmentId) { + shipmentId = request.getAttribute("shipmentId"); +} +shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false); // orderHeader is needed here to determine type of order and hence types of shipment status -orderHeader = null; -primaryOrderId = null; -if (shipment == null) { +if (!shipment) { primaryOrderId = request.getParameter("primaryOrderId"); } else { - primaryOrderId = shipment.get("primaryOrderId"); + primaryOrderId = shipment.primaryOrderId; } -orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", primaryOrderId)); +orderHeader = delegator.findOne("OrderHeader", [orderId : primaryOrderId], false); HtmlFormWrapper editShipmentWrapper = new HtmlFormWrapper("component://product/webapp/facility/shipment/ShipmentForms.xml", "EditShipment", request, response); editShipmentWrapper.putInContext("shipmentId", shipmentId); editShipmentWrapper.putInContext("shipment", shipment); editShipmentWrapper.putInContext("productStoreId", null); // seems to be needed not exist != null -if (shipment == null) editShipmentWrapper.setUseRequestParameters(true); + +if (!shipment) { + editShipmentWrapper.setUseRequestParameters(true); +} // the kind of StatusItem to use is based on the type of order -if ((orderHeader != null) && (orderHeader.getString("orderTypeId").equals("PURCHASE_ORDER"))) { +if (orderHeader && "PURCHASE_ORDER".equals(orderHeader.orderTypeId)) { statusItemType = "PURCH_SHIP_STATUS"; } else { statusItemType = "SHIPMENT_STATUS"; } editShipmentWrapper.putInContext("statusItemType", statusItemType); -context.put("shipmentId", shipmentId); -context.put("shipment", shipment); -context.put("editShipmentWrapper", editShipmentWrapper); +context.shipmentId = shipmentId; +context.shipment = shipment; +context.editShipmentWrapper = editShipmentWrapper; -if (shipment != null) { +if (shipment) { currentStatus = shipment.getRelatedOne("StatusItem"); originPostalAddress = shipment.getRelatedOne("OriginPostalAddress"); destinationPostalAddress = shipment.getRelatedOne("DestinationPostalAddress"); @@ -78,27 +77,23 @@ editShipmentWrapper.putInContext("fromPerson", fromPerson); editShipmentWrapper.putInContext("fromPartyGroup", fromPartyGroup); editShipmentWrapper.putInContext("orderHeader", orderHeader); - if (orderHeader != null) { + if (orderHeader) { editShipmentWrapper.putInContext("productStoreId", orderHeader.get("productStoreId")); } - context.put("currentStatus", currentStatus); - context.put("originPostalAddress", originPostalAddress); - context.put("destinationPostalAddress", destinationPostalAddress); - context.put("originTelecomNumber", originTelecomNumber); - context.put("destinationTelecomNumber", destinationTelecomNumber); - context.put("toPerson", toPerson); - context.put("toPartyGroup", toPartyGroup); - context.put("fromPerson", fromPerson); - context.put("fromPartyGroup", fromPartyGroup); + context.currentStatus = currentStatus; + context.originPostalAddress = originPostalAddress; + context.destinationPostalAddress = destinationPostalAddress; + context.originTelecomNumber = originTelecomNumber; + context.destinationTelecomNumber = destinationTelecomNumber; + context.toPerson = toPerson; + context.toPartyGroup = toPartyGroup; + context.fromPerson = fromPerson; + context.fromPartyGroup = fromPartyGroup; - if (primaryOrderId != null) { - ord = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", primaryOrderId)); + if (primaryOrderId) { + ord = delegator.findOne("OrderHeader", [orderId : primaryOrderId], false); pfc = delegator.findList("ProductStoreFacility", null, null, null, null, false); - fac = delegator.findByAnd("ProductStoreFacilityByOrder", UtilMisc.toMap("orderId", primaryOrderId)); - Debug.log("" + ord); - Debug.log("" + pfc); - Debug.log("" + fac); + fac = delegator.findList("ProductStoreFacilityByOrder", EntityCondition.makeCondition([orderId : primaryOrderId]), null, null, null, false); } -} - +} \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.groovy (from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.bsh&r1=667620&r2=667640&rev=667640&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentItems.groovy Fri Jun 13 13:27:17 2008 @@ -17,61 +17,52 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; - -delegator = request.getAttribute("delegator"); +import org.ofbiz.entity.* +import org.ofbiz.base.util.* shipmentId = request.getParameter("shipmentId"); -if (UtilValidate.isEmpty(shipmentId)) { - shipmentId = context.get("shipmentId"); +if (!shipmentId) { + shipmentId = context.shipmentId; } shipment = null; -if (UtilValidate.isNotEmpty(shipmentId)) { - shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); +if (shipmentId) { + shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false); } -if (shipment != null) { - shipmentItems = shipment.getRelated("ShipmentItem", null, UtilMisc.toList("shipmentItemSeqId")); - shipmentItemDatas = new LinkedList(); - if (shipmentItems != null && shipmentItems.size() > 0) { - shipmentItemIter = shipmentItems.iterator(); - while (shipmentItemIter.hasNext()) { - shipmentItem = shipmentItemIter.next(); +if (shipment) { + shipmentItems = shipment.getRelated("ShipmentItem", null, ['shipmentItemSeqId']); + shipmentItemDatas = [] as LinkedList; + if (shipmentItems) { + shipmentItems.each { shipmentItem -> shipmentPackageContents = shipmentItem.getRelated("ShipmentPackageContent"); totalQuantityPackaged = 0; - shipmentPackageContentIter = shipmentPackageContents.iterator(); - while (shipmentPackageContentIter.hasNext()) { - shipmentPackageContent = shipmentPackageContentIter.next(); - if (shipmentPackageContent.get("quantity") != null) { + shipmentPackageContents.each { shipmentPackageContent -> + if (shipmentPackageContent.quantity) { totalQuantityPackaged += shipmentPackageContent.getDouble("quantity"); } } totalQuantityToPackage = 0; - if (shipmentItem.get("quantity") != null) { + if (shipmentItem.quantity) { totalQuantityToPackage = shipmentItem.getDouble("quantity") - totalQuantityPackaged; } - shipmentItemData = new HashMap(); - shipmentItemData.put("shipmentItem", shipmentItem); - shipmentItemData.put("shipmentPackageContents", shipmentPackageContents); - shipmentItemData.put("itemIssuances", shipmentItem.getRelated("ItemIssuance")); - shipmentItemData.put("orderShipments", shipmentItem.getRelated("OrderShipment")); - shipmentItemData.put("product", shipmentItem.getRelatedOne("Product")); - shipmentItemData.put("totalQuantityPackaged", totalQuantityPackaged); - shipmentItemData.put("totalQuantityToPackage", totalQuantityToPackage); + shipmentItemData = [:]; + shipmentItemData.shipmentItem = shipmentItem; + shipmentItemData.shipmentPackageContents = shipmentPackageContents; + shipmentItemData.itemIssuances = shipmentItem.getRelated("ItemIssuance"); + shipmentItemData.orderShipments = shipmentItem.getRelated("OrderShipment"); + shipmentItemData.product = shipmentItem.getRelatedOne("Product"); + shipmentItemData.totalQuantityPackaged = totalQuantityPackaged; + shipmentItemData.totalQuantityToPackage = totalQuantityToPackage; shipmentItemDatas.add(shipmentItemData); } } + shipmentPackages = shipment.getRelated("ShipmentPackage", null, ['shipmentPackageSeqId']); - shipmentPackages = shipment.getRelated("ShipmentPackage", null, UtilMisc.toList("shipmentPackageSeqId")); - - context.put("shipment", shipment); - context.put("shipmentItemDatas", shipmentItemDatas); - context.put("shipmentPackages", shipmentPackages); + context.shipment = shipment; + context.shipmentItemDatas = shipmentItemDatas; + context.shipmentPackages = shipmentPackages; } - -context.put("shipmentId", shipmentId); +context.shipmentId = shipmentId; \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.groovy (from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.bsh&r1=667620&r2=667640&rev=667640&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPackages.groovy Fri Jun 13 13:27:17 2008 @@ -17,49 +17,42 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; - -delegator = request.getAttribute("delegator"); +import org.ofbiz.entity.condition.* shipmentId = request.getParameter("shipmentId"); -if (UtilValidate.isEmpty(shipmentId)) { - shipmentId = context.get("shipmentId"); +if (!shipmentId) { + shipmentId = context.shipmentId; } shipment = null; -if (UtilValidate.isNotEmpty(shipmentId)) { - shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); +if (shipmentId) { + shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false); } -if (shipment != null) { - shipmentPackages = shipment.getRelated("ShipmentPackage", null, UtilMisc.toList("shipmentPackageSeqId")); - shipmentPackageDatas = new LinkedList(); - if (shipmentPackages != null && shipmentPackages.size() > 0) { - shipmentPackageIter = shipmentPackages.iterator(); - while (shipmentPackageIter.hasNext()) { - shipmentPackage = shipmentPackageIter.next(); - shipmentPackageData = new HashMap(); - shipmentPackageData.put("shipmentPackage", shipmentPackage); - shipmentPackageData.put("shipmentPackageContents", shipmentPackage.getRelated("ShipmentPackageContent")); - shipmentPackageData.put("shipmentPackageRouteSegs", shipmentPackage.getRelated("ShipmentPackageRouteSeg")); - shipmentPackageData.put("weightUom", shipmentPackage.getRelatedOne("WeightUom")); +if (shipment) { + shipmentPackages = shipment.getRelated("ShipmentPackage", null, ['shipmentPackageSeqId']); + shipmentPackageDatas = [] as LinkedList; + if (shipmentPackages) { + shipmentPackages.each { shipmentPackage -> + shipmentPackageData = [:]; + shipmentPackageData.shipmentPackage = shipmentPackage; + shipmentPackageData.shipmentPackageContents = shipmentPackage.getRelated("ShipmentPackageContent"); + shipmentPackageData.shipmentPackageRouteSegs = shipmentPackage.getRelated("ShipmentPackageRouteSeg"); + shipmentPackageData.weightUom = shipmentPackage.getRelatedOne("WeightUom"); shipmentPackageDatas.add(shipmentPackageData); } } - shipmentItems = shipment.getRelated("ShipmentItem", null, UtilMisc.toList("shipmentItemSeqId")); - shipmentRouteSegments = shipment.getRelated("ShipmentRouteSegment", null, UtilMisc.toList("shipmentRouteSegmentId")); - weightUoms = delegator.findByAnd("Uom", UtilMisc.toMap("uomTypeId", "WEIGHT_MEASURE"), UtilMisc.toList("description")); + shipmentItems = shipment.getRelated("ShipmentItem", null, ['shipmentItemSeqId']); + shipmentRouteSegments = shipment.getRelated("ShipmentRouteSegment", null, ['shipmentRouteSegmentId']); + weightUoms = delegator.findList("Uom", EntityCondition.makeCondition([uomTypeId : 'WEIGHT_MEASURE']), null, ['description'], null, false); boxTypes = delegator.findList("ShipmentBoxType", null, null, null, null, false); - context.put("shipment", shipment); - context.put("shipmentPackageDatas", shipmentPackageDatas); - context.put("shipmentItems", shipmentItems); - context.put("shipmentRouteSegments", shipmentRouteSegments); - context.put("weightUoms", weightUoms); - context.put("boxTypes", boxTypes); + context.shipment = shipment; + context.shipmentPackageDatas = shipmentPackageDatas; + context.shipmentItems = shipmentItems; + context.shipmentRouteSegments = shipmentRouteSegments; + context.weightUoms = weightUoms; + context.boxTypes = boxTypes; } - -context.put("shipmentId", shipmentId); +context.shipmentId = shipmentId; \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.groovy (from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.bsh&r1=667620&r2=667640&rev=667640&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentPlan.groovy Fri Jun 13 13:27:17 2008 @@ -17,25 +17,20 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; import org.ofbiz.widget.html.*; -delegator = request.getAttribute("delegator"); - shipmentId = request.getParameter("shipmentId"); orderId = request.getParameter("orderId"); shipGroupSeqId = request.getParameter("shipGroupSeqId"); -if (UtilValidate.isEmpty(shipmentId)) { - shipmentId = context.get("shipmentId"); +if (!shipmentId) { + shipmentId = context.shipmentId; } action = request.getParameter("action"); shipment = null; -if (UtilValidate.isNotEmpty(shipmentId)) { - shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); +if (!shipmentId) { + shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false); } @@ -46,13 +41,13 @@ // ************************************** // Search method: search by productId // ************************************** -if (UtilValidate.isNotEmpty(action) && UtilValidate.isNotEmpty(orderId)) { - orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId)); - if (orderHeader != null && orderHeader.getString("orderTypeId").equals("SALES_ORDER")) { - if (UtilValidate.isNotEmpty(shipGroupSeqId)) { - orderItemShipGroupAssocs = delegator.findByAnd("OrderItemShipGroupAssoc", UtilMisc.toMap("orderId", orderId, "shipGroupSeqId", shipGroupSeqId)); +if (action && orderId) { + orderHeader = delegator.findOne("OrderHeader", [orderId : orderId], false); + if (orderHeader && "SALES_ORDER".equals(orderHeader.orderTypeId)) { + if (shipGroupSeqId) { + orderItemShipGroupAssocs = delegator.findList("OrderItemShipGroupAssoc", EntityCondition.makeCondition([orderId : orderId, shipGroupSeqId : shipGroupSeqId]), null, null, null, false); } else { - orderItemShipGroupAssocs = delegator.findByAnd("OrderItemShipGroupAssoc", UtilMisc.toMap("orderId", orderId)); + orderItemShipGroupAssocs = delegator.findList("OrderItemShipGroupAssoc", EntityCondition.makeCondition([orderId : orderId]), null, null, null, false); } } } @@ -64,65 +59,59 @@ totVolume = 0; shipmentPlans = null; shipmentPlansIt = null; -rows = new ArrayList(); -if (shipment != null) { - shipmentPlans = delegator.findByAnd("OrderShipment", UtilMisc.toMap("shipmentId", shipment.getString("shipmentId"))); +rows = [] as ArrayList; +if (shipment) { + shipmentPlans = delegator.findList("OrderShipment", EntityCondition.makeCondition([shipmentId : shipment.shipmentId]), null, null, null, false); } -if (shipmentPlans != null) { - shipmentPlansIt = shipmentPlans.iterator(); - while (shipmentPlansIt.hasNext()) { - shipmentPlan = shipmentPlansIt.next(); +if (shipmentPlans) { + shipmentPlans.each { shipmentPlan -> oneRow = new HashMap(shipmentPlan); // oneRow.putAll(shipmentPlan.getRelatedOne("OrderItemShipGrpInvRes")); orderItem = shipmentPlan.getRelatedOne("OrderItem"); - oneRow.put("productId", orderItem.getString("productId")); + oneRow.productId = orderItem.productId; orderedQuantity = orderItem.getDouble("quantity"); canceledQuantity = orderItem.getDouble("cancelQuantity"); - if (canceledQuantity != null) { + if (canceledQuantity) { orderedQuantity = Double.valueOf(orderedQuantity.doubleValue() - canceledQuantity.doubleValue()); } - oneRow.put("totOrderedQuantity", orderedQuantity.intValue()); + oneRow.totOrderedQuantity = orderedQuantity.intValue(); // Total quantity issued issuedQuantity = 0.0; - qtyIssuedInShipment = new HashMap(); + qtyIssuedInShipment = [:]; issuances = orderItem.getRelated("ItemIssuance"); - issuancesIt = issuances.iterator(); - while (issuancesIt.hasNext()) { - issuance = issuancesIt.next(); - if (issuance.get("quantity") != null) { + issuances.each { issuance -> + if (issuance.quantity) { issuedQuantity += issuance.getDouble("quantity"); - if (issuance.get("cancelQuantity") != null) { + if (issuance.cancelQuantity) { issuedQuantity -= issuance.getDouble("cancelQuantity"); } - if (qtyIssuedInShipment.containsKey(issuance.getString("shipmentId"))) { - qtyInShipment = ((Double)qtyIssuedInShipment.get(issuance.getString("shipmentId"))).doubleValue(); + if (qtyIssuedInShipment.containsKey(issuance.shipmentId)) { + qtyInShipment = ((Double)qtyIssuedInShipment.get(issuance.shipmentId)).doubleValue(); qtyInShipment += issuance.getDouble("quantity"); - if (issuance.get("cancelQuantity") != null) { + if (issuance.cancelQuantity) { qtyInShipment -= issuance.getDouble("cancelQuantity"); } - qtyIssuedInShipment.put(issuance.getString("shipmentId"), qtyInShipment); + qtyIssuedInShipment.put(issuance.shipmentId, qtyInShipment); } else { qtyInShipment = issuance.getDouble("quantity"); - if (issuance.get("cancelQuantity") != null) { + if (issuance.cancelQuantity) { qtyInShipment -= issuance.getDouble("cancelQuantity"); } - qtyIssuedInShipment.put(issuance.getString("shipmentId"), qtyInShipment); + qtyIssuedInShipment.put(issuance.shipmentId, qtyInShipment); } } } - oneRow.put("totIssuedQuantity", issuedQuantity); + oneRow.totIssuedQuantity = issuedQuantity; // Total quantity planned not issued plannedQuantity = 0.0; - qtyPlannedInShipment = new HashMap(); - plans = delegator.findByAnd("OrderShipment", UtilMisc.toMap("orderId", orderItem.getString("orderId"), "orderItemSeqId", orderItem.getString("orderItemSeqId"))); - plansIt = plans.iterator(); - while (plansIt.hasNext()) { - plan = plansIt.next(); - if (plan.get("quantity") != null) { + qtyPlannedInShipment = [:]; + plans = delegator.findList("OrderShipment", EntityCondition.makeCondition([orderId : orderItem.orderId, orderItemSeqId : orderItem.orderItemSeqId]), null, null, null, false); + plans.each { plan -> + if (plan.quantity) { netPlanQty = plan.getDouble("quantity"); - if (qtyIssuedInShipment.containsKey(plan.getString("shipmentId"))) { - qtyInShipment = ((Double)qtyIssuedInShipment.get(plan.getString("shipmentId"))).doubleValue(); + if (qtyIssuedInShipment.containsKey(plan.shipmentId)) { + qtyInShipment = ((Double)qtyIssuedInShipment.get(plan.shipmentId)).doubleValue(); if (netPlanQty > qtyInShipment) { netPlanQty -= qtyInShipment; } else { @@ -130,72 +119,66 @@ } } plannedQuantity += netPlanQty; - if (qtyPlannedInShipment.containsKey(plan.getString("shipmentId"))) { - qtyInShipment = ((Double)qtyPlannedInShipment.get(plan.getString("shipmentId"))).doubleValue(); + if (qtyPlannedInShipment.containsKey(plan.shipmentId)) { + qtyInShipment = ((Double)qtyPlannedInShipment.get(plan.shipmentId)).doubleValue(); qtyInShipment += netPlanQty; - qtyPlannedInShipment.put(plan.getString("shipmentId"), qtyInShipment); + qtyPlannedInShipment.put(plan.shipmentId, qtyInShipment); } else { - qtyPlannedInShipment.put(plan.getString("shipmentId"), netPlanQty); + qtyPlannedInShipment.put(plan.shipmentId, netPlanQty); } } } - oneRow.put("totPlannedQuantity", plannedQuantity); + oneRow.totPlannedQuantity = plannedQuantity; if (qtyIssuedInShipment.containsKey(shipmentId)) { - oneRow.put("issuedQuantity", qtyIssuedInShipment.get(shipmentId)); + oneRow.issuedQuantity = qtyIssuedInShipment.get(shipmentId); } else { - oneRow.put("issuedQuantity", ""); + oneRow.issuedQuantity = ""; } // Reserved and Not Available quantity reservedQuantity = 0.0; reservedNotAvailable = 0.0; reservations = orderItem.getRelated("OrderItemShipGrpInvRes"); - reservationsIt = reservations.iterator(); - while (reservationsIt.hasNext()) { - reservation = reservationsIt.next(); - if (reservation.get("quantity") != null) { + reservations.each { reservation -> + if (reservation.quantity) { reservedQuantity += reservation.getDouble("quantity"); } - if (reservation.get("quantityNotAvailable") != null) { + if (reservation.quantityNotAvailable) { reservedNotAvailable += reservation.getDouble("quantityNotAvailable"); } } - oneRow.put("notAvailableQuantity", reservedNotAvailable); + oneRow.notAvailableQuantity = reservedNotAvailable; + // Planned Weight and Volume product = orderItem.getRelatedOne("Product"); weight = 0.0; quantity = 0.0; - if (shipmentPlan.getDouble("quantity") != null) { + if (shipmentPlan.getDouble("quantity")) { quantity = shipmentPlan.getDouble("quantity"); } - if (product.getDouble("weight") != null) { + if (product.getDouble("weight")) { weight = product.getDouble("weight") * quantity; } - oneRow.put("weight", weight); - if (product.get("weightUomId") != null) { - weightUom = delegator.findByPrimaryKeyCache("Uom", UtilMisc.toMap("uomId", product.getString("weightUomId"))); - oneRow.put("weightUom", weightUom.getString("abbreviation")); + oneRow.weight = weight; + if (product.weightUomId) { + weightUom = delegator.findOne("Uom", [uomId : product.weightUomId], false); + oneRow.weightUom = weightUom.abbreviation; } volume = 0.0; - if (product.getDouble("productHeight") != null && - product.getDouble("productWidth") != null && - product.getDouble("productDepth") != null) { + if (product.getDouble("productHeight") && + product.getDouble("productWidth") && + product.getDouble("productDepth")) { // TODO: check if uom conversion is needed volume = product.getDouble("productHeight") * product.getDouble("productWidth") * product.getDouble("productDepth") * quantity; } - oneRow.put("volume", volume); - if (product.get("heightUomId") != null && - product.get("widthUomId") != null && - product.get("depthUomId") != null) { - - heightUom = delegator.findByPrimaryKeyCache("Uom", UtilMisc.toMap("uomId", product.getString("heightUomId"))); - widthUom = delegator.findByPrimaryKeyCache("Uom", UtilMisc.toMap("uomId", product.getString("widthUomId"))); - depthUom = delegator.findByPrimaryKeyCache("Uom", UtilMisc.toMap("uomId", product.getString("depthUomId"))); - oneRow.put("volumeUom", heightUom.getString("abbreviation") + "x" + - widthUom.getString("abbreviation") + "x" + - depthUom.getString("abbreviation")); + oneRow.volume = volume; + if (product.heightUomId && product.widthUomId && product.depthUomId) { + heightUom = delegator.findOne("Uom",[uomId : product.heightUomId], true); + widthUom = delegator.findOne("Uom", [uomId : product.widthUomId], true); + depthUom = delegator.findOne("Uom", [uomId : product.depthUomId], true); + oneRow.volumeUom = heightUom.abbreviation + "x" + widthUom.abbreviation + "x" + depthUom.abbreviation; } totWeight += weight; totVolume += volume; @@ -208,97 +191,86 @@ // ************************************** // ShipmentPlan add form // ************************************** -addRows = new ArrayList(); -if (orderItemShipGroupAssocs != null) { - orderItemShipGroupAssocIt = orderItemShipGroupAssocs.iterator(); - while (orderItemShipGroupAssocIt.hasNext()) { - orderItemShipGroupAssoc = orderItemShipGroupAssocIt.next(); +addRows = [] as ArrayList; +if (orderItemShipGroupAssocs) { + orderItemShipGroupAssocs.each { orderItemShipGroupAssoc -> orderItem = orderItemShipGroupAssoc.getRelatedOne("OrderItem"); - oneRow = new HashMap(); - oneRow.put("shipmentId", shipmentId); - oneRow.put("orderId", orderItem.getString("orderId")); - oneRow.put("orderItemSeqId", orderItem.getString("orderItemSeqId")); - oneRow.put("productId", orderItem.getString("productId")); + oneRow = [:]; + oneRow.shipmentId = shipmentId; + oneRow.orderId = orderItem.orderId; + oneRow.orderItemSeqId = orderItem.orderItemSeqId; + oneRow.productId = orderItem.productId; orderedQuantity = orderItem.getDouble("quantity"); canceledQuantity = orderItem.getDouble("cancelQuantity"); - if (canceledQuantity != null) { + if (canceledQuantity) { orderedQuantity = Double.valueOf(orderedQuantity.doubleValue() - canceledQuantity.doubleValue()); } - oneRow.put("orderedQuantity", orderedQuantity); + oneRow.orderedQuantity = orderedQuantity; // Total quantity issued issuedQuantity = 0.0; - qtyIssuedInShipment = new HashMap(); + qtyIssuedInShipment = [:]; issuances = orderItem.getRelated("ItemIssuance"); - issuancesIt = issuances.iterator(); - while (issuancesIt.hasNext()) { - issuance = issuancesIt.next(); - if (issuance.get("quantity") != null) { + issuances.each { issuance -> + if (issuance.quantity) { issuedQuantity += issuance.getDouble("quantity"); - if (issuance.get("cancelQuantity") != null) { + if (issuance.cancelQuantity) { issuedQuantity -= issuance.getDouble("cancelQuantity"); } - if (qtyIssuedInShipment.containsKey(issuance.getString("shipmentId"))) { - qtyInShipment = ((Double)qtyIssuedInShipment.get(issuance.getString("shipmentId"))).doubleValue(); + if (qtyIssuedInShipment.containsKey(issuance.shipmentId)) { + qtyInShipment = ((Double)qtyIssuedInShipment.get(issuance.shipmentId)).doubleValue(); qtyInShipment += issuance.getDouble("quantity"); - qtyIssuedInShipment.put(issuance.getString("shipmentId"), qtyInShipment); + qtyIssuedInShipment.put(issuance.shipmentId, qtyInShipment); } else { qtyInShipment = issuance.getDouble("quantity"); - if (issuance.get("cancelQuantity") != null) { + if (issuance.cancelQuantity) { qtyInShipment -= issuance.getDouble("cancelQuantity"); } - qtyIssuedInShipment.put(issuance.getString("shipmentId"), qtyInShipment); + qtyIssuedInShipment.put(issuance.shipmentId, qtyInShipment); } } } - oneRow.put("issuedQuantity", issuedQuantity); + oneRow.issuedQuantity = issuedQuantity; // Total quantity planned not issued plannedQuantity = 0.0; - plans = delegator.findByAnd("OrderShipment", UtilMisc.toMap("orderId", orderItem.getString("orderId"), "orderItemSeqId", orderItem.getString("orderItemSeqId"))); - plansIt = plans.iterator(); - while (plansIt.hasNext()) { - plan = plansIt.next(); - if (plan.get("quantity") != null) { + plans = delegator.findList("OrderShipment", EntityCondition.makeCondition([orderId : orderItem.orderId, orderItemSeqId : orderItem.orderItemSeqId]), null, null, null, false); + plans.each { plan -> + if (plan.quantity) { netPlanQty = plan.getDouble("quantity"); plannedQuantity += netPlanQty; } } - oneRow.put("plannedQuantity", plannedQuantity); + oneRow.plannedQuantity = plannedQuantity; + // (default) quantity for plan planQuantity = (orderedQuantity - plannedQuantity - issuedQuantity > 0? orderedQuantity - plannedQuantity - issuedQuantity: 0); - oneRow.put("quantity", planQuantity); + oneRow.quantity = planQuantity; + // Planned (unitary) Weight and Volume weight = new Double(0); product = orderItem.getRelatedOne("Product"); - if (product.getDouble("weight") != null) { + if (product.getDouble("weight")) { weight = product.getDouble("weight"); } - oneRow.put("weight", weight); + oneRow.weight = weight; - if (product.getString("weightUomId") != null) { - weightUom = delegator.findByPrimaryKeyCache("Uom", UtilMisc.toMap("uomId", product.getString("weightUomId"))); - oneRow.put("weightUom", weightUom.getString("abbreviation")); + if (product.weightUomId) { + weightUom = delegator.findOne("Uom", [uomId : product.weightUomId], true); + oneRow.weightUom = weightUom.abbreviation; } volume = 0.0; - if (product.getDouble("productHeight") != null && - product.getDouble("productWidth") != null && - product.getDouble("productDepth") != null) { + if (product.getDouble("productHeight") && product.getDouble("productWidth") && product.getDouble("productDepth")) { // TODO: check if uom conversion is needed volume = product.getDouble("productHeight") * product.getDouble("productWidth") * product.getDouble("productDepth"); } - oneRow.put("volume", volume); - if (product.get("heightUomId") != null && - product.get("widthUomId") != null && - product.get("depthUomId") != null) { - - heightUom = delegator.findByPrimaryKeyCache("Uom", UtilMisc.toMap("uomId", product.getString("heightUomId"))); - widthUom = delegator.findByPrimaryKeyCache("Uom", UtilMisc.toMap("uomId", product.getString("widthUomId"))); - depthUom = delegator.findByPrimaryKeyCache("Uom", UtilMisc.toMap("uomId", product.getString("depthUomId"))); - oneRow.put("volumeUom", heightUom.getString("abbreviation") + "x" + - widthUom.getString("abbreviation") + "x" + - depthUom.getString("abbreviation")); + oneRow.volume = volume; + if (product.heightUomId && product.widthUomId && product.depthUomId) { + heightUom = delegator.findOne("Uom", [uomId : product.heightUomId], true); + widthUom = delegator.findOne("Uom", [uomId : product.widthUomId], true); + depthUom = delegator.findOne("Uom", [uomId : product.depthUomId], true); + oneRow.volumeUom = heightUom.abbreviation + "x" + widthUom.abbreviation + "x" + depthUom.abbreviation; } addRows.add(oneRow); } @@ -309,26 +281,24 @@ HtmlFormWrapper findOrderItemsForm = new HtmlFormWrapper("component://product/webapp/facility/shipment/ShipmentForms.xml", "findOrderItems", request, response); findOrderItemsForm.putInContext("shipmentId", shipmentId); -if (shipment != null && shipment.get("primaryOrderId") != null) { - findOrderItemsForm.putInContext("orderId", shipment.getString("primaryOrderId")); - if (UtilValidate.isNotEmpty(shipment.get("primaryShipGroupSeqId"))) { - findOrderItemsForm.putInContext("shipGroupSeqId", shipment.getString("primaryShipGroupSeqId")); +if (shipment && shipment.primaryOrderId) { + findOrderItemsForm.putInContext("orderId", shipment.primaryOrderId); + if (shipment.primaryShipGroupSeqId) { + findOrderItemsForm.putInContext("shipGroupSeqId", shipment.primaryShipGroupSeqId); } } HtmlFormWrapper shipmentPlanToOrderItemsForm = new HtmlFormWrapper("component://product/webapp/facility/shipment/ShipmentForms.xml", "shipmentPlanToOrderItems", request, response); shipmentPlanToOrderItemsForm.putInContext("shipmentId", shipmentId); - -context.put("findOrderItemsForm", findOrderItemsForm); // Form for Order search: find By orderId -context.put("shipmentPlanToOrderItemsForm", shipmentPlanToOrderItemsForm); // From Shipment Plan to Order Items -context.put("listShipmentPlanForm", listShipmentPlanForm); // Form for ShipmentPlan list -context.put("listShipmentPlanRows", shipmentPlans); -context.put("addToShipmentPlanForm", addToShipmentPlanForm); // For for ShipmentPlan entry -context.put("addToShipmentPlanRows", addRows); -context.put("rowCount", addRows.size()); -context.put("shipmentId", shipmentId); -context.put("shipment", shipment); -context.put("totWeight", totWeight); -context.put("totVolume", totVolume); - +context.findOrderItemsForm = findOrderItemsForm; // Form for Order search: find By orderId +context.shipmentPlanToOrderItemsForm = shipmentPlanToOrderItemsForm; // From Shipment Plan to Order Items +context.listShipmentPlanForm = listShipmentPlanForm; // Form for ShipmentPlan list +context.listShipmentPlanRows = shipmentPlans; +context.addToShipmentPlanForm = addToShipmentPlanForm; // For for ShipmentPlan entry +context.addToShipmentPlanRows = addRows; +context.rowCount = addRows.size(); +context.shipmentId = shipmentId; +context.shipment = shipment; +context.totWeight = totWeight; +context.totVolume = totVolume; \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.groovy (from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.bsh&r1=667620&r2=667640&rev=667640&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/EditShipmentRouteSegments.groovy Fri Jun 13 13:27:17 2008 @@ -17,84 +17,72 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; - -delegator = request.getAttribute("delegator"); +import org.ofbiz.base.util.* shipmentId = request.getParameter("shipmentId"); -if (UtilValidate.isEmpty(shipmentId)) { - shipmentId = context.get("shipmentId"); +if (!shipmentId) { + shipmentId = context.shipmentId; } shipment = null; -if (UtilValidate.isNotEmpty(shipmentId)) { - shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); +if (!shipmentId) { + shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false); } -if (shipment != null) { - shipmentRouteSegments = shipment.getRelated("ShipmentRouteSegment", null, UtilMisc.toList("shipmentRouteSegmentId")); - shipmentRouteSegmentDatas = new LinkedList(); - if (shipmentRouteSegments != null && shipmentRouteSegments.size() > 0) { - shipmentRouteSegmentIter = shipmentRouteSegments.iterator(); - while (shipmentRouteSegmentIter.hasNext()) { - shipmentRouteSegment = shipmentRouteSegmentIter.next(); - shipmentRouteSegmentData = new HashMap(); - shipmentRouteSegmentData.put("shipmentRouteSegment", shipmentRouteSegment); - shipmentRouteSegmentData.put("originFacility", shipmentRouteSegment.getRelatedOne("OriginFacility")); - shipmentRouteSegmentData.put("destFacility", shipmentRouteSegment.getRelatedOne("DestFacility")); - shipmentRouteSegmentData.put("originPostalAddress", shipmentRouteSegment.getRelatedOne("OriginPostalAddress")); - shipmentRouteSegmentData.put("originTelecomNumber", shipmentRouteSegment.getRelatedOne("OriginTelecomNumber")); - shipmentRouteSegmentData.put("destPostalAddress", shipmentRouteSegment.getRelatedOne("DestPostalAddress")); - shipmentRouteSegmentData.put("destTelecomNumber", shipmentRouteSegment.getRelatedOne("DestTelecomNumber")); - shipmentRouteSegmentData.put("shipmentMethodType", shipmentRouteSegment.getRelatedOne("ShipmentMethodType")); - shipmentRouteSegmentData.put("carrierPerson", shipmentRouteSegment.getRelatedOne("CarrierPerson")); - shipmentRouteSegmentData.put("carrierPartyGroup", shipmentRouteSegment.getRelatedOne("CarrierPartyGroup")); - shipmentRouteSegmentData.put("shipmentPackageRouteSegs", shipmentRouteSegment.getRelated("ShipmentPackageRouteSeg")); - shipmentRouteSegmentData.put("carrierServiceStatusItem", shipmentRouteSegment.getRelatedOne("CarrierServiceStatusItem")); - shipmentRouteSegmentData.put("currencyUom", shipmentRouteSegment.getRelatedOne("CurrencyUom")); - shipmentRouteSegmentData.put("billingWeightUom", shipmentRouteSegment.getRelatedOne("BillingWeightUom")); - if (UtilValidate.isNotEmpty(shipmentRouteSegment.getString("carrierServiceStatusId"))) { - shipmentRouteSegmentData.put("carrierServiceStatusValidChangeToDetails", delegator.findByAnd("StatusValidChangeToDetail", UtilMisc.toMap("statusId", shipmentRouteSegment.get("carrierServiceStatusId")), UtilMisc.toList("sequenceId"))); +if (shipment) { + shipmentRouteSegments = shipment.getRelated("ShipmentRouteSegment", null, ['shipmentRouteSegmentId']); + shipmentRouteSegmentDatas = [] as LinkedList; + if (shipmentRouteSegments) { + shipmentRouteSegments.each { shipmentRouteSegment -> + shipmentRouteSegmentData = [:]; + shipmentRouteSegmentData.shipmentRouteSegment = shipmentRouteSegment; + shipmentRouteSegmentData.originFacility = shipmentRouteSegment.getRelatedOne("OriginFacility"); + shipmentRouteSegmentData.destFacility = shipmentRouteSegment.getRelatedOne("DestFacility"); + shipmentRouteSegmentData.originPostalAddress = shipmentRouteSegment.getRelatedOne("OriginPostalAddress"); + shipmentRouteSegmentData.originTelecomNumber = shipmentRouteSegment.getRelatedOne("OriginTelecomNumber"); + shipmentRouteSegmentData.destPostalAddress = shipmentRouteSegment.getRelatedOne("DestPostalAddress"); + shipmentRouteSegmentData.destTelecomNumber = shipmentRouteSegment.getRelatedOne("DestTelecomNumber"); + shipmentRouteSegmentData.shipmentMethodType = shipmentRouteSegment.getRelatedOne("ShipmentMethodType"); + shipmentRouteSegmentData.carrierPerson = shipmentRouteSegment.getRelatedOne("CarrierPerson"); + shipmentRouteSegmentData.carrierPartyGroup = shipmentRouteSegment.getRelatedOne("CarrierPartyGroup"); + shipmentRouteSegmentData.shipmentPackageRouteSegs = shipmentRouteSegment.getRelated("ShipmentPackageRouteSeg"); + shipmentRouteSegmentData.carrierServiceStatusItem = shipmentRouteSegment.getRelatedOne("CarrierServiceStatusItem"); + shipmentRouteSegmentData.currencyUom = shipmentRouteSegment.getRelatedOne("CurrencyUom"); + shipmentRouteSegmentData.billingWeightUom = shipmentRouteSegment.getRelatedOne("BillingWeightUom"); + if (shipmentRouteSegment.carrierServiceStatusId) { + shipmentRouteSegmentData.carrierServiceStatusValidChangeToDetails = delegator.findList("StatusValidChangeToDetail", EntityCondition.makeCondition([statusId : shipmentRouteSegment.carrierServiceStatusId]), null, ['sequenceId'], null, false); } else { - shipmentRouteSegmentData.put("carrierServiceStatusValidChangeToDetails", delegator.findByAnd("StatusValidChangeToDetail", UtilMisc.toMap("statusId", "SHRSCS_NOT_STARTED"), UtilMisc.toList("sequenceId"))); + shipmentRouteSegmentData.carrierServiceStatusValidChangeToDetails = delegator.findList("StatusValidChangeToDetail", EntityCondition.makeCondition([statusId : 'SHRSCS_NOT_STARTED']), null, ['sequenceId'], null, false); } shipmentRouteSegmentDatas.add(shipmentRouteSegmentData); } } - shipmentPackages = shipment.getRelated("ShipmentPackage", null, UtilMisc.toList("shipmentPackageSeqId")); - facilities = delegator.findList("Facility", null, null, UtilMisc.toList("facilityName"), null, false); - shipmentMethodTypes = delegator.findList("ShipmentMethodType", null, null, UtilMisc.toList("description"), null, false); - weightUoms = delegator.findByAnd("Uom", UtilMisc.toMap("uomTypeId", "WEIGHT_MEASURE")); - currencyUoms = delegator.findByAnd("Uom", UtilMisc.toMap("uomTypeId", "CURRENCY_MEASURE")); + shipmentPackages = shipment.getRelated("ShipmentPackage", null, ['shipmentPackageSeqId']); + facilities = delegator.findList("Facility", null, null, ['facilityName'], null, false); + shipmentMethodTypes = delegator.findList("ShipmentMethodType", null, null, ['description'], null, false); + weightUoms = delegator.findList("Uom", EntityCondition.makeCondition([uomTypeId : 'WEIGHT_MEASURE']), null, null, null, false); + currencyUoms = delegator.findList("Uom", EntityCondition.makeCondition([uomTypeId : 'CURRENCY_MEASURE']), null, null, null, false); - carrierPartyRoles = delegator.findByAnd("PartyRole", UtilMisc.toMap("roleTypeId", "CARRIER")); - carrierPartyDatas = new LinkedList(); - carrierPartyRoleIter = carrierPartyRoles.iterator(); - while (carrierPartyRoleIter.hasNext()) { - carrierPartyRole = carrierPartyRoleIter.next(); + carrierPartyRoles = delegator.findList("PartyRole", EntityCondition.makeCondition([roleTypeId : 'CARRIER']), null, null, null, false); + carrierPartyDatas = [] as LinkedList; + carrierPartyRoles.each { carrierPartyRole -> party = carrierPartyRole.getRelatedOne("Party"); - carrierPartyData = new HashMap(); - carrierPartyData.put("party", party); - carrierPartyData.put("person", party.getRelatedOne("Person")); - carrierPartyData.put("partyGroup", party.getRelatedOne("PartyGroup")); + carrierPartyData = [:]; + carrierPartyData.party = party; + carrierPartyData.person = party.getRelatedOne("Person"); + carrierPartyData.partyGroup = party.getRelatedOne("PartyGroup"); carrierPartyDatas.add(carrierPartyData); } - context.put("shipment", shipment); - context.put("shipmentRouteSegmentDatas", shipmentRouteSegmentDatas); - context.put("shipmentPackages", shipmentPackages); - context.put("facilities", facilities); - context.put("shipmentMethodTypes", shipmentMethodTypes); - context.put("weightUoms", weightUoms); - context.put("currencyUoms", currencyUoms); - context.put("carrierPartyDatas", carrierPartyDatas); + context.shipment = shipment; + context.shipmentRouteSegmentDatas = shipmentRouteSegmentDatas; + context.shipmentPackages = shipmentPackages; + context.facilities = facilities; + context.shipmentMethodTypes = shipmentMethodTypes; + context.weightUoms = weightUoms; + context.currencyUoms = currencyUoms; + context.carrierPartyDatas = carrierPartyDatas; } - -context.put("shipmentId", shipmentId); - -nowTimestampString = UtilDateTime.nowTimestamp().toString(); -context.put("nowTimestampString", nowTimestampString); - +context.shipmentId = shipmentId; +context.nowTimestampString = UtilDateTime.nowTimestamp().toString(); \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy (from r667620, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.bsh&r1=667620&r2=667640&rev=667640&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/FindShipment.groovy Fri Jun 13 13:27:17 2008 @@ -17,13 +17,12 @@ * under the License. */ -import java.util.*; -import java.sql.Timestamp; -import org.ofbiz.base.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.util.*; -import org.ofbiz.entity.condition.*; -import org.ofbiz.entity.transaction.*; +import java.util.* +import java.sql.Timestamp +import org.ofbiz.entity.* +import org.ofbiz.entity.util.* +import org.ofbiz.entity.condition.* +import org.ofbiz.entity.transaction.* delegator = request.getAttribute("delegator"); @@ -42,7 +41,7 @@ } catch (Exception e) { viewIndex = 1; } -context.put("viewIndex", viewIndex); +context.viewIndex = viewIndex; viewSize = 20; try { @@ -50,71 +49,71 @@ } catch (Exception e) { viewSize = 20; } -context.put("viewSize", viewSize); +context.viewSize = viewSize; -findShipmentExprs = new LinkedList(); +findShipmentExprs = [] as LinkedList; paramListBuffer = new StringBuffer(); -if (UtilValidate.isNotEmpty(shipmentTypeId)) { +if (shipmentTypeId) { paramListBuffer.append("&shipmentTypeId="); paramListBuffer.append(shipmentTypeId); findShipmentExprs.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, shipmentTypeId)); - - currentShipmentType = delegator.findByPrimaryKeyCache("ShipmentType", UtilMisc.toMap("shipmentTypeId", shipmentTypeId)); - context.put("currentShipmentType", currentShipmentType); + currentShipmentType = delegator.findOne("ShipmentType", [shipmentTypeId : shipmentTypeId], true); + context.currentShipmentType = currentShipmentType; } -if (UtilValidate.isNotEmpty(originFacilityId)) { +if (originFacilityId) { paramListBuffer.append("&originFacilityId="); paramListBuffer.append(originFacilityId); findShipmentExprs.add(EntityCondition.makeCondition("originFacilityId", EntityOperator.EQUALS, originFacilityId)); - - currentOriginFacility = delegator.findByPrimaryKeyCache("Facility", UtilMisc.toMap("facilityId", originFacilityId)); - context.put("currentOriginFacility", currentOriginFacility); + currentOriginFacility = delegator.findOne("Facility", [facilityId : originFacilityId], true); + context.currentOriginFacility = currentOriginFacility; } -if (UtilValidate.isNotEmpty(destinationFacilityId)) { +if (destinationFacilityId) { paramListBuffer.append("&destinationFacilityId="); paramListBuffer.append(destinationFacilityId); findShipmentExprs.add(EntityCondition.makeCondition("destinationFacilityId", EntityOperator.EQUALS, destinationFacilityId)); - - currentDestinationFacility = delegator.findByPrimaryKeyCache("Facility", UtilMisc.toMap("facilityId", destinationFacilityId)); - context.put("currentDestinationFacility", currentDestinationFacility); + currentDestinationFacility = delegator.findOne("Facility", [facilityId : destinationFacilityId], true); + context.currentDestinationFacility = currentDestinationFacility; } -if (UtilValidate.isNotEmpty(statusId)) { +if (statusId) { paramListBuffer.append("&statusId="); paramListBuffer.append(statusId); findShipmentExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, statusId)); - - currentStatus = delegator.findByPrimaryKeyCache("StatusItem", UtilMisc.toMap("statusId", statusId)); - context.put("currentStatus", currentStatus); + currentStatus = delegator.findOne("StatusItem", [statusId : statusId], true); + context.currentStatus = currentStatus; } -if (minDate != null && minDate.length() > 8) { +if (minDate && minDate.length() > 8) { minDate = minDate.trim(); - if (minDate.length() < 14) minDate = minDate + " " + "00:00:00.000"; + if (minDate.length() < 14) { + minDate = minDate + " " + "00:00:00.000"; + } paramListBuffer.append("&minDate="); paramListBuffer.append(minDate); findShipmentExprs.add(EntityCondition.makeCondition("estimatedShipDate", EntityOperator.GREATER_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(minDate, "Timestamp", null, null))); } -if (maxDate != null && maxDate.length() > 8) { +if (maxDate && maxDate.length() > 8) { maxDate = maxDate.trim(); - if (maxDate.length() < 14) maxDate = maxDate + " " + "23:59:59.999"; + if (maxDate.length() < 14) { + maxDate = maxDate + " " + "23:59:59.999"; + } paramListBuffer.append("&maxDate="); paramListBuffer.append(maxDate); findShipmentExprs.add(EntityCondition.makeCondition("estimatedShipDate", EntityOperator.LESS_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(maxDate, "Timestamp", null, null))); } if ("Y".equals(lookupFlag)) { - context.put("paramList", paramListBuffer.toString()); + context.paramList = paramListBuffer.toString(); if (findShipmentExprs.size() > 0) { - EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); + findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); mainCond = EntityCondition.makeCondition(findShipmentExprs, EntityOperator.AND); - List orderBy = UtilMisc.toList("-estimatedShipDate"); + orderBy = ['-estimatedShipDate']; - boolean beganTransaction = false; + beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); // using list iterator - EntityListIterator orli = delegator.find("Shipment", mainCond, null, null, orderBy, findOpts); + orli = delegator.find("Shipment", mainCond, null, null, orderBy, findOpts); // get the indexes for the partial list lowIndex = (((viewIndex - 1) * viewSize) + 1); @@ -132,13 +131,13 @@ if (shipmentListSize > 0) { shipmentList = orli.getPartialList(lowIndex, viewSize); } else { - shipmentList = new ArrayList(); + shipmentList = [] as ArrayList; } // close the list iterator orli.close(); } catch (GenericEntityException e) { - String errMsg = "Failure in operation, rolling back transaction"; + errMsg = "Failure in operation, rolling back transaction"; Debug.logError(e, errMsg, module); try { // only rollback the transaction if we started one... @@ -153,31 +152,27 @@ TransactionUtil.commit(beganTransaction); } } else { - shipmentList = new ArrayList(); + shipmentList = [] as ArrayList; shipmentListSize = 0; highIndex = 0; lowIndex = 0; } - context.put("shipmentList", shipmentList); - context.put("listSize", shipmentListSize); - context.put("highIndex", highIndex); - context.put("lowIndex", lowIndex); + context.shipmentList = shipmentList; + context.listSize = shipmentListSize; + context.highIndex = highIndex; + context.lowIndex = lowIndex; } // =============== Prepare the Option Data for the Find Form ================= -shipmentTypes = delegator.findList("ShipmentType", null, null, UtilMisc.toList("description"), null, false); -context.put("shipmentTypes", shipmentTypes); +context.shipmentTypes = delegator.findList("ShipmentType", null, null, ['description'], null, false); -facilities = delegator.findList("Facility", null, null, UtilMisc.toList("facilityName"), null, false); -context.put("facilities", facilities); +context.facilities = delegator.findList("Facility", null, null, ['facilityName'], null, false); // since purchase and sales shipments have different status codes, we'll need to make two separate lists -shipmentStatuses = delegator.findByAnd("StatusItem", UtilMisc.toMap("statusTypeId", "SHIPMENT_STATUS"), UtilMisc.toList("sequenceId")); -context.put("shipmentStatuses", shipmentStatuses); -purchaseShipmentStatuses = delegator.findByAnd("StatusItem", UtilMisc.toMap("statusTypeId", "PURCH_SHIP_STATUS"), UtilMisc.toList("sequenceId")); -context.put("purchaseShipmentStatuses", purchaseShipmentStatuses); +context.shipmentStatuses = delegator.findList("StatusItem", EntityCondition.makeCondition([statusTypeId : 'SHIPMENT_STATUS']), null, ['sequenceId'], null, false); +context.purchaseShipmentStatuses = delegator.findList("StatusItem", EntityCondition.makeCondition([statusTypeId : 'PURCH_SHIP_STATUS']), null, ['sequenceId'], null, false); // create the fromDate for calendar fromCal = Calendar.getInstance(); @@ -190,7 +185,7 @@ fromTs = new Timestamp(fromCal.getTimeInMillis()); fromStr = fromTs.toString(); fromStr = fromStr.substring(0, fromStr.indexOf('.')); -context.put("fromDateStr", fromStr); +context.fromDateStr = fromStr; // create the thruDate for calendar toCal = Calendar.getInstance(); @@ -202,5 +197,4 @@ toCal.set(Calendar.MILLISECOND, toCal.getActualMaximum(Calendar.MILLISECOND)); toTs = new Timestamp(toCal.getTimeInMillis()); toStr = toTs.toString(); -context.put("thruDateStr", toStr); - +context.thruDateStr = toStr; \ No newline at end of file |
Free forum by Nabble | Edit this page |