Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/feature/QuickAddProductFeatures.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/feature/QuickAddProductFeatures.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/feature/QuickAddProductFeatures.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/feature/QuickAddProductFeatures.groovy Wed Nov 2 19:09:13 2016 @@ -17,6 +17,6 @@ * under the License. */ -context.productFeatureTypes = from("ProductFeatureType").orderBy("description").cache(true).queryList(); +context.productFeatureTypes = from("ProductFeatureType").orderBy("description").cache(true).queryList() -context.featureCategory = from("ProductFeatureCategory").where("productFeatureCategoryId", parameters.productFeatureCategoryId).queryOne(); +context.featureCategory = from("ProductFeatureCategory").where("productFeatureCategoryId", parameters.productFeatureCategoryId).queryOne() Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/find/AdvancedSearchOptions.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/find/AdvancedSearchOptions.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/find/AdvancedSearchOptions.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/find/AdvancedSearchOptions.groovy Wed Nov 2 19:09:13 2016 @@ -21,42 +21,42 @@ import org.apache.ofbiz.entity.condition import org.apache.ofbiz.product.catalog.* import org.apache.ofbiz.product.feature.* import org.apache.ofbiz.product.product.* -import org.apache.ofbiz.product.store.ProductStoreWorker; -searchCategoryId = parameters.SEARCH_CATEGORY_ID; -productStoreId = ProductStoreWorker.getProductStoreId(request); +import org.apache.ofbiz.product.store.ProductStoreWorker +searchCategoryId = parameters.SEARCH_CATEGORY_ID +productStoreId = ProductStoreWorker.getProductStoreId(request) if ((!searchCategoryId || searchCategoryId.length() == 0) && !productStoreId) { - currentCatalogId = CatalogWorker.getCurrentCatalogId(request); - searchCategoryId = CatalogWorker.getCatalogSearchCategoryId(request, currentCatalogId); + currentCatalogId = CatalogWorker.getCurrentCatalogId(request) + searchCategoryId = CatalogWorker.getCatalogSearchCategoryId(request, currentCatalogId) } -searchCategory = from("ProductCategory").where("productCategoryId", searchCategoryId).queryOne(); +searchCategory = from("ProductCategory").where("productCategoryId", searchCategoryId).queryOne() if (searchCategoryId) { - productFeaturesByTypeMap = ParametricSearch.makeCategoryFeatureLists(searchCategoryId, delegator, 2000); + productFeaturesByTypeMap = ParametricSearch.makeCategoryFeatureLists(searchCategoryId, delegator, 2000) } else { - productFeaturesByTypeMap = ParametricSearch.getAllFeaturesByType(delegator, 2000); + productFeaturesByTypeMap = ParametricSearch.getAllFeaturesByType(delegator, 2000) } -productFeatureTypeIdsOrdered = new ArrayList(new TreeSet(productFeaturesByTypeMap.keySet())); +productFeatureTypeIdsOrdered = new ArrayList(new TreeSet(productFeaturesByTypeMap.keySet())) -searchOperator = parameters.SEARCH_OPERATOR; +searchOperator = parameters.SEARCH_OPERATOR if (!"AND".equals(searchOperator) && !"OR".equals(searchOperator)) { - searchOperator = "OR"; + searchOperator = "OR" } -searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator); -searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request); +searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator) +searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request) // get suppliers in system -supplerPartyRoleAndPartyDetails = from("PartyRoleAndPartyDetail").where(roleTypeId : "SUPPLIER").orderBy("groupName", "firstName").queryList(); +supplerPartyRoleAndPartyDetails = from("PartyRoleAndPartyDetail").where(roleTypeId : "SUPPLIER").orderBy("groupName", "firstName").queryList() // get the GoodIdentification types -goodIdentificationTypes = from("GoodIdentificationType").orderBy("description").queryList(); +goodIdentificationTypes = from("GoodIdentificationType").orderBy("description").queryList() -context.searchCategoryId = searchCategoryId; -context.searchCategory = searchCategory; -context.productFeaturesByTypeMap = productFeaturesByTypeMap; -context.productFeatureTypeIdsOrdered = productFeatureTypeIdsOrdered; -context.searchOperator = searchOperator; -context.searchConstraintStrings = searchConstraintStrings; -context.searchSortOrderString = searchSortOrderString; -context.supplerPartyRoleAndPartyDetails = supplerPartyRoleAndPartyDetails; -context.goodIdentificationTypes = goodIdentificationTypes; +context.searchCategoryId = searchCategoryId +context.searchCategory = searchCategory +context.productFeaturesByTypeMap = productFeaturesByTypeMap +context.productFeatureTypeIdsOrdered = productFeatureTypeIdsOrdered +context.searchOperator = searchOperator +context.searchConstraintStrings = searchConstraintStrings +context.searchSortOrderString = searchSortOrderString +context.supplerPartyRoleAndPartyDetails = supplerPartyRoleAndPartyDetails +context.goodIdentificationTypes = goodIdentificationTypes Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/find/KeywordSearch.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/find/KeywordSearch.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/find/KeywordSearch.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/find/KeywordSearch.groovy Wed Nov 2 19:09:13 2016 @@ -21,31 +21,31 @@ import org.apache.ofbiz.entity.condition import org.apache.ofbiz.product.catalog.* import org.apache.ofbiz.product.product.* -module = "KeywordSearch.groovy"; +module = "KeywordSearch.groovy" // note: this can be run multiple times in the same request without causing problems, will check to see on its own if it has run again -ProductSearchSession.processSearchParameters(parameters, request); -prodCatalogId = CatalogWorker.getCurrentCatalogId(request); -result = ProductSearchSession.getProductSearchResult(request, delegator, prodCatalogId); +ProductSearchSession.processSearchParameters(parameters, request) +prodCatalogId = CatalogWorker.getCurrentCatalogId(request) +result = ProductSearchSession.getProductSearchResult(request, delegator, prodCatalogId) -applicationTypes = from("ProductFeatureApplType").orderBy("description").queryList(); +applicationTypes = from("ProductFeatureApplType").orderBy("description").queryList() expr = EntityCondition.makeCondition(EntityCondition.makeCondition("showInSelect", EntityOperator.EQUALS, null), EntityOperator.OR, - EntityCondition.makeCondition("showInSelect", EntityOperator.NOT_EQUAL, "N")); -productCategories = from("ProductCategory").where(expr).orderBy("description").queryList(); + EntityCondition.makeCondition("showInSelect", EntityOperator.NOT_EQUAL, "N")) +productCategories = from("ProductCategory").where(expr).orderBy("description").queryList() -context.applicationTypes = applicationTypes; -context.productCategories = productCategories; +context.applicationTypes = applicationTypes +context.productCategories = productCategories -context.noConditionFind = result.noConditionFind; -context.productIds = result.productIds; -context.viewIndex = result.viewIndex; -context.viewSize = result.viewSize; -context.listSize = result.listSize; -context.lowIndex = result.lowIndex; -context.highIndex = result.highIndex; -context.paging = result.paging; -context.previousViewSize = result.previousViewSize; -context.searchConstraintStrings = result.searchConstraintStrings; -context.searchSortOrderString = result.searchSortOrderString; +context.noConditionFind = result.noConditionFind +context.productIds = result.productIds +context.viewIndex = result.viewIndex +context.viewSize = result.viewSize +context.listSize = result.listSize +context.lowIndex = result.lowIndex +context.highIndex = result.highIndex +context.paging = result.paging +context.previousViewSize = result.previousViewSize +context.searchConstraintStrings = result.searchConstraintStrings +context.searchSortOrderString = result.searchSortOrderString Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/find/KeywordSearchBox.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/find/KeywordSearchBox.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/find/KeywordSearchBox.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/find/KeywordSearchBox.groovy Wed Nov 2 19:09:13 2016 @@ -17,15 +17,15 @@ * under the License. */ -state = request.getParameter("SearchProductsState"); -isOpen = true; +state = request.getParameter("SearchProductsState") +isOpen = true if (state) { - session.setAttribute("SearchProductsState", state); - isOpen = "open".equals(state); + session.setAttribute("SearchProductsState", state) + isOpen = "open".equals(state) } else { - state = (String) session.getAttribute("SearchProductsState"); + state = (String) session.getAttribute("SearchProductsState") if (state) { - isOpen = "open".equals(state); + isOpen = "open".equals(state) } } -context.isOpen = isOpen; +context.isOpen = isOpen Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/find/MiniProductList.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/find/MiniProductList.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/find/MiniProductList.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/find/MiniProductList.groovy Wed Nov 2 19:09:13 2016 @@ -19,35 +19,35 @@ import org.apache.ofbiz.base.util.* -state = request.getParameter("CategoryProductsState"); -isOpen = true; +state = request.getParameter("CategoryProductsState") +isOpen = true if (state) { - session.setAttribute("CategoryProductsState", state); - isOpen = "open".equals(state); + session.setAttribute("CategoryProductsState", state) + isOpen = "open".equals(state) } else { - state = (String) session.getAttribute("CategoryProductsState"); + state = (String) session.getAttribute("CategoryProductsState") if (state) { - isOpen = "open".equals(state); + isOpen = "open".equals(state) } } -context.isOpen = isOpen; +context.isOpen = isOpen // Get a list of all products in the current category if (isOpen) { - paramInMap = [:]; - paramInMap.productCategoryId = UtilFormatOut.checkNull(request.getParameter("productCategoryId")); - paramInMap.defaultViewSize = 30; - paramInMap.limitView = true; - paramInMap.useCacheForMembers = false; - paramInMap.checkViewAllow = false; + paramInMap = [:] + paramInMap.productCategoryId = UtilFormatOut.checkNull(request.getParameter("productCategoryId")) + paramInMap.defaultViewSize = 30 + paramInMap.limitView = true + paramInMap.useCacheForMembers = false + paramInMap.checkViewAllow = false // Returns: viewIndex, viewSize, lowIndex, highIndex, listSize, productCategory, productCategoryMembers - outMap = runService('getProductCategoryAndLimitedMembers', paramInMap); - context.viewIndex = outMap.viewIndex; - context.viewSize = outMap.viewSize; - context.lowIndex = outMap.lowIndex; - context.highIndex = outMap.highIndex; - context.listSize = outMap.listSize; - context.productCategory = outMap.productCategory; - context.productCategoryMembers = outMap.productCategoryMembers; + outMap = runService('getProductCategoryAndLimitedMembers', paramInMap) + context.viewIndex = outMap.viewIndex + context.viewSize = outMap.viewSize + context.lowIndex = outMap.lowIndex + context.highIndex = outMap.highIndex + context.listSize = outMap.listSize + context.productCategory = outMap.productCategory + context.productCategoryMembers = outMap.productCategoryMembers } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/find/SideCatalogs.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/find/SideCatalogs.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/find/SideCatalogs.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/find/SideCatalogs.groovy Wed Nov 2 19:09:13 2016 @@ -17,30 +17,30 @@ * under the License. */ -state = request.getParameter("BrowseCatalogsState"); -isOpen = true; +state = request.getParameter("BrowseCatalogsState") +isOpen = true if (state) { - session.setAttribute("BrowseCatalogsState", state); - isOpen = "open".equals(state); + session.setAttribute("BrowseCatalogsState", state) + isOpen = "open".equals(state) } else { - state = (String) session.getAttribute("BrowseCatalogsState"); + state = (String) session.getAttribute("BrowseCatalogsState") if (state) { - isOpen = "open".equals(state); + isOpen = "open".equals(state) } } -context.isOpen = isOpen; +context.isOpen = isOpen //prodCatalogs if (isOpen) { - prodCatalogs = from("ProdCatalog").queryList(); - context.prodCatalogs = prodCatalogs; + prodCatalogs = from("ProdCatalog").queryList() + context.prodCatalogs = prodCatalogs } //get the current prodCatalogId -curProdCatalogId = request.getParameter("prodCatalogId"); +curProdCatalogId = request.getParameter("prodCatalogId") if (curProdCatalogId) { - session.setAttribute("curProdCatalogId", curProdCatalogId); + session.setAttribute("curProdCatalogId", curProdCatalogId) } else { - curProdCatalogId = (String) session.getAttribute("curProdCatalogId"); + curProdCatalogId = (String) session.getAttribute("curProdCatalogId") } -context.curProdCatalogId = curProdCatalogId; +context.curProdCatalogId = curProdCatalogId Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/find/SideDeepCategory.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/find/SideDeepCategory.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/find/SideDeepCategory.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/find/SideDeepCategory.groovy Wed Nov 2 19:09:13 2016 @@ -20,39 +20,39 @@ import org.apache.ofbiz.base.util.* import org.apache.ofbiz.entity.* import org.apache.ofbiz.product.category.* -import org.apache.ofbiz.entity.util.EntityUtilProperties; +import org.apache.ofbiz.entity.util.EntityUtilProperties -state = request.getParameter("BrowseCategoriesState"); -isOpen = true; +state = request.getParameter("BrowseCategoriesState") +isOpen = true if (state) { - session.setAttribute("BrowseCategoriesState", state); - isOpen = "open".equals(state); + session.setAttribute("BrowseCategoriesState", state) + isOpen = "open".equals(state) } else { - state = (String) session.getAttribute("BrowseCategoriesState"); + state = (String) session.getAttribute("BrowseCategoriesState") if (state) { - isOpen = "open".equals(state); + isOpen = "open".equals(state) } } -context.isOpen = isOpen; +context.isOpen = isOpen -requestParameters = UtilHttp.getParameterMap(request); -defaultTopCategoryId = requestParameters.TOP_CATEGORY ? requestParameters.TOP_CATEGORY : EntityUtilProperties.getPropertyValue("catalog", "top.category.default", delegator); -currentTopCategoryId = CategoryWorker.getCatalogTopCategory(request, defaultTopCategoryId); -currentTopCategory = null; +requestParameters = UtilHttp.getParameterMap(request) +defaultTopCategoryId = requestParameters.TOP_CATEGORY ? requestParameters.TOP_CATEGORY : EntityUtilProperties.getPropertyValue("catalog", "top.category.default", delegator) +currentTopCategoryId = CategoryWorker.getCatalogTopCategory(request, defaultTopCategoryId) +currentTopCategory = null if (isOpen) { - CategoryWorker.getRelatedCategories(request, "topLevelList", currentTopCategoryId, false); - currentTopCategory = from("ProductCategory").where("productCategoryId", currentTopCategoryId).cache(true).queryOne(); - context.topLevelList = request.getAttribute("topLevelList"); + CategoryWorker.getRelatedCategories(request, "topLevelList", currentTopCategoryId, false) + currentTopCategory = from("ProductCategory").where("productCategoryId", currentTopCategoryId).cache(true).queryOne() + context.topLevelList = request.getAttribute("topLevelList") } -curCategoryId = UtilFormatOut.checkNull(requestParameters.productCategoryId); -CategoryWorker.setTrail(request, curCategoryId); +curCategoryId = UtilFormatOut.checkNull(requestParameters.productCategoryId) +CategoryWorker.setTrail(request, curCategoryId) -context.curCategoryId = curCategoryId; -context.currentTopCategory = currentTopCategory; +context.curCategoryId = curCategoryId +context.currentTopCategory = currentTopCategory -categoryList = request.getAttribute("topLevelList"); +categoryList = request.getAttribute("topLevelList") if (categoryList) { - catContentWrappers = [:]; - CategoryWorker.getCategoryContentWrappers(catContentWrappers, categoryList, request); - context.catContentWrappers = catContentWrappers; + catContentWrappers = [:] + CategoryWorker.getCategoryContentWrappers(catContentWrappers, categoryList, request) + context.catContentWrappers = catContentWrappers } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/CheckAction.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/CheckAction.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/CheckAction.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/CheckAction.groovy Wed Nov 2 19:09:13 2016 @@ -17,14 +17,14 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; +import org.apache.ofbiz.base.util.* -Map paramMap = UtilHttp.getParameterMap(request); +Map paramMap = UtilHttp.getParameterMap(request) def result -int rowCount = UtilHttp.getMultiFormRowCount(paramMap); +int rowCount = UtilHttp.getMultiFormRowCount(paramMap) if (rowCount > 1) { for (int i = 0; i < rowCount; i++) { - String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i; + String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i if(paramMap.get("action" +thisSuffix)){ result = paramMap.get("action" +thisSuffix) } @@ -34,6 +34,6 @@ else { result = paramMap.get("action_o_0") } if (result == null) { - result = "noAction"; + result = "noAction" } -return result; +return result Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/CheckRejected.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/CheckRejected.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/CheckRejected.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/CheckRejected.groovy Wed Nov 2 19:09:13 2016 @@ -17,14 +17,14 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; +import org.apache.ofbiz.base.util.* -Map paramMap = UtilHttp.getParameterMap(request); +Map paramMap = UtilHttp.getParameterMap(request) def rejected = false -int rowCount = UtilHttp.getMultiFormRowCount(paramMap); +int rowCount = UtilHttp.getMultiFormRowCount(paramMap) if (rowCount > 1) { for (int i = 0; i < rowCount; i++) { - String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i; + String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i if(paramMap.get("checkStatusId" +thisSuffix)){ def temp = paramMap.get("checkStatusId" +thisSuffix) def splitTemp = temp.split("/") Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageFrame.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageFrame.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageFrame.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageFrame.groovy Wed Nov 2 19:09:13 2016 @@ -17,22 +17,22 @@ * under the License. */ -import javax.servlet.http.HttpSession; -import org.apache.ofbiz.base.util.UtilValidate; +import javax.servlet.http.HttpSession +import org.apache.ofbiz.base.util.UtilValidate -frameContentId = null; -frameDataResourceId = null; +frameContentId = null +frameDataResourceId = null if (UtilValidate.isNotEmpty(session.getAttribute("frameContentId")) && UtilValidate.isNotEmpty(session.getAttribute("frameDataResourceId"))) { - frameContentId = session.getAttribute("frameContentId"); - frameDataResourceId = session.getAttribute("frameDataResourceId"); + frameContentId = session.getAttribute("frameContentId") + frameDataResourceId = session.getAttribute("frameDataResourceId") } else { - frameContentId = parameters.get("frameContentId"); - frameDataResourceId = parameters.get("frameDataResourceId"); + frameContentId = parameters.get("frameContentId") + frameDataResourceId = parameters.get("frameDataResourceId") } -context.frameContentId = frameContentId; -context.frameDataResourceId = frameDataResourceId; +context.frameContentId = frameContentId +context.frameDataResourceId = frameDataResourceId -session.removeAttribute("frameContentId"); -session.removeAttribute("frameDataResourceId"); \ No newline at end of file +session.removeAttribute("frameContentId") +session.removeAttribute("frameDataResourceId") \ No newline at end of file Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageGallery.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageGallery.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageGallery.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageGallery.groovy Wed Nov 2 19:09:13 2016 @@ -22,28 +22,28 @@ * should not contain order component's specific code. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.condition.*; -import org.apache.ofbiz.entity.util.*; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.condition.* +import org.apache.ofbiz.entity.util.* -productImageList = []; -productContentAndInfoImageManamentList = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "IMAGE", "statusId", "IM_APPROVED").orderBy("sequenceNum").queryList(); +productImageList = [] +productContentAndInfoImageManamentList = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "IMAGE", "statusId", "IM_APPROVED").orderBy("sequenceNum").queryList() if(productContentAndInfoImageManamentList) { productContentAndInfoImageManamentList.each { productContentAndInfoImageManament -> - contentAssocThumb = from("ContentAssoc").where("contentId", productContentAndInfoImageManament.contentId, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryFirst(); + contentAssocThumb = from("ContentAssoc").where("contentId", productContentAndInfoImageManament.contentId, "contentAssocTypeId", "IMAGE_THUMBNAIL").queryFirst() if(contentAssocThumb) { - imageContentThumb = from("Content").where("contentId", contentAssocThumb.contentIdTo).queryOne(); + imageContentThumb = from("Content").where("contentId", contentAssocThumb.contentIdTo).queryOne() if(imageContentThumb) { - productImageThumb = from("ContentDataResourceView").where("contentId", imageContentThumb.contentId, "drDataResourceId", imageContentThumb.dataResourceId).queryOne(); - productImageMap = [:]; - productImageMap.contentId = productContentAndInfoImageManament.contentId; - productImageMap.dataResourceId = productContentAndInfoImageManament.dataResourceId; - productImageMap.productImageThumb = productImageThumb.drObjectInfo; - productImageMap.productImage = productContentAndInfoImageManament.drObjectInfo; - productImageList.add(productImageMap); + productImageThumb = from("ContentDataResourceView").where("contentId", imageContentThumb.contentId, "drDataResourceId", imageContentThumb.dataResourceId).queryOne() + productImageMap = [:] + productImageMap.contentId = productContentAndInfoImageManament.contentId + productImageMap.dataResourceId = productContentAndInfoImageManament.dataResourceId + productImageMap.productImageThumb = productImageThumb.drObjectInfo + productImageMap.productImage = productContentAndInfoImageManament.drObjectInfo + productImageList.add(productImageMap) } } } - context.productImageList = productImageList; + context.productImageList = productImageList } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageRecentlyApproved.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageRecentlyApproved.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageRecentlyApproved.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageRecentlyApproved.groovy Wed Nov 2 19:09:13 2016 @@ -17,13 +17,13 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.entity.util.*; -import java.text.SimpleDateFormat; -import java.util.List; -import java.util.Set; -import org.apache.ofbiz.entity.condition.EntityCondition; -import org.apache.ofbiz.entity.condition.EntityOperator; +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.entity.util.* +import java.text.SimpleDateFormat +import java.util.List +import java.util.Set +import org.apache.ofbiz.entity.condition.EntityCondition +import org.apache.ofbiz.entity.condition.EntityOperator import org.apache.ofbiz.entity.util.EntityFindOptions def limit = 13 // set number of days @@ -46,10 +46,10 @@ for(i in 0..limit){ exprs.add(EntityCondition.makeCondition("purchaseFromDate", EntityOperator.GREATER_THAN_EQUAL_TO, timeStampDate1)) exprs.add(EntityCondition.makeCondition("purchaseFromDate", EntityOperator.LESS_THAN, timeStampDate2)) // query result - def productContentAndInfoList = select("productId").from("ProductContentAndInfo").where(exprs).distinct().queryList(); + def productContentAndInfoList = select("productId").from("ProductContentAndInfo").where(exprs).distinct().queryList() // finding time - def timeList = from("ProductContentAndInfo").where(exprs).orderBy("productId").queryList(); + def timeList = from("ProductContentAndInfo").where(exprs).orderBy("productId").queryList() def groupByTimeList = timeList.groupBy{it.productId} def tempTimeList = [] groupByTimeList.each() { @@ -65,34 +65,34 @@ for(i in 0..limit){ def showDate = sdf2.format(today-i) switch (i) { - case 0: context.approved_0 = productContentAndInfoList; context.time_0 = time; context.date0 = showDate; - context.timeStampDate1_0 = timeStampDate1; context.timeStampDate2_0 = timeStampDate2; break; - case 1: context.approved_1 = productContentAndInfoList; context.time_1 = time; context.date1 = showDate; - context.timeStampDate1_1 = timeStampDate1; context.timeStampDate2_1 = timeStampDate2; break; - case 2: context.approved_2 = productContentAndInfoList; context.time_2 = time; context.date2 = showDate; - context.timeStampDate1_2 = timeStampDate1; context.timeStampDate2_2 = timeStampDate2; break; - case 3: context.approved_3 = productContentAndInfoList; context.time_3 = time; context.date3 = showDate; - context.timeStampDate1_3 = timeStampDate1; context.timeStampDate2_3 = timeStampDate2; break; - case 4: context.approved_4 = productContentAndInfoList; context.time_4 = time; context.date4 = showDate; - context.timeStampDate1_4 = timeStampDate1; context.timeStampDate2_4 = timeStampDate2; break; - case 5: context.approved_5 = productContentAndInfoList; context.time_5 = time; context.date5 = showDate; - context.timeStampDate1_5 = timeStampDate1; context.timeStampDate2_5 = timeStampDate2; break; - case 6: context.approved_6 = productContentAndInfoList; context.time_6 = time; context.date6 = showDate; - context.timeStampDate1_6 = timeStampDate1; context.timeStampDate2_6 = timeStampDate2; break; - case 7: context.approved_7 = productContentAndInfoList; context.time_7 = time; context.date7 = showDate; - context.timeStampDate1_7 = timeStampDate1; context.timeStampDate2_7 = timeStampDate2; break; - case 8: context.approved_8 = productContentAndInfoList; context.time_8 = time; context.date8 = showDate; - context.timeStampDate1_8 = timeStampDate1; context.timeStampDate2_8 = timeStampDate2; break; - case 9: context.approved_9 = productContentAndInfoList; context.time_9 = time; context.date9 = showDate; - context.timeStampDate1_9 = timeStampDate1; context.timeStampDate2_9 = timeStampDate2; break; - case 10: context.approved_10 = productContentAndInfoList; context.time_10 = time; context.date10 = showDate; - context.timeStampDate1_10 = timeStampDate1; context.timeStampDate2_10 = timeStampDate2; break; - case 11: context.approved_11 = productContentAndInfoList; context.time_11 = time; context.date11 = showDate; - context.timeStampDate1_11 = timeStampDate1; context.timeStampDate2_11 = timeStampDate2; break; - case 12: context.approved_12 = productContentAndInfoList; context.time_12 = time; context.date12 = showDate; - context.timeStampDate1_12 = timeStampDate1; context.timeStampDate2_12 = timeStampDate2; break; - case 13: context.approved_13 = productContentAndInfoList; context.time_13 = time; context.date13 = showDate; - context.timeStampDate1_13 = timeStampDate1; context.timeStampDate2_13 = timeStampDate2; break; - default: context.error = "error"; + case 0: context.approved_0 = productContentAndInfoList; context.time_0 = time; context.date0 = showDate + context.timeStampDate1_0 = timeStampDate1; context.timeStampDate2_0 = timeStampDate2; break + case 1: context.approved_1 = productContentAndInfoList; context.time_1 = time; context.date1 = showDate + context.timeStampDate1_1 = timeStampDate1; context.timeStampDate2_1 = timeStampDate2; break + case 2: context.approved_2 = productContentAndInfoList; context.time_2 = time; context.date2 = showDate + context.timeStampDate1_2 = timeStampDate1; context.timeStampDate2_2 = timeStampDate2; break + case 3: context.approved_3 = productContentAndInfoList; context.time_3 = time; context.date3 = showDate + context.timeStampDate1_3 = timeStampDate1; context.timeStampDate2_3 = timeStampDate2; break + case 4: context.approved_4 = productContentAndInfoList; context.time_4 = time; context.date4 = showDate + context.timeStampDate1_4 = timeStampDate1; context.timeStampDate2_4 = timeStampDate2; break + case 5: context.approved_5 = productContentAndInfoList; context.time_5 = time; context.date5 = showDate + context.timeStampDate1_5 = timeStampDate1; context.timeStampDate2_5 = timeStampDate2; break + case 6: context.approved_6 = productContentAndInfoList; context.time_6 = time; context.date6 = showDate + context.timeStampDate1_6 = timeStampDate1; context.timeStampDate2_6 = timeStampDate2; break + case 7: context.approved_7 = productContentAndInfoList; context.time_7 = time; context.date7 = showDate + context.timeStampDate1_7 = timeStampDate1; context.timeStampDate2_7 = timeStampDate2; break + case 8: context.approved_8 = productContentAndInfoList; context.time_8 = time; context.date8 = showDate + context.timeStampDate1_8 = timeStampDate1; context.timeStampDate2_8 = timeStampDate2; break + case 9: context.approved_9 = productContentAndInfoList; context.time_9 = time; context.date9 = showDate + context.timeStampDate1_9 = timeStampDate1; context.timeStampDate2_9 = timeStampDate2; break + case 10: context.approved_10 = productContentAndInfoList; context.time_10 = time; context.date10 = showDate + context.timeStampDate1_10 = timeStampDate1; context.timeStampDate2_10 = timeStampDate2; break + case 11: context.approved_11 = productContentAndInfoList; context.time_11 = time; context.date11 = showDate + context.timeStampDate1_11 = timeStampDate1; context.timeStampDate2_11 = timeStampDate2; break + case 12: context.approved_12 = productContentAndInfoList; context.time_12 = time; context.date12 = showDate + context.timeStampDate1_12 = timeStampDate1; context.timeStampDate2_12 = timeStampDate2; break + case 13: context.approved_13 = productContentAndInfoList; context.time_13 = time; context.date13 = showDate + context.timeStampDate1_13 = timeStampDate1; context.timeStampDate2_13 = timeStampDate2; break + default: context.error = "error" } } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy Wed Nov 2 19:09:13 2016 @@ -17,133 +17,133 @@ * under the License. */ -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.base.util.string.*; -import org.apache.ofbiz.entity.util.EntityUtilProperties; -import org.apache.ofbiz.product.image.ScaleImage; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.base.util.string.* +import org.apache.ofbiz.entity.util.EntityUtilProperties +import org.apache.ofbiz.product.image.ScaleImage import org.apache.ofbiz.entity.condition.* -context.nowTimestampString = UtilDateTime.nowTimestamp().toString(); +context.nowTimestampString = UtilDateTime.nowTimestamp().toString() // make the image file formats -context.tenantId = delegator.getDelegatorTenantId(); -imageFilenameFormat = EntityUtilProperties.getPropertyValue('catalog', 'image.filename.format', delegator); -imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context); -imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), context); -imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath; -imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix; -context.imageFilenameFormat = imageFilenameFormat; -context.imageServerPath = imageServerPath; -context.imageUrlPrefix = imageUrlPrefix; - -filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat); -context.imageNameSmall = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'small' , id : productId]); -context.imageNameMedium = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'medium', id : productId]); -context.imageNameLarge = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'large' , id : productId]); -context.imageNameDetail = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'detail', id : productId]); -context.imageNameOriginal = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'original', id : productId]); +context.tenantId = delegator.getDelegatorTenantId() +imageFilenameFormat = EntityUtilProperties.getPropertyValue('catalog', 'image.filename.format', delegator) +imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context) +imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), context) +imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath +imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix +context.imageFilenameFormat = imageFilenameFormat +context.imageServerPath = imageServerPath +context.imageUrlPrefix = imageUrlPrefix + +filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat) +context.imageNameSmall = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'small' , id : productId]) +context.imageNameMedium = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'medium', id : productId]) +context.imageNameLarge = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'large' , id : productId]) +context.imageNameDetail = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'detail', id : productId]) +context.imageNameOriginal = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', type : 'original', id : productId]) // Start ProductContent stuff -productContent = null; +productContent = null if (product) { - productContent = product.getRelated('ProductContent', null, ['productContentTypeId'], false); + productContent = product.getRelated('ProductContent', null, ['productContentTypeId'], false) } -context.productContent = productContent; +context.productContent = productContent // End ProductContent stuff -tryEntity = true; +tryEntity = true if (request.getAttribute("_ERROR_MESSAGE_")) { - tryEntity = false; + tryEntity = false } if (!product) { - tryEntity = false; + tryEntity = false } if ("true".equalsIgnoreCase((String) request.getParameter("tryEntity"))) { - tryEntity = true; + tryEntity = true } -context.tryEntity = tryEntity; +context.tryEntity = tryEntity // UPLOADING STUFF -forLock = new Object(); -contentType = null; -String fileType = request.getParameter("upload_file_type"); +forLock = new Object() +contentType = null +String fileType = request.getParameter("upload_file_type") if (fileType) { - context.fileType = fileType; + context.fileType = fileType - fileLocation = filenameExpander.expandString([location : 'products', type : fileType, id : productId]); - filePathPrefix = ""; - filenameToUse = fileLocation; + fileLocation = filenameExpander.expandString([location : 'products', type : fileType, id : productId]) + filePathPrefix = "" + filenameToUse = fileLocation if (fileLocation.lastIndexOf("/") != -1) { - filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash - filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1); + filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1) // adding 1 to include the trailing slash + filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1) } - int i1; + int i1 if (contentType && (i1 = contentType.indexOf("boundary=")) != -1) { - contentType = contentType.substring(i1 + 9); - contentType = "--" + contentType; + contentType = contentType.substring(i1 + 9) + contentType = "--" + contentType } - defaultFileName = filenameToUse + "_temp"; - uploadObject = new HttpRequestFileUpload(); - uploadObject.setOverrideFilename(defaultFileName); - uploadObject.setSavePath(imageServerPath + "/" + filePathPrefix); - uploadObject.doUpload(request); + defaultFileName = filenameToUse + "_temp" + uploadObject = new HttpRequestFileUpload() + uploadObject.setOverrideFilename(defaultFileName) + uploadObject.setSavePath(imageServerPath + "/" + filePathPrefix) + uploadObject.doUpload(request) - clientFileName = uploadObject.getFilename(); + clientFileName = uploadObject.getFilename() if (clientFileName) { - context.clientFileName = clientFileName; + context.clientFileName = clientFileName } if (clientFileName && clientFileName.length() > 0) { if (clientFileName.lastIndexOf(".") > 0 && clientFileName.lastIndexOf(".") < clientFileName.length()) { - filenameToUse += clientFileName.substring(clientFileName.lastIndexOf(".")); + filenameToUse += clientFileName.substring(clientFileName.lastIndexOf(".")) } else { - filenameToUse += ".jpg"; + filenameToUse += ".jpg" } - context.clientFileName = clientFileName; - context.filenameToUse = filenameToUse; + context.clientFileName = clientFileName + context.filenameToUse = filenameToUse - characterEncoding = request.getCharacterEncoding(); - imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding); + characterEncoding = request.getCharacterEncoding() + imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding) try { - file = new File(imageServerPath + "/" + filePathPrefix, defaultFileName); - file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse); + file = new File(imageServerPath + "/" + filePathPrefix, defaultFileName) + file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse) try { - file1.delete(); + file1.delete() } catch (Exception e) { - System.out.println("error deleting existing file (not neccessarily a problem)"); + System.out.println("error deleting existing file (not neccessarily a problem)") } - file.renameTo(file1); + file.renameTo(file1) } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace() } if (imageUrl && imageUrl.length() > 0) { - context.imageUrl = imageUrl; - product.set(fileType + "ImageUrl", imageUrl); + context.imageUrl = imageUrl + product.set(fileType + "ImageUrl", imageUrl) // call scaleImageInAllSize if (fileType.equals("original")) { - context.delegator = delegator; - result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0"); + context.delegator = delegator + result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0") if (result.containsKey("responseMessage") && result.get("responseMessage").equals("success")) { - imgMap = result.get("imageUrlMap"); + imgMap = result.get("imageUrlMap") imgMap.each() { key, value -> - product.set(key + "ImageUrl", value); + product.set(key + "ImageUrl", value) } } } - product.store(); + product.store() } } } -context.productFeatures = from("ProductFeature").where("productFeatureTypeId", "SIZE", "productFeatureCategoryId", "IMAGE").queryList(); +context.productFeatures = from("ProductFeature").where("productFeatureTypeId", "SIZE", "productFeatureCategoryId", "IMAGE").queryList() Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SeoLocales.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SeoLocales.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SeoLocales.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SeoLocales.groovy Wed Nov 2 19:09:13 2016 @@ -24,50 +24,50 @@ import org.apache.ofbiz.entity.model.* import javax.servlet.* import javax.servlet.http.* -Locale locale = UtilHttp.getLocale(request); -String serverName = request.getServerName(); -String serverLocal = serverName.substring(serverName.lastIndexOf(".") + 1); +Locale locale = UtilHttp.getLocale(request) +String serverName = request.getServerName() +String serverLocal = serverName.substring(serverName.lastIndexOf(".") + 1) -def nameLocal; -def productTextData; +def nameLocal +def productTextData contentAssocs.each { contentAssoc -> -content = from("Content").where("contentId", contentAssoc.contentIdTo).queryOne(); -localeString = content.localeString; +content = from("Content").where("contentId", contentAssoc.contentIdTo).queryOne() +localeString = content.localeString if (serverLocal == "au") { - nameLocal = "en_AU"; + nameLocal = "en_AU" } else if (serverLocal == "ca") { - nameLocal = "en_CA"; + nameLocal = "en_CA" } else if (serverLocal == "de") { - nameLocal = "de"; + nameLocal = "de" } else if (serverLocal == "ie") { - nameLocal = "en_IE"; + nameLocal = "en_IE" } else if (serverLocal == "fr") { - nameLocal = "fr"; + nameLocal = "fr" } else if (serverLocal == "es") { - nameLocal = "es"; + nameLocal = "es" } else if (serverLocal == "it") { - nameLocal = "it"; + nameLocal = "it" } else if (serverLocal == "uk") { - nameLocal = "en_GB"; + nameLocal = "en_GB" } else if (serverLocal == "sg") { - nameLocal = "en_SG"; + nameLocal = "en_SG" } else { - nameLocal = "en_US"; + nameLocal = "en_US" } if (localeString == nameLocal) { - electronicText = from("ElectronicText").where("dataResourceId", content.dataResourceId).queryOne(); - productTextData = electronicText.textData; + electronicText = from("ElectronicText").where("dataResourceId", content.dataResourceId).queryOne() + productTextData = electronicText.textData } } if (productTextData == null) { - context.productTextData = product.productName; + context.productTextData = product.productName } else { - context.productTextData = productTextData; + context.productTextData = productTextData } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy Wed Nov 2 19:09:13 2016 @@ -17,169 +17,169 @@ * under the License. */ -import java.awt.image.BufferedImage; -import java.awt.image.RenderedImage; -import java.io.File; -import java.util.List; +import java.awt.image.BufferedImage +import java.awt.image.RenderedImage +import java.io.File +import java.util.List -import javax.imageio.ImageIO; +import javax.imageio.ImageIO -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.entity.util.EntityUtilProperties; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.base.util.string.*; -import org.apache.ofbiz.product.image.ScaleImage; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.entity.util.EntityUtilProperties +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.base.util.string.* +import org.apache.ofbiz.product.image.ScaleImage -context.nowTimestampString = UtilDateTime.nowTimestamp().toString(); +context.nowTimestampString = UtilDateTime.nowTimestamp().toString() -imageManagementPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.path", delegator), context); +imageManagementPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.management.path", delegator), context) -String fileType = "original"; -String productId = request.getParameter("productId"); +String fileType = "original" +String productId = request.getParameter("productId") -productContentList = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "DEFAULT_IMAGE").queryList(); +productContentList = from("ProductContentAndInfo").where("productId", productId, "productContentTypeId", "DEFAULT_IMAGE").queryList() if (productContentList) { dataResourceName = productContentList.get(0).drDataResourceName } // make the image file formats -context.tenantId = delegator.getDelegatorTenantId(); -imageFilenameFormat = EntityUtilProperties.getPropertyValue('catalog', 'image.filename.format', delegator); -imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context); -imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), context); -imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath; -imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix; -context.imageFilenameFormat = imageFilenameFormat; -context.imageServerPath = imageServerPath; -context.imageUrlPrefix = imageUrlPrefix; - -filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat); -context.imageNameSmall = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'small']); -context.imageNameMedium = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'medium']); -context.imageNameLarge = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'large']); -context.imageNameDetail = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'detail']); -context.imageNameOriginal = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'original']); +context.tenantId = delegator.getDelegatorTenantId() +imageFilenameFormat = EntityUtilProperties.getPropertyValue('catalog', 'image.filename.format', delegator) +imageServerPath = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.server.path", delegator), context) +imageUrlPrefix = FlexibleStringExpander.expandString(EntityUtilProperties.getPropertyValue("catalog", "image.url.prefix",delegator), context) +imageServerPath = imageServerPath.endsWith("/") ? imageServerPath.substring(0, imageServerPath.length()-1) : imageServerPath +imageUrlPrefix = imageUrlPrefix.endsWith("/") ? imageUrlPrefix.substring(0, imageUrlPrefix.length()-1) : imageUrlPrefix +context.imageFilenameFormat = imageFilenameFormat +context.imageServerPath = imageServerPath +context.imageUrlPrefix = imageUrlPrefix + +filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat) +context.imageNameSmall = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'small']) +context.imageNameMedium = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'medium']) +context.imageNameLarge = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'large']) +context.imageNameDetail = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'detail']) +context.imageNameOriginal = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'original']) // Start ProductContent stuff if (productId) { - product = from("Product").where("productId", productId).queryOne(); - context.productId = productId; + product = from("Product").where("productId", productId).queryOne() + context.productId = productId } -productContent = null; +productContent = null if (product) { - productContent = product.getRelated('ProductContent', null, ['productContentTypeId'], false); + productContent = product.getRelated('ProductContent', null, ['productContentTypeId'], false) } -context.productContent = productContent; +context.productContent = productContent // End ProductContent stuff -tryEntity = true; +tryEntity = true if (request.getAttribute("_ERROR_MESSAGE_")) { - tryEntity = false; + tryEntity = false } if (!product) { - tryEntity = false; + tryEntity = false } if ("true".equalsIgnoreCase((String) request.getParameter("tryEntity"))) { - tryEntity = true; + tryEntity = true } -context.tryEntity = tryEntity; +context.tryEntity = tryEntity //UPLOADING STUFF -forLock = new Object(); -contentType = null; +forLock = new Object() +contentType = null if (fileType) { - context.fileType = fileType; + context.fileType = fileType - fileLocation = filenameExpander.expandString([location : 'products', id : productId, type : fileType]); - filePathPrefix = ""; - filenameToUse = fileLocation; + fileLocation = filenameExpander.expandString([location : 'products', id : productId, type : fileType]) + filePathPrefix = "" + filenameToUse = fileLocation if (fileLocation.lastIndexOf("/") != -1) { - filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash - filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1); + filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1) // adding 1 to include the trailing slash + filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1) } - int i1; + int i1 if (contentType && (i1 = contentType.indexOf("boundary=")) != -1) { - contentType = contentType.substring(i1 + 9); - contentType = "--" + contentType; + contentType = contentType.substring(i1 + 9) + contentType = "--" + contentType } - defaultFileName = "temp_" + dataResourceName; - checkPathFile = imageManagementPath + "/" + productId + "/" + dataResourceName; + defaultFileName = "temp_" + dataResourceName + checkPathFile = imageManagementPath + "/" + productId + "/" + dataResourceName if (checkPathFile.equals(productContentList.get(0).drObjectInfo)) { - BufferedImage bufImg = ImageIO.read(new File(imageManagementPath + "/" + productId + "/" + dataResourceName)); + BufferedImage bufImg = ImageIO.read(new File(imageManagementPath + "/" + productId + "/" + dataResourceName)) } else { - BufferedImage bufImg = ImageIO.read(new File(productContentList.get(0).drObjectInfo)); + BufferedImage bufImg = ImageIO.read(new File(productContentList.get(0).drObjectInfo)) } - ImageIO.write((RenderedImage) bufImg, "jpg", new File(imageManagementPath + "/" + productId + "/" + defaultFileName)); + ImageIO.write((RenderedImage) bufImg, "jpg", new File(imageManagementPath + "/" + productId + "/" + defaultFileName)) - clientFileName = dataResourceName; + clientFileName = dataResourceName if (clientFileName) { - context.clientFileName = clientFileName; + context.clientFileName = clientFileName } if (clientFileName && clientFileName.length() > 0) { if (clientFileName.lastIndexOf(".") > 0 && clientFileName.lastIndexOf(".") < clientFileName.length()) { - filenameToUse += clientFileName.substring(clientFileName.lastIndexOf(".")); + filenameToUse += clientFileName.substring(clientFileName.lastIndexOf(".")) } else { - filenameToUse += ".jpg"; + filenameToUse += ".jpg" } - context.clientFileName = clientFileName; - context.filenameToUse = filenameToUse; + context.clientFileName = clientFileName + context.filenameToUse = filenameToUse - characterEncoding = request.getCharacterEncoding(); - imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding); + characterEncoding = request.getCharacterEncoding() + imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding) try { - file = new File(imageManagementPath + "/" + productId + "/" + defaultFileName); - file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse); + file = new File(imageManagementPath + "/" + productId + "/" + defaultFileName) + file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse) try { // Delete existing image files - File targetDir = new File(imageServerPath + "/" + filePathPrefix); + File targetDir = new File(imageServerPath + "/" + filePathPrefix) // Images are ordered by productId (${location}/${id}/${viewtype}/${sizetype}) if (!filenameToUse.startsWith(productId + ".")) { - File[] files = targetDir.listFiles(); + File[] files = targetDir.listFiles() for(File file : files) { - if (file.isFile() && !file.getName().equals(defaultFileName)) file.delete(); + if (file.isFile() && !file.getName().equals(defaultFileName)) file.delete() } // Images aren't ordered by productId (${location}/${viewtype}/${sizetype}/${id}) !!! BE CAREFUL !!! } else { - File[] files = targetDir.listFiles(); + File[] files = targetDir.listFiles() for(File file : files) { - if (file.isFile() && !file.getName().equals(defaultFileName) && file.getName().startsWith(productId + ".")) file.delete(); + if (file.isFile() && !file.getName().equals(defaultFileName) && file.getName().startsWith(productId + ".")) file.delete() } } } catch (Exception e) { - System.out.println("error deleting existing file (not neccessarily a problem)"); + System.out.println("error deleting existing file (not neccessarily a problem)") } - file.renameTo(file1); + file.renameTo(file1) } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace() } if (imageUrl && imageUrl.length() > 0) { - context.imageUrl = imageUrl; - product.set(fileType + "ImageUrl", imageUrl); + context.imageUrl = imageUrl + product.set(fileType + "ImageUrl", imageUrl) // call scaleImageInAllSize if (fileType.equals("original")) { - context.delegator = delegator; - result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0"); + context.delegator = delegator + result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0") if (result.containsKey("responseMessage") && result.get("responseMessage").equals("success")) { - imgMap = result.get("imageUrlMap"); + imgMap = result.get("imageUrlMap") imgMap.each() { key, value -> - product.set(key + "ImageUrl", value); + product.set(key + "ImageUrl", value) } } } - product.store(); + product.store() } } } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SortSequenceNum.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SortSequenceNum.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SortSequenceNum.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/imagemanagement/SortSequenceNum.groovy Wed Nov 2 19:09:13 2016 @@ -20,12 +20,12 @@ import org.apache.ofbiz.entity.* import org.apache.ofbiz.base.util.* -allSequenceNums = from("ProductContent").where("productId", parameters.productId, "productContentTypeId", "IMAGE").queryList(); -nullSequenceNums = from("ProductContent").where("productId", parameters.productId, "productContentTypeId", "IMAGE", "sequenceNum", null).queryList(); +allSequenceNums = from("ProductContent").where("productId", parameters.productId, "productContentTypeId", "IMAGE").queryList() +nullSequenceNums = from("ProductContent").where("productId", parameters.productId, "productContentTypeId", "IMAGE", "sequenceNum", null).queryList() productContents = allSequenceNums - nullSequenceNums def duplicate = 0 if(parameters.sequenceNum){ - findExisted = from("ProductContent").where("productId", parameters.productId, "productContentTypeId", "IMAGE", "sequenceNum", (Long)parameters.sequenceNum).queryList(); + findExisted = from("ProductContent").where("productId", parameters.productId, "productContentTypeId", "IMAGE", "sequenceNum", (Long)parameters.sequenceNum).queryList() duplicate = findExisted.size() } if(duplicate > 1){ Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/lookup/LookupVariantProduct.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/lookup/LookupVariantProduct.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/lookup/LookupVariantProduct.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/lookup/LookupVariantProduct.groovy Wed Nov 2 19:09:13 2016 @@ -17,60 +17,60 @@ * under the License. */ -import org.apache.ofbiz.base.util.*; +import org.apache.ofbiz.base.util.* -productId = request.getParameter("productId"); -productVariantId = productId + "_"; -productFeatureIds = ""; -product = from("Product").where("productId", productId).queryOne(); - -result = runService('getProductFeaturesByType', [productId : productId, productFeatureApplTypeId : "SELECTABLE_FEATURE"]); -featureTypes = result.productFeatureTypes; -featuresByTypes = result.productFeaturesByType; -searchFeatures = []; -selectedFeatureTypeValues = []; +productId = request.getParameter("productId") +productVariantId = productId + "_" +productFeatureIds = "" +product = from("Product").where("productId", productId).queryOne() + +result = runService('getProductFeaturesByType', [productId : productId, productFeatureApplTypeId : "SELECTABLE_FEATURE"]) +featureTypes = result.productFeatureTypes +featuresByTypes = result.productFeaturesByType +searchFeatures = [] +selectedFeatureTypeValues = [] if (featureTypes) { featureTypes.each { featureType -> - featuresByType = featuresByTypes[featureType]; - featureTypeAndValues = [featureType : featureType, features : featuresByType]; - searchFeatures.add(featureTypeAndValues); + featuresByType = featuresByTypes[featureType] + featureTypeAndValues = [featureType : featureType, features : featuresByType] + searchFeatures.add(featureTypeAndValues) // - selectedFeatureTypeValue = request.getParameter(featureType); + selectedFeatureTypeValue = request.getParameter(featureType) if (selectedFeatureTypeValue) { - featureTypeAndValues.selectedFeatureId = selectedFeatureTypeValue; - selectedFeatureTypeValues.add(selectedFeatureTypeValue); - feature = from("ProductFeature").where("productFeatureId", selectedFeatureTypeValue).cache(true).queryOne(); - productVariantId += feature.getString("idCode") ?: ""; - productFeatureIds += "|" + selectedFeatureTypeValue; + featureTypeAndValues.selectedFeatureId = selectedFeatureTypeValue + selectedFeatureTypeValues.add(selectedFeatureTypeValue) + feature = from("ProductFeature").where("productFeatureId", selectedFeatureTypeValue).cache(true).queryOne() + productVariantId += feature.getString("idCode") ?: "" + productFeatureIds += "|" + selectedFeatureTypeValue } } } -variants = []; - result = runService('getAllExistingVariants', [productId : productId, productFeatureAppls : selectedFeatureTypeValues]); - variants = result.variantProductIds; +variants = [] + result = runService('getAllExistingVariants', [productId : productId, productFeatureAppls : selectedFeatureTypeValues]) + variants = result.variantProductIds // Quick Add Variant -productFeatureIdsPar = request.getParameter("productFeatureIds"); -productVariantIdPar = request.getParameter("productVariantId"); +productFeatureIdsPar = request.getParameter("productFeatureIds") +productVariantIdPar = request.getParameter("productVariantId") if (productVariantIdPar && productFeatureIdsPar) { - result = runService('quickAddVariant', [productId : productId, productFeatureIds : productFeatureIdsPar, productVariantId : productVariantIdPar]); + result = runService('quickAddVariant', [productId : productId, productFeatureIds : productFeatureIdsPar, productVariantId : productVariantIdPar]) } -context.product = product; -context.searchFeatures = searchFeatures; -context.variants = variants; +context.product = product +context.searchFeatures = searchFeatures +context.variants = variants // also need the variant products themselves -variantProducts = []; +variantProducts = [] variants.each { variantId -> - variantProducts.add(from("Product").where("productId", variantId).cache(true).queryOne()); + variantProducts.add(from("Product").where("productId", variantId).cache(true).queryOne()) } -context.variantProducts = variantProducts; +context.variantProducts = variantProducts if (security.hasEntityPermission("CATALOG", "_CREATE", session)) { if (selectedFeatureTypeValues.size() == featureTypes.size() && variants.size() == 0) { - context.productFeatureIds = productFeatureIds; - context.productVariantId = productVariantId; + context.productFeatureIds = productFeatureIds + context.productVariantId = productVariantId } } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/price/EditProductPriceRules.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/price/EditProductPriceRules.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/price/EditProductPriceRules.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/price/EditProductPriceRules.groovy Wed Nov 2 19:09:13 2016 @@ -18,47 +18,47 @@ */ import org.apache.ofbiz.entity.condition.* -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.base.util.UtilMisc; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.base.util.UtilMisc -context.inputParamEnums = from("Enumeration").where("enumTypeId", "PROD_PRICE_IN_PARAM").orderBy("sequenceId").cache(true).queryList(); -context.condOperEnums = from("Enumeration").where("enumTypeId", "PROD_PRICE_COND").orderBy("sequenceId").cache(true).queryList(); -context.productPriceActionTypes = from("ProductPriceActionType").orderBy("description").cache(true).queryList(); +context.inputParamEnums = from("Enumeration").where("enumTypeId", "PROD_PRICE_IN_PARAM").orderBy("sequenceId").cache(true).queryList() +context.condOperEnums = from("Enumeration").where("enumTypeId", "PROD_PRICE_COND").orderBy("sequenceId").cache(true).queryList() +context.productPriceActionTypes = from("ProductPriceActionType").orderBy("description").cache(true).queryList() -String priceRuleId = request.getParameter("productPriceRuleId"); +String priceRuleId = request.getParameter("productPriceRuleId") if (!priceRuleId) { - priceRuleId = parameters.get("productPriceRuleId"); + priceRuleId = parameters.get("productPriceRuleId") } if (priceRuleId) { - productPriceRules = []; - productPriceRules.add(from("ProductPriceRule").where("productPriceRuleId", priceRuleId).queryOne()); - productPriceConds = productPriceRules[0].getRelated("ProductPriceCond", null, ["productPriceCondSeqId"], true); - productPriceActions = productPriceRules[0].getRelated("ProductPriceAction", null, ["productPriceActionSeqId"], true); + productPriceRules = [] + productPriceRules.add(from("ProductPriceRule").where("productPriceRuleId", priceRuleId).queryOne()) + productPriceConds = productPriceRules[0].getRelated("ProductPriceCond", null, ["productPriceCondSeqId"], true) + productPriceActions = productPriceRules[0].getRelated("ProductPriceAction", null, ["productPriceActionSeqId"], true) - productPriceCondAdd = []; - productPriceCondAdd.add(delegator.makeValue("ProductPriceCond")); - productPriceCondAdd[0].productPriceRuleId = priceRuleId; - productPriceCondAdd[0].inputParamEnumId = context.inputParamEnums[0].enumId; - productPriceCondAdd[0].operatorEnumId = context.condOperEnums[0].enumId; + productPriceCondAdd = [] + productPriceCondAdd.add(delegator.makeValue("ProductPriceCond")) + productPriceCondAdd[0].productPriceRuleId = priceRuleId + productPriceCondAdd[0].inputParamEnumId = context.inputParamEnums[0].enumId + productPriceCondAdd[0].operatorEnumId = context.condOperEnums[0].enumId - productPriceActionAdd = []; - productPriceActionAdd.add(delegator.makeValue("ProductPriceAction")); - productPriceActionAdd[0].productPriceRuleId = priceRuleId; - productPriceActionAdd[0].productPriceActionTypeId = context.productPriceActionTypes[0].productPriceActionTypeId; - productPriceActionAdd[0].amount = BigDecimal.ZERO; + productPriceActionAdd = [] + productPriceActionAdd.add(delegator.makeValue("ProductPriceAction")) + productPriceActionAdd[0].productPriceRuleId = priceRuleId + productPriceActionAdd[0].productPriceActionTypeId = context.productPriceActionTypes[0].productPriceActionTypeId + productPriceActionAdd[0].amount = BigDecimal.ZERO - context.productPriceRules = productPriceRules; - context.productPriceConds = productPriceConds; - context.productPriceActions = productPriceActions; - context.productPriceCondAdd = productPriceCondAdd; - context.productPriceActionAdd = productPriceActionAdd; + context.productPriceRules = productPriceRules + context.productPriceConds = productPriceConds + context.productPriceActions = productPriceActions + context.productPriceCondAdd = productPriceCondAdd + context.productPriceActionAdd = productPriceActionAdd } else { - context.productPriceRules = null; - context.productPriceConds = null; - context.productPriceActions = null; - context.productPriceCondsAdd = null; - context.productPriceActionsAdd = null; + context.productPriceRules = null + context.productPriceConds = null + context.productPriceActions = null + context.productPriceCondsAdd = null + context.productPriceActionsAdd = null } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/price/EditProductPriceRules_old.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/price/EditProductPriceRules_old.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/price/EditProductPriceRules_old.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/price/EditProductPriceRules_old.groovy Wed Nov 2 19:09:13 2016 @@ -19,13 +19,13 @@ import org.apache.ofbiz.entity.condition.* -String priceRuleId = request.getParameter("productPriceRuleId"); +String priceRuleId = request.getParameter("productPriceRuleId") if (priceRuleId) { - context.productPriceRule = from("ProductPriceRule").where("productPriceRuleId", priceRuleId).queryOne(); + context.productPriceRule = from("ProductPriceRule").where("productPriceRuleId", priceRuleId).queryOne() } -context.inputParamEnums = from("Enumeration").where("enumTypeId", 'PROD_PRICE_IN_PARAM').orderBy("sequenceId").cache(true).queryList(); +context.inputParamEnums = from("Enumeration").where("enumTypeId", 'PROD_PRICE_IN_PARAM').orderBy("sequenceId").cache(true).queryList() -context.condOperEnums = from("Enumeration").where("enumTypeId", "PROD_PRICE_COND").orderBy("sequenceId").cache(true).queryList(); +context.condOperEnums = from("Enumeration").where("enumTypeId", "PROD_PRICE_COND").orderBy("sequenceId").cache(true).queryList() -context.productPriceActionTypes = from("ProductPriceActionType").orderBy("description").cache(true).queryList(); +context.productPriceActionTypes = from("ProductPriceActionType").orderBy("description").cache(true).queryList() Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/ApplyFeaturesFromCategory.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/ApplyFeaturesFromCategory.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/ApplyFeaturesFromCategory.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/ApplyFeaturesFromCategory.groovy Wed Nov 2 19:09:13 2016 @@ -23,50 +23,50 @@ import org.apache.ofbiz.entity.util.Enti import org.apache.ofbiz.entity.transaction.* import org.apache.ofbiz.base.util.* -module = "ApplyFeaturesFromCategory.groovy"; +module = "ApplyFeaturesFromCategory.groovy" -context.nowTimestampString = UtilDateTime.nowTimestamp().toString(); +context.nowTimestampString = UtilDateTime.nowTimestamp().toString() -productFeatureCategoryId = request.getParameter("productFeatureCategoryId"); -context.productFeatureCategoryId = productFeatureCategoryId; +productFeatureCategoryId = request.getParameter("productFeatureCategoryId") +context.productFeatureCategoryId = productFeatureCategoryId -context.selFeatureApplTypeId = request.getParameter("productFeatureApplTypeId"); +context.selFeatureApplTypeId = request.getParameter("productFeatureApplTypeId") -context.curProductFeatureCategory = from("ProductFeatureCategory").where("productFeatureCategoryId", productFeatureCategoryId).queryOne(); +context.curProductFeatureCategory = from("ProductFeatureCategory").where("productFeatureCategoryId", productFeatureCategoryId).queryOne() -context.productFeatureTypes = from("ProductFeatureType").orderBy("description").queryList(); +context.productFeatureTypes = from("ProductFeatureType").orderBy("description").queryList() -context.productFeatureCategories = from("ProductFeatureCategory").orderBy("description").queryList(); +context.productFeatureCategories = from("ProductFeatureCategory").orderBy("description").queryList() //we only need these if we will be showing the apply feature to category forms if (productId) { - context.productFeatureApplTypes = from("ProductFeatureApplType").orderBy("description").queryList(); + context.productFeatureApplTypes = from("ProductFeatureApplType").orderBy("description").queryList() } -productFeaturesSize = from("ProductFeature").where("productFeatureCategoryId", productFeatureCategoryId).queryCount(); +productFeaturesSize = from("ProductFeature").where("productFeatureCategoryId", productFeatureCategoryId).queryCount() -highIndex = 0; -lowIndex = 0; -listSize = (int) productFeaturesSize; +highIndex = 0 +lowIndex = 0 +listSize = (int) productFeaturesSize if (viewIndex == null) { - viewIndex = 0; + viewIndex = 0 } -lowIndex = viewIndex * viewSize; -highIndex = (viewIndex + 1) * viewSize; +lowIndex = viewIndex * viewSize +highIndex = (viewIndex + 1) * viewSize if (listSize < highIndex) { - highIndex = listSize; + highIndex = listSize } -context.viewIndex = viewIndex; -context.viewSize = viewSize; -context.listSize = listSize; -context.lowIndex = lowIndex; -context.highIndex = highIndex; +context.viewIndex = viewIndex +context.viewSize = viewSize +context.listSize = listSize +context.lowIndex = lowIndex +context.highIndex = highIndex -boolean beganTransaction = false; +boolean beganTransaction = false try { - beganTransaction = TransactionUtil.begin(); + beganTransaction = TransactionUtil.begin() productFeaturesEli = from("ProductFeature") .where("productFeatureCategoryId", productFeatureCategoryId) @@ -74,38 +74,38 @@ try { .distinct() .cursorScrollInsensitive() .maxRows(highIndex) - .queryIterator(); - productFeatures = productFeaturesEli.getPartialList(lowIndex + 1, highIndex - lowIndex); - productFeaturesEli.close(); + .queryIterator() + productFeatures = productFeaturesEli.getPartialList(lowIndex + 1, highIndex - lowIndex) + productFeaturesEli.close() } catch (GenericEntityException e) { - String errMsg = "Failure in operation, rolling back transaction"; - Debug.logError(e, errMsg, module); + String errMsg = "Failure in operation, rolling back transaction" + Debug.logError(e, errMsg, module) try { // only rollback the transaction if we started one... - TransactionUtil.rollback(beganTransaction, errMsg, e); + TransactionUtil.rollback(beganTransaction, errMsg, e) } catch (GenericEntityException e2) { - Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), module); + Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), module) } // after rolling back, rethrow the exception - throw e; + throw e } finally { // only commit the transaction if we started one... this will throw an exception if it fails - TransactionUtil.commit(beganTransaction); + TransactionUtil.commit(beganTransaction) } -context.productFeatures = productFeatures; +context.productFeatures = productFeatures -productFeatureApplMap = [:]; -productFeatureAppls = null; -productFeatureIter = productFeatures.iterator(); -productFeatureApplIter = null; +productFeatureApplMap = [:] +productFeatureAppls = null +productFeatureIter = productFeatures.iterator() +productFeatureApplIter = null while (productFeatureIter) { - productFeature = productFeatureIter.next(); - productFeatureAppls = from("ProductFeatureAppl").where("productId", productId, "productFeatureId", productFeature.productFeatureId).queryList(); - productFeatureApplIter = productFeatureAppls.iterator(); + productFeature = productFeatureIter.next() + productFeatureAppls = from("ProductFeatureAppl").where("productId", productId, "productFeatureId", productFeature.productFeatureId).queryList() + productFeatureApplIter = productFeatureAppls.iterator() while (productFeatureApplIter) { - productFeatureAppl = productFeatureApplIter.next(); - productFeatureApplMap.put(productFeatureAppl.productFeatureId, productFeatureAppl.productFeatureApplTypeId); + productFeatureAppl = productFeatureApplIter.next() + productFeatureApplMap.put(productFeatureAppl.productFeatureId, productFeatureAppl.productFeatureApplTypeId) } } -context.productFeatureApplMap = productFeatureApplMap; +context.productFeatureApplMap = productFeatureApplMap Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/ApplyFeaturesFromGroup.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/ApplyFeaturesFromGroup.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/ApplyFeaturesFromGroup.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/ApplyFeaturesFromGroup.groovy Wed Nov 2 19:09:13 2016 @@ -24,21 +24,21 @@ import org.apache.ofbiz.entity.* -productFeatureGroupId = parameters.get("productFeatureGroupId"); +productFeatureGroupId = parameters.get("productFeatureGroupId") if (productFeatureGroupId) { - productFeatureGroup = from("ProductFeatureGroup").where("productFeatureGroupId", productFeatureGroupId).queryOne(); - productFeatures = []; - productFeatureGroupAppls = productFeatureGroup.getRelated("ProductFeatureGroupAppl", null, ['sequenceNum'], false); + productFeatureGroup = from("ProductFeatureGroup").where("productFeatureGroupId", productFeatureGroupId).queryOne() + productFeatures = [] + productFeatureGroupAppls = productFeatureGroup.getRelated("ProductFeatureGroupAppl", null, ['sequenceNum'], false) for (pFGAi = productFeatureGroupAppls.iterator(); pFGAi;) { - productFeatureGroupAppl = (GenericEntity)pFGAi.next(); - productFeature = (GenericEntity)productFeatureGroupAppl.getRelatedOne("ProductFeature", false); - productFeature.set("defaultSequenceNum", productFeatureGroupAppl.getLong("sequenceNum")); - productFeatures.add(productFeature); + productFeatureGroupAppl = (GenericEntity)pFGAi.next() + productFeature = (GenericEntity)productFeatureGroupAppl.getRelatedOne("ProductFeature", false) + productFeature.set("defaultSequenceNum", productFeatureGroupAppl.getLong("sequenceNum")) + productFeatures.add(productFeature) } - context.productFeatureGroup = productFeatureGroup; - context.productFeatures = productFeatures; + context.productFeatureGroup = productFeatureGroup + context.productFeatures = productFeatures // this will not break out the product features by view size - context.listSize = productFeatures.size(); - context.highIndex = productFeatures.size(); + context.listSize = productFeatures.size() + context.highIndex = productFeatures.size() } |
Free forum by Nabble | Edit this page |