Author: mrisaliti
Date: Thu Jun 12 13:55:47 2008 New Revision: 667226 URL: http://svn.apache.org/viewvc?rev=667226&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/facility/CountFacilityInventoryByProduct.groovy - copied, changed from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/countFacilityInventoryByProduct.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.groovy - copied, changed from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.groovy - copied, changed from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.groovy - copied, changed from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.groovy - copied, changed from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.groovy - copied, changed from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindInventoryItemsByLabels.groovy - copied, changed from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/findInventoryItemsByLabels.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.groovy - copied, changed from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.groovy - copied, changed from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh Removed: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/countFacilityInventoryByProduct.bsh ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/findInventoryItemsByLabels.bsh Modified: ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/CountFacilityInventoryByProduct.groovy (from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/countFacilityInventoryByProduct.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/CountFacilityInventoryByProduct.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/CountFacilityInventoryByProduct.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/countFacilityInventoryByProduct.bsh&r1=667195&r2=667226&rev=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/countFacilityInventoryByProduct.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/CountFacilityInventoryByProduct.groovy Thu Jun 12 13:55:47 2008 @@ -27,50 +27,42 @@ // However, since the quantities are not computed using the inventory // services (getInventoryAvailableByFacility and getMktgPackagesAvailable) // there are some limitations: the virtual inventory of marketing packages -// is not computed; you can use the ViewFacilityInventoryByProduct.bsh if you +// is not computed; you can use the ViewFacilityInventoryByProduct.groovy if you // need it (but it is slower than this one). -import java.util.*; -import org.ofbiz.base.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.condition.*; -import org.ofbiz.entity.transaction.*; -import org.ofbiz.entity.util.EntityListIterator; -import org.ofbiz.entity.model.DynamicViewEntity; -import org.ofbiz.entity.model.ModelKeyMap; -import org.ofbiz.entity.model.ModelViewEntity.ComplexAlias; -import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasField; -import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasMember; -import org.ofbiz.entity.util.EntityFindOptions; -import org.ofbiz.product.inventory.*; - -import javolution.util.FastList; -import javolution.util.FastMap; - -delegator = request.getAttribute("delegator"); -dispatcher = request.getAttribute("dispatcher"); +import org.ofbiz.entity.* +import org.ofbiz.entity.condition.* +import org.ofbiz.entity.transaction.* +import org.ofbiz.entity.util.EntityListIterator +import org.ofbiz.entity.model.DynamicViewEntity +import org.ofbiz.entity.model.ModelKeyMap +import org.ofbiz.entity.model.ModelViewEntity.ComplexAlias +import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasField +import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasMember +import org.ofbiz.entity.util.EntityFindOptions +import org.ofbiz.product.inventory.* action = request.getParameter("action"); -String searchParameterString = ""; +searchParameterString = ""; searchParameterString = "action=Y&facilityId=" + facilityId; offsetQOH = -1; offsetATP = -1; -boolean hasOffsetQOH = false; -boolean hasOffsetATP = false; +hasOffsetQOH = false; +hasOffsetATP = false; EntityListIterator prodsEli = null; -List rows = new ArrayList(); +rows = [] as ArrayList; -if (action != null) { +if (action) { // ------------------------------ - DynamicViewEntity prodView = new DynamicViewEntity(); - ComplexAlias atpDiffComplexAlias = new ComplexAlias("-"); + prodView = new DynamicViewEntity(); + atpDiffComplexAlias = new ComplexAlias("-"); - Map conditionMap = UtilMisc.toMap("facilityId", facilityId); + conditionMap = [facilityId : facilityId]; - if (offsetQOHQty != null && offsetQOHQty.length() > 0) { + if (offsetQOHQty) { try { offsetQOH = Integer.parseInt(offsetQOHQty); hasOffsetQOH = true; @@ -78,7 +70,7 @@ } catch(NumberFormatException nfe) { } } - if (offsetATPQty != null && offsetATPQty.length() > 0) { + if (offsetATPQty) { try { offsetATP = Integer.parseInt(offsetATPQty); hasOffsetATP = true; @@ -99,9 +91,9 @@ prodView.addAlias("PROD", "internalName", null, null, null, Boolean.TRUE, null); prodView.addAlias("PROD", "isVirtual", null, null, null, Boolean.TRUE, null); prodView.addAlias("PROD", "salesDiscontinuationDate", null, null, null, Boolean.TRUE, null); - if (productTypeId != null && productTypeId.length() > 0) { + if (productTypeId) { prodView.addAlias("PROD", "productTypeId", null, null, null, Boolean.TRUE, null); - conditionMap.put("productTypeId", productTypeId); + conditionMap.productTypeId = productTypeId; searchParameterString = searchParameterString + "&productTypeId=" + productTypeId; } @@ -109,62 +101,64 @@ prodView.addViewLink("PRFA", "IITE", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId", "productId", "facilityId", "facilityId")); prodView.addAlias("IITE", "totalQuantityOnHandTotal", "quantityOnHandTotal", null, null, null, "sum"); prodView.addAlias("IITE", "totalAvailableToPromiseTotal", "availableToPromiseTotal", null, null, null, "sum"); - ComplexAlias qohDiffComplexAlias = new ComplexAlias("-"); + qohDiffComplexAlias = new ComplexAlias("-"); qohDiffComplexAlias.addComplexAliasMember(new ComplexAliasField("IITE", "quantityOnHandTotal", null, "sum")); qohDiffComplexAlias.addComplexAliasMember(new ComplexAliasField("PRFA", "minimumStock", null, null)); prodView.addAlias(null, "offsetQOHQtyAvailable", null, null, null, null, null, qohDiffComplexAlias); - ComplexAlias atpDiffComplexAlias = new ComplexAlias("-"); + atpDiffComplexAlias = new ComplexAlias("-"); atpDiffComplexAlias.addComplexAliasMember(new ComplexAliasField("IITE", "availableToPromiseTotal", null, "sum")); atpDiffComplexAlias.addComplexAliasMember(new ComplexAliasField("PRFA", "minimumStock", null, null)); prodView.addAlias(null, "offsetATPQtyAvailable", null, null, null, null, null, atpDiffComplexAlias); - if (searchInProductCategoryId != null && searchInProductCategoryId.length() > 0) { + if (searchInProductCategoryId) { prodView.addMemberEntity("PRCA", "ProductCategoryMember"); prodView.addViewLink("PRFA", "PRCA", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId")); prodView.addAlias("PRCA", "productCategoryId", null, null, null, Boolean.TRUE, null); - conditionMap.put("productCategoryId", searchInProductCategoryId); + conditionMap.productCategoryId = searchInProductCategoryId; searchParameterString = searchParameterString + "&searchInProductCategoryId=" + searchInProductCategoryId; } - if (productSupplierId != null && productSupplierId.length() > 0) { + if (productSupplierId) { prodView.addMemberEntity("SPPR", "SupplierProduct"); prodView.addViewLink("PRFA", "SPPR", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId")); prodView.addAlias("SPPR", "partyId", null, null, null, Boolean.TRUE, null); - conditionMap.put("partyId", productSupplierId); + conditionMap.partyId = productSupplierId; searchParameterString = searchParameterString + "&productSupplierId=" + productSupplierId; } // set distinct on so we only get one row per product - EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); - EntityCondition searchCondition = EntityCondition.makeCondition(conditionMap, EntityOperator.AND); - EntityCondition notVirtualCondition = EntityCondition.makeCondition(EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, null), - EntityOperator.OR, - EntityCondition.makeCondition("isVirtual", EntityOperator.NOT_EQUAL, "Y")); + findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); + searchCondition = EntityCondition.makeCondition(conditionMap, EntityOperator.AND); + notVirtualCondition = EntityCondition.makeCondition(EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, null), + EntityOperator.OR, + EntityCondition.makeCondition("isVirtual", EntityOperator.NOT_EQUAL, "Y")); - whereConditionsList = UtilMisc.toList(searchCondition, notVirtualCondition); + whereConditionsList = [searchCondition, notVirtualCondition]; // add the discontinuation date condition - if (UtilValidate.isNotEmpty(productsSoldThruTimestamp)) { - EntityCondition discontinuationDateCondition = EntityCondition.makeCondition(UtilMisc.toList( + if (productsSoldThruTimestamp) { + discontinuationDateCondition = EntityCondition.makeCondition( + [ EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.EQUALS, null), - EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.GREATER_THAN, productsSoldThruTimestamp)), - EntityOperator.OR); + EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.GREATER_THAN, productsSoldThruTimestamp) + ], + EntityOperator.OR); whereConditionsList.add(discontinuationDateCondition); searchParameterString = searchParameterString + "&productsSoldThruTimestamp=" + productsSoldThruTimestamp; } // add search on internal name - if (UtilValidate.isNotEmpty(internalName)) { + if (internalName) { whereConditionsList.add(EntityCondition.makeCondition("internalName", true, EntityOperator.LIKE, "%" + internalName + "%", true)); searchParameterString = searchParameterString + "&internalName=" + internalName; } // add search on productId - if (UtilValidate.isNotEmpty(productId)) { + if (productId) { whereConditionsList.add(EntityCondition.makeCondition("productId", true, EntityOperator.LIKE, productId + "%", true)); searchParameterString = searchParameterString + "&productId=" + productId; } - List orderBy = FastList.newInstance(); + orderBy = []; if (hasOffsetATP) { orderBy.add("offsetATPQtyAvailable"); } @@ -176,7 +170,7 @@ // If the user has specified a number of months over which to sum usage quantities, define the correct timestamp checkTime = null; monthsInPastLimitStr = request.getParameter("monthsInPastLimit"); - if (UtilValidate.isNotEmpty(monthsInPastLimitStr)) { + if (monthsInPastLimitStr) { try { monthsInPastLimit = Integer.parseInt(monthsInPastLimitStr); cal = UtilDateTime.toCalendar(null); @@ -188,7 +182,7 @@ } } - if (! UtilValidate.isEmpty(checkTime)) { + if (checkTime) { // Construct a dynamic view entity to search against for sales usage quantities salesUsageViewEntity = new DynamicViewEntity(); @@ -219,12 +213,11 @@ productionUsageViewEntity.addAlias("WE", "workEffortTypeId"); productionUsageViewEntity.addAlias("II", "facilityId"); productionUsageViewEntity.addAlias("II", "productId"); - } - EntityCondition whereCondition = EntityCondition.makeCondition(whereConditionsList, EntityOperator.AND); + whereCondition = EntityCondition.makeCondition(whereConditionsList, EntityOperator.AND); - boolean beganTransaction = false; + beganTransaction = false; List prods = null; try { beganTransaction = TransactionUtil.begin(); @@ -236,54 +229,50 @@ // get the partial list for this page prods = prodsEli.getPartialList(lowIndex, highIndex); - Iterator prodsIt = prods.iterator(); - - while (prodsIt.hasNext()) { - GenericValue oneProd = prodsIt.next(); - - Double offsetQOHQtyAvailable = oneProd.getDouble("offsetQOHQtyAvailable"); - Double offsetATPQtyAvailable = oneProd.getDouble("offsetATPQtyAvailable"); + prodsIt = prods.iterator(); + while (prodsIt) { + oneProd = prodsIt.next(); + offsetQOHQtyAvailable = oneProd.getDouble("offsetQOHQtyAvailable"); + offsetATPQtyAvailable = oneProd.getDouble("offsetATPQtyAvailable"); if (hasOffsetATP) { - if (offsetATPQtyAvailable != null && offsetATPQtyAvailable.doubleValue() > offsetATP) { + if (offsetATPQtyAvailable && offsetATPQtyAvailable.doubleValue() > offsetATP) { break; } } if (hasOffsetQOH) { - if (offsetQOHQtyAvailable != null && offsetQOHQtyAvailable.doubleValue() > offsetQOH) { + if (offsetQOHQtyAvailable && offsetQOHQtyAvailable.doubleValue() > offsetQOH) { break; } } - Map oneInventory = FastMap.newInstance(); - oneInventory.put("productId", oneProd.getString("productId")); - oneInventory.put("minimumStock", oneProd.getString("minimumStock")); - oneInventory.put("reorderQuantity", oneProd.getString("reorderQuantity")); - oneInventory.put("daysToShip", oneProd.getString("daysToShip")); - oneInventory.put("totalQuantityOnHand", oneProd.get("totalQuantityOnHandTotal")); - oneInventory.put("totalAvailableToPromise", oneProd.get("totalAvailableToPromiseTotal")); - oneInventory.put("offsetQOHQtyAvailable", offsetQOHQtyAvailable); - oneInventory.put("offsetATPQtyAvailable", offsetATPQtyAvailable); - oneInventory.put("quantityOnOrder", InventoryWorker.getOutstandingPurchasedQuantity(oneProd.getString("productId"), delegator)); + oneInventory = [:]; + oneInventory.productId = oneProd.productId; + oneInventory.minimumStock = oneProd.minimumStock; + oneInventory.reorderQuantity = oneProd.reorderQuantity; + oneInventory.daysToShip = oneProd.daysToShip; + oneInventory.totalQuantityOnHand = oneProd.totalQuantityOnHandTotal; + oneInventory.totalAvailableToPromise = oneProd.totalAvailableToPromiseTotal; + oneInventory.offsetQOHQtyAvailable = offsetQOHQtyAvailable; + oneInventory.offsetATPQtyAvailable = offsetATPQtyAvailable; + oneInventory.quantityOnOrder = InventoryWorker.getOutstandingPurchasedQuantity(oneProd.productId, delegator); - if (! UtilValidate.isEmpty(checkTime)) { + if (checkTime) { // Make a query against the sales usage view entity salesUsageIt = delegator.findListIteratorByCondition(salesUsageViewEntity, EntityCondition.makeCondition( - UtilMisc.toList( - EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), - EntityCondition.makeCondition("productId", EntityOperator.EQUALS, oneProd.getString("productId")), - EntityCondition.makeCondition("statusId", EntityOperator.IN, UtilMisc.toList("ORDER_COMPLETED", "ORDER_APPROVED", "ORDER_HELD")), - EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER"), - EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, checkTime) - ), - EntityOperator.AND), - null, null, null, null); + [EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), + EntityCondition.makeCondition("productId", EntityOperator.EQUALS, oneProd.productId), + EntityCondition.makeCondition("statusId", EntityOperator.IN, ['ORDER_COMPLETED', 'ORDER_APPROVED', 'ORDER_HELD']), + EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER"), + EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, checkTime) + ], + EntityOperator.AND), null, null, null, null); // Sum the sales usage quantities found salesUsageQuantity = 0; - while((salesUsageItem = salesUsageIt.next()) != null) { - if (salesUsageItem.get("quantity") != null) { + salesUsageIt.each { salesUsageItem -> + if (salesUsageItem.quantity) { try { salesUsageQuantity += salesUsageItem.getDouble("quantity").doubleValue(); } catch (Exception e) { @@ -296,19 +285,17 @@ // Make a query against the production usage view entity productionUsageIt = delegator.findListIteratorByCondition(productionUsageViewEntity, EntityCondition.makeCondition( - UtilMisc.toList( - EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), - EntityCondition.makeCondition("productId", EntityOperator.EQUALS, oneProd.getString("productId")), - EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_TASK"), - EntityCondition.makeCondition("actualCompletionDate", EntityOperator.GREATER_THAN_EQUAL_TO, checkTime) - ), - EntityOperator.AND), - null, null, null, null); + [EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), + EntityCondition.makeCondition("productId", EntityOperator.EQUALS, oneProd.productId), + EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_TASK"), + EntityCondition.makeCondition("actualCompletionDate", EntityOperator.GREATER_THAN_EQUAL_TO, checkTime) + ], + EntityOperator.AND), null, null, null, null); // Sum the production usage quantities found productionUsageQuantity = 0; - while((productionUsageItem = productionUsageIt.next()) != null) { - if (productionUsageItem.get("quantity") != null) { + productionUsageIt.each { productionUsageItem -> + if (productionUsageItem.quantity) { try { productionUsageQuantity += productionUsageItem.getDouble("quantity").doubleValue(); } catch (Exception e) { @@ -316,12 +303,9 @@ } } } - productionUsageIt.close(); - - oneInventory.put("usageQuantity", salesUsageQuantity + productionUsageQuantity); - - } - + productionUsageIt.close(); + oneInventory.usageQuantity = salesUsageQuantity + productionUsageQuantity; + } rows.add(oneInventory); } if (rows.size() < viewSize.intValue()) { @@ -329,18 +313,17 @@ } else { // attempt to get the full size if (hasOffsetQOH || hasOffsetATP) { - GenericValue nextValue = null; - int rowProcessed = 0; - while ((nextValue = prodsEli.next()) != null) { - Double offsetQOHQtyAvailable = nextValue.getDouble("offsetQOHQtyAvailable"); - Double offsetATPQtyAvailable = nextValue.getDouble("offsetATPQtyAvailable"); + rowProcessed = 0; + while (nextValue = prodsEli.next()) { + offsetQOHQtyAvailable = nextValue.getDouble("offsetQOHQtyAvailable"); + offsetATPQtyAvailable = nextValue.getDouble("offsetATPQtyAvailable"); if (hasOffsetATP) { - if (offsetATPQtyAvailable != null && offsetATPQtyAvailable.doubleValue() > offsetATP) { + if (offsetATPQtyAvailable && offsetATPQtyAvailable.doubleValue() > offsetATP) { break; } } if (hasOffsetQOH) { - if (offsetQOHQtyAvailable != null && offsetQOHQtyAvailable.doubleValue() > offsetQOH) { + if (offsetQOHQtyAvailable && offsetQOHQtyAvailable.doubleValue() > offsetQOH) { break; } } @@ -356,12 +339,12 @@ if (highIndex > productListSize) { highIndex = productListSize; } - context.put("overrideListSize", productListSize); - context.put("highIndex", highIndex); - context.put("lowIndex", lowIndex); + context.overrideListSize = productListSize; + context.highIndex = highIndex; + context.lowIndex = lowIndex; } catch (GenericEntityException e) { - String errMsg = "Failure in operation, rolling back transaction"; + errMsg = "Failure in operation, rolling back transaction"; Debug.logError(e, errMsg, "ViewFacilityInventoryByProduct"); try { // only rollback the transaction if we started one... @@ -372,7 +355,7 @@ // after rolling back, rethrow the exception throw e; } finally { - if (prodsEli != null) { + if (prodsEli) { try { prodsEli.close(); } catch (Exception exc) {} @@ -381,5 +364,5 @@ TransactionUtil.commit(beganTransaction); } } -context.put("inventoryByProduct", rows); -context.put("searchParameterString", searchParameterString); +context.inventoryByProduct = rows; +context.searchParameterString = searchParameterString; \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.groovy (from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.bsh&r1=667195&r2=667226&rev=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditContactMech.groovy Thu Jun 12 13:55:47 2008 @@ -17,43 +17,53 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; -import org.ofbiz.securityext.login.*; -import org.ofbiz.common.*; import org.ofbiz.party.contact.*; -import org.ofbiz.webapp.control.*; -String facilityId = parameters.get("facilityId"); -context.put("facilityId", facilityId); -GenericValue facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId)); -context.put("facility", facility); +facilityId = parameters.facilityId; +context.facilityId = facilityId; -Map mechMap = new HashMap(); +facility = delegator.findOne("Facility", [facilityId : facilityId], false); +context.facility = facility; + +mechMap = [:]; ContactMechWorker.getFacilityContactMechAndRelated(request, facilityId, mechMap); +context.mechMap = mechMap; + +contactMechId = mechMap.contactMechId; +if (contactMechId) { + context.contactMechId = contactMechId; +} -context.put("mechMap", mechMap); +preContactMechTypeId = request.getParameter("preContactMechTypeId"); +if (preContactMechTypeId) { + context.preContactMechTypeId = preContactMechTypeId; +} -String contactMechId = (String) mechMap.get("contactMechId"); -if(contactMechId != null) context.put("contactMechId", contactMechId); +paymentMethodId = request.getParameter("paymentMethodId"); +if (!paymentMethodId) { + paymentMethodId = request.getAttribute("paymentMethodId"); +} +if (paymentMethodId) { + context.paymentMethodId = paymentMethodId; +} -String preContactMechTypeId = request.getParameter("preContactMechTypeId"); -if(preContactMechTypeId != null) context.put("preContactMechTypeId", preContactMechTypeId); +donePage = request.getParameter("DONE_PAGE"); +if (!donePage) { + donePage = request.getAttribute("DONE_PAGE"); +} +if (!donePage || donePage.length() <= 0) { + donePage = "ViewContactMechs"; +} +context.donePage = donePage; -String paymentMethodId = request.getParameter("paymentMethodId"); -if(paymentMethodId == null) paymentMethodId = (String) request.getAttribute("paymentMethodId"); -if(paymentMethodId != null) context.put("paymentMethodId", paymentMethodId); - -String donePage = request.getParameter("DONE_PAGE"); -if (donePage == null) donePage = (String) request.getAttribute("DONE_PAGE"); -if (donePage == null || donePage.length() <= 0) donePage = "ViewContactMechs"; -context.put("donePage", donePage); - -String cmNewPurposeTypeId = request.getParameter("contactMechPurposeTypeId"); -if (cmNewPurposeTypeId == null) cmNewPurposeTypeId = (String) mechMap.get("contactMechPurposeTypeId"); -if (cmNewPurposeTypeId != null) { - context.put("contactMechPurposeTypeId", cmNewPurposeTypeId); - GenericValue contactMechPurposeType = delegator.findByPrimaryKey("ContactMechPurposeType", UtilMisc.toMap("contactMechPurposeTypeId", cmNewPurposeTypeId)); - if(contactMechPurposeType != null) context.put("contactMechPurposeType", contactMechPurposeType); +cmNewPurposeTypeId = request.getParameter("contactMechPurposeTypeId"); +if (!cmNewPurposeTypeId) { + cmNewPurposeTypeId = mechMap.contactMechPurposeTypeId; } +if (cmNewPurposeTypeId) { + context.contactMechPurposeTypeId = cmNewPurposeTypeId; + contactMechPurposeType = delegator.findOne("ContactMechPurposeType", [contactMechPurposeTypeId : cmNewPurposeTypeId], false); + if (contactMechPurposeType) { + context.contactMechPurposeType = contactMechPurposeType; + } +} \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.groovy (from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.bsh&r1=667195&r2=667226&rev=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacility.groovy Thu Jun 12 13:55:47 2008 @@ -17,37 +17,31 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; +import org.ofbiz.entity.condition.*; -delegator = request.getAttribute("delegator"); - -String facilityId = request.getParameter("facilityId"); -if (UtilValidate.isEmpty(facilityId) && UtilValidate.isNotEmpty((String) request.getAttribute("facilityId"))) { - facilityId = (String) request.getAttribute("facilityId"); +facilityId = request.getParameter("facilityId"); +if (!facilityId && request.getAttribute("facilityId")) { + facilityId = request.getAttribute("facilityId"); } -GenericValue facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId)); -GenericValue facilityType = null; -if(facility == null) { +facility = delegator.findOne("Facility", [facilityId : facilityId], false); +if (!facility) { facility = delegator.makeValue("Facility"); facilityType = delegator.makeValue("FacilityType"); } else { facilityType = facility.getRelatedOne("FacilityType"); } -context.put("facility", facility); -context.put("facilityType", facilityType); -context.put("facilityId", facilityId); +context.facility = facility; +context.facilityType = facilityType; +context.facilityId = facilityId; //Facility types -Collection facilityTypes = delegator.findList("FacilityType", null, null, null, null, false); -if (facilityTypes != null) - context.put("facilityTypes", facilityTypes); +facilityTypes = delegator.findList("FacilityType", null, null, null, null, false); +if (facilityTypes) { + context.facilityTypes = facilityTypes; +} // all possible inventory item types -inventoryItemTypes = delegator.findList("InventoryItemType", null, null, UtilMisc.toList("description"), null, true); -context.put("inventoryItemTypes", inventoryItemTypes); +context.inventoryItemTypes = delegator.findList("InventoryItemType", null, null, ['description'], null, true); // unit of measures -weightUomList = delegator.findByAndCache("Uom", UtilMisc.toMap("uomTypeId", "WEIGHT_MEASURE")); -context.put("weightUomList", weightUomList); +context.weightUomList = delegator.findList("Uom", EntityCondition.makeCondition([uomTypeId : 'WEIGHT_MEASURE']), null, null, null, true); \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.groovy (from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.bsh&r1=667195&r2=667226&rev=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.groovy Thu Jun 12 13:55:47 2008 @@ -17,45 +17,39 @@ * under the License. */ -import java.util.*; -import java.io.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; -import org.ofbiz.widget.html.*; - -delegator = request.getAttribute("delegator"); +import org.ofbiz.entity.condition.*; facilityId = request.getParameter("facilityId"); locationSeqId = request.getParameter("locationSeqId"); facility = null; facilityLocation = null; -if (UtilValidate.isEmpty(facilityId) && UtilValidate.isNotEmpty((String) request.getAttribute("facilityId"))) { - facilityId = (String) request.getAttribute("facilityId"); +if (!facilityId && request.getAttribute("facilityId")) { + facilityId = request.getAttribute("facilityId"); } -if (UtilValidate.isEmpty(locationSeqId) && UtilValidate.isNotEmpty((String) request.getAttribute("locationSeqId"))) { - locationSeqId = (String) request.getAttribute("locationSeqId"); +if (!locationSeqId && request.getAttribute("locationSeqId")) { + locationSeqId = request.getAttribute("locationSeqId"); } -if (facilityId != null && locationSeqId != null) { - facilityLocation = delegator.findByPrimaryKey("FacilityLocation", UtilMisc.toMap("facilityId", facilityId, "locationSeqId", locationSeqId)); +if (facilityId && locationSeqId) { + facilityLocation = delegator.findOne("FacilityLocation", [facilityId : facilityId, locationSeqId : locationSeqId], false); } -if (facilityId != null) { - facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId)); +if (facilityId) { + facility = delegator.findOne("Facility", [facilityId : facilityId], false); } -locationTypeEnums = delegator.findByAnd("Enumeration", UtilMisc.toMap("enumTypeId", "FACLOC_TYPE")); +locationTypeEnums = delegator.findList("Enumeration", EntityCondition.makeCondition([enumTypeId : 'FACLOC_TYPE']), null, null, null, false); // ProductFacilityLocation stuff productFacilityLocations = null; -if (facilityLocation != null) { - productFacilityLocations = facilityLocation.getRelated("ProductFacilityLocation", null, UtilMisc.toList("productId")); +if (facilityLocation) { + productFacilityLocations = facilityLocation.getRelated("ProductFacilityLocation", null, ['productId']); } -context.put("facilityId", facilityId); -context.put("locationSeqId", locationSeqId); -context.put("facility", facility); -context.put("facilityLocation", facilityLocation); -context.put("locationTypeEnums", locationTypeEnums); -context.put("productFacilityLocations", productFacilityLocations); +context.facilityId = facilityId; +context.locationSeqId = locationSeqId; +context.facility = facility; +context.facilityLocation = facilityLocation; +context.locationTypeEnums = locationTypeEnums; +context.productFacilityLocations = productFacilityLocations; \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.groovy (from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.bsh&r1=667195&r2=667226&rev=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.groovy Thu Jun 12 13:55:47 2008 @@ -17,45 +17,37 @@ * under the License. */ -import java.util.*; -import java.io.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; -import org.ofbiz.widget.html.*; +import org.ofbiz.entity.condition.* +import org.ofbiz.base.util.* -delegator = request.getAttribute("delegator"); - -facilityId = parameters.get("facilityId"); -context.put("facilityId", facilityId); +facilityId = parameters.facilityId; +context.facilityId = facilityId; lookup = request.getParameter("look_up"); itemId = request.getParameter("inventoryItemId"); -if (itemId != null) { +if (itemId) { session.setAttribute("inventoryItemId", itemId); } itemId = session.getAttribute("inventoryItemId"); -context.put("itemId", itemId); +context.itemId = itemId; -facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId)); -context.put("facility", facility); +facility = delegator.findOne("Facility", [facilityId : facilityId], false); +context.facility = facility; UtilHttp.parametersToAttributes(request); -List foundLocations = null; -if (lookup != null) { - Map reqParamMap = UtilHttp.getParameterMap(request); - Map paramMap = new HashMap(reqParamMap); +if (lookup) { + reqParamMap = UtilHttp.getParameterMap(request); + paramMap = new HashMap(reqParamMap); paramMap.remove("look_up"); - Iterator i = reqParamMap.keySet().iterator(); - while (i.hasNext()) { - Object key = i.next(); - String value = (String) paramMap.get(key); - if (value == null || value.length() == 0) { + reqParamMap.keySet().each { key -> + value = paramMap.get(key); + if (!value || value.length() == 0) { paramMap.remove(key); } } - foundLocations = delegator.findByAnd("FacilityLocation", paramMap); - if (foundLocations != null && foundLocations.size() > 0) { - context.put("foundLocations", foundLocations); + foundLocations = delegator.findList("FacilityLocation", EntityCondition.makeCondition(paramMap), null, null, null, false); + if (foundLocations) { + context.foundLocations = foundLocations; } -} +} \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.groovy (from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.bsh&r1=667195&r2=667226&rev=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.groovy Thu Jun 12 13:55:47 2008 @@ -17,43 +17,48 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; import org.ofbiz.entity.condition.*; -import org.ofbiz.base.util.*; //default this to true, ie only show active -boolean activeOnly = !"false".equals(request.getParameter("activeOnly")); -context.put("activeOnly", activeOnly); +activeOnly = !"false".equals(request.getParameter("activeOnly")); +context.activeOnly = activeOnly; // if the completeRequested was set, then we'll lookup only requested status -boolean completeRequested = "true".equals(request.getParameter("completeRequested")); -context.put("completeRequested", completeRequested); +completeRequested = "true".equals(request.getParameter("completeRequested")); +context.completeRequested = completeRequested; // get the 'to' this facility transfers -List exprsTo = null; if (activeOnly) { - exprsTo = UtilMisc.toList(EntityCondition.makeCondition("facilityIdTo", EntityOperator.EQUALS, facilityId), EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "IXF_COMPLETE"), EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "IXF_CANCELLED")); + exprsTo = [EntityCondition.makeCondition("facilityIdTo", EntityOperator.EQUALS, facilityId), + EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "IXF_COMPLETE"), + EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "IXF_CANCELLED")]; } else { - exprsTo = UtilMisc.toList(EntityCondition.makeCondition("facilityIdTo", EntityOperator.EQUALS, facilityId)); + exprsTo = [EntityCondition.makeCondition("facilityIdTo", EntityOperator.EQUALS, facilityId)]; } if (completeRequested) { - exprsTo = UtilMisc.toList(EntityCondition.makeCondition("facilityIdTo", EntityOperator.EQUALS, facilityId), EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "IXF_REQUESTED")); + exprsTo = [EntityCondition.makeCondition("facilityIdTo", EntityOperator.EQUALS, facilityId), + EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "IXF_REQUESTED")]; +} +ecl = EntityCondition.makeCondition(exprsTo, EntityOperator.AND); +toTransfers = delegator.findList("InventoryTransfer", ecl, null, ['sendDate'], null, false); +if (toTransfers) { + context.toTransfers = toTransfers; } -EntityConditionList ecl = EntityCondition.makeCondition(exprsTo, EntityOperator.AND); -List toTransfers = delegator.findList("InventoryTransfer", ecl, null, UtilMisc.toList("sendDate"), null, false); -if (toTransfers != null) context.put("toTransfers", toTransfers); // get the 'from' this facility transfers -List exprsFrom = null; if (activeOnly) { - exprsFrom = UtilMisc.toList(EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "IXF_COMPLETE"), EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "IXF_CANCELLED")); + exprsFrom = [EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), + EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "IXF_COMPLETE"), + EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "IXF_CANCELLED")]; } else { - exprsFrom = UtilMisc.toList(EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId)); + exprsFrom = [EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId)]; } if (completeRequested) { - exprsFrom = UtilMisc.toList(EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "IXF_REQUESTED")); + exprsFrom = [EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId), + EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "IXF_REQUESTED")]; } ecl = EntityCondition.makeCondition(exprsFrom, EntityOperator.AND); -List fromTransfers = delegator.findList("InventoryTransfer", ecl, null, UtilMisc.toList("sendDate"), null, false); -if (fromTransfers != null) context.put("fromTransfers", fromTransfers); +fromTransfers = delegator.findList("InventoryTransfer", ecl, null, ['sendDate'], null, false); +if (fromTransfers) { + context.fromTransfers = fromTransfers; +} \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindInventoryItemsByLabels.groovy (from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/findInventoryItemsByLabels.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindInventoryItemsByLabels.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindInventoryItemsByLabels.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/findInventoryItemsByLabels.bsh&r1=667195&r2=667226&rev=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/findInventoryItemsByLabels.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/FindInventoryItemsByLabels.groovy Thu Jun 12 13:55:47 2008 @@ -17,54 +17,50 @@ * under the License. */ -import java.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; -import org.ofbiz.entity.condition.EntityConditionList; -import org.ofbiz.entity.condition.EntityExpr; -import org.ofbiz.entity.condition.EntityOperator; -import org.ofbiz.entity.model.DynamicViewEntity; -import org.ofbiz.entity.model.ModelKeyMap; -import org.ofbiz.entity.transaction.*; -import org.ofbiz.entity.util.EntityFindOptions; -import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.* +import org.ofbiz.entity.condition.* +import org.ofbiz.entity.model.DynamicViewEntity +import org.ofbiz.entity.model.ModelKeyMap +import org.ofbiz.entity.transaction.* +import org.ofbiz.entity.util.EntityFindOptions +import org.ofbiz.entity.util.EntityListIterator -String facilityId = parameters.get("facilityId"); +facilityId = parameters.facilityId; -int numberOfFields = 0; -numberOfFieldsStr = parameters.get("numberOfFields"); +numberOfFields = 0; +numberOfFieldsStr = parameters.numberOfFields; try { numberOfFields = Integer.parseInt(numberOfFieldsStr); } catch(Exception exc) { numberOfFields = 0; } -DynamicViewEntity inventoryItemAndLabelsView = new DynamicViewEntity(); +inventoryItemAndLabelsView = new DynamicViewEntity(); inventoryItemAndLabelsView.addMemberEntity("II", "InventoryItem"); inventoryItemAndLabelsView.addAliasAll("II", null); for (int i = 1; i <= numberOfFields; i++) { - String inventoryItemLabelId = parameters.get("inventoryItemLabelId_" + i); - if (UtilValidate.isNotEmpty(inventoryItemLabelId)) { + inventoryItemLabelId = parameters.get("inventoryItemLabelId_" + i); + if (inventoryItemLabelId) { inventoryItemAndLabelsView.addMemberEntity("IL" + i, "InventoryItemLabelAppl"); inventoryItemAndLabelsView.addViewLink("II", "IL" + i, new Boolean(false), ModelKeyMap.makeKeyMapList("inventoryItemId")); } } -List andCondition = UtilMisc.toList(EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId)); +andCondition = [EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId)]; for (int i = 1; i <= numberOfFields; i++) { - String inventoryItemLabelId = parameters.get("inventoryItemLabelId_" + i); - if (UtilValidate.isNotEmpty(inventoryItemLabelId)) { + inventoryItemLabelId = parameters.get("inventoryItemLabelId_" + i); + if (inventoryItemLabelId) { inventoryItemAndLabelsView.addAlias("IL" + i, "inventoryItemLabelId" + i, "inventoryItemLabelId", null, null, null, null); andCondition.add(EntityCondition.makeCondition("inventoryItemLabelId" + i, EntityOperator.EQUALS, inventoryItemLabelId)); } } EntityListIterator inventoryItemsEli = null; -boolean beganTransaction = false; +beganTransaction = false; List inventoryItems = null; if (andCondition.size() > 1) { try { - 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); beganTransaction = TransactionUtil.begin(); - inventoryItemsEli = delegator.find(inventoryItemAndLabelsView, EntityCondition.makeCondition(andCondition, EntityOperator.AND), null, null, null, findOpts); + inventoryItemsEli = delegator.findListIteratorByCondition(inventoryItemAndLabelsView, EntityCondition.makeCondition(andCondition, EntityOperator.AND), null, null, null, findOpts); // get the indexes for the partial list lowIndex = ((viewIndex * viewSize) + 1); @@ -73,7 +69,7 @@ // attempt to get the full size inventoryItemsEli.last(); inventoryItemsSize = inventoryItemsEli.currentIndex(); - context.put("inventoryItemsSize", inventoryItemsSize); + context.inventoryItemsSize = inventoryItemsSize; if (highIndex > inventoryItemsSize) { highIndex = inventoryItemsSize; } @@ -83,13 +79,13 @@ if (inventoryItemsSize > 0) { inventoryItems = inventoryItemsEli.getPartialList(lowIndex, viewSize); } else { - inventoryItems = new ArrayList(); + inventoryItems = [] as ArrayList; } // close the list iterator inventoryItemsEli.close(); } catch (GenericEntityException e) { - String errMsg = "Failure in operation, rolling back transaction"; + errMsg = "Failure in operation, rolling back transaction"; Debug.logError(e, errMsg, "findInventoryItemsByLabels"); try { // only rollback the transaction if we started one... @@ -104,4 +100,4 @@ TransactionUtil.commit(beganTransaction); } } -context.put("inventoryItems", inventoryItems); +context.inventoryItems = inventoryItems; \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.groovy (from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.bsh&r1=667195&r2=667226&rev=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.groovy Thu Jun 12 13:55:47 2008 @@ -17,27 +17,25 @@ * under the License. */ -import org.ofbiz.base.util.*; -import org.ofbiz.party.contact.*; +import org.ofbiz.base.util.* +import org.ofbiz.party.contact.* -context.put("nowStr", UtilDateTime.nowTimestamp()); +context.nowStr = UtilDateTime.nowTimestamp(); -facilityId = parameters.get("facilityId"); -facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId)); +facilityId = parameters.facilityId; +facility = delegator.findOne("Facility", [facilityId : facilityId], false); facilityType = null; -if (facility == null) { - context.put("facility", delegator.makeValue( "Facility", null ) ); - context.put("facilityType", delegator.makeValue( "FacilityType", null ) ); +if (!facility) { + context.facility = delegator.makeValue("Facility", null); + context.facilityType = delegator.makeValue("FacilityType", null); } else { facilityType = facility.getRelatedOne("FacilityType"); } -context.put("facility", facility); -context.put("facilityType", facilityType); -context.put("facilityId", facilityId); +context.facility = facility; +context.facilityType = facilityType; +context.facilityId = facilityId; -boolean showOld = "true".equals(request.getParameter("SHOW_OLD")); -context.put("showOld", new Boolean(showOld)); - -List facilityContactMechValueMaps = ContactMechWorker.getFacilityContactMechValueMaps(delegator, facilityId, showOld, null); -context.put("contactMeches", facilityContactMechValueMaps); +showOld = "true".equals(request.getParameter("SHOW_OLD")); +context.showOld = new Boolean(showOld); +context.contactMeches = ContactMechWorker.getFacilityContactMechValueMaps(delegator, facilityId, showOld, null); \ No newline at end of file Copied: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.groovy (from r667195, ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.groovy?p2=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.groovy&p1=ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh&r1=667195&r2=667226&rev=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh (original) +++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.groovy Thu Jun 12 13:55:47 2008 @@ -17,41 +17,35 @@ * under the License. */ - -import java.util.*; -import org.ofbiz.base.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.condition.*; -import org.ofbiz.entity.transaction.*; -import org.ofbiz.entity.model.DynamicViewEntity; -import org.ofbiz.entity.model.ModelKeyMap; -import org.ofbiz.entity.util.EntityFindOptions; -import org.ofbiz.product.inventory.*; - -import org.ofbiz.widget.html.*; -import java.sql.Timestamp; - -delegator = request.getAttribute("delegator"); -dispatcher = request.getAttribute("dispatcher"); +import java.util.* +import java.sql.Timestamp +import org.ofbiz.base.util.* +import org.ofbiz.entity.* +import org.ofbiz.entity.condition.* +import org.ofbiz.entity.transaction.* +import org.ofbiz.entity.model.DynamicViewEntity +import org.ofbiz.entity.model.ModelKeyMap +import org.ofbiz.entity.util.EntityFindOptions +import org.ofbiz.product.inventory.* action = request.getParameter("action"); -String searchParameterString = ""; +searchParameterString = ""; searchParameterString = "action=Y&facilityId=" + facilityId; offsetQOH = -1; offsetATP = -1; -boolean hasOffsetQOH = false; -boolean hasOffsetATP = false; +hasOffsetQOH = false; +hasOffsetATP = false; -List rows = new ArrayList(); +rows = [] as ArrayList; -if (action != null) { +if (action) { // ------------------------------ - DynamicViewEntity prodView = new DynamicViewEntity(); - Map conditionMap = UtilMisc.toMap("facilityId", facilityId); + prodView = new DynamicViewEntity(); + conditionMap = [facilityId : facilityId]; - if (offsetQOHQty != null && offsetQOHQty.length() > 0) { + if (offsetQOHQty) { try { offsetQOH = Integer.parseInt(offsetQOHQty); hasOffsetQOH = true; @@ -59,7 +53,7 @@ } catch(NumberFormatException nfe) { } } - if (offsetATPQty != null && offsetATPQty.length() > 0) { + if (offsetATPQty) { try { offsetATP = Integer.parseInt(offsetATPQty); hasOffsetATP = true; @@ -76,67 +70,69 @@ prodView.addAlias("PROD", "internalName"); prodView.addAlias("PROD", "isVirtual"); prodView.addAlias("PROD", "salesDiscontinuationDate"); - if (productTypeId != null && productTypeId.length() > 0) { + if (productTypeId) { prodView.addAlias("PROD", "productTypeId"); - conditionMap.put("productTypeId", productTypeId); + conditionMap.productTypeId = productTypeId; searchParameterString = searchParameterString + "&productTypeId=" + productTypeId; } - if (searchInProductCategoryId != null && searchInProductCategoryId.length() > 0) { + if (searchInProductCategoryId) { prodView.addMemberEntity("PRCA", "ProductCategoryMember"); prodView.addViewLink("PRFA", "PRCA", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId")); prodView.addAlias("PRCA", "productCategoryId"); - conditionMap.put("productCategoryId", searchInProductCategoryId); + conditionMap.productCategoryId = searchInProductCategoryId; searchParameterString = searchParameterString + "&searchInProductCategoryId=" + searchInProductCategoryId; } - if (productSupplierId != null && productSupplierId.length() > 0) { + if (productSupplierId) { prodView.addMemberEntity("SPPR", "SupplierProduct"); prodView.addViewLink("PRFA", "SPPR", Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId")); prodView.addAlias("SPPR", "partyId"); - conditionMap.put("partyId", productSupplierId); + conditionMap.partyId = productSupplierId; searchParameterString = searchParameterString + "&productSupplierId=" + productSupplierId; } // set distinct on so we only get one row per product - EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); - EntityCondition searchCondition = EntityCondition.makeCondition(conditionMap, EntityOperator.AND); - EntityCondition notVirtualCondition = EntityCondition.makeCondition(EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, null), + findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); + searchCondition = EntityCondition.makeCondition(conditionMap, EntityOperator.AND); + notVirtualCondition = EntityCondition.makeCondition(EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("isVirtual", EntityOperator.NOT_EQUAL, "Y")); - whereConditionsList = UtilMisc.toList(searchCondition, notVirtualCondition); + whereConditionsList = [searchCondition, notVirtualCondition]; // add the discontinuation date condition - if (UtilValidate.isNotEmpty(productsSoldThruTimestamp)) { - EntityCondition discontinuationDateCondition = EntityCondition.makeCondition(UtilMisc.toList( + if (productsSoldThruTimestamp) { + discontinuationDateCondition = EntityCondition.makeCondition( + [ EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.EQUALS, null), - EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.GREATER_THAN, productsSoldThruTimestamp)), - EntityOperator.OR); + EntityCondition.makeCondition("salesDiscontinuationDate", EntityOperator.GREATER_THAN, productsSoldThruTimestamp) + ], + EntityOperator.OR); whereConditionsList.add(discontinuationDateCondition); searchParameterString = searchParameterString + "&productsSoldThruTimestamp=" + productsSoldThruTimestamp; } // add search on internal name - if (UtilValidate.isNotEmpty(internalName)) { + if (internalName) { whereConditionsList.add(EntityCondition.makeCondition("internalName", true, EntityOperator.LIKE, "%" + internalName + "%", true)); searchParameterString = searchParameterString + "&internalName=" + internalName; } // add search on productId - if (UtilValidate.isNotEmpty(productId)) { + if (productId) { whereConditionsList.add(EntityCondition.makeCondition("productId", true, EntityOperator.LIKE, productId + "%", true)); searchParameterString = searchParameterString + "&productId=" + productId; } - EntityCondition whereCondition = EntityCondition.makeCondition(whereConditionsList, EntityOperator.AND); + whereCondition = EntityCondition.makeCondition(whereConditionsList, EntityOperator.AND); - boolean beganTransaction = false; + beganTransaction = false; List prods = null; try { beganTransaction = TransactionUtil.begin(); - prodsEli = delegator.findListIteratorByCondition(prodView, whereCondition, null, null, UtilMisc.toList("productId"), findOpts); + prodsEli = delegator.findListIteratorByCondition(prodView, whereCondition, null, null, ['productId'], findOpts); prods = prodsEli.getCompleteList(); prodsEli.close(); } catch (GenericEntityException e) { - String errMsg = "Failure in operation, rolling back transaction"; + errMsg = "Failure in operation, rolling back transaction"; Debug.logError(e, errMsg, "ViewFacilityInventoryByProduct"); try { // only rollback the transaction if we started one... @@ -154,7 +150,7 @@ // If the user has specified a number of months over which to sum usage quantities, define the correct timestamp Timestamp checkTime = null; monthsInPastLimitStr = request.getParameter("monthsInPastLimit"); - if (UtilValidate.isNotEmpty(monthsInPastLimitStr)) { + if (monthsInPastLimitStr) { try { monthsInPastLimit = Integer.parseInt(monthsInPastLimitStr); cal = UtilDateTime.toCalendar(null); @@ -166,20 +162,17 @@ } } - prodsIt = prods.iterator(); - while (prodsIt.hasNext()) { - oneProd = prodsIt.next(); - Map oneInventory = new HashMap(); - oneInventory.put("checkTime", checkTime); - oneInventory.put("facilityId", facilityId); - oneInventory.put("productId", oneProd.getString("productId")); - oneInventory.put("minimumStock", oneProd.getString("minimumStock")); - oneInventory.put("reorderQuantity", oneProd.getString("reorderQuantity")); - oneInventory.put("daysToShip", oneProd.getString("daysToShip")); - oneInventory.put("statusId", statusId); + prods.each { oneProd -> + oneInventory = [:]; + oneInventory.checkTime = checkTime; + oneInventory.facilityId = facilityId; + oneInventory.productId = oneProd.productId; + oneInventory.minimumStock = oneProd.minimumStock as String; + oneInventory.reorderQuantity = oneProd.reorderQuantity; + oneInventory.daysToShip = oneProd.daysToShip; rows.add(oneInventory); } } -context.put("inventoryByProduct", rows); -context.put("searchParameterString", searchParameterString); +context.inventoryByProduct = rows; +context.searchParameterString = searchParameterString; \ No newline at end of file Modified: ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml?rev=667226&r1=667225&r2=667226&view=diff ============================================================================== --- ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml (original) +++ ofbiz/trunk/applications/product/widget/facility/FacilityScreens.xml Thu Jun 12 13:55:47 2008 @@ -86,7 +86,7 @@ <set field="titleProperty" value="ProductNewFacility"/> <set field="headerItem" value="facility"/> <set field="tabButtonItem" value="EditFacility"/> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/EditFacility.bsh"/> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/EditFacility.groovy"/> </actions> <widgets> <section> @@ -126,7 +126,7 @@ <set field="tabButtonItem" value="FindFacilityTransfers"/> <set field="facilityId" from-field="parameters.facilityId"/> <entity-one entity-name="Facility" value-name="facility"/> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.bsh"/> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/FindFacilityTransfers.groovy"/> </actions> <widgets> <decorator-screen name="CommonFacilityDecorator" location="${parameters.commonFacilityDecoratorLocation}"> @@ -184,7 +184,7 @@ <section> <actions> <set field="tabButtonItem" value="FindFacilityLocation"/> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.bsh"/> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/FindFacilityLocation.groovy"/> <entity-one entity-name="Facility" value-name="facility"/> <property-map resource="ProductUiLabels" map-name="uiLabelMap"/> <set field="title" value="${uiLabelMap.PageTitleFindFacilityLocation}"/> @@ -205,7 +205,7 @@ <section> <actions> <set field="tabButtonItem" value="FindFacilityLocation"/> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.bsh"/> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/EditFacilityLocation.groovy"/> <entity-one entity-name="Facility" value-name="facility"/> <property-map resource="ProductUiLabels" map-name="uiLabelMap"/> <set field="title" value="${uiLabelMap.PageTitleNewFacilityLocation}"/> @@ -276,7 +276,7 @@ <entity-one entity-name="Facility" value-name="facility"/> <entity-condition entity-name="InventoryItemLabelType" list-name="labelTypes"/> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/findInventoryItemsByLabels.bsh"/> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/FindInventoryItemsByLabels.groovy"/> </actions> <widgets> <decorator-screen name="CommonFacilityDecorator" location="${parameters.commonFacilityDecoratorLocation}"> @@ -329,8 +329,8 @@ <set field="internalName" from-field="parameters.internalName"/> <set field="productId" from-field="parameters.productId"/> <set field="statusId" from-field="parameters.statusId"/> - <!-- do not use the countFacilityInventoryByProduct.bsh script unless the issues mentioned in it are correctly addressed --> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.bsh"/> + <!-- do not use the CountFacilityInventoryByProduct.groovy script unless the issues mentioned in it are correctly addressed --> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/ViewFacilityInventoryByProduct.groovy"/> <entity-one entity-name="Facility" value-name="facility"/> <property-map resource="ProductUiLabels" map-name="uiLabelMap"/> <set field="title" value="${uiLabelMap.PageTitleFindFacilityInventoryItems}"/> @@ -387,9 +387,9 @@ <set field="offsetATPQty" from-field="parameters.offsetATPQty"/> <set field="productsSoldThruTimestamp" from-field="parameters.productsSoldThruTimestamp"/> <set field="internalName" from-field="parameters.internalName"/> - <set field="productId" from-field="parameters.productId"/> + <set field="productId" from-field="parameters.productId"/> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/countFacilityInventoryByProduct.bsh"/> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/CountFacilityInventoryByProduct.groovy"/> </actions> <widgets> <decorator-screen name="SimpleDecorator" location="component://common/widget/CommonScreens.xml"> @@ -430,7 +430,7 @@ <set field="internalName" from-field="parameters.internalName"/> <set field="productId" from-field="parameters.productId"/> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/countFacilityInventoryByProduct.bsh"/> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/CountFacilityInventoryByProduct.groovy"/> </actions> <widgets> <decorator-screen name="SimpleDecorator" location="component://common/widget/CommonScreens.xml"> @@ -700,7 +700,7 @@ <section> <actions> <set field="tabButtonItem" value="ViewContactMechs"/> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.bsh"/> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/ViewContactMechs.groovy"/> <set field="facilityId" from-field="parameters.facilityId"/> <entity-one entity-name="Facility" value-name="facility"/> <property-map resource="ProductUiLabels" map-name="uiLabelMap"/> @@ -722,7 +722,7 @@ <section> <actions> <set field="tabButtonItem" value="ViewContactMechs"/> - <script location="component://product/webapp/facility/WEB-INF/actions/facility/EditContactMech.bsh"/> + <script location="component://product/webapp/facility/WEB-INF/actions/facility/EditContactMech.groovy"/> <set field="facilityId" from-field="parameters.facilityId"/> <entity-one entity-name="Facility" value-name="facility"/> <property-map resource="ProductUiLabels" map-name="uiLabelMap"/> |
Free forum by Nabble | Edit this page |