You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2011/03/14 07:59:17 UTC

svn commit: r1081270 [1/2] - in /ofbiz/trunk/specialpurpose/googlebase: config/ data/ data/helpdata/ script/ script/org/ script/org/ofbiz/ script/org/ofbiz/googlebase/ servicedef/ src/org/ofbiz/googlebase/ webapp/googlebase/WEB-INF/ webapp/googlebase/W...

Author: hansbak
Date: Mon Mar 14 06:59:16 2011
New Revision: 1081270

URL: http://svn.apache.org/viewvc?rev=1081270&view=rev
Log:

• Fix any errors on GoogleBaseSearchEvents.java and ProductsExportToGoogle.java file.
• Edit productsExportToGoogle form to constrain the country code that getting it from defaultLocaleString field of ProductStore entity (before it was a combobox that select by user).
• Add the new type of GoodIdentificationType entity that relate to Google Base Id including GOOGLE_ID_en_US, GOOGLE_ID_en_GB, GOOGLE_ID_de for identify each productStore with its language.
• Add the Google Base Auto Update function.
• Add the new filter of GoogleBaseAdvanceSearch including ACTIVE_PRODUCT, GOOGLE_SYNCED and DISCONTINUED_PRODUCT.
• Add allowRecommended option for add the recommended attribute to Google Base such as QUANTITY, COLOR,  YEAR_MADE etc.
• Add the Google Base help.
A contribution of Antwebsystems employees M and Ton2

Added:
    ofbiz/trunk/specialpurpose/googlebase/config/autoUpdateToGoogleBase.properties   (with props)
    ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseHelpData.xml   (with props)
    ofbiz/trunk/specialpurpose/googlebase/data/helpdata/
    ofbiz/trunk/specialpurpose/googlebase/data/helpdata/HELP_GOOGLEBASE.xml   (with props)
    ofbiz/trunk/specialpurpose/googlebase/script/
    ofbiz/trunk/specialpurpose/googlebase/script/org/
    ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/
    ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/
    ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseEvents.xml   (with props)
    ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseServices.xml   (with props)
    ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/FilterProducts.groovy   (with props)
    ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/autoUpdateConfig.groovy   (with props)
    ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/googlebaseDivideList.groovy   (with props)
    ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/productsToGooglebase.groovy   (with props)
Modified:
    ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.xml
    ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseTypeData.xml
    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/webapp/googlebase/WEB-INF/actions/GoogleBaseAdvancedSearch.groovy
    ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/productsExportToGoogle.groovy
    ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/controller.xml
    ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/find/GoogleBaseAdvancedSearch.ftl
    ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/find/googleExportLink.ftl
    ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseForms.xml
    ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseMenus.xml
    ofbiz/trunk/specialpurpose/googlebase/widget/GoogleBaseScreens.xml

Modified: ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.xml?rev=1081270&r1=1081269&r2=1081270&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.xml (original)
+++ ofbiz/trunk/specialpurpose/googlebase/config/GoogleBaseUiLabels.xml Mon Mar 14 06:59:16 2011
@@ -72,6 +72,10 @@
         <value xml:lang="th">ฐานข้อมูลสาธารณะทั้งหมด</value>
         <value xml:lang="zh">Google Base集成</value>
     </property>
+    <property key="GoogleBaseAutoUpdate">
+        <value xml:lang="en">Auto Update Options</value>
+        <value xml:lang="th">อัพเดทแบบอัตโนมัติ</value>
+    </property>
     <property key="GoogleBaseCompanyName">
         <value xml:lang="en">Ofbiz</value>
         <value xml:lang="fr">Ofbiz</value>
@@ -176,6 +180,10 @@
         <value xml:lang="th">คุณไม่มีการอนุญาตให้แสดงหน้านี้. ("GOOGLEBASE_VIEW" ต้องการ)</value>
         <value xml:lang="zh">你没有浏览这个页面的权限(需要GOOGLEBASE_VIEW)。</value>
     </property>
+    <property key="GoogleBaseRecommended">
+        <value xml:lang="en">Allow Google Base Recommended</value>
+        <value xml:lang="th">อนุญาติให้เพิ่มฟิลด์ที่แนะนำ</value>
+    </property>
     <property key="PageTitleGoogleBaseProductsExportToGoogle">
         <value xml:lang="en">Export Products to Google Base</value>
         <value xml:lang="fr">Exporter les articles vers Google Base</value>

Added: ofbiz/trunk/specialpurpose/googlebase/config/autoUpdateToGoogleBase.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/config/autoUpdateToGoogleBase.properties?rev=1081270&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/config/autoUpdateToGoogleBase.properties (added)
+++ ofbiz/trunk/specialpurpose/googlebase/config/autoUpdateToGoogleBase.properties Mon Mar 14 06:59:16 2011
@@ -0,0 +1,63 @@
+###############################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+###############################################################################
+####
+# OFBiz Auto Update To Google Base Setting
+####
+# Google Base Configuration
+
+# separate each value by comma(',') with no space and setting of each productStore are ordered from left to right.
+# for example: 
+# autoUpdateGoogleBase.productStoreId=9000,9001
+# autoUpdateGoogleBase.productStore.option.outOfStock=Y,N
+# autoUpdateGoogleBase.productStore.option.backInStock=N,Y
+# it means productStoreId:9000 has outOfStock option:Y and backInStock option:N
+# and productStoreId:9001 has outOfStock option:N and backInStock option:Y
+autoUpdateGoogleBase.productStoreId=9000
+
+# productStore.option.outOfStock
+# default value: "Y"
+autoUpdateGoogleBase.productStore.option.outOfStock=Y
+# productStore.option.backIntoStock
+# default value: "Y"
+autoUpdateGoogleBase.productStore.option.backInStock=Y
+
+# productStore.webSiteUrl of productStore; if null, it will get from standardContentPrefix field of WebSite entity
+# default value: http://demo.ofbiz.org
+autoUpdateGoogleBase.productStore.webSiteUrl=http://demo.ofbiz.org
+# productStore.actionType including: "insert", "update", "delete"
+# default value: "insert"
+autoUpdateGoogleBase.productStore.actionType=insert
+# productStore.statusId including "draft", "publish"
+# default value: "draft"
+autoUpdateGoogleBase.productStore.statusId=draft
+# productStore.testMode including "Y", "N"
+# default value: "N"
+autoUpdateGoogleBase.productStore.testMode=N
+# productStore.webSiteMountPoint 
+# default value: ecommerce
+autoUpdateGoogleBase.productStore.webSiteMountPoint=ecommerce
+# productStore.countryCode including "US", "GB", "DE" 
+# default value: "US"
+autoUpdateGoogleBase.productStore.countryCode=US
+# productStore.trackingCodeId 
+# default value: _NA_
+autoUpdateGoogleBase.productStore.trackingCodeId=_NA_
+# productStore.autoUpdateGoogleBase
+# default value: "N"
+autoUpdateGoogleBase.productStore.allowRecommended=N

Propchange: ofbiz/trunk/specialpurpose/googlebase/config/autoUpdateToGoogleBase.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/googlebase/config/autoUpdateToGoogleBase.properties
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/googlebase/config/autoUpdateToGoogleBase.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseHelpData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseHelpData.xml?rev=1081270&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseHelpData.xml (added)
+++ ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseHelpData.xml Mon Mar 14 06:59:16 2011
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<entity-engine-xml>
+    <!-- Google Base Help -->
+    <DataResource dataResourceId="GOOGLEBASE_MAIN" localeString="en" dataResourceTypeId="OFBIZ_FILE" objectInfo="specialpurpose/googlebase/data/helpdata/HELP_GOOGLEBASE.xml" dataTemplateTypeId="NONE" statusId="CTNT_IN_PROGRESS" dataResourceName="Google Base" mimeTypeId="text/xml" isPublic="Y" />
+    <Content contentId="GOOGLEBASE_MAIN" contentTypeId="DOCUMENT" contentName="Google Base" templateDataResourceId="HELP_TEMPL" dataResourceId="GOOGLEBASE_MAIN" statusId="CTNT_IN_PROGRESS" mimeTypeId="text/html"/>
+    <ContentAssoc contentId="HELP_ROOT" contentIdTo="GOOGLEBASE_MAIN" contentAssocTypeId="TREE_CHILD" fromDate="2010-11-12 01:01:01" sequenceNum="01" mapKey="GOOGLEBASE_main"/>
+</entity-engine-xml>

Propchange: ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseHelpData.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseHelpData.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseHelpData.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseTypeData.xml?rev=1081270&r1=1081269&r2=1081270&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseTypeData.xml (original)
+++ ofbiz/trunk/specialpurpose/googlebase/data/GoogleBaseTypeData.xml Mon Mar 14 06:59:16 2011
@@ -22,4 +22,8 @@ under the License.
 
     <GoodIdentificationType description="Google Id" goodIdentificationTypeId="GOOGLE_ID" hasTable="N" parentTypeId=""/>
     <WebSite webSiteId="GOOGLEBASE" siteName="Google Base Application" visualThemeSetId="BACKOFFICE"/>
+    
+    <GoodIdentificationType description="Google Id en_US" goodIdentificationTypeId="GOOGLE_ID_en_US" hasTable="N"/>
+    <GoodIdentificationType description="Google Id en_GB" goodIdentificationTypeId="GOOGLE_ID_en_GB" hasTable="N"/>
+    <GoodIdentificationType description="Google Id de" goodIdentificationTypeId="GOOGLE_ID_de" hasTable="N"/>
 </entity-engine-xml>

Added: ofbiz/trunk/specialpurpose/googlebase/data/helpdata/HELP_GOOGLEBASE.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/data/helpdata/HELP_GOOGLEBASE.xml?rev=1081270&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/data/helpdata/HELP_GOOGLEBASE.xml (added)
+++ ofbiz/trunk/specialpurpose/googlebase/data/helpdata/HELP_GOOGLEBASE.xml Mon Mar 14 06:59:16 2011
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to you under the Apache License, Version
+    2.0 (the "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+    http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+    applicable law or agreed to in writing, software distributed under the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+    CONDITIONS OF ANY KIND, either express or implied. See the License for
+    the specific language governing permissions and limitations under the
+    License.
+-->
+<section xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5.0" 
+    xmlns:xl="http://www.w3.org/1999/xlink" 
+    xmlns:xi="http://www.w3.org/2001/XInclude"
+    xsi:schemaLocation="http://docbook.org/ns/docbook ../../../content/dtd/docbook.xsd"
+    xmlns="http://docbook.org/ns/docbook">
+    <title>Google Base Help</title>
+    <para>The google base component provide to export products feed up to google base.</para>
+    <para>
+        <orderedlist>
+           <listitem>
+               <para>Go to Google Base Component.</para>
+               <para>There are 3 main menus including Google Base Configurations, Export to Google Base and Auto Update Options.</para>
+           </listitem>
+        </orderedlist>
+    </para>
+    <section>
+        <title>How to add the Google Base Configurations?</title>
+        <para>First of all, you must add the google base configuration to each product store.</para>
+        <para>
+            <orderedlist>
+                <listitem>
+                    <para>At 'Add Google Base Configuration' screen.</para>
+                    <para>Appropriately insert all field of the google base configuration.</para>
+                    <para>Select the Product Store Id.</para>
+                    <para>The Authentication Url is "https://www.google.com/accounts/ClientLogin".</para>
+                    <para>The Post Items Url is "http://www.google.com/base/feeds/items/batch".</para>
+                    <para>The Web Site Id is "GOOGLEBASE" (default).</para>
+                    <para>Lastly, click 'Add'.</para>
+                </listitem>
+            </orderedlist>
+        </para>
+        <para>Notice: The Developer Key is got from google base according to your google's account.</para>
+    </section>
+    <section>
+        <title>How to export product feed to google base?</title>
+        <para>You can export the selected products up to google base, this function generates the feed for google base.</para>
+                <para>Addition: Filter Product Status Description.</para>
+        <orderedlist>
+            <listitem>
+                <para>"Active Product" is the product which is active in OFBiz, not in Google Base. There use "thruDate" field to check what is active or not.</para>
+                <para>"Product not currently synced with Google Base" is the product which hasn't exported to Google Base yet.</para>
+            </listitem>
+        </orderedlist>
+        <para>Addition: Discontinued Description.</para>
+        <para>If you check "Exclude sending discontinued product and stock is zero" box, the search result will only has the product which is not discontinued and is available in stock.</para>
+        <para>
+            <orderedlist>
+                <listitem>
+                    <para>At 'Export To Google Base' screen.</para>
+                    <para>Choose the product store, you can fill in any search option.</para>
+                    <para>Click 'Find'.</para>
+                    <para>Select any products, then click 'Export to Google Base'.</para>
+                    <para>Fill in the configurations including "Country Code", "Web Site Url". For example; Country Code = "US", Web Site Url = "http://ofbizdemo2.antwebsystems.com", Web Site Mount Point = "ecommerce", Action Type = "insert", Status ID = "Publish Draft", Test Mode = "No".</para>
+                    <para>You can select 'GoogleBaseRecommended' for add more detail of google base feed elements.</para>
+                    <para>Click 'Export to Google Base', the system will exports product feed to Google Base.</para>
+                </listitem>
+            </orderedlist>
+        </para>
+    </section>
+    <section>
+        <title>How to use the auto update to google base?</title>
+        <para>The auto update function repeats to export feed according to the frequency of scheduled job. So don't forget to add the scheduled job to run "autoUpdateToGoogleBase" service.</para>
+        <para>
+            <orderedlist>
+                <listitem>
+                    <para>Set the Auto Update to Google Base at "autoUpdateToGoogleBase.properties".</para>
+                    <para>You can see that config at Google Base Auto Update Config section.</para>
+                    <para>Add the scheduled job to run "autoUpdateToGoogleBase" service.</para>
+                </listitem>
+            </orderedlist>
+        </para>
+        <para>Notice: After you once created the scheduled job of "autoUpdateToGoogleBase" service, you can start/stop scheduled at 'Start/Stop Auto Update to Google Base Scheduled' section.</para>
+    </section>
+</section>

Propchange: ofbiz/trunk/specialpurpose/googlebase/data/helpdata/HELP_GOOGLEBASE.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/googlebase/data/helpdata/HELP_GOOGLEBASE.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/googlebase/data/helpdata/HELP_GOOGLEBASE.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseEvents.xml?rev=1081270&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseEvents.xml (added)
+++ ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseEvents.xml Mon Mar 14 06:59:16 2011
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
+    <simple-method method-name="startStopScheduledGbase" short-description="Start or Stop Auto Update to Googlebase Scheduled">
+        <entity-and list="jobSandboxs" entity-name="JobSandbox">
+            <field-map field-name="serviceName" value="autoUpdateToGoogleBase"/>
+            <field-map field-name="parentJobId" value=""/>
+        </entity-and>
+        <first-from-list entry="jobSandbox" list="jobSandboxs"/>
+        <set field="inMap.jobId" from-field="jobSandbox.jobId"/><!-- jobId of autoUpdateToGoogleBase service -->
+        
+        <entity-and entity-name="JobSandbox" list="pendingList">
+            <field-map field-name="serviceName" value="autoUpdateToGoogleBase"/>
+            <field-map field-name="statusId" value="SERVICE_PENDING"/>
+            <order-by field-name="-lastUpdatedStamp"/>
+        </entity-and>
+        
+        <if-empty field="pendingList">
+        <call-service service-name="resetScheduledJob" in-map-name="inMap">
+            <result-to-field result-name="responseMessage"/>
+        </call-service>
+            <else>
+                <entity-and list="jobSandboxs" entity-name="JobSandbox">
+                    <field-map field-name="serviceName" value="autoUpdateToGoogleBase"/>
+                    <field-map field-name="statusId" value="SERVICE_PENDING"/>
+                </entity-and>
+                <iterate entry="jobSandbox" list="jobSandboxs">
+                    <set field="inMap.jobId" from-field="jobSandbox.jobId"/>
+                    <call-service service-name="cancelScheduledJob" in-map-name="inMap">
+                        <result-to-field result-name="cancelDateTime"/>
+                        <result-to-field result-name="responseMessage"/>
+                    </call-service>
+                </iterate>
+            </else>
+        </if-empty>
+    </simple-method>
+</simple-methods>

Propchange: ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseEvents.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseEvents.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseEvents.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseServices.xml?rev=1081270&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseServices.xml (added)
+++ ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseServices.xml Mon Mar 14 06:59:16 2011
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+    http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
+    <simple-method method-name="autoUpdateToGoogleBase" short-description="Auto update to google base" >
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="productStoreIds">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStoreId"/>
+        </call-class-method>
+        <set field="productStoreIds" value="${groovy: spl = productStoreIds.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="outOfStocks">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.option.outOfStock"/>
+        </call-class-method>
+        <set field="outOfStocks" value="${groovy: spl = outOfStocks.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="backInStocks">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.option.backInStock"/>
+        </call-class-method>
+        <set field="backInStocks" value="${groovy: spl = backInStocks.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="webSiteUrls">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.webSiteUrl"/>
+        </call-class-method>
+        <set field="webSiteUrls" value="${groovy: spl = webSiteUrls.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="actionTypes">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.actionType"/>
+        </call-class-method>
+        <set field="actionTypes" value="${groovy: spl = actionTypes.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="statusIds">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.statusId"/>
+        </call-class-method>
+        <set field="statusIds" value="${groovy: spl = statusIds.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="testModes">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.testMode"/>
+        </call-class-method>
+        <set field="testModes" value="${groovy: spl = testModes.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="webSiteMountPoints">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.webSiteMountPoint"/>
+        </call-class-method>
+        <set field="webSiteMountPoints" value="${groovy: spl = webSiteMountPoints.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="countryCodes">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.countryCode"/>
+        </call-class-method>
+        <set field="countryCodes" value="${groovy: spl = countryCodes.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="trackingCodeIds">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.trackingCodeId"/>
+        </call-class-method>
+        <set field="trackingCodeIds" value="${groovy: spl = trackingCodeIds.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        <call-class-method method-name="getPropertyValue" class-name="org.ofbiz.base.util.UtilProperties" ret-field="allowRecommendeds">
+            <string value="autoUpdateToGoogleBase.properties"/>
+            <string value="autoUpdateGoogleBase.productStore.allowRecommended"/>
+        </call-class-method>
+        <set field="allowRecommendeds" value="${groovy: spl = allowRecommendeds.split(&quot;,&quot;); return spl.toList();}" type="List"/>
+        
+        <!-- read configs from autoUpdateToGoogleBase.properties, then iterate each ProductStore-->
+        <set field="indexOfSetting" value="0" type="Integer"/>
+        <iterate entry="productStoreId" list="productStoreIds">
+            <entity-one value-field="productStore" entity-name="ProductStore"/>
+            <log level="info" message="======= autoUpdateToGoogleBase.properties of productStoreId[${productStoreId}] ==="/>
+            <log level="info" message="=== outOfStocks: ${outOfStocks[indexOfSetting]}"/>
+            <log level="info" message="=== backInStocks: ${backInStocks[indexOfSetting]}"/>
+            <log level="info" message="=== webSiteUrls: ${webSiteUrls[indexOfSetting]}"/>
+            <log level="info" message="=== actionTypes: ${actionTypes[indexOfSetting]}"/>
+            <log level="info" message="=== statusIds: ${statusIds[indexOfSetting]}"/>
+            <log level="info" message="=== testModes: ${testModes[indexOfSetting]}"/>
+            <log level="info" message="=== webSiteMountPoints: ${webSiteMountPoints[indexOfSetting]}"/>
+            <log level="info" message="=== countryCodes$: ${countryCodes[indexOfSetting]}"/>
+            <log level="info" message="=== trackingCodeIds: ${trackingCodeIds[indexOfSetting]}"/>
+            <log level="info" message="=== allowRecommendeds: ${allowRecommendeds[indexOfSetting]}"/>
+            <set field="parameters.productStoreId" from-field="productStoreId"/>
+            <script location="component://googlebase/webapp/googlebase/WEB-INF/actions/productsToGooglebase.groovy"/>
+            <!-- iterate each CatalogList in each ProductStore -->
+            <iterate entry="catalogCategoryIds" list="categoryIds">
+                <if-not-empty field="catalogCategoryIds">
+                    <!-- iterate each Category in each Catalog -->
+                    <iterate entry="categoryId" list="catalogCategoryIds">
+                        <if-not-empty field="categoryId">
+                            <set field="categoryIdMap.categoryId" from-field="categoryId"/>
+                            <call-service service-name="getProductCategoryMembers" in-map-name="categoryIdMap">
+                                <result-to-field result-name="categoryMembers"/>
+                            </call-service>
+                            <if-not-empty field="categoryMembers">
+                            <!-- iterate each CategoryMembers(Product) in Category-->
+                                <iterate entry="categoryMember" list="categoryMembers">
+                                    <field-to-list list="productList" field="categoryMember.productId"/>
+                                </iterate>
+                            </if-not-empty>
+                        </if-not-empty>
+                    </iterate>
+                </if-not-empty>
+            </iterate>
+            <if>
+                <condition>
+                    <and>
+                        <if-compare operator="equals" value="N" field="outOfStocks[indexOfSetting]"/>
+                        <if-compare operator="equals" value="N" field="backInStocks[indexOfSetting]"/>
+                    </and>
+                </condition>
+                <then>
+                    <return/>
+                </then>
+            </if>
+            <if-not-empty field="productList">
+                <script location="component://googlebase/webapp/googlebase/WEB-INF/actions/googlebaseDivideList.groovy"/>
+                <set field="i" value="0" type="Integer"/>
+                <iterate entry="productExportList" list="productExportLists">
+                    <iterate entry="checkProductId" list="productExportList">
+                        <set field="isAvailableMap.productId" from-field="checkProductId"/>
+                        <set field="isAvailableMap.productStoreId" from-field="productStoreId"/>
+                        <set field="isAvailableMap.quantity" value="1" type="BigDecimal"/>
+                        <call-service service-name="isStoreInventoryAvailable" in-map-name="isAvailableMap">
+                            <result-to-field result-name="available"/>
+                        </call-service>
+                        <if-compare operator="not-equals" value="N" field="outOfStocks[indexOfSetting]">
+                            <if-compare operator="equals" value="N" field="available">
+                                <field-to-list list="selectResult" field="checkProductId"/>
+                            </if-compare>
+                        </if-compare>
+                        <if-compare operator="not-equals" value="N" field="backInStocks[indexOfSetting]">
+                            <if-compare operator="equals" value="Y" field="available">
+                                <field-to-list list="selectResult" field="checkProductId"/>
+                            </if-compare>
+                        </if-compare>
+                    </iterate>
+                    <set field="inMap.selectResult" from-field="selectResult"/>
+                    <set field="inMap.webSiteUrl" from-field="webSiteUrls[indexOfSetting]"/>
+                    <set field="inMap.actionType" from-field="actionTypes[indexOfSetting]"/>
+                    <set field="inMap.statusId" from-field="statusIds[indexOfSetting]"/>
+                    <set field="inMap.testMode" from-field="testModes[indexOfSetting]"/>
+                    <set field="inMap.webSiteMountPoint" from-field="webSiteMountPoints[indexOfSetting]"/>
+                    <set field="inMap.countryCode" from-field="countryCodes[indexOfSetting]"/>
+                    <set field="inMap.trackingCodeId" from-field="trackingCodeIds[indexOfSetting]"/>
+                    <set field="inMap.allowRecommended" from-field="allowRecommendeds[indexOfSetting]"/>
+                    <set field="inMap.userLogin" from-field="userLogin"/>
+                    <set field="inMap.productStoreId" from-field="productStoreId"/>
+                    <!--<log level="info" message="=== productStoreId[${productStoreId}] inMap section[${i}]: ${inMap}"/>-->
+                    <call-service service-name="exportToGoogle" in-map-name="inMap"/>
+                    <field-to-list list="allProductExportList" field="selectResult"/>
+                    <clear-field field="selectResult"/>
+                    <clear-field field="inMap"/>
+                    <clear-field field="productList"/>
+                    <set field="i" value="${groovy: i+1}" type="Integer"/>
+                </iterate>
+            </if-not-empty>
+            <set field="indexOfSetting" value="${groovy: indexOfSetting + 1;}" type="Integer"/>
+        </iterate>
+        <field-to-result field="allProductExportList"/>
+        <log level="info" message="=== allProductExportList ${allProductExportList}"/>
+    </simple-method>
+</simple-methods>

Propchange: ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseServices.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseServices.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/googlebase/script/org/ofbiz/googlebase/GooglebaseServices.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml?rev=1081270&r1=1081269&r2=1081270&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/googlebase/servicedef/services.xml Mon Mar 14 06:59:16 2011
@@ -37,6 +37,7 @@ under the License.
         <attribute type="String" mode="IN" name="webSiteMountPoint" optional="false"/>
         <attribute type="String" mode="IN" name="countryCode" optional="false"/>
         <attribute type="String" mode="IN" name="productStoreId" optional="true"/>
+        <attribute type="String" mode="IN" name="allowRecommended" optional="true"/>
     </service>
     <service name="exportProductCategoryToGoogle" engine="java"
              location="org.ofbiz.googlebase.ProductsExportToGoogle" invoke="exportProductCategoryToGoogle" auth="true">
@@ -63,4 +64,10 @@ under the License.
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
     
+    <!-- Auto update to google base **scheduled service -->
+    <service name="autoUpdateToGoogleBase" engine="simple"
+        location="component://googlebase/script/org/ofbiz/googlebase/GooglebaseServices.xml" invoke="autoUpdateToGoogleBase" auth="true" use-transaction="false">
+        <description>Auto update to google base</description>
+        <attribute type="List" mode="OUT" name="allProductExportList" optional="true"/>
+    </service>
 </services>

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=1081270&r1=1081269&r2=1081270&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/GoogleBaseSearchEvents.java Mon Mar 14 06:59:16 2011
@@ -81,7 +81,17 @@ public class GoogleBaseSearchEvents {
                     if (selectResult.startsWith("[")) {
                         productExportList = StringUtil.toList(selectResult);
                     } else {
-                        productExportList.add(selectResult);
+                        if(!selectResult.startsWith("{")){
+                            productExportList.add(selectResult);
+                        }else {
+                            List<String> listTemp = FastList.newInstance();
+                            String temp = selectResult.substring(1, selectResult.length()-1);
+                            String arrayTemp[] = temp.split(",");
+                            for(int i=0; i<arrayTemp.length; i++){
+                                listTemp.add(arrayTemp[i].trim());
+                            }
+                            productExportList = listTemp;
+                        }
                     }
                 }
                 String webSiteUrl = request.getParameter("webSiteUrl");
@@ -93,6 +103,7 @@ public class GoogleBaseSearchEvents {
                 String webSiteMountPoint = request.getParameter("webSiteMountPoint");
                 String countryCode = request.getParameter("countryCode");
                 String productStoreId = request.getParameter("productStoreId");
+                String allowRecommended = (String) request.getParameter("allowRecommended");
 
                 // Export all or selected products to Google Base
                 try {
@@ -107,6 +118,7 @@ public class GoogleBaseSearchEvents {
                     inMap.put("trackingCodeId", trackingCodeId);
                     inMap.put("userLogin", userLogin);
                     inMap.put("productStoreId", productStoreId);
+                    inMap.put("allowRecommended", allowRecommended);
                     Map<String, Object> exportResult = dispatcher.runSync("exportToGoogle", inMap);
                     if (ServiceUtil.isError(exportResult)) {
                         List<String> errorMessages = UtilGenerics.checkList(exportResult.get(ModelService.ERROR_MESSAGE_LIST), String.class);
@@ -119,12 +131,13 @@ public class GoogleBaseSearchEvents {
                     } else if (ServiceUtil.isFailure(exportResult)) {
                         List<String> eventMessages = UtilGenerics.checkList(exportResult.get(ModelService.ERROR_MESSAGE_LIST), String.class);
                         if (UtilValidate.isNotEmpty(eventMessages)) {
-                            request.setAttribute("_EVENT_MESSAGE_LIST_", eventMessages);
+                            request.setAttribute("_ERROR_MESSAGE_LIST_", eventMessages);
                         } else {
-                            request.setAttribute("_EVENT_MESSAGE_", ServiceUtil.getErrorMessage(exportResult));
+                            request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(exportResult));
                         }
+                        return "error";
                     } else {
-                        request.setAttribute("_EVENT_MESSAGE_", exportResult.get("successMessage"));
+                        request.setAttribute("_EVENT_MESSAGE_", exportResult.get("responseMessage"));
                     }
                 } catch (GenericServiceException e) {
                     errMsg = UtilProperties.getMessage(resource, "googlebasesearchevents.exceptionCallingExportToGoogle", locale);

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=1081270&r1=1081269&r2=1081270&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java (original)
+++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java Mon Mar 14 06:59:16 2011
@@ -19,10 +19,17 @@
 package org.ofbiz.googlebase;
 
 import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLEncoder;
@@ -48,6 +55,7 @@ import org.ofbiz.entity.GenericEntityExc
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -56,6 +64,7 @@ import org.ofbiz.service.ServiceUtil;
 import org.ofbiz.base.util.StringUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 
 public class ProductsExportToGoogle {
 
@@ -83,8 +92,9 @@ public class ProductsExportToGoogle {
                 if (token != null) {
                     List<String> newProductsInGoogle = UtilGenerics.checkList(result.get("newProductsInGoogle"), String.class);
                     List<String> productsRemovedFromGoogle = UtilGenerics.checkList(result.get("productsRemovedFromGoogle"), String.class);
+                    String localeString = result.get("localeString").toString();
                     result = postItem(token, googleBaseConfigResult.get("postItemsUrl").toString(), googleBaseConfigResult.get("developerKey").toString(), dataItemsXml,
-                            locale, (String)context.get("testMode"), newProductsInGoogle, productsRemovedFromGoogle, dispatcher, delegator);
+                            locale, (String)context.get("testMode"), newProductsInGoogle, productsRemovedFromGoogle, dispatcher, delegator, localeString);
                 } else {
                     Debug.logError("Error during authentication to Google Account", module);
                     return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToGoogle.errorDuringAuthenticationToGoogle", locale));
@@ -246,7 +256,7 @@ public class ProductsExportToGoogle {
 
     private static Map<String, Object> postItem(String token, String postItemsUrl, String developerKey, StringBuffer dataItems,
                                 Locale locale, String testMode, List<String> newProductsInGoogle, List<String> productsRemovedFromGoogle,
-                                LocalDispatcher dispatcher, Delegator delegator) throws IOException {
+                                LocalDispatcher dispatcher, Delegator delegator, String localeString) throws IOException {
         if (Debug.verboseOn()) {
             Debug.logVerbose("Request To Google Base :\n" + dataItems.toString(), module);
         }
@@ -277,7 +287,7 @@ public class ProductsExportToGoogle {
             inputStream = connection.getInputStream();
             response = toString(inputStream);
             if (UtilValidate.isNotEmpty(response)) {
-                result = readResponseFromGoogle(response, newProductsInGoogle, productsRemovedFromGoogle, dispatcher, delegator, locale);
+                result = readResponseFromGoogle(response, newProductsInGoogle, productsRemovedFromGoogle, dispatcher, delegator, locale, localeString);
                 //String msg = ServiceUtil.getErrorMessage(result);
                 if (ServiceUtil.isError(result)) {
                     result = ServiceUtil.returnFailure(UtilGenerics.checkList(result.get(ModelService.ERROR_MESSAGE_LIST)));
@@ -301,6 +311,7 @@ public class ProductsExportToGoogle {
         Locale locale = (Locale)context.get("locale");
         List<String> newProductsInGoogle = FastList.newInstance();
         List<String> productsRemovedFromGoogle = FastList.newInstance();
+        String localeString = null;
         try {
             Delegator delegator = dctx.getDelegator();
             LocalDispatcher dispatcher = dctx.getDispatcher();
@@ -329,10 +340,13 @@ public class ProductsExportToGoogle {
             String productCurrency = null;
             if ("US".equals(countryCode)) {
                 productCurrency = "USD";
+                localeString = "en_US";
             } else if ("GB".equals(countryCode)) {
                 productCurrency = "GBP";
+                localeString = "en_GB";
             } else if ("DE".equals(countryCode)) {
                 productCurrency = "EUR";
+                localeString = "de";
             } 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));
@@ -370,14 +384,39 @@ public class ProductsExportToGoogle {
                 }
                 // TODO: improve this (i.e. get the relative path from the properties file)
                 String link = webSiteUrl + "/" + webSiteMountPoint + "/control/product/~product_id=" + prod.getString("productId") + trackingCodeId;
-                String title = UtilFormatOut.encodeXmlValue(prod.getString("productName"));
-                if (UtilValidate.isEmpty(title)) {
-                    title = UtilFormatOut.encodeXmlValue(prod.getString("internalName"));
+                String productName = null;
+                String productDescription = null;
+                String productURL = null;
+                List<GenericValue> productAndInfos = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", prod.getString("productId"), "localeString", localeString, "thruDate", null));
+                if (productAndInfos.size() > 0) {
+                    for (GenericValue productContentAndInfo : productAndInfos ) {
+                        String dataReSourceId = productContentAndInfo.getString("dataResourceId");
+                        GenericValue electronicText = delegator.findByPrimaryKey("ElectronicText", UtilMisc.toMap("dataResourceId", dataReSourceId));
+                        if ("PRODUCT_NAME".equals(productContentAndInfo.getString("productContentTypeId")))
+                            productName = electronicText.getString("textData");
+                        if ("LONG_DESCRIPTION".equals(productContentAndInfo.getString("productContentTypeId")))
+                            productDescription = electronicText.getString("textData");
+                        if ("PRODUCT_URL".equals(productContentAndInfo.getString("productContentTypeId")))
+                            productURL = electronicText.getString("textData");
+                        }
+                } else {
+                    productName = prod.getString("internalName");
+                    productDescription = prod.getString("longDescription");
+                    if (UtilValidate.isEmpty(productDescription)) {
+                        productDescription = prod.getString("description");
+                    }
                 }
-                String description = UtilFormatOut.encodeXmlValue(prod.getString("description"));
-                if (UtilValidate.isEmpty(description)) {
+                String title = UtilFormatOut.encodeXmlValue(productName);
+                if (UtilValidate.isEmpty(title)) 
+                    title = UtilFormatOut.encodeXmlValue(prod.getString("productName"));
+                if (UtilValidate.isEmpty(title)) 
+                    title = UtilFormatOut.encodeXmlValue(prod.getString("internalName"));
+                String description = UtilFormatOut.encodeXmlValue(productDescription);
+                if (UtilValidate.isEmpty(description))
+                    description = UtilFormatOut.encodeXmlValue(prod.getString("description"));
+                if (UtilValidate.isEmpty(description))
                     description = UtilFormatOut.encodeXmlValue(prod.getString("internalName"));
-                }
+                
                 String imageLink = "";
                 if (UtilValidate.isNotEmpty(prod.getString("largeImageUrl"))) {
                     imageLink = webSiteUrl + prod.getString("largeImageUrl");
@@ -386,11 +425,32 @@ public class ProductsExportToGoogle {
                 } else if (UtilValidate.isNotEmpty(prod.getString("smallImageUrl"))) {
                     imageLink = webSiteUrl + prod.getString("smallImageUrl");
                 }
-
+                
+                // should use image management script task.
+                /*try {
+                    List<GenericValue> productContentAndInfos = delegator.findByAnd("ProductContentAndInfo", 
+                            UtilMisc.toMap("productId", prod.getString("productId"), "productContentTypeId","DEFAULT_IMAGE"));
+                    if (UtilValidate.isNotEmpty(productContentAndInfos)) {
+                        imageLink = webSiteUrl + productContentAndInfos.get(0).getString("drObjectInfo");
+                    } else {
+                        productContentAndInfos = delegator.findByAnd("ProductContentAndInfo", 
+                                UtilMisc.toMap("productId", prod.getString("productId"),
+                                        "productContentTypeId","IMAGE", 
+                                        "statusId","IM_APPROVED",
+                                        "drIsPublic", "Y"),
+                                        UtilMisc.toList("contentId"));
+                        if (UtilValidate.isNotEmpty(productContentAndInfos)) {
+                            imageLink = webSiteUrl + productContentAndInfos.get(0).getString("drObjectInfo");
+                        }
+                    }
+                } catch (Exception e) {
+                    Debug.logError(e, module);
+                }*/
+                
                 String googleProductId = null;
                 if (!"insert".equals(actionType)) {
                     try {
-                        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_" + localeString));
                         if (UtilValidate.isNotEmpty(googleProduct)) {
                             googleProductId = googleProduct.getString("idValue");
                         }
@@ -403,11 +463,16 @@ public class ProductsExportToGoogle {
                 }
                 Element entryElem = UtilXml.addChildElement(feedElem, "entry", feedDocument);
                 Element batchElem = UtilXml.addChildElementNSElement(entryElem, "batch:operation", feedDocument, googleBaseBatchUrl);
-                Element batchOperationElem = UtilXml.firstChildElement(batchElem, "batch:operation");
+
+                Element batchOperationElem = (Element) batchElem.getFirstChild();
                 batchOperationElem.setAttribute("type", itemActionType);
+                
+                if("delete".equals(actionType) || "update".equals(actionType)){
+                    UtilXml.addChildElementNSValue(entryElem, "id", googleProductId, feedDocument, "");
+                }
 
                 Element appControlElem = UtilXml.addChildElementNSElement(entryElem, "app:control", feedDocument, googleBaseAppUrl);
-                Element appControlChildElem = UtilXml.firstChildElement(appControlElem, "app:control");
+                Element appControlChildElem = (Element) appControlElem.getLastChild();
                 // Add the publishing priority for the product. By default it takes about 24 hours to publish your product if you submit data from Data Feed. By adding publishing priority your data
                 // can be published in 15 - 30 minutes.
                 UtilXml.addChildElementNSValue(appControlChildElem, "gm:publishing_priority", "high", feedDocument, googleBaseMetadataUrl);
@@ -422,22 +487,18 @@ public class ProductsExportToGoogle {
                     }
                 }
 
+                //Add product title
                 UtilXml.addChildElementValue(entryElem, "title", title, feedDocument);
 
                 Element contentElem = UtilXml.addChildElementValue(entryElem, "content", description, feedDocument);
                 contentElem.setAttribute("type", "xhtml");
 
-                if (UtilValidate.isNotEmpty(googleProductId)) {
-                    UtilXml.addChildElementNSValue(entryElem, "g:id", googleProductId, feedDocument, googleBaseNSUrl);
-                } else {
-                    UtilXml.addChildElementNSValue(entryElem, "g:id", link, feedDocument, googleBaseNSUrl);
-                }
-
+                UtilXml.addChildElementNSValue(entryElem, "g:id", prod.getString("productId"), feedDocument, googleBaseNSUrl);
                 Element linkElem = UtilXml.addChildElement(entryElem, "link", feedDocument);
-                linkElem.setAttribute("rel", "alternate");
-                linkElem.setAttribute("type", "text/html");
                 linkElem.setAttribute("href", link);
-
+                linkElem.setAttribute("rel", "self");
+                linkElem.setAttribute("type", "application/atom+xml");
+                
                 // item_type is the categories in which your product should belong.
                 UtilXml.addChildElementNSValue(entryElem, "g:item_type", "products", feedDocument, googleBaseNSUrl);
 
@@ -447,8 +508,14 @@ public class ProductsExportToGoogle {
                 while (productCategoryMembersIter.hasNext()) {
                     GenericValue productCategoryMember = productCategoryMembersIter.next();
                     GenericValue productCategory = productCategoryMember.getRelatedOne("ProductCategory");
-                    String productCategoryTypeId = productCategory.getString("productCategoryTypeId");
-                    if (UtilValidate.isNotEmpty(productCategoryTypeId) && "GOOGLE_BASE_CATEGORY".equals(productCategoryTypeId)) {
+                    String productCategoryId = productCategory.getString("productCategoryId");
+                    String checkCategory = null;
+                    if ("GB".equals(countryCode)) {
+                        checkCategory = "UK";
+                    } else {
+                        checkCategory = countryCode;
+                    }
+                    if (UtilValidate.isNotEmpty(productCategoryId) && (checkCategory.equals(productCategoryId.substring(0, 2)))) {
                         String categoryDescription = "";
                         if (UtilValidate.isNotEmpty(productCategory.getString("categoryName"))) {
                             categoryDescription = productCategory.getString("categoryName");
@@ -457,17 +524,14 @@ public class ProductsExportToGoogle {
                         } else if (UtilValidate.isNotEmpty(productCategory.getString("longDescription"))) {
                             categoryDescription = productCategory.getString("longDescription");
                         }
-                        if (UtilValidate.isNotEmpty(productCategory)) {
+                        if (UtilValidate.isNotEmpty(categoryDescription)) {
                             UtilXml.addChildElementNSValue(entryElem, "g:product_type", StringUtil.wrapString(categoryDescription).toString() , feedDocument, googleBaseNSUrl);
                         }
                     }
                 }
-
+                //Add product price
                 UtilXml.addChildElementNSValue(entryElem, "g:price", price, feedDocument, googleBaseNSUrl);
-
-                // Might be nicer to load this from the product but for now we'll set it based on the country destination
-                UtilXml.addChildElementNSValue(entryElem, "g:currency", productCurrency, feedDocument, googleBaseNSUrl);
-
+                
                 // Ensure the load goes to the correct country location either US dollar, GB sterling or DE euro
                 UtilXml.addChildElementNSValue(entryElem, "g:target_country", countryCode, feedDocument, googleBaseNSUrl);
                 if (UtilValidate.isNotEmpty(prod.getString("brandName"))) {
@@ -481,8 +545,14 @@ public class ProductsExportToGoogle {
                 } catch (GenericEntityException gee) {
                     Debug.logInfo("Unable to get the SKU for product [" + prod.getString("productId") + "]: " + gee.getMessage(), module);
                 }
-
-                UtilXml.addChildElementNSValue(entryElem, "g:condition", "new", feedDocument, googleBaseNSUrl);
+                
+                String condition = null;
+                if ("US".equals(countryCode) || "GB".equals(countryCode)) {
+                    condition = "new";
+                } else if ("DE".equals(countryCode)) {
+                    condition = "new";
+                }
+                UtilXml.addChildElementNSValue(entryElem, "g:condition", condition, feedDocument, googleBaseNSUrl);
                 // This is a US specific requirement for product feeds
                 //                     UtilXml.addChildElementValue(entryElem, "g:mpn", "", feedDocument);
 
@@ -501,6 +571,10 @@ public class ProductsExportToGoogle {
                     newProductsInGoogle.add(null);
                     productsRemovedFromGoogle.add(null);
                 }
+                //Add product condition
+                if ("Y".equals(context.get("allowRecommended"))) {
+                    setRecommendedAttributes(prod, feedDocument, entryElem, delegator, countryCode, productCurrency);
+                }
                 index++;
             }
             //Debug.logInfo("The value of generated String is ========\n" + UtilXml.writeXmlDocument(feedDocument), module);
@@ -514,7 +588,8 @@ public class ProductsExportToGoogle {
         Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("newProductsInGoogle", newProductsInGoogle);
         result.put("productsRemovedFromGoogle", productsRemovedFromGoogle);
-        Debug.log("======returning with result: " + result);
+        result.put("localeString", localeString);
+        //Debug.log("======returning with result: " + result);
         return result;
     }
 
@@ -534,7 +609,7 @@ public class ProductsExportToGoogle {
     }
 
     private static Map<String, Object> readResponseFromGoogle(String msg, List<String> newProductsInGoogle, List<String> productsRemovedFromGoogle,
-            LocalDispatcher dispatcher, Delegator delegator, Locale locale) {
+            LocalDispatcher dispatcher, Delegator delegator, Locale locale, String localeString) {
         List<String> message = FastList.newInstance();
         // Debug.log("====get xml response from google: " + msg);
         try {
@@ -544,13 +619,18 @@ public class ProductsExportToGoogle {
             Iterator<? extends Element> atomEntryElemIter = atomEntryList.iterator();
             int index = 0;
             while (atomEntryElemIter.hasNext()) {
+                String id = null;
                 Element atomEntryElement = atomEntryElemIter.next();
-                String id = UtilXml.childElementValue(atomEntryElement, "atom:id", "");
+                Node atomId = atomEntryElement.getElementsByTagName("atom:id").item(0);
+                if(UtilValidate.isNotEmpty(atomId)) {
+                    id = atomId.getTextContent();
+                }
+                String productId = "";
                 if (UtilValidate.isNotEmpty(id) && newProductsInGoogle.get(index) != null) {
-                    String productId = newProductsInGoogle.get(index);
+                    productId = newProductsInGoogle.get(index);
                     try {
                         GenericValue googleProductId = delegator.makeValue("GoodIdentification");
-                        googleProductId.set("goodIdentificationTypeId", "GOOGLE_ID");
+                        googleProductId.set("goodIdentificationTypeId", "GOOGLE_ID_" + localeString);
                         googleProductId.set("productId", productId);
                         googleProductId.set("idValue", id);
                         delegator.createOrStore(googleProductId);
@@ -559,20 +639,23 @@ public class ProductsExportToGoogle {
                     }
                 }
                 if (UtilValidate.isNotEmpty(id) && productsRemovedFromGoogle.get(index) != null) {
-                    String productId = productsRemovedFromGoogle.get(index);
+                    productId = productsRemovedFromGoogle.get(index);
                     try {
-                        delegator.removeByAnd("GoodIdentification", UtilMisc.toMap("goodIdentificationTypeId", "GOOGLE_ID", "productId", productId));
+                        delegator.removeByAnd("GoodIdentification", UtilMisc.toMap("goodIdentificationTypeId", "GOOGLE_ID_" + localeString, "productId", productId));
                     } catch (GenericEntityException gee) {
                         Debug.logError("Unable to remove Google id for product [" + productId + "]: " + gee.getMessage(), module);
                     }
                 }
-                String title = "Google response: " + UtilXml.childElementValue(atomEntryElement, "atom:title", "");
+                if (UtilValidate.isEmpty(productId)){
+                    productId = atomEntryElement.getElementsByTagName("g:id").item(0).getTextContent();
+                }
+                String title = "Google response:" + UtilXml.childElementValue(atomEntryElement, "atom:title", "");
                 List<? extends Element> batchStatusList = UtilXml.childElementList(atomEntryElement, "batch:status");
                 Iterator<? extends Element> batchStatusEntryElemIter = batchStatusList.iterator();
                 while (batchStatusEntryElemIter.hasNext()) {
                     Element batchStatusEntryElement = batchStatusEntryElemIter.next();
                     if (UtilValidate.isNotEmpty(batchStatusEntryElement.getAttribute("reason"))) {
-                        message.add(title + " " + batchStatusEntryElement.getAttribute("reason"));
+                        message.add(title + " " + productId + ":" + batchStatusEntryElement.getAttribute("reason"));
                     }
                 }
                 String errors = UtilXml.childElementValue(atomEntryElement, "batch:status", "");
@@ -585,10 +668,8 @@ public class ProductsExportToGoogle {
             Debug.logError("Exception reading response from Google: " + e.getMessage(), module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "productsExportToGoogle.exceptionReadingResponseFromGoogle", locale));
         }
-
-        if (message.size() > 0) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "productsExportToGoogle.errorInTheResponseFromGoogle", locale), message);
-        }
+        //Debug.logInfo("===== batch:status - message: " + message, module);
+        //Debug.logInfo("===== Exports: " + message.size() + " products" , null);
         return ServiceUtil.returnSuccess();
     }
 
@@ -620,4 +701,70 @@ public class ProductsExportToGoogle {
         }
         return buildGoogleBaseConfigContext;
     }
+    private static void setRecommendedAttributes(GenericValue product, Document feedDocument, Element entryElem, Delegator delegator, String countryCode, String productCurrency) {
+        if (UtilValidate.isEmpty(product) && UtilValidate.isEmpty(feedDocument) && UtilValidate.isEmpty(countryCode) && UtilValidate.isNotEmpty(entryElem)) {
+            Debug.logError("Required parameters in setRecommended method", module);
+        }
+        try {
+            //Add brand name
+            if (UtilValidate.isNotEmpty(product.getString("brandName"))) {
+                UtilXml.addChildElementNSValue(entryElem, "g:brand", product.getString("brandName"), feedDocument, googleBaseNSUrl);
+            }
+            
+            //Add quantity item
+            List<GenericValue> inventoryItems = delegator.findByAnd("InventoryItem", UtilMisc.toMap("productId", product.getString("productId")));
+            if (UtilValidate.isNotEmpty(inventoryItems)) {
+                BigDecimal totalquantity = new BigDecimal(0);
+                for (GenericValue inventoryItem : inventoryItems) {
+                    BigDecimal availableToPromiseTotal = new BigDecimal(inventoryItem.getString("availableToPromiseTotal"));
+                    totalquantity = totalquantity.add(availableToPromiseTotal);
+                }
+                if ("DE".equals(countryCode)) {
+                    UtilXml.addChildElementNSValue(entryElem, "g:menge", totalquantity.toString(), feedDocument, googleBaseNSUrl);
+                } else {
+                    Integer intValue = totalquantity.intValue();
+                    UtilXml.addChildElementNSValue(entryElem, "g:quantity", intValue.toString(), feedDocument, googleBaseNSUrl);
+                }
+            }
+            //Add Online Only
+            UtilXml.addChildElementNSValue(entryElem, "g:online_only", "y", feedDocument, googleBaseNSUrl);
+            //Add shipping weight
+            if (UtilValidate.isNotEmpty(product.getString("weight")) && UtilValidate.isNotEmpty(product.getString("weightUomId"))) {
+                GenericValue uom = delegator.findByPrimaryKey("Uom", UtilMisc.toMap("uomId", product.getString("weightUomId")));
+                String shippingWeight = product.getString("weight") + " " + uom.getString("description");
+                UtilXml.addChildElementNSValue(entryElem, "g:shipping_weight", shippingWeight, feedDocument, googleBaseNSUrl);
+            }
+            List<GenericValue> productFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", product.getString("productId")));
+            if (productFeatureAndAppls.size() > 0) {
+                for (GenericValue productFeatureAndAppl : productFeatureAndAppls) {
+                    //Add Genre
+                    if ("GENRE".equals(productFeatureAndAppl.getString("productFeatureTypeId"))) {
+                        UtilXml.addChildElementNSValue(entryElem, "g:genre", productFeatureAndAppl.getString("description"), feedDocument, googleBaseNSUrl);
+                    }
+                    //Add color
+                    if ("COLOR".equals(productFeatureAndAppl.getString("productFeatureTypeId"))) {
+                        UtilXml.addChildElementNSValue(entryElem, "g:color", productFeatureAndAppl.getString("description"), feedDocument, googleBaseNSUrl);
+                    }
+                    //Add size
+                    if ("SIZE".equals(productFeatureAndAppl.getString("productFeatureTypeId"))) {
+                        UtilXml.addChildElementNSValue(entryElem, "g:size", productFeatureAndAppl.getString("description"), feedDocument, googleBaseNSUrl);
+                    }
+                    //Add year
+                    if ("YEAR_MADE".equals(productFeatureAndAppl.getString("productFeatureTypeId"))) {
+                        UtilXml.addChildElementNSValue(entryElem, "g:year", productFeatureAndAppl.getString("description"), feedDocument, googleBaseNSUrl);
+                    }
+                    //Add author
+                    if ("ARTIST".equals(productFeatureAndAppl.getString("productFeatureTypeId"))) {
+                        UtilXml.addChildElementNSValue(entryElem, "g:author", productFeatureAndAppl.getString("description"), feedDocument, googleBaseNSUrl);
+                    }
+                    //Add edition
+                    if ("EDITION".equals(productFeatureAndAppl.getString("productFeatureTypeId"))) {
+                        UtilXml.addChildElementNSValue(entryElem, "g:edition", productFeatureAndAppl.getString("description"), feedDocument, googleBaseNSUrl);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            Debug.logError(e.toString(), module);
+        }
+    }
 }

Added: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/FilterProducts.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/FilterProducts.groovy?rev=1081270&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/FilterProducts.groovy (added)
+++ ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/FilterProducts.groovy Mon Mar 14 06:59:16 2011
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import javolution.util.FastList;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.UtilDateTime;
+import java.math.BigDecimal;
+import javax.servlet.http.HttpSession;
+
+defaultLocaleString = "";
+if (parameters.productStoreId) {
+    productStore = delegator.findByAnd("ProductStore", ["productStoreId":parameters.productStoreId]);
+    defaultLocaleString = productStore[0].defaultLocaleString.toString()
+}
+active = parameters.ACTIVE_PRODUCT;
+notSynced = parameters.GOOGLE_SYNCED;
+
+productList = FastList.newInstance();
+if (UtilValidate.isNotEmpty(productIds) && ("Y".equals(active) || "Y".equals(notSynced))) {
+    for (int i = 0; i < productIds.size(); i++) {
+        productId = productIds[i];
+        productCategoryMembers = delegator.findByAnd("ProductCategoryMember", [productId : productId]);
+        productCategoryMember = EntityUtil.getFirst(productCategoryMembers);
+        if (UtilValidate.isNotEmpty(productCategoryMember)) {
+            if ("Y".equals(active) && "Y".equals(notSynced)) {
+                thruDate = productCategoryMember.get("thruDate");
+                goodIdentification = delegator.findByPrimaryKey("GoodIdentification", [productId : productId, goodIdentificationTypeId : "GOOGLE_ID_" + defaultLocaleString]);
+                if (UtilValidate.isEmpty(thruDate) && UtilValidate.isEmpty(goodIdentification)) {
+                    productList.add(productId);
+                }
+            } else if ("Y".equals(active)) {
+                thruDate = productCategoryMember.get("thruDate");
+                if (UtilValidate.isEmpty(thruDate)) {
+                    productList.add(productId);
+                }
+                parameters.GOOGLE_SYNCED = "N"
+            } else if ("Y".equals(notSynced)) {
+                goodIdentification = delegator.findByPrimaryKey("GoodIdentification", [productId : productId, goodIdentificationTypeId : "GOOGLE_ID_" + defaultLocaleString]);
+                if (UtilValidate.isEmpty(goodIdentification)) {
+                    productList.add(productId);
+                }
+                parameters.ACTIVE_PRODUCT = "N"
+            }
+        }
+    }
+    productIds = productList;
+} else {
+    parameters.ACTIVE_PRODUCT = "N"
+    parameters.GOOGLE_SYNCED = "N"
+}
+
+//stop sending discontinued product.
+def notDiscontProdList = []
+if(parameters.DISCONTINUED_PRODUCT == 'Y'){
+    productIds.each { value ->
+        def stockIsZero = dispatcher.runSync("isStoreInventoryAvailable", ["productId": value, "productStoreId": parameters.productStoreId, "quantity": BigDecimal.valueOf(1.00)]);
+        def thisProduct = delegator.findByPrimaryKey("Product", [productId : value]);
+        if (stockIsZero.get("available") == 'Y'){
+            notDiscontProdList.add(value);
+        }else {
+            if (thisProduct.salesDiscontinuationDate == null || thisProduct.salesDiscontinuationDate > UtilDateTime.nowTimestamp()){
+                notDiscontProdList.add(value);
+            }
+        }
+    }
+} else {
+    parameters.DISCONTINUED_PRODUCT = 'N'
+}
+if (notDiscontProdList){
+    context.productIds = notDiscontProdList;
+} else {
+    context.productIds = productIds;
+}

Propchange: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/FilterProducts.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/FilterProducts.groovy
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/FilterProducts.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/GoogleBaseAdvancedSearch.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/GoogleBaseAdvancedSearch.groovy?rev=1081270&r1=1081269&r2=1081270&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/GoogleBaseAdvancedSearch.groovy (original)
+++ ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/GoogleBaseAdvancedSearch.groovy Mon Mar 14 06:59:16 2011
@@ -32,6 +32,10 @@ if (parameters.productStoreId) {
     productStoreId = ProductStoreWorker.getProductStoreId(request);
 }
 googleBaseConfigList = delegator.findList("GoogleBaseConfig", null, null, null, null, false);
+if (!productStoreId) {
+    googleBaseProductStore = EntityUtil.getFirst(googleBaseConfigList);
+    productStoreId = googleBaseProductStore.productStoreId;
+}
 if (productStoreId) {
     productStoreCatalogs = CatalogWorker.getStoreCatalogs(delegator, productStoreId);
     if (productStoreCatalogs) {

Added: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/autoUpdateConfig.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/autoUpdateConfig.groovy?rev=1081270&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/autoUpdateConfig.groovy (added)
+++ ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/autoUpdateConfig.groovy Mon Mar 14 06:59:16 2011
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import javolution.util.FastList
+import org.ofbiz.base.util.UtilProperties
+
+configList = []
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStoreId")
+productStoreIds = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.option.outOfStock")
+outOfStock = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.option.backInStock")
+backInStock = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.webSiteUrl")
+webSiteUrl = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.actionType")
+actionType = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.statusId")
+statusId = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.testMode")
+testMode = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.webSiteMountPoint")
+webSiteMountPoint = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.countryCode")
+countryCode = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.trackingCodeId")
+trackingCodeId = str.split(",")
+str = UtilProperties.getPropertyValue("autoUpdateToGoogleBase.properties", "autoUpdateGoogleBase.productStore.allowRecommended")
+allowRecommended = str.split(",")
+
+productStoreIds.eachWithIndex{ productStoreId, i ->
+    configMap = [:]
+    configMap.productStoreId = productStoreId
+    configMap.outOfStock = outOfStock[i]
+    configMap.backInStock = backInStock[i]
+    configMap.webSiteUrl = webSiteUrl[i]
+    configMap.actionType = actionType[i]
+    configMap.statusId = statusId[i]
+    configMap.testMode = testMode[i]
+    configMap.webSiteMountPoint = webSiteMountPoint[i]
+    configMap.countryCode = countryCode[i]
+    configMap.trackingCodeId = trackingCodeId[i]
+    configMap.allowRecommended = allowRecommended[i]
+    configList.add(configMap)
+}
+context.configList = configList

Propchange: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/autoUpdateConfig.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/autoUpdateConfig.groovy
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/autoUpdateConfig.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/googlebaseDivideList.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/googlebaseDivideList.groovy?rev=1081270&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/googlebaseDivideList.groovy (added)
+++ ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/googlebaseDivideList.groovy Mon Mar 14 06:59:16 2011
@@ -0,0 +1,27 @@
+import java.util.List;
+import javolution.util.FastList;
+
+//productList.unique() like distinct sql command, return string type.
+def productUniqueStr = productList.unique();
+def productUniqueStrList = productUniqueStr.toList();
+def googleBaseList = delegator.findByAnd("GoodIdentification",["goodIdentificationTypeId":"GOOGLE_ID_" + productStore.defaultLocaleString]);
+//find product is existed in google base.
+def notNeededList = productUniqueStrList - googleBaseList.productId;
+def resultList = productUniqueStrList - notNeededList;
+def list = [];
+def productExportList = [];
+//if feed more than 1000 always found an IO error, so should divide to any sections.
+def amountPerSection = 1000;
+def section = (int)(resultList.size()/amountPerSection);
+if(resultList.size() % amountPerSection != 0){
+	section = section+1;
+}
+
+for(int i=0; i<section; i++){
+	if(!(i == (section-1))){
+		productExportList.add(resultList.subList((i*amountPerSection), ((i+1)*amountPerSection)));
+	} else {
+		productExportList.add(resultList.subList((i*amountPerSection), resultList.size()));
+	}
+}
+context.productExportLists = productExportList

Propchange: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/googlebaseDivideList.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/googlebaseDivideList.groovy
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/googlebaseDivideList.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/productsExportToGoogle.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/productsExportToGoogle.groovy?rev=1081270&r1=1081269&r2=1081270&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/productsExportToGoogle.groovy (original)
+++ ofbiz/trunk/specialpurpose/googlebase/webapp/googlebase/WEB-INF/actions/productsExportToGoogle.groovy Mon Mar 14 06:59:16 2011
@@ -20,6 +20,9 @@
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.base.util.*;
+
+uiLabelMap = UtilProperties.getResourceBundleMap("GoogleBaseUiLabels", locale);
 
 webSiteList = [];
 webSite = null;
@@ -38,3 +41,17 @@ if (parameters.productStoreId) {
     context.webSiteUrl = webSite.standardContentPrefix;
     parameters.webSiteUrl = webSite.standardContentPrefix;;
 }
+
+if (parameters.productStoreId) {
+    productStore = delegator.findByAnd("ProductStore", ["productStoreId":parameters.productStoreId]);
+    str = productStore[0].defaultLocaleString.toString().toUpperCase();
+    localeString = str.substring(str.length()-2, str.length());
+    if(localeString.equals("US")){
+        context.showText = uiLabelMap.GoogleBaseExportCountryCodeUS;
+    }else if(localeString.equals("GB")){
+        context.showText = uiLabelMap.GoogleBaseExportCountryCodeGB;
+    }else{ // "DE"
+        context.showText = uiLabelMap.GoogleBaseExportCountryCodeDE;
+    }
+    context.countryCode = localeString;
+}