Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/BestProducts.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/BestProducts.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/BestProducts.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/BestProducts.groovy Wed Nov 2 19:09:13 2016 @@ -17,88 +17,88 @@ * under the License. */ -import org.apache.ofbiz.base.util.UtilDateTime; -import org.apache.ofbiz.entity.condition.EntityCondition; -import org.apache.ofbiz.entity.condition.EntityOperator; -import org.apache.ofbiz.product.product.ProductContentWrapper; - -bestSellingProducts = []; -exprList = []; -exprList.add(EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, UtilDateTime.getDayStart(filterDate))); -exprList.add(EntityCondition.makeCondition("orderDate", EntityOperator.LESS_THAN_EQUAL_TO, UtilDateTime.getDayEnd(filterDate))); -exprList.add(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER")); -exprList.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED")); +import org.apache.ofbiz.base.util.UtilDateTime +import org.apache.ofbiz.entity.condition.EntityCondition +import org.apache.ofbiz.entity.condition.EntityOperator +import org.apache.ofbiz.product.product.ProductContentWrapper + +bestSellingProducts = [] +exprList = [] +exprList.add(EntityCondition.makeCondition("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, UtilDateTime.getDayStart(filterDate))) +exprList.add(EntityCondition.makeCondition("orderDate", EntityOperator.LESS_THAN_EQUAL_TO, UtilDateTime.getDayEnd(filterDate))) +exprList.add(EntityCondition.makeCondition("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER")) +exprList.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED")) -orderHeaderList = from("OrderHeader").where(exprList).queryList(); +orderHeaderList = from("OrderHeader").where(exprList).queryList() orderHeaderList.each { orderHeader -> - exprList.clear(); - exprList.add(EntityCondition.makeCondition("orderId", orderHeader.orderId)); - exprList.add(EntityCondition.makeCondition("orderItemTypeId", "PRODUCT_ORDER_ITEM")); - exprList.add(EntityCondition.makeCondition("isPromo", "N")); - exprList.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED")); + exprList.clear() + exprList.add(EntityCondition.makeCondition("orderId", orderHeader.orderId)) + exprList.add(EntityCondition.makeCondition("orderItemTypeId", "PRODUCT_ORDER_ITEM")) + exprList.add(EntityCondition.makeCondition("isPromo", "N")) + exprList.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED")) - orderItemList = from("OrderItem").where(exprList).queryList(); + orderItemList = from("OrderItem").where(exprList).queryList() orderItemList.each { orderItem -> - orderItemDetail = [:]; - qtyOrdered = BigDecimal.ZERO; - qtyOrdered += orderItem.quantity; + orderItemDetail = [:] + qtyOrdered = BigDecimal.ZERO + qtyOrdered += orderItem.quantity if (orderItem.cancelQuantity) { - qtyOrdered -= orderItem.cancelQuantity; + qtyOrdered -= orderItem.cancelQuantity } - amount = BigDecimal.ZERO;; - amount = qtyOrdered * orderItem.unitPrice; + amount = BigDecimal.ZERO + amount = qtyOrdered * orderItem.unitPrice inListFlag = false bestSellingProducts.each { bestSellingProduct -> if ((bestSellingProduct.productId).equals(orderItem.productId) && (bestSellingProduct.currencyUom).equals(orderHeader.currencyUom)) { - inListFlag = true; - bestSellingProduct.amount += amount; - bestSellingProduct.qtyOrdered += qtyOrdered; + inListFlag = true + bestSellingProduct.amount += amount + bestSellingProduct.qtyOrdered += qtyOrdered } } if (inListFlag == false) { - orderItemDetail.productId = orderItem.productId; + orderItemDetail.productId = orderItem.productId product = from("Product").where("productId", orderItem.productId).queryOne() - contentWrapper = new ProductContentWrapper(product, request); - orderItemDetail.productName = contentWrapper.get("PRODUCT_NAME", "html"); - orderItemDetail.amount = amount; - orderItemDetail.qtyOrdered = qtyOrdered; - orderItemDetail.currencyUom = orderHeader.currencyUom; - bestSellingProducts.add(orderItemDetail); + contentWrapper = new ProductContentWrapper(product, request) + orderItemDetail.productName = contentWrapper.get("PRODUCT_NAME", "html") + orderItemDetail.amount = amount + orderItemDetail.qtyOrdered = qtyOrdered + orderItemDetail.currencyUom = orderHeader.currencyUom + bestSellingProducts.add(orderItemDetail) } } } // Sorting List -topSellingProducts = []; -itr = 1; +topSellingProducts = [] +itr = 1 while (itr <= 5) { - orderItemDetail = [:]; + orderItemDetail = [:] bestSellingProducts.each { bestSellingProduct -> if (!(orderItemDetail.isEmpty())) { if (bestSellingProduct.qtyOrdered > orderItemDetail.qtyOrdered) { - orderItemDetail = bestSellingProduct; + orderItemDetail = bestSellingProduct } if (bestSellingProduct.qtyOrdered == orderItemDetail.qtyOrdered && bestSellingProduct.amount > orderItemDetail.amount) { - orderItemDetail = bestSellingProduct; + orderItemDetail = bestSellingProduct } } else { - orderItemDetail = bestSellingProduct; + orderItemDetail = bestSellingProduct } } if (!orderItemDetail.isEmpty()) { if (orderItemDetail.amount) { - orderItemDetail.amount = orderItemDetail.amount.setScale(2, BigDecimal.ROUND_HALF_UP); + orderItemDetail.amount = orderItemDetail.amount.setScale(2, BigDecimal.ROUND_HALF_UP) } - topSellingProducts.add(orderItemDetail); - bestSellingProducts.remove(orderItemDetail); + topSellingProducts.add(orderItemDetail) + bestSellingProducts.remove(orderItemDetail) } - itr++; + itr++ } -context.bestSellingProducts = topSellingProducts; +context.bestSellingProducts = topSellingProducts -context.now = UtilDateTime.toDateString(UtilDateTime.nowDate()); +context.now = UtilDateTime.toDateString(UtilDateTime.nowDate()) Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductAssoc.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductAssoc.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductAssoc.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductAssoc.groovy Wed Nov 2 19:09:13 2016 @@ -20,22 +20,22 @@ import org.apache.ofbiz.entity.* import org.apache.ofbiz.base.util.* -uiLabelMap = UtilProperties.getResourceBundleMap("ProductUiLabels", locale); +uiLabelMap = UtilProperties.getResourceBundleMap("ProductUiLabels", locale) -product = from("Product").where("productId", parameters.productId).queryOne(); +product = from("Product").where("productId", parameters.productId).queryOne() -fromDate = UtilDateTime.nowTimestamp(); +fromDate = UtilDateTime.nowTimestamp() if (UtilValidate.isNotEmpty(parameters.fromDate)) { - fromDate = ObjectType.simpleTypeConvert(parameters.fromDate, "Timestamp", null, timeZone, locale, false); + fromDate = ObjectType.simpleTypeConvert(parameters.fromDate, "Timestamp", null, timeZone, locale, false) } -productAssoc = from("ProductAssoc").where("productId", parameters.productId, "productIdTo", parameters.productIdTo, "productAssocTypeId", parameters.productAssocTypeId, "fromDate", fromDate).queryOne(); -context.productAssoc = productAssoc; +productAssoc = from("ProductAssoc").where("productId", parameters.productId, "productIdTo", parameters.productIdTo, "productAssocTypeId", parameters.productAssocTypeId, "fromDate", fromDate).queryOne() +context.productAssoc = productAssoc if (product) { - assocFromProducts = product.getRelated("MainProductAssoc", null, ['sequenceNum'], false); - assocToProducts = product.getRelated("AssocProductAssoc", null, null, false); - assocFromMap = ["assocProducts" : assocFromProducts, "sectionTitle" : uiLabelMap.ProductAssociationsFromProduct]; - assocToMap = ["assocProducts" : assocToProducts, "sectionTitle" : uiLabelMap.ProductAssociationsToProduct]; - context.assocSections = [assocFromMap, assocToMap]; + assocFromProducts = product.getRelated("MainProductAssoc", null, ['sequenceNum'], false) + assocToProducts = product.getRelated("AssocProductAssoc", null, null, false) + assocFromMap = ["assocProducts" : assocFromProducts, "sectionTitle" : uiLabelMap.ProductAssociationsFromProduct] + assocToMap = ["assocProducts" : assocToProducts, "sectionTitle" : uiLabelMap.ProductAssociationsToProduct] + context.assocSections = [assocFromMap, assocToMap] } \ No newline at end of file Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductContent.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductContent.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductContent.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductContent.groovy Wed Nov 2 19:09:13 2016 @@ -17,148 +17,148 @@ * 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 -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', 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 -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', 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 = 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 { // 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().contains(filenameToUse.substring(0, filenameToUse.indexOf(".")+1)) && !fileType.equals("original")) { - file.delete(); + file.delete() } else if(file.isFile() && fileType.equals("original") && !file.getName().equals(defaultFileName)) { - file.delete(); + 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/product/EditProductContentContent.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductContentContent.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductContentContent.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductContentContent.groovy Wed Nov 2 19:09:13 2016 @@ -17,132 +17,132 @@ * under the License. */ -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.*; -import org.apache.ofbiz.base.util.*; -import java.sql.Timestamp; +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.* +import org.apache.ofbiz.base.util.* +import java.sql.Timestamp import org.apache.ofbiz.base.util.ObjectType -contentId = parameters.contentId; +contentId = parameters.contentId if (!contentId) { - contentId = null; + contentId = null } -productContentTypeId = parameters.productContentTypeId; +productContentTypeId = parameters.productContentTypeId -fromDate = parameters.fromDate; +fromDate = parameters.fromDate if (!fromDate) { - fromDate = null; + fromDate = null } else { fromDate = ObjectType.simpleTypeConvert(fromDate, "Timestamp", null, null, false) } -description = parameters.description; +description = parameters.description if (!description) { - description = null; + description = null } -productContent = from("ProductContent").where("contentId", contentId, "productId", productId, "productContentTypeId", productContentTypeId, "fromDate", fromDate).queryOne(); +productContent = from("ProductContent").where("contentId", contentId, "productId", productId, "productContentTypeId", productContentTypeId, "fromDate", fromDate).queryOne() if (!productContent) { - productContent = [:]; - productContent.productId = productId; - productContent.contentId = contentId; - productContent.productContentTypeId = productContentTypeId; - productContent.fromDate = fromDate; - productContent.thruDate = parameters.thruDate; - productContent.purchaseFromDate = parameters.purchaseFromDate; - productContent.purchaseThruDate = parameters.purchaseThruDate; - productContent.useCountLimit = parameters.useCountLimit; - productContent.useTime = parameters.useTime; - productContent.useTimeUomId = parameters.useTimeUomId; - productContent.useRoleTypeId = parameters.useRoleTypeId; + productContent = [:] + productContent.productId = productId + productContent.contentId = contentId + productContent.productContentTypeId = productContentTypeId + productContent.fromDate = fromDate + productContent.thruDate = parameters.thruDate + productContent.purchaseFromDate = parameters.purchaseFromDate + productContent.purchaseThruDate = parameters.purchaseThruDate + productContent.useCountLimit = parameters.useCountLimit + productContent.useTime = parameters.useTime + productContent.useTimeUomId = parameters.useTimeUomId + productContent.useRoleTypeId = parameters.useRoleTypeId } -context.productContent = productContent; +context.productContent = productContent -productContentData = [:]; -productContentData.putAll(productContent); +productContentData = [:] +productContentData.putAll(productContent) -content = [:]; -context.contentId = contentId; +content = [:] +context.contentId = contentId if (contentId) { - content = from("Content").where("contentId", contentId).queryOne(); - context.content = content; + content = from("Content").where("contentId", contentId).queryOne() + context.content = content } else { if (description) { - content.description = description; + content.description = description } } if ("FULFILLMENT_EMAIL".equals(productContentTypeId)) { - emailData = [:]; + emailData = [:] if (contentId && content) { - subjectDr = content.getRelatedOne("DataResource", false); + subjectDr = content.getRelatedOne("DataResource", false) if (subjectDr) { - subject = subjectDr.getRelatedOne("ElectronicText", false); - emailData.subject = subject.textData; - emailData.subjectDataResourceId = subject.dataResourceId; + subject = subjectDr.getRelatedOne("ElectronicText", false) + emailData.subject = subject.textData + emailData.subjectDataResourceId = subject.dataResourceId } - result = runService('findAssocContent', [userLogin : userLogin, contentId : contentId, mapKeys : ['plainBody', 'htmlBody']]); - contentAssocs = result.get("contentAssocs"); + result = runService('findAssocContent', [userLogin : userLogin, contentId : contentId, mapKeys : ['plainBody', 'htmlBody']]) + contentAssocs = result.get("contentAssocs") if (contentAssocs) { contentAssocs.each { contentAssoc -> - bodyContent = contentAssoc.getRelatedOne("ToContent", false); - bodyDr = bodyContent.getRelatedOne("DataResource", false); - body = bodyDr.getRelatedOne("ElectronicText", false); - emailData.put(contentAssoc.mapKey, body.textData); - emailData.put(contentAssoc.get("mapKey")+"DataResourceId", body.dataResourceId); + bodyContent = contentAssoc.getRelatedOne("ToContent", false) + bodyDr = bodyContent.getRelatedOne("DataResource", false) + body = bodyDr.getRelatedOne("ElectronicText", false) + emailData.put(contentAssoc.mapKey, body.textData) + emailData.put(contentAssoc.get("mapKey")+"DataResourceId", body.dataResourceId) } } } - context.contentFormName = "EditProductContentEmail"; - context.emailData = emailData; + context.contentFormName = "EditProductContentEmail" + context.emailData = emailData } else if ("DIGITAL_DOWNLOAD".equals(productContentTypeId)) { - downloadData = [:]; + downloadData = [:] if (contentId && content) { - downloadDr = content.getRelatedOne("DataResource", false); + downloadDr = content.getRelatedOne("DataResource", false) if (downloadDr) { - download = downloadDr.getRelatedOne("OtherDataResource", false); + download = downloadDr.getRelatedOne("OtherDataResource", false) if (download) { - downloadData.file = download.dataResourceContent; - downloadData.fileDataResourceId = download.dataResourceId; + downloadData.file = download.dataResourceContent + downloadData.fileDataResourceId = download.dataResourceId } } } - context.contentFormName = "EditProductContentDownload"; - context.downloadData = downloadData; + context.contentFormName = "EditProductContentDownload" + context.downloadData = downloadData } else if ("FULFILLMENT_EXTERNAL".equals(productContentTypeId)) { - context.contentFormName = "EditProductContentExternal"; + context.contentFormName = "EditProductContentExternal" } else if (productContentTypeId && productContentTypeId.indexOf("_IMAGE") > -1) { - context.contentFormName = "EditProductContentImage"; + context.contentFormName = "EditProductContentImage" } else { //Assume it is a generic simple text content - textData = [:]; + textData = [:] if (contentId && content) { - textDr = content.getRelatedOne("DataResource", false); + textDr = content.getRelatedOne("DataResource", false) if (textDr) { - text = textDr.getRelatedOne("ElectronicText", false); + text = textDr.getRelatedOne("ElectronicText", false) if (text) { - textData.text = text.textData; - textData.textDataResourceId = text.dataResourceId; + textData.text = text.textData + textData.textDataResourceId = text.dataResourceId } } } - context.contentFormName = "EditProductContentSimpleText"; - context.textData = textData; + context.contentFormName = "EditProductContentSimpleText" + context.textData = textData } if (productContentTypeId) { - productContentType = from("ProductContentType").where("productContentTypeId", productContentTypeId).queryOne(); + productContentType = from("ProductContentType").where("productContentTypeId", productContentTypeId).queryOne() if (productContentType && "DIGITAL_DOWNLOAD".equals(productContentType.parentTypeId)) { - context.contentFormName = "EditProductContentDownload"; + context.contentFormName = "EditProductContentDownload" } } if (("PAGE_TITLE".equals(productContentTypeId))||("META_KEYWORD".equals(productContentTypeId))||("META_DESCRIPTION".equals(productContentTypeId))) { - context.contentFormName = "EditProductContentSEO"; + context.contentFormName = "EditProductContentSEO" } -context.productContentData = productContentData; -context.content = content; -context.contentId = contentId; +context.productContentData = productContentData +context.content = content +context.contentId = contentId Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductFeatures.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductFeatures.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductFeatures.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductFeatures.groovy Wed Nov 2 19:09:13 2016 @@ -17,14 +17,14 @@ * under the License. */ -import org.apache.ofbiz.entity.condition.*; +import org.apache.ofbiz.entity.condition.* -context.productFeatureAndAppls = from("ProductFeatureAndAppl").where("productId", productId).orderBy("sequenceNum", "productFeatureApplTypeId", "productFeatureTypeId", "description").queryList(); +context.productFeatureAndAppls = from("ProductFeatureAndAppl").where("productId", productId).orderBy("sequenceNum", "productFeatureApplTypeId", "productFeatureTypeId", "description").queryList() -context.productFeatureCategories = from("ProductFeatureCategory").orderBy("description").queryList(); +context.productFeatureCategories = from("ProductFeatureCategory").orderBy("description").queryList() -context.productFeatureApplTypes = from("ProductFeatureApplType").orderBy("description").cache(true).queryList(); +context.productFeatureApplTypes = from("ProductFeatureApplType").orderBy("description").cache(true).queryList() -context.productFeatureGroups = from("ProductFeatureGroup").orderBy("description").queryList(); +context.productFeatureGroups = from("ProductFeatureGroup").orderBy("description").queryList() -context.productFeatureTypes = from("ProductFeatureType").orderBy("description").queryList(); +context.productFeatureTypes = from("ProductFeatureType").orderBy("description").queryList() Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductInventoryItems.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductInventoryItems.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductInventoryItems.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductInventoryItems.groovy Wed Nov 2 19:09:13 2016 @@ -22,142 +22,142 @@ import org.apache.ofbiz.entity.util.Enti import org.apache.ofbiz.product.inventory.InventoryWorker if (product) { - boolean isMarketingPackage = EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG"); - context.isMarketingPackage = (isMarketingPackage? "true": "false"); + boolean isMarketingPackage = EntityTypeUtil.hasParentType(delegator, "ProductType", "productTypeId", product.productTypeId, "parentTypeId", "MARKETING_PKG") + context.isMarketingPackage = (isMarketingPackage? "true": "false") //If product is virtual gather summary data from variants if (product.isVirtual && "Y".equals(product.isVirtual)) { //Get the virtual product feature types - result = runService('getProductFeaturesByType', [productId : productId, productFeatureApplTypeId : 'SELECTABLE_FEATURE']); - featureTypeIds = result.productFeatureTypes; + result = runService('getProductFeaturesByType', [productId : productId, productFeatureApplTypeId : 'SELECTABLE_FEATURE']) + featureTypeIds = result.productFeatureTypes //Get the variants - result = runService('getAllProductVariants', [productId : productId]); - variants = result.assocProducts; - variantIterator = variants.iterator(); - variantInventorySummaries = []; + result = runService('getAllProductVariants', [productId : productId]) + variants = result.assocProducts + variantIterator = variants.iterator() + variantInventorySummaries = [] while (variantIterator) { - variant = variantIterator.next(); + variant = variantIterator.next() //create a map of each variant id and inventory summary (all facilities) - inventoryAvailable = runService('getProductInventoryAvailable', [productId : variant.productIdTo]); + inventoryAvailable = runService('getProductInventoryAvailable', [productId : variant.productIdTo]) variantInventorySummary = [productId : variant.productIdTo, availableToPromiseTotal : inventoryAvailable.availableToPromiseTotal, - quantityOnHandTotal : inventoryAvailable.quantityOnHandTotal]; + quantityOnHandTotal : inventoryAvailable.quantityOnHandTotal] //add the applicable features to the map - featureTypeIdsIterator = featureTypeIds.iterator(); + featureTypeIdsIterator = featureTypeIds.iterator() while (featureTypeIdsIterator) { - featureTypeId = featureTypeIdsIterator.next(); - result = runService('getProductFeatures', [productId : variant.productIdTo, type : 'STANDARD_FEATURE', distinct : featureTypeId]); - variantFeatures = result.productFeatures; + featureTypeId = featureTypeIdsIterator.next() + result = runService('getProductFeatures', [productId : variant.productIdTo, type : 'STANDARD_FEATURE', distinct : featureTypeId]) + variantFeatures = result.productFeatures if (variantFeatures) { //there should only be one result in this collection - variantInventorySummary.put(featureTypeId, variantFeatures.get(0)); + variantInventorySummary.put(featureTypeId, variantFeatures.get(0)) } } - variantInventorySummaries.add(variantInventorySummary); + variantInventorySummaries.add(variantInventorySummary) } - context.featureTypeIds = featureTypeIds; - context.variantInventorySummaries = variantInventorySummaries; + context.featureTypeIds = featureTypeIds + context.variantInventorySummaries = variantInventorySummaries } else { //Gather information for a non virtual product - quantitySummaryByFacility = [:]; - manufacturingInQuantitySummaryByFacility = [:]; - manufacturingOutQuantitySummaryByFacility = [:]; + quantitySummaryByFacility = [:] + manufacturingInQuantitySummaryByFacility = [:] + manufacturingOutQuantitySummaryByFacility = [:] // The warehouse list is selected - showAllFacilities = parameters.showAllFacilities; + showAllFacilities = parameters.showAllFacilities if (showAllFacilities && "Y".equals(showAllFacilities)) { - facilityList = from("Facility").queryList(); + facilityList = from("Facility").queryList() } else { - facilityList = from("ProductFacility").where("productId", productId).queryList(); + facilityList = from("ProductFacility").where("productId", productId).queryList() } - facilityIterator = facilityList.iterator(); - dispatcher = request.getAttribute("dispatcher"); - Map contextInput = null; - Map resultOutput = null; + facilityIterator = facilityList.iterator() + dispatcher = request.getAttribute("dispatcher") + Map contextInput = null + Map resultOutput = null // inventory quantity summary by facility: For every warehouse the product's atp and qoh // are obtained (calling the "getInventoryAvailableByFacility" service) while (facilityIterator) { - facility = facilityIterator.next(); - resultOutput = runService('getInventoryAvailableByFacility', [productId : productId, facilityId : facility.facilityId]); + facility = facilityIterator.next() + resultOutput = runService('getInventoryAvailableByFacility', [productId : productId, facilityId : facility.facilityId]) - quantitySummary = [:]; - quantitySummary.facilityId = facility.facilityId; - quantitySummary.totalQuantityOnHand = resultOutput.quantityOnHandTotal; - quantitySummary.totalAvailableToPromise = resultOutput.availableToPromiseTotal; + quantitySummary = [:] + quantitySummary.facilityId = facility.facilityId + quantitySummary.totalQuantityOnHand = resultOutput.quantityOnHandTotal + quantitySummary.totalAvailableToPromise = resultOutput.availableToPromiseTotal // if the product is a MARKETING_PKG_AUTO/PICK, then also get the quantity which can be produced from components if (isMarketingPackage) { - resultOutput = runService('getMktgPackagesAvailable', [productId : productId, facilityId : facility.facilityId]); - quantitySummary.mktgPkgQOH = resultOutput.quantityOnHandTotal; - quantitySummary.mktgPkgATP = resultOutput.availableToPromiseTotal; + resultOutput = runService('getMktgPackagesAvailable', [productId : productId, facilityId : facility.facilityId]) + quantitySummary.mktgPkgQOH = resultOutput.quantityOnHandTotal + quantitySummary.mktgPkgATP = resultOutput.availableToPromiseTotal } - quantitySummaryByFacility.put(facility.facilityId, quantitySummary); + quantitySummaryByFacility.put(facility.facilityId, quantitySummary) } - productInventoryItems = from("InventoryItem").where("productId", productId).orderBy("facilityId", "-datetimeReceived", "-inventoryItemId").queryList(); + productInventoryItems = from("InventoryItem").where("productId", productId).orderBy("facilityId", "-datetimeReceived", "-inventoryItemId").queryList() // TODO: get all incoming shipments not yet arrived coming into each facility that this product is in, use a view entity with ShipmentAndItem - findIncomingShipmentsConds = []; + findIncomingShipmentsConds = [] - findIncomingShipmentsConds.add(EntityCondition.makeCondition('productId', EntityOperator.EQUALS, productId)); + findIncomingShipmentsConds.add(EntityCondition.makeCondition('productId', EntityOperator.EQUALS, productId)) - findIncomingShipmentsTypeConds = []; - findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "INCOMING_SHIPMENT")); - findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "PURCHASE_SHIPMENT")); - findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "SALES_RETURN")); - findIncomingShipmentsConds.add(EntityCondition.makeCondition(findIncomingShipmentsTypeConds, EntityOperator.OR)); - - findIncomingShipmentsStatusConds = []; - findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_DELIVERED")); - findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_CANCELLED")); - findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PURCH_SHIP_RECEIVED")); - findIncomingShipmentsConds.add(EntityCondition.makeCondition(findIncomingShipmentsStatusConds, EntityOperator.AND)); - - findIncomingShipmentsStatusCondition = EntityCondition.makeCondition(findIncomingShipmentsConds, EntityOperator.AND); - incomingShipmentAndItems = from("ShipmentAndItem").where(findIncomingShipmentsStatusCondition).orderBy("-estimatedArrivalDate").queryList(); - incomingShipmentAndItemIter = incomingShipmentAndItems.iterator(); + findIncomingShipmentsTypeConds = [] + findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "INCOMING_SHIPMENT")) + findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "PURCHASE_SHIPMENT")) + findIncomingShipmentsTypeConds.add(EntityCondition.makeCondition("shipmentTypeId", EntityOperator.EQUALS, "SALES_RETURN")) + findIncomingShipmentsConds.add(EntityCondition.makeCondition(findIncomingShipmentsTypeConds, EntityOperator.OR)) + + findIncomingShipmentsStatusConds = [] + findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_DELIVERED")) + findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_CANCELLED")) + findIncomingShipmentsStatusConds.add(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PURCH_SHIP_RECEIVED")) + findIncomingShipmentsConds.add(EntityCondition.makeCondition(findIncomingShipmentsStatusConds, EntityOperator.AND)) + + findIncomingShipmentsStatusCondition = EntityCondition.makeCondition(findIncomingShipmentsConds, EntityOperator.AND) + incomingShipmentAndItems = from("ShipmentAndItem").where(findIncomingShipmentsStatusCondition).orderBy("-estimatedArrivalDate").queryList() + incomingShipmentAndItemIter = incomingShipmentAndItems.iterator() while (incomingShipmentAndItemIter) { - incomingShipmentAndItem = incomingShipmentAndItemIter.next(); - facilityId = incomingShipmentAndItem.destinationFacilityId; + incomingShipmentAndItem = incomingShipmentAndItemIter.next() + facilityId = incomingShipmentAndItem.destinationFacilityId - quantitySummary = quantitySummaryByFacility.get(facilityId); + quantitySummary = quantitySummaryByFacility.get(facilityId) if (!quantitySummary) { - quantitySummary = [:]; - quantitySummary.facilityId = facilityId; - quantitySummaryByFacility.facilityId = quantitySummary; + quantitySummary = [:] + quantitySummary.facilityId = facilityId + quantitySummaryByFacility.facilityId = quantitySummary } - incomingShipmentAndItemList = quantitySummary.incomingShipmentAndItemList; + incomingShipmentAndItemList = quantitySummary.incomingShipmentAndItemList if (!incomingShipmentAndItemList) { - incomingShipmentAndItemList = []; - quantitySummary.incomingShipmentAndItemList = incomingShipmentAndItemList; + incomingShipmentAndItemList = [] + quantitySummary.incomingShipmentAndItemList = incomingShipmentAndItemList } - incomingShipmentAndItemList.add(incomingShipmentAndItem); + incomingShipmentAndItemList.add(incomingShipmentAndItem) } // -------------------- // Production Runs resultOutput = runService('getProductManufacturingSummaryByFacility', - [productId : productId, userLogin : userLogin]); + [productId : productId, userLogin : userLogin]) // incoming products - manufacturingInQuantitySummaryByFacility = resultOutput.summaryInByFacility; + manufacturingInQuantitySummaryByFacility = resultOutput.summaryInByFacility // outgoing products (materials) - manufacturingOutQuantitySummaryByFacility = resultOutput.summaryOutByFacility; + manufacturingOutQuantitySummaryByFacility = resultOutput.summaryOutByFacility - showEmpty = "true".equals(request.getParameter("showEmpty")); + showEmpty = "true".equals(request.getParameter("showEmpty")) // Find oustanding purchase orders for this item. - purchaseOrders = InventoryWorker.getOutstandingPurchaseOrders(productId, delegator); + purchaseOrders = InventoryWorker.getOutstandingPurchaseOrders(productId, delegator) - context.productInventoryItems = productInventoryItems; - context.quantitySummaryByFacility = quantitySummaryByFacility; - context.manufacturingInQuantitySummaryByFacility = manufacturingInQuantitySummaryByFacility; - context.manufacturingOutQuantitySummaryByFacility = manufacturingOutQuantitySummaryByFacility; - context.showEmpty = showEmpty; - context.purchaseOrders = purchaseOrders; + context.productInventoryItems = productInventoryItems + context.quantitySummaryByFacility = quantitySummaryByFacility + context.manufacturingInQuantitySummaryByFacility = manufacturingInQuantitySummaryByFacility + context.manufacturingOutQuantitySummaryByFacility = manufacturingOutQuantitySummaryByFacility + context.showEmpty = showEmpty + context.purchaseOrders = purchaseOrders } } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductQuickAdmin.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductQuickAdmin.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductQuickAdmin.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductQuickAdmin.groovy Wed Nov 2 19:09:13 2016 @@ -22,296 +22,296 @@ import org.apache.ofbiz.entity.* import org.apache.ofbiz.entity.condition.* import org.apache.ofbiz.entity.util.* import org.apache.ofbiz.product.product.* -import org.apache.ofbiz.entity.util.EntityUtilProperties; +import org.apache.ofbiz.entity.util.EntityUtilProperties -context.nowTimestampString = UtilDateTime.nowTimestamp().toString(); +context.nowTimestampString = UtilDateTime.nowTimestamp().toString() -context.assocTypes = from("ProductAssocType").queryList(); +context.assocTypes = from("ProductAssocType").queryList() -context.featureTypes = from("ProductFeatureType").queryList(); +context.featureTypes = from("ProductFeatureType").queryList() // add/remove feature types -addedFeatureTypes = (HashMap) session.getAttribute("addedFeatureTypes"); +addedFeatureTypes = (HashMap) session.getAttribute("addedFeatureTypes") if (addedFeatureTypes == null) { - addedFeatureTypes = [:]; - session.setAttribute("addedFeatureTypes", addedFeatureTypes); + addedFeatureTypes = [:] + session.setAttribute("addedFeatureTypes", addedFeatureTypes) } -featuresByType = new HashMap(); -String[] addFeatureTypeId = request.getParameterValues("addFeatureTypeId"); -List addFeatureTypeIdList = []; +featuresByType = new HashMap() +String[] addFeatureTypeId = request.getParameterValues("addFeatureTypeId") +List addFeatureTypeIdList = [] if (addFeatureTypeId) { - addFeatureTypeIdList.addAll(Arrays.asList(addFeatureTypeId)); + addFeatureTypeIdList.addAll(Arrays.asList(addFeatureTypeId)) } -addFeatureTypeIdIter = addFeatureTypeIdList.iterator(); +addFeatureTypeIdIter = addFeatureTypeIdList.iterator() while (addFeatureTypeIdIter) { - String curFeatureTypeId = addFeatureTypeIdIter.next(); - GenericValue featureType = from("ProductFeatureType").where("productFeatureTypeId", curFeatureTypeId).queryOne(); + String curFeatureTypeId = addFeatureTypeIdIter.next() + GenericValue featureType = from("ProductFeatureType").where("productFeatureTypeId", curFeatureTypeId).queryOne() if ((featureType) && !addedFeatureTypes.containsKey(curFeatureTypeId)) { - addedFeatureTypes.put(curFeatureTypeId, featureType); + addedFeatureTypes.put(curFeatureTypeId, featureType) } } -String[] removeFeatureTypeId = request.getParameterValues("removeFeatureTypeId"); +String[] removeFeatureTypeId = request.getParameterValues("removeFeatureTypeId") if (removeFeatureTypeId) { for (int i = 0; i < removeFeatureTypeId.length; i++) { - GenericValue featureType = from("ProductFeatureType").where("productFeatureTypeId", addFeatureTypeId[i]).queryOne(); + GenericValue featureType = from("ProductFeatureType").where("productFeatureTypeId", addFeatureTypeId[i]).queryOne() if ((featureType) && addedFeatureTypes.containsKey(removeFeatureTypeId[i])) { - addedFeatureTypes.remove(removeFeatureTypeId[i]); - featuresByType.remove(removeFeatureTypeId[i]); + addedFeatureTypes.remove(removeFeatureTypeId[i]) + featuresByType.remove(removeFeatureTypeId[i]) } } } -Iterator iter = addedFeatureTypes.values().iterator(); +Iterator iter = addedFeatureTypes.values().iterator() while (iter) { - GenericValue featureType = (GenericValue)iter.next(); - featuresByType.put(featureType.productFeatureTypeId, featureType.getRelated("ProductFeature", null, ['description'], false)); + GenericValue featureType = (GenericValue)iter.next() + featuresByType.put(featureType.productFeatureTypeId, featureType.getRelated("ProductFeature", null, ['description'], false)) } -context.addedFeatureTypeIds = addedFeatureTypes.keySet(); -context.addedFeatureTypes = addedFeatureTypes; -context.featuresByType = featuresByType; +context.addedFeatureTypeIds = addedFeatureTypes.keySet() +context.addedFeatureTypes = addedFeatureTypes +context.featuresByType = featuresByType -productId = parameters.get("productId"); +productId = parameters.get("productId") if (!productId) { - productId = parameters.get("PRODUCT_ID"); + productId = parameters.get("PRODUCT_ID") } if (!productId) { - productId = request.getAttribute("productId"); + productId = request.getAttribute("productId") } if (productId) { - context.productId = productId; + context.productId = productId } -product = from("Product").where("productId", productId).queryOne(); -assocProducts = []; -featureFloz = [:]; -featureMl = [:]; -featureNtwt = [:]; -featureGrams = [:]; -featureHazmat = [:]; -featureSalesThru = [:]; -featureThruDate = [:]; -selFeatureDesc = [:]; -BigDecimal floz = null; -BigDecimal ml = null; -BigDecimal ntwt = null; -BigDecimal grams = null; -String hazmat = "nbsp;"; -String salesthru = null; -String thrudate = null; -String productFeatureTypeId = request.getParameter("productFeatureTypeId"); -context.productFeatureTypeId = productFeatureTypeId; +product = from("Product").where("productId", productId).queryOne() +assocProducts = [] +featureFloz = [:] +featureMl = [:] +featureNtwt = [:] +featureGrams = [:] +featureHazmat = [:] +featureSalesThru = [:] +featureThruDate = [:] +selFeatureDesc = [:] +BigDecimal floz = null +BigDecimal ml = null +BigDecimal ntwt = null +BigDecimal grams = null +String hazmat = "nbsp;" +String salesthru = null +String thrudate = null +String productFeatureTypeId = request.getParameter("productFeatureTypeId") +context.productFeatureTypeId = productFeatureTypeId if (product) { - context.product = product; + context.product = product // get categories allCategories = from("ProductCategory").where(EntityCondition.makeCondition(EntityCondition.makeCondition("showInSelect", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("showInSelect", EntityOperator.NOT_EQUAL, "N"))) - .orderBy("description").queryList(); + .orderBy("description").queryList() - categoryMembers = product.getRelated("ProductCategoryMember", null, null, false); - categoryMembers = EntityUtil.filterByDate(categoryMembers); - context.allCategories = allCategories; - context.productCategoryMembers = categoryMembers; + categoryMembers = product.getRelated("ProductCategoryMember", null, null, false) + categoryMembers = EntityUtil.filterByDate(categoryMembers) + context.allCategories = allCategories + context.productCategoryMembers = categoryMembers - productFeatureAndAppls = product.getRelated("ProductFeatureAndAppl", null, null, false); + productFeatureAndAppls = product.getRelated("ProductFeatureAndAppl", null, null, false) // get standard features for this product - standardFeatureAppls = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureApplTypeId : "STANDARD_FEATURE"]); - productFeatureTypeLookup = [:]; - standardFeatureLookup = [:]; - Iterator standardFeatureApplIter = standardFeatureAppls.iterator(); + standardFeatureAppls = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureApplTypeId : "STANDARD_FEATURE"]) + productFeatureTypeLookup = [:] + standardFeatureLookup = [:] + Iterator standardFeatureApplIter = standardFeatureAppls.iterator() while (standardFeatureApplIter) { - GenericValue standardFeatureAndAppl = (GenericValue) standardFeatureApplIter.next(); - GenericValue featureType = standardFeatureAndAppl.getRelatedOne("ProductFeatureType", true); - productFeatureTypeLookup.put(standardFeatureAndAppl.getString("productFeatureId"), featureType); - standardFeatureLookup.put(standardFeatureAndAppl.getString("productFeatureId"), standardFeatureAndAppl); + GenericValue standardFeatureAndAppl = (GenericValue) standardFeatureApplIter.next() + GenericValue featureType = standardFeatureAndAppl.getRelatedOne("ProductFeatureType", true) + productFeatureTypeLookup.put(standardFeatureAndAppl.getString("productFeatureId"), featureType) + standardFeatureLookup.put(standardFeatureAndAppl.getString("productFeatureId"), standardFeatureAndAppl) } - context.standardFeatureLookup = standardFeatureLookup; - context.standardFeatureAppls = standardFeatureAppls; + context.standardFeatureLookup = standardFeatureLookup + context.standardFeatureAppls = standardFeatureAppls // get selectable features for this product - List selectableFeatureAppls = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureApplTypeId : 'SELECTABLE_FEATURE']); - selectableFeatureLookup = [:]; + List selectableFeatureAppls = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureApplTypeId : 'SELECTABLE_FEATURE']) + selectableFeatureLookup = [:] // get feature types that are deleteable from selectable features section - Set selectableFeatureTypes = new HashSet(); + Set selectableFeatureTypes = new HashSet() - Iterator selectableFeatureAndApplIter = selectableFeatureAppls.iterator(); + Iterator selectableFeatureAndApplIter = selectableFeatureAppls.iterator() while (selectableFeatureAndApplIter) { - GenericValue selectableFeatureAndAppl = (GenericValue) selectableFeatureAndApplIter.next(); - GenericValue featureType = selectableFeatureAndAppl.getRelatedOne("ProductFeatureType", true); - productFeatureTypeLookup.put(selectableFeatureAndAppl.productFeatureId, featureType); - selectableFeatureLookup.put(selectableFeatureAndAppl.productFeatureId, selectableFeatureAndAppl); - selectableFeatureTypes.add(featureType); - } - context.selectableFeatureLookup = selectableFeatureLookup; - context.selectableFeatureAppls = selectableFeatureAppls; - context.selectableFeatureTypes = selectableFeatureTypes; + GenericValue selectableFeatureAndAppl = (GenericValue) selectableFeatureAndApplIter.next() + GenericValue featureType = selectableFeatureAndAppl.getRelatedOne("ProductFeatureType", true) + productFeatureTypeLookup.put(selectableFeatureAndAppl.productFeatureId, featureType) + selectableFeatureLookup.put(selectableFeatureAndAppl.productFeatureId, selectableFeatureAndAppl) + selectableFeatureTypes.add(featureType) + } + context.selectableFeatureLookup = selectableFeatureLookup + context.selectableFeatureAppls = selectableFeatureAppls + context.selectableFeatureTypes = selectableFeatureTypes if ("Y".equalsIgnoreCase(product.isVariant)) { - Set distinguishingFeatures = ProductWorker.getVariantDistinguishingFeatures(product); - context.distinguishingFeatures = distinguishingFeatures; - Iterator distinguishingFeatureIter = distinguishingFeatures.iterator(); + Set distinguishingFeatures = ProductWorker.getVariantDistinguishingFeatures(product) + context.distinguishingFeatures = distinguishingFeatures + Iterator distinguishingFeatureIter = distinguishingFeatures.iterator() while (distinguishingFeatureIter) { - distFeature = (GenericValue) distinguishingFeatureIter.next(); - featureType = distFeature.getRelatedOne("ProductFeatureType", true); + distFeature = (GenericValue) distinguishingFeatureIter.next() + featureType = distFeature.getRelatedOne("ProductFeatureType", true) if (!productFeatureTypeLookup.containsKey(distFeature.productFeatureId)) { - productFeatureTypeLookup.put(distFeature.productFeatureId, featureType); + productFeatureTypeLookup.put(distFeature.productFeatureId, featureType) } } } - context.productFeatureTypeLookup = productFeatureTypeLookup; + context.productFeatureTypeLookup = productFeatureTypeLookup // get shipping dimensions and weights for single product - prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'VLIQ_ozUS']); + prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'VLIQ_ozUS']) if (prodFeaturesFiltered) { try { - floz = ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified"); + floz = ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified") } catch (Exception e) { - floz = null; + floz = null } - context.floz = floz; + context.floz = floz } - prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'VLIQ_ml']); + prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'VLIQ_ml']) if (prodFeaturesFiltered) { try { - ml = ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified"); + ml = ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified") } catch (Exception e) { - ml = null; + ml = null } - context.ml = ml; + context.ml = ml } - prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'WT_g']); + prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'WT_g']) if (prodFeaturesFiltered) { try { - grams = ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified"); + grams = ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified") } catch (Exception e) { - grams = null; + grams = null } - context.grams = grams; + context.grams = grams } - prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'WT_oz']); + prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'WT_oz']) if (prodFeaturesFiltered) { try { - ntwt = ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified"); + ntwt = ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified") } catch (Exception e) { - ntwt = null; + ntwt = null } - context.ntwt = ntwt; + context.ntwt = ntwt } - prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'HAZMAT']); + prodFeaturesFiltered = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : 'HAZMAT']) if (prodFeaturesFiltered) { try { - hazmat = ((GenericValue)prodFeaturesFiltered.get(0)).getString("description"); + hazmat = ((GenericValue)prodFeaturesFiltered.get(0)).getString("description") } catch (Exception e) { - hazmat = "nbsp;"; + hazmat = "nbsp;" } if (hazmat == null) { - hazmat = "nbsp;"; + hazmat = "nbsp;" } - context.hazmat = hazmat; + context.hazmat = hazmat } - java.sql.Timestamp salesThru = product.getTimestamp("salesDiscontinuationDate"); + java.sql.Timestamp salesThru = product.getTimestamp("salesDiscontinuationDate") if (!salesThru) { - salesthru = "[ ]"; + salesthru = "[ ]" } else if (salesThru.after(new java.util.Date())) { - salesthru = "<span style='color: blue'>[x]</span>"; + salesthru = "<span style='color: blue'>[x]</span>" } else { - salesthru = "<span style='color: red'>[x]</span>"; + salesthru = "<span style='color: red'>[x]</span>" } - context.salesthru = salesthru; - thrudate = ""; - context.thrudate = thrudate; + context.salesthru = salesthru + thrudate = "" + context.thrudate = thrudate // get all variants - associations first - productAssocs = product.getRelated("MainProductAssoc", [productAssocTypeId : 'PRODUCT_VARIANT'], null, false); - Iterator productAssocIter = productAssocs.iterator(); + productAssocs = product.getRelated("MainProductAssoc", [productAssocTypeId : 'PRODUCT_VARIANT'], null, false) + Iterator productAssocIter = productAssocs.iterator() // get shipping dimensions and weights for all the variants while (productAssocIter) { // now get the variant product - productAssoc = (GenericValue)productAssocIter.next(); - assocProduct = productAssoc.getRelatedOne("AssocProduct", false); + productAssoc = (GenericValue)productAssocIter.next() + assocProduct = productAssoc.getRelatedOne("AssocProduct", false) if (assocProduct) { - assocProducts.add(assocProduct); - assocProductFeatureAndAppls = assocProduct.getRelated("ProductFeatureAndAppl", null, null, false); - prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'VLIQ_ozUS']); + assocProducts.add(assocProduct) + assocProductFeatureAndAppls = assocProduct.getRelated("ProductFeatureAndAppl", null, null, false) + prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'VLIQ_ozUS']) if (prodFeaturesFiltered) { - featureFloz.put(assocProduct.productId, ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified")); + featureFloz.put(assocProduct.productId, ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified")) } - prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'VLIQ_ml']); + prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'VLIQ_ml']) if (prodFeaturesFiltered) { - featureMl.put(assocProduct.productId, ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified")); + featureMl.put(assocProduct.productId, ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified")) } - prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'WT_g']); + prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'WT_g']) if (prodFeaturesFiltered) { - featureGrams.put(assocProduct.productId, ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified")); + featureGrams.put(assocProduct.productId, ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified")) } - prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'WT_oz']); + prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'AMOUNT', uomId : 'WT_oz']) if (prodFeaturesFiltered) { - featureNtwt.put(assocProduct.productId, ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified")); + featureNtwt.put(assocProduct.productId, ((GenericValue)prodFeaturesFiltered.get(0)).getBigDecimal("numberSpecified")) } - prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'HAZMAT']); + prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : 'HAZMAT']) if (prodFeaturesFiltered) { featureHazmat.put(assocProduct.productId, - ((GenericValue)prodFeaturesFiltered.get(0)).getString("description")); + ((GenericValue)prodFeaturesFiltered.get(0)).getString("description")) } else { - featureHazmat.put(assocProduct.productId, " "); + featureHazmat.put(assocProduct.productId, " ") } - salesThru = assocProduct.getTimestamp("salesDiscontinuationDate"); + salesThru = assocProduct.getTimestamp("salesDiscontinuationDate") if (!salesThru) { - featureSalesThru.put(assocProduct.productId, "<span style='color: blue'>[ ]</span>"); + featureSalesThru.put(assocProduct.productId, "<span style='color: blue'>[ ]</span>") } else if (salesThru.after(new java.util.Date())) { - featureSalesThru.put(assocProduct.productId, "<span style='color: blue'>[x]</span>"); + featureSalesThru.put(assocProduct.productId, "<span style='color: blue'>[x]</span>") } else { - featureSalesThru.put(assocProduct.productId, "<span style='color: red'>[x]</span>"); + featureSalesThru.put(assocProduct.productId, "<span style='color: red'>[x]</span>") } - java.sql.Timestamp thruDate = productAssoc.getTimestamp("thruDate"); + java.sql.Timestamp thruDate = productAssoc.getTimestamp("thruDate") if (!thruDate) { - featureThruDate.put(assocProduct.productId, "<span style='color: blue'>[ ]</span>"); + featureThruDate.put(assocProduct.productId, "<span style='color: blue'>[ ]</span>") } else if (thruDate.after(new java.util.Date())) { - featureThruDate.put(assocProduct.productId, "<span style='color: blue'>[x]</span>"); + featureThruDate.put(assocProduct.productId, "<span style='color: blue'>[x]</span>") } else { - featureThruDate.put(assocProduct.productId, "<span style='color: red'>[x]</span>"); + featureThruDate.put(assocProduct.productId, "<span style='color: red'>[x]</span>") } - prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : productFeatureTypeId]); + prodFeaturesFiltered = EntityUtil.filterByAnd(assocProductFeatureAndAppls, [productFeatureTypeId : productFeatureTypeId]) if (prodFeaturesFiltered) { // this is used for the selectable feature descriptions section; only include here iff the description is also associated with the virtual product as a selectable feature, ie if this is a distinguishing feature - String curSelDescription = ((GenericValue) prodFeaturesFiltered.get(0)).getString("description"); - testProductFeatureAndAppls = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : productFeatureTypeId, description : curSelDescription, productFeatureApplTypeId : 'SELECTABLE_FEATURE']); + String curSelDescription = ((GenericValue) prodFeaturesFiltered.get(0)).getString("description") + testProductFeatureAndAppls = EntityUtil.filterByAnd(productFeatureAndAppls, [productFeatureTypeId : productFeatureTypeId, description : curSelDescription, productFeatureApplTypeId : 'SELECTABLE_FEATURE']) if (testProductFeatureAndAppls) { - selFeatureDesc.put(assocProduct.productId, curSelDescription); + selFeatureDesc.put(assocProduct.productId, curSelDescription) } } } } - assocProducts = EntityUtil.orderBy(assocProducts, ['internalName']); - context.assocProducts = assocProducts; - context.productAssocs = productAssocs; + assocProducts = EntityUtil.orderBy(assocProducts, ['internalName']) + context.assocProducts = assocProducts + context.productAssocs = productAssocs } -context.featureFloz = featureFloz; -context.featureMl = featureMl; -context.featureNtwt = featureNtwt; -context.featureGrams = featureGrams; -context.featureHazmat = featureHazmat; -context.featureSalesThru = featureSalesThru; -context.featureThruDate = featureThruDate; -context.selFeatureDesc = selFeatureDesc; +context.featureFloz = featureFloz +context.featureMl = featureMl +context.featureNtwt = featureNtwt +context.featureGrams = featureGrams +context.featureHazmat = featureHazmat +context.featureSalesThru = featureSalesThru +context.featureThruDate = featureThruDate +context.selFeatureDesc = selFeatureDesc // get "all" category id -String allCategoryId = EntityUtilProperties.getPropertyValue("catalog", "all.product.category", delegator); -context.allCategoryId = allCategoryId; +String allCategoryId = EntityUtilProperties.getPropertyValue("catalog", "all.product.category", delegator) +context.allCategoryId = allCategoryId // show the publish or unpublish section -prodCatMembs = from("ProductCategoryMember").where("productCategoryId", allCategoryId, "productId", productId).queryList(); -//don't filter by date, show all categories: prodCatMembs = EntityUtil.filterByDate(prodCatMembs); +prodCatMembs = from("ProductCategoryMember").where("productCategoryId", allCategoryId, "productId", productId).queryList() +//don't filter by date, show all categories: prodCatMembs = EntityUtil.filterByDate(prodCatMembs) -String showPublish = "false"; +String showPublish = "false" if (prodCatMembs.size() == 0) { - showPublish = "true"; + showPublish = "true" } -context.showPublish = showPublish; +context.showPublish = showPublish Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductSEO.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductSEO.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductSEO.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/EditProductSEO.groovy Wed Nov 2 19:09:13 2016 @@ -17,24 +17,24 @@ * under the License. */ -productId = parameters.productId; +productId = parameters.productId if (productId) { - productContents = from("ProductContent").where("productId", productId).queryList(); + productContents = from("ProductContent").where("productId", productId).queryList() productContents.each{ productContent-> if (productContent.productContentTypeId == "PAGE_TITLE") { - contentTitle = from("Content").where("contentId", productContent.contentId).queryOne(); - dataTextTitle = from("ElectronicText").where("dataResourceId", contentTitle.dataResourceId).queryOne(); - context.title = dataTextTitle.textData; + contentTitle = from("Content").where("contentId", productContent.contentId).queryOne() + dataTextTitle = from("ElectronicText").where("dataResourceId", contentTitle.dataResourceId).queryOne() + context.title = dataTextTitle.textData } if (productContent.productContentTypeId == "META_KEYWORD") { - contentMetaKeyword = from("Content").where("contentId", productContent.contentId).queryOne(); - dataTextMetaKeyword = from("ElectronicText").where("dataResourceId", contentMetaKeyword.dataResourceId).queryOne(); - context.metaKeyword = dataTextMetaKeyword.textData; + contentMetaKeyword = from("Content").where("contentId", productContent.contentId).queryOne() + dataTextMetaKeyword = from("ElectronicText").where("dataResourceId", contentMetaKeyword.dataResourceId).queryOne() + context.metaKeyword = dataTextMetaKeyword.textData } if (productContent.productContentTypeId == "META_DESCRIPTION") { - contentMetaDescription = from("Content").where("contentId", productContent.contentId).queryOne(); - dataTextMetaDescription = from("ElectronicText").where("dataResourceId", contentMetaDescription.dataResourceId).queryOne(); - context.metaDescription = dataTextMetaDescription.textData; + contentMetaDescription = from("Content").where("contentId", productContent.contentId).queryOne() + dataTextMetaDescription = from("ElectronicText").where("dataResourceId", contentMetaDescription.dataResourceId).queryOne() + context.metaDescription = dataTextMetaDescription.textData } } } Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/product/QuickAddVariants.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/product/QuickAddVariants.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/product/QuickAddVariants.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/product/QuickAddVariants.groovy Wed Nov 2 19:09:13 2016 @@ -17,8 +17,8 @@ * under the License. */ -result = runService('getProductFeaturesByType', [productId : productId, productFeatureApplTypeId : 'SELECTABLE_FEATURE']); -context.featureTypes = result.productFeatureTypes; +result = runService('getProductFeaturesByType', [productId : productId, productFeatureApplTypeId : 'SELECTABLE_FEATURE']) +context.featureTypes = result.productFeatureTypes -result = runService('getVariantCombinations', [productId : productId]); -context.featureCombinationInfos = result.featureCombinations; +result = runService('getVariantCombinations', [productId : productId]) +context.featureCombinationInfos = result.featureCombinations Modified: ofbiz/trunk/applications/product/groovyScripts/catalog/promo/EditProductPromoCode.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/groovyScripts/catalog/promo/EditProductPromoCode.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/product/groovyScripts/catalog/promo/EditProductPromoCode.groovy (original) +++ ofbiz/trunk/applications/product/groovyScripts/catalog/promo/EditProductPromoCode.groovy Wed Nov 2 19:09:13 2016 @@ -17,34 +17,34 @@ * under the License. */ -productPromoCodeId = request.getParameter("productPromoCodeId"); +productPromoCodeId = request.getParameter("productPromoCodeId") if (!productPromoCodeId) { - productPromoCodeId = request.getAttribute("productPromoCodeId"); + productPromoCodeId = request.getAttribute("productPromoCodeId") } -productPromoCode = from("ProductPromoCode").where("productPromoCodeId", productPromoCodeId).queryOne(); +productPromoCode = from("ProductPromoCode").where("productPromoCodeId", productPromoCodeId).queryOne() -productPromoId = null; +productPromoId = null if (productPromoCode) { - productPromoId = productPromoCode.productPromoId; + productPromoId = productPromoCode.productPromoId } else { - productPromoId = request.getParameter("productPromoId"); + productPromoId = request.getParameter("productPromoId") } -productPromo = null; +productPromo = null if (productPromoId) { - productPromo = from("ProductPromo").where("productPromoId", productPromoId).queryOne(); + productPromo = from("ProductPromo").where("productPromoId", productPromoId).queryOne() } -productPromoCodeEmails = null; -productPromoCodeParties = null; +productPromoCodeEmails = null +productPromoCodeParties = null if (productPromoCode) { - productPromoCodeEmails = productPromoCode.getRelated("ProductPromoCodeEmail", null, null, false); - productPromoCodeParties = productPromoCode.getRelated("ProductPromoCodeParty", null, null, false); + productPromoCodeEmails = productPromoCode.getRelated("ProductPromoCodeEmail", null, null, false) + productPromoCodeParties = productPromoCode.getRelated("ProductPromoCodeParty", null, null, false) } -context.productPromoId = productPromoId; -context.productPromo = productPromo; -context.productPromoCodeId = productPromoCodeId; -context.productPromoCode = productPromoCode; -context.productPromoCodeEmails = productPromoCodeEmails; -context.productPromoCodeParties = productPromoCodeParties; +context.productPromoId = productPromoId +context.productPromo = productPromo +context.productPromoCodeId = productPromoCodeId +context.productPromoCode = productPromoCode +context.productPromoCodeEmails = productPromoCodeEmails +context.productPromoCodeParties = productPromoCodeParties |
Free forum by Nabble | Edit this page |