Author: jacopoc
Date: Mon Aug 31 11:24:43 2009 New Revision: 809539 URL: http://svn.apache.org/viewvc?rev=809539&view=rev Log: A bunch of enhancements and cleanups for the eBay component; added ability to: * export product images to eBay Action * export a description based on content (a new product content type has been added for this purpose) Modified: ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml Modified: ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml?rev=809539&r1=809538&r2=809539&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml (original) +++ ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml Mon Aug 31 11:24:43 2009 @@ -21,4 +21,5 @@ <entity-engine-xml> <ProductPricePurpose productPricePurposeId="EBAY" description="eBay Auction"/> <ProductCategoryType productCategoryTypeId="EBAY_CATEGORY" description="eBay" hasTable="N" parentTypeId=""/> + <ProductContentType productContentTypeId="EBAY_DESCRIPTION" description="Detail Page for eBay Auctions"/> </entity-engine-xml> Modified: ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml?rev=809539&r1=809538&r2=809539&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml (original) +++ ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml Mon Aug 31 11:24:43 2009 @@ -31,6 +31,7 @@ <attribute type="List" mode="IN" name="selectResult" optional="false"/> <attribute type="String" mode="IN" name="country" optional="false"/> <attribute type="String" mode="IN" name="location" optional="false"/> + <attribute type="String" mode="IN" name="webSiteUrl" optional="false"/> <attribute type="String" mode="IN" name="ebayCategory" optional="true"/> <attribute type="String" mode="IN" name="paymentPayPal" optional="true"/> <attribute type="String" mode="IN" name="paymentVisaMC" optional="true"/> Modified: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java?rev=809539&r1=809538&r2=809539&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java (original) +++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java Mon Aug 31 11:24:43 2009 @@ -36,6 +36,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; @@ -46,7 +47,9 @@ import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ServiceUtil; +import org.ofbiz.product.product.ProductContentWrapper; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -181,8 +184,11 @@ Locale locale = (Locale)context.get("locale"); try { GenericDelegator delegator = dctx.getDelegator(); + String webSiteUrl = (String)context.get("webSiteUrl"); List selectResult = (List)context.get("selectResult"); + StringUtil.SimpleEncoder encoder = StringUtil.getEncoder("xml"); + // Get the list of products to be exported to eBay List productsList = delegator.findList("Product", EntityCondition.makeCondition("productId", EntityOperator.IN, selectResult), null, null, null, false); @@ -197,8 +203,7 @@ Iterator productsListItr = productsList.iterator(); while (productsListItr.hasNext()) { GenericValue prod = (GenericValue)productsListItr.next(); - String title = parseText(prod.getString("internalName")); - String description = parseText(prod.getString("internalName")); + String title = encoder.encode(prod.getString("internalName")); String qnt = (String)context.get("quantity"); if (UtilValidate.isEmpty(qnt)) { qnt = "1"; @@ -219,10 +224,31 @@ UtilXml.addChildElementValue(itemElem, "ApplicationData", prod.getString("productId"), itemDocument); UtilXml.addChildElementValue(itemElem, "SKU", prod.getString("productId"), itemDocument); UtilXml.addChildElementValue(itemElem, "Title", title, itemDocument); - UtilXml.addChildElementValue(itemElem, "Description", description, itemDocument); UtilXml.addChildElementValue(itemElem, "ListingDuration", (String)context.get("listingDuration"), itemDocument); UtilXml.addChildElementValue(itemElem, "Quantity", qnt, itemDocument); + ProductContentWrapper pcw = new ProductContentWrapper(dctx.getDispatcher(), prod, locale, "text/html"); + StringUtil.StringWrapper ebayDescription = pcw.get("EBAY_DESCRIPTION"); + if (UtilValidate.isNotEmpty(ebayDescription)) { + UtilXml.addChildElementCDATAValue(itemElem, "Description", ebayDescription.toString(), itemDocument); + } else { + UtilXml.addChildElementValue(itemElem, "Description", encoder.encode(prod.getString("productName")), itemDocument); + } + String smallImage = prod.getString("smallImageUrl"); + String mediumImage = prod.getString("mediumImageUrl"); + String largeImage = prod.getString("largeImageUrl"); + String ebayImage = null; + if (UtilValidate.isNotEmpty(largeImage)) { + ebayImage = largeImage; + } else if (UtilValidate.isNotEmpty(mediumImage)) { + ebayImage = mediumImage; + } else if (UtilValidate.isNotEmpty(smallImage)) { + ebayImage = smallImage; + } + if (UtilValidate.isNotEmpty(ebayImage)) { + Element pictureDetails = UtilXml.addChildElement(itemElem, "PictureDetails", itemDocument); + UtilXml.addChildElementValue(pictureDetails, "PictureURL", webSiteUrl + ebayImage, itemDocument); + } setPaymentMethodAccepted(itemDocument, itemElem, context); setMiscDetails(itemDocument, itemElem, context); @@ -535,18 +561,4 @@ } return results; } - - private static String parseText(String text) { - Pattern htmlPattern = Pattern.compile("[<](.+?)[>]"); - Pattern tabPattern = Pattern.compile("\\s"); - if (null != text && text.length() > 0) { - Matcher matcher = htmlPattern.matcher(text); - text = matcher.replaceAll(""); - matcher = tabPattern.matcher(text); - text = matcher.replaceAll(" "); - } else { - text = ""; - } - return text; - } } Modified: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy?rev=809539&r1=809538&r2=809539&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy (original) +++ ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy Mon Aug 31 11:24:43 2009 @@ -36,4 +36,3 @@ } else { context.hideExportOptions = "N"; } - Modified: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl?rev=809539&r1=809538&r2=809539&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl (original) +++ ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl Mon Aug 31 11:24:43 2009 @@ -97,6 +97,13 @@ </td> </tr> <tr> + <td align="right" class="label">${uiLabelMap.FormFieldTitle_webSiteUrl}</td> + <td> </td> + <td> + <input type="text" name="webSiteUrl" size="100" value="${webSiteUrl?if_exists}"/> + </td> + </tr> + <tr> <td align="center" colspan="3"><b><u>${uiLabelMap.FormFieldTitle_paymentMethodsAccepted}</u></b></td> </tr> <tr> Modified: ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml?rev=809539&r1=809538&r2=809539&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml (original) +++ ofbiz/trunk/specialpurpose/ebay/widget/EbayScreens.xml Mon Aug 31 11:24:43 2009 @@ -170,6 +170,8 @@ <screen name="ProductsExportToEbay"> <section> <actions> + <property-map resource="ebayExport.properties" map-name="ebayExportProperties" global="true"/> + <set field="webSiteUrl" value="${ebayExportProperties.webSiteUrl}"/> <set field="headerItem" value="export"/> <set field="titleProperty" value="PageTitleEbayProductsExportToEbay"/> <set field="selectResult" from-field="parameters.selectResult"/> |
Free forum by Nabble | Edit this page |