svn commit: r597108 - in /ofbiz/trunk/specialpurpose/googlebase: config/ servicedef/ src/org/ofbiz/googlebase/ widget/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r597108 - in /ofbiz/trunk/specialpurpose/googlebase: config/ servicedef/ src/org/ofbiz/googlebase/ widget/

rayb-2
Author: rayb
Date: Wed Nov 21 07:09:37 2007
New Revision: 597108

URL: http://svn.apache.org/viewvc?rev=597108&view=rev
Log:
Added a few more fields to the googlebase screens and source to allow loading of UK and potentially DE (EURO-not tested) products. Also added a couple more fields like brand and SKU.

Modified:
    ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.properties
    ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml
    ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java
    ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
    ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml

Modified: ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.properties?rev=597108&r1=597107&r2=597108&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.properties (original)
+++ ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.properties Wed Nov 21 07:09:37 2007
@@ -25,6 +25,10 @@
 GoogleBaseExportTestMode=(Yes=Validate the xml document request to Google Base, No=Send the xml document request to Google Base)
 GoogleBaseExportNoTrackingRequested=Not Requested
 GoogleBaseViewPermissionError=You do not have permission to view this page. ("GOOGLEBASE_VIEW" needed)
+GoogleBaseExportCountryCode=Select your country destination
+GoogleBaseExportCountryCodeUS=US - $
+GoogleBaseExportCountryCodeGB=UK - £
+GoogleBaseExportCountryCodeDE=DE - €
 
 FormFieldTitle_webSiteUrl=Web Site Url
 FormFieldTitle_trackingCodeId=Tracking Code Id
@@ -33,6 +37,7 @@
 
 PageTitleGoogleBaseProductsExportToGoogle=Export Products to Google Base
 
+productsExportToGoogle.invalidCountryCode=Country Code must be either US, UK or DE.
 productsExportToGoogle.cannotRetrieveUserLogin=Cannot retrieve User Login
 productsExportToGoogle.errorDuringAuthenticationToGoogle=Error during authentication with Google Account
 productsExportToGoogle.errorInTheResponseFromGoogle=Error in the response from Google:

Modified: ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml?rev=597108&r1=597107&r2=597108&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml Wed Nov 21 07:09:37 2007
@@ -34,6 +34,8 @@
         <attribute type="String" mode="IN" name="statusId" optional="false"/>
         <attribute type="String" mode="IN" name="testMode" optional="false"/>
         <attribute type="String" mode="IN" name="trackingCodeId" optional="true"/>
+        <attribute type="String" mode="IN" name="webSiteMountPoint" optional="false"/>
+        <attribute type="String" mode="IN" name="countryCode" optional="false"/>
     </service>
     <service name="exportProductCategoryToGoogle" engine="java"
              location="org.ofbiz.googlebase.ProductsExportToGoogle" invoke="exportProductCategoryToGoogle" auth="true">

Modified: ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java?rev=597108&r1=597107&r2=597108&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java Wed Nov 21 07:09:37 2007
@@ -88,6 +88,8 @@
                 String statusId = (String) request.getParameter("statusId");
                 String testMode = (String) request.getParameter("testMode");
                 String trackingCodeId = (String) request.getParameter("trackingCodeId");
+                String webSiteMountPoint = (String) request.getParameter("webSiteMountPoint");
+                String countryCode = (String) request.getParameter("countryCode");
                 
                 // Export all or selected products to Google Base
                 try {
@@ -96,7 +98,9 @@
                                                "imageUrl", imageUrl,
                                                "actionType", actionType,
                                                "statusId", statusId,
-                                               "testMode", testMode);
+                                               "testMode", testMode,
+                                               "webSiteMountPoint", webSiteMountPoint,
+                                               "countryCode", countryCode);
                     inMap.put("trackingCodeId", trackingCodeId);
                     inMap.put("userLogin", userLogin);
                     Map exportResult = dispatcher.runSync("exportToGoogle", inMap);

Modified: ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java?rev=597108&r1=597107&r2=597108&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java Wed Nov 21 07:09:37 2007
@@ -320,6 +320,8 @@
              String actionType = (String)context.get("actionType");
              String statusId = (String)context.get("statusId");
              String trackingCodeId = (String)context.get("trackingCodeId");
+             String countryCode = (String)context.get("countryCode");
+             String webSiteMountPoint = (String)context.get("webSiteMountPoint");
             
              if (!webSiteUrl.startsWith("http://") && !webSiteUrl.startsWith("https://")) {
                  webSiteUrl = "http://" + webSiteUrl;
@@ -327,6 +329,25 @@
              if (webSiteUrl.endsWith("/")) {
                  webSiteUrl = webSiteUrl.substring(0, webSiteUrl.length() - 1);
              }
+
+             if (webSiteMountPoint.endsWith("/")) {
+                 webSiteMountPoint = webSiteMountPoint.substring(0, webSiteMountPoint.length() - 1);
+             }
+             if (webSiteMountPoint.startsWith("/")) {
+                 webSiteMountPoint = webSiteMountPoint.substring(1, webSiteMountPoint.length());
+             }
+
+             String productCurrency = null;
+             if ("US".equals(countryCode)) {
+                 productCurrency = "USD";
+             } else if ("GB".equals(countryCode)) {
+                 productCurrency = "GBP";
+             } else if ("DE".equals(countryCode)) {
+                 productCurrency = "EUR";
+             } else {
+                 Debug.logError("Exception during building data items to Google, Country Code must be either US, UK or DE: "+countryCode, module);
+                 return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToGoogle.invalidCountryCode", locale));
+             }
              // Get the list of products to be exported to Google Base
              List productsList  = delegator.findByCondition("Product", new EntityExpr("productId", EntityOperator.IN, selectResult), null, null);
             
@@ -350,6 +371,7 @@
                  Iterator productsListItr = productsList.iterator();
                  int index = 0;
                  String itemActionType = null;
+                 GenericValue googleProduct;
                  while(productsListItr.hasNext()) {
                      itemActionType = actionType;
                      GenericValue prod = (GenericValue)productsListItr.next();
@@ -359,7 +381,7 @@
                          continue;
                      }
                      // TODO: improve this (i.e. get the relative path from the properies file)
-                     String link = webSiteUrl + "/ecommerce/control/product/~product_id=" + prod.getString("productId") + trackingCodeId;
+                     String link = webSiteUrl + "/"+webSiteMountPoint+"/control/product/~product_id=" + prod.getString("productId") + trackingCodeId;
                      String title = UtilFormatOut.encodeXmlValue(prod.getString("productName"));
                      String description = UtilFormatOut.encodeXmlValue(prod.getString("description"));
                      String imageLink = "";
@@ -374,7 +396,7 @@
                      String googleProductId = null;
                      if (!"insert".equals(actionType)) {
                          try {
-                             GenericValue googleProduct = delegator.findByPrimaryKey("GoodIdentification", UtilMisc.toMap("productId", prod.getString("productId"), "goodIdentificationTypeId", "GOOGLE_ID"));
+                             googleProduct = delegator.findByPrimaryKey("GoodIdentification", UtilMisc.toMap("productId", prod.getString("productId"), "goodIdentificationTypeId", "GOOGLE_ID"));
                              if (UtilValidate.isNotEmpty(googleProduct)) {
                                 googleProductId = googleProduct.getString("idValue");
                              }
@@ -419,6 +441,27 @@
                      UtilXml.addChildElementValue(entryElem, "g:item_type", "products", feedDocument);
                      UtilXml.addChildElementValue(entryElem, "g:price", price, feedDocument);
                     
+                     // Might be nicer to load this from the product but for now we'll set it based on the country destination
+                     UtilXml.addChildElementValue(entryElem, "g:currency", productCurrency, feedDocument);
+
+                     // Ensure the load goes to the correct country location either US dollar, GB sterling or DE euro
+                     UtilXml.addChildElementValue(entryElem, "g:target_country", countryCode, feedDocument);
+
+                     UtilXml.addChildElementValue(entryElem, "g:brand", prod.getString("brandName"), feedDocument);
+
+                     try {
+                         googleProduct = delegator.findByPrimaryKey("GoodIdentification", UtilMisc.toMap("productId", prod.getString("productId"), "goodIdentificationTypeId", "SKU"));
+                         if (UtilValidate.isNotEmpty(googleProduct)) {
+                            UtilXml.addChildElementValue(entryElem, "g:ean", googleProduct.getString("idValue"), feedDocument);
+                         }
+                     } catch(GenericEntityException gee) {
+                         Debug.logInfo("Unable to get the SKU for product [" + prod.getString("productId") + "]: " + gee.getMessage(), module);
+                     }
+
+                     UtilXml.addChildElementValue(entryElem, "g:condition", "new", feedDocument);
+                     // This is a US specific requirement for product feeds
+//                     UtilXml.addChildElementValue(entryElem, "g:mpn", "", feedDocument);
+
                      // if the product has an image it will be published on Google Product Search
                      if (UtilValidate.isNotEmpty(imageLink)) {
                          UtilXml.addChildElementValue(entryElem, "g:image_link", imageLink, feedDocument);

Modified: ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml?rev=597108&r1=597107&r2=597108&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml (original)
+++ ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml Wed Nov 21 07:09:37 2007
@@ -22,7 +22,15 @@
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">
     <form name="ProductsExportToGoogle" type="single" target="searchExportProductListToGoogle">
         <field name="selectResult"><hidden/></field>
+        <field name="countryCode" tooltip="${uiLabelMap.GoogleBaseExportCountryCode}">
+            <drop-down no-current-selected-key="US">
+                <option key="US" description="${uiLabelMap.GoogleBaseExportCountryCodeUS}"/>
+                <option key="GB" description="${uiLabelMap.GoogleBaseExportCountryCodeGB}"/>
+                <option key="DE" description="${uiLabelMap.GoogleBaseExportCountryCodeDE}"/>
+            </drop-down>
+        </field>
         <field name="webSiteUrl"><text size="50" maxlength="250"/></field>
+        <field name="webSiteMountPoint"><text size="30" maxlength="30" default-value="ecommerce"/></field>
         <field name="actionType" widget-style="selectBox">
             <drop-down no-current-selected-key="insert">
                 <option key="insert" description="${uiLabelMap.CommonInsert}"/>