Author: mrisaliti
Date: Fri Jun 6 13:51:48 2008 New Revision: 664118 URL: http://svn.apache.org/viewvc?rev=664118&view=rev Log: Misc improvements suggested by Scott after conversion to groovy (Part of issue OFBIZ-1801) Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureCategoryFeatures.groovy ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureGroups.groovy ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/QuickAddProductFeatures.groovy ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/FindProductPriceRule.groovy ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/promo/EditProductPromoCode.groovy ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreRoles.groovy ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreSurveys.groovy ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/thesaurus/EditKeywordThesaurus.groovy Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureCategoryFeatures.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureCategoryFeatures.groovy?rev=664118&r1=664117&r2=664118&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureCategoryFeatures.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureCategoryFeatures.groovy Fri Jun 6 13:51:48 2008 @@ -25,14 +25,7 @@ module = "EditFeatureCategoryFeatures.groovy"; -security = request.getAttribute("security"); -delegator = request.getAttribute("delegator"); - -if(security.hasEntityPermission("CATALOG", "_VIEW", session)) { - context.hasPermission = Boolean.TRUE; -} else { - context.hasPermission = Boolean.FALSE; -} +context.hasPermission = security.hasEntityPermission("CATALOG", "_VIEW", session); context.nowTimestampString = UtilDateTime.nowTimestamp().toString(); @@ -42,26 +35,24 @@ productFeatureCategoryId = parameters.get("productFeatureCategoryId"); context.productFeatureCategoryId = productFeatureCategoryId; -context.curProductFeatureCategory = delegator.findByPrimaryKey("ProductFeatureCategory", ['productFeatureCategoryId' : productFeatureCategoryId]); +context.curProductFeatureCategory = delegator.findOne("ProductFeatureCategory", [productFeatureCategoryId : productFeatureCategoryId], false); context.productFeatureTypes = delegator.findList("ProductFeatureType", null, null, ['description'], null, false); context.productFeatureCategories = delegator.findList("ProductFeatureCategory", null, null, ['description'], null, false); //we only need these if we will be showing the apply feature to category forms -if (productId && productId.length() > 0) { +if (productId) { context.productFeatureApplTypes = delegator.findList("ProductFeatureApplType", null, null, ['description'], null, false); } -productFeaturesSize = delegator.findCountByCondition("ProductFeature", new EntityExpr("productFeatureCategoryId", EntityOperator.EQUALS, productFeatureCategoryId), null, null); +productFeaturesSize = delegator.findCountByCondition("ProductFeature", EntityCondition.makeCondition("productFeatureCategoryId", EntityOperator.EQUALS, productFeatureCategoryId), null, null); -int highIndex = 0; -int lowIndex = 0; -int listSize = (int) productFeaturesSize; +highIndex = 0; +lowIndex = 0; +listSize = (int) productFeaturesSize; -if (viewIndex == null) { - viewIndex = 0; -} +viewIndex = (viewIndex) ?: 0; lowIndex = viewIndex * viewSize; highIndex = (viewIndex + 1) * viewSize; @@ -75,7 +66,7 @@ context.lowIndex = lowIndex; context.highIndex = highIndex; -whereCondition = new EntityFieldMap(['productFeatureCategoryId' : productFeatureCategoryId], EntityOperator.AND); +whereCondition = EntityCondition.makeCondition([productFeatureCategoryId : productFeatureCategoryId], EntityOperator.AND); EntityFindOptions efo = new EntityFindOptions(); efo.setDistinct(true); efo.setResultSetType(EntityFindOptions.TYPE_SCROLL_INSENSITIVE); @@ -105,15 +96,15 @@ context.productFeatures = productFeatures; -productFeatureApplMap = new HashMap(); +productFeatureApplMap = [:]; productFeatureAppls = null; productFeatureIter = productFeatures.iterator(); productFeatureApplIter = null; -while (productFeatureIter.hasNext()) { +while (productFeatureIter) { productFeature = productFeatureIter.next(); - productFeatureAppls = delegator.findByAnd("ProductFeatureAppl", ['productId' : productId, 'productFeatureId' : productFeature.productFeatureId], null); + productFeatureAppls = delegator.findList("ProductFeatureAppl", EntityCondition.makeCondition([productId : productId, productFeatureId : productFeature.productFeatureId]), null, null, null, false); productFeatureApplIter = productFeatureAppls.iterator(); - while (productFeatureApplIter.hasNext()) { + while (productFeatureApplIter) { productFeatureAppl = productFeatureApplIter.next(); productFeatureApplMap.put(productFeatureAppl.productFeatureId, productFeatureAppl.productFeatureApplTypeId); } Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureGroups.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureGroups.groovy?rev=664118&r1=664117&r2=664118&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureGroups.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/EditFeatureGroups.groovy Fri Jun 6 13:51:48 2008 @@ -17,13 +17,6 @@ * under the License. */ -security = request.getAttribute("security"); -delegator = request.getAttribute("delegator"); +context.hasPermission = security.hasEntityPermission("CATALOG", "_VIEW", session) -if(security.hasEntityPermission("CATALOG", "_VIEW", session)) { - context.hasPermission = Boolean.TRUE; -} else { - context.hasPermission = Boolean.FALSE; -} - -context.productFeatureGroups = delegator.findList("ProductFeatureGroup", null, null, null, null, false); \ No newline at end of file +context.productFeatureGroups = delegator.findList("ProductFeatureGroup", null, null, null, null, false); Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/QuickAddProductFeatures.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/QuickAddProductFeatures.groovy?rev=664118&r1=664117&r2=664118&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/QuickAddProductFeatures.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/feature/QuickAddProductFeatures.groovy Fri Jun 6 13:51:48 2008 @@ -17,8 +17,6 @@ * under the License. */ -import org.ofbiz.base.util.UtilMisc - context.productFeatureTypes = delegator.findList("ProductFeatureType", null, null, ['description'], null, true); -context.featureCategory = delegator.findByPrimaryKey("ProductFeatureCategory", ['productFeatureCategoryId' : parameters.productFeatureCategoryId]); \ No newline at end of file +context.featureCategory = delegator.findOne("ProductFeatureCategory", [productFeatureCategoryId : parameters.productFeatureCategoryId], false); Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy?rev=664118&r1=664117&r2=664118&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/EditProductPriceRules.groovy Fri Jun 6 13:51:48 2008 @@ -17,17 +17,15 @@ * under the License. */ -import org.ofbiz.entity.* -import org.ofbiz.entity.util.* -import org.ofbiz.base.util.* +import org.ofbiz.entity.condition.* String priceRuleId = request.getParameter("productPriceRuleId"); if (priceRuleId) { - context.productPriceRule = delegator.findByPrimaryKey("ProductPriceRule", ['productPriceRuleId' : priceRuleId]); + context.productPriceRule = delegator.findOne("ProductPriceRule", [productPriceRuleId : priceRuleId], false); } -context.inputParamEnums = delegator.findByAndCache("Enumeration", ['enumTypeId' : 'PROD_PRICE_IN_PARAM'], ['sequenceId']); +context.inputParamEnums = delegator.findList("Enumeration", EntityCondition.makeCondition([enumTypeId : 'PROD_PRICE_IN_PARAM']), null, ['sequenceId'], null, true); -context.condOperEnums = delegator.findByAndCache("Enumeration", ['enumTypeId' : 'PROD_PRICE_COND'], ['sequenceId']); +context.condOperEnums = delegator.findList("Enumeration", EntityCondition.makeCondition([enumTypeId : 'PROD_PRICE_COND']), null, ['sequenceId'], null, true); context.productPriceActionTypes = delegator.findList("ProductPriceActionType", null, null, ['description'], null, true); \ No newline at end of file Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/FindProductPriceRule.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/FindProductPriceRule.groovy?rev=664118&r1=664117&r2=664118&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/FindProductPriceRule.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/price/FindProductPriceRule.groovy Fri Jun 6 13:51:48 2008 @@ -17,19 +17,13 @@ * under the License. */ -import org.ofbiz.entity.* -import org.ofbiz.entity.util.* - -boolean activeOnly = true; -if ("false".equals(request.getParameter("activeOnly"))) { - activeOnly = false; -} +boolean activeOnly = "false".equals(request.getParameter("activeOnly")); context.activeOnly = activeOnly; List productPriceRules = delegator.findList("ProductPriceRule", null, null, null, null, false); if (activeOnly) { productPriceRules = EntityUtil.filterByDate(productPriceRules, true); } -if (productPriceRules && productPriceRules.size() > 0) { +if (productPriceRules) { context.productPriceRules = productPriceRules; -} \ No newline at end of file +} Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/promo/EditProductPromoCode.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/promo/EditProductPromoCode.groovy?rev=664118&r1=664117&r2=664118&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/promo/EditProductPromoCode.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/promo/EditProductPromoCode.groovy Fri Jun 6 13:51:48 2008 @@ -17,14 +17,11 @@ * under the License. */ -import org.ofbiz.entity.* -import org.ofbiz.base.util.* - productPromoCodeId = request.getParameter("productPromoCodeId"); -if (UtilValidate.isEmpty(productPromoCodeId)) { +if (!productPromoCodeId) { productPromoCodeId = request.getAttribute("productPromoCodeId"); } -productPromoCode = delegator.findByPrimaryKey("ProductPromoCode", ['productPromoCodeId' : productPromoCodeId]); +productPromoCode = delegator.findOne("ProductPromoCode", [productPromoCodeId : productPromoCodeId], false); productPromoId = null; if (productPromoCode) { @@ -35,7 +32,7 @@ productPromo = null; if (productPromoId) { - productPromo = delegator.findByPrimaryKey("ProductPromo", ['productPromoId' : productPromoId]); + productPromo = delegator.findOne("ProductPromo", [productPromoId : productPromoId], false); } productPromoCodeEmails = null; Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreRoles.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreRoles.groovy?rev=664118&r1=664117&r2=664118&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreRoles.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreRoles.groovy Fri Jun 6 13:51:48 2008 @@ -17,13 +17,13 @@ * under the License. */ -import org.ofbiz.entity.* +import org.ofbiz.entity.condition.* import org.ofbiz.entity.util.* -List productStoreRoles = delegator.findByAnd("ProductStoreRole", ['productStoreId' : productStoreId], ['sequenceNum']); +productStoreRoles = delegator.findList("ProductStoreRole", EntityCondition.makeCondition([productStoreId : productStoreId]), null, ['sequenceNum'], null, true); if (!request.getParameter("showAll")) { productStoreRoles = EntityUtil.filterByDate(productStoreRoles); } context.productStoreRoles = productStoreRoles; -context.roleTypes = delegator.findList("RoleType", null, null, ['description'], null, false); \ No newline at end of file +context.roleTypes = delegator.findList("RoleType", null, null, ['description'], null, false); Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreSurveys.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreSurveys.groovy?rev=664118&r1=664117&r2=664118&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreSurveys.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/store/EditProductStoreSurveys.groovy Fri Jun 6 13:51:48 2008 @@ -17,27 +17,20 @@ * under the License. */ -import org.ofbiz.base.util.*; -import org.ofbiz.entity.*; -import org.ofbiz.entity.util.*; - -security = request.getAttribute("security"); -delegator = request.getAttribute("delegator"); - -if (security.hasEntityPermission("CATALOG", "_VIEW", session)) { - context.hasPermission = Boolean.TRUE; -} else { - context.hasPermission = Boolean.FALSE; -} +import org.ofbiz.base.util.* +import org.ofbiz.entity.condition.* +import org.ofbiz.entity.util.* + +context.hasPermission = security.hasEntityPermission("CATALOG", "_VIEW", session); productStoreId = request.getParameter("productStoreId"); if (productStoreId) { - productStore = delegator.findByPrimaryKey("ProductStore", ['productStoreId' : productStoreId]); + productStore = delegator.findOne("ProductStore", [productStoreId : productStoreId], false); context.productStoreId = productStoreId; context.productStore = productStore; } -context.productStoreSurveys = EntityUtil.filterByDate(delegator.findByAnd("ProductStoreSurveyAppl", ['productStoreId' : productStoreId])); +context.productStoreSurveys = EntityUtil.filterByDate(delegator.findList("ProductStoreSurveyAppl", EntityCondition.makeCondition([productStoreId : productStoreId]), null, null, null, false)); context.surveys = delegator.findList("Survey", null, null, ['description'], null, false); Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/thesaurus/EditKeywordThesaurus.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/thesaurus/EditKeywordThesaurus.groovy?rev=664118&r1=664117&r2=664118&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/thesaurus/EditKeywordThesaurus.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/thesaurus/EditKeywordThesaurus.groovy Fri Jun 6 13:51:48 2008 @@ -17,16 +17,15 @@ * under the License. */ -import org.ofbiz.entity.* -import org.ofbiz.base.util.* +import org.ofbiz.entity.condition.* -relationshipEnums = delegator.findByAndCache("Enumeration", ['enumTypeId' : 'KW_THES_REL'], ['sequenceId']); +relationshipEnums = delegator.findList("Enumeration", EntityCondition.makeCondition([enumTypeId : 'KW_THES_REL']), null, ['sequenceId'], null, true); keywordThesauruses = delegator.findList("KeywordThesaurus", null, null, ['enteredKeyword'], null, false); //if no param sent in make firstLetter 'a' else use firstLetter passed in firstLetterString = request.getParameter("firstLetter"); -if (UtilValidate.isEmpty(firstLetterString)) { +if (!firstLetterString) { firstLetter = 'a'; } else { @@ -36,11 +35,11 @@ //add elememts to new list as long as it is smaller then 20, // but always get all of the first letter keywordThesaurusIter = keywordThesauruses.iterator(); -newKeywordThesaurus = new LinkedList(); -specialCharKeywordThesaurus = new LinkedList(); +newKeywordThesaurus = []; +specialCharKeywordThesaurus = []; currentLetter = firstLetter; -if (keywordThesaurusIter.hasNext()) { - while (keywordThesaurusIter.hasNext()) { +if (keywordThesaurusIter) { + while (keywordThesaurusIter) { keywordThesaurus = keywordThesaurusIter.next(); if (keywordThesaurus.get("enteredKeyword").charAt(0)<'a' || keywordThesaurus.get("enteredKeyword").charAt(0)>'z') { @@ -56,14 +55,14 @@ } if ((specialCharKeywordThesaurus.size() > 0 && newKeywordThesaurus.size()<20) || firstLetter=='z') { specialCharKeywordThesaurusIter = specialCharKeywordThesaurus.iterator(); - while (specialCharKeywordThesaurusIter.hasNext()) { + while (specialCharKeywordThesaurusIter) { keywordThesaurus = specialCharKeywordThesaurusIter.next(); newKeywordThesaurus.add(keywordThesaurus); } } //create list for a-z -letterList=new LinkedList(); +letterList = []; for (i='a'; i<='z'; i++) { letterList.add(i); } |
Free forum by Nabble | Edit this page |