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 2010/06/24 08:10:30 UTC

svn commit: r957427 - in /ofbiz/trunk/specialpurpose/ebaystore: src/org/ofbiz/ebaystore/EbayEvents.java webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy webapp/ebaystore/store/productsearchExport.ftl

Author: hansbak
Date: Thu Jun 24 06:10:29 2010
New Revision: 957427

URL: http://svn.apache.org/viewvc?rev=957427&view=rev
Log:
Revising Open Ebay item specific Listings

Modified:
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java
    ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy
    ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java?rev=957427&r1=957426&r2=957427&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java Thu Jun 24 06:10:29 2010
@@ -50,6 +50,7 @@ import com.ebay.sdk.ApiContext;
 import com.ebay.sdk.ApiException;
 import com.ebay.sdk.SdkException;
 import com.ebay.sdk.call.AddItemCall;
+import com.ebay.sdk.call.GetCategorySpecificsCall;
 import com.ebay.sdk.call.GetSellingManagerInventoryCall;
 import com.ebay.sdk.call.ReviseSellingManagerProductCall;
 import com.ebay.sdk.call.VerifyAddItemCall;
@@ -59,12 +60,17 @@ import com.ebay.soap.eBLBaseComponents.B
 import com.ebay.soap.eBLBaseComponents.CategoryType;
 import com.ebay.soap.eBLBaseComponents.CountryCodeType;
 import com.ebay.soap.eBLBaseComponents.CurrencyCodeType;
+import com.ebay.soap.eBLBaseComponents.DetailLevelCodeType;
 import com.ebay.soap.eBLBaseComponents.GetSellingManagerInventoryRequestType;
 import com.ebay.soap.eBLBaseComponents.GetSellingManagerInventoryResponseType;
 import com.ebay.soap.eBLBaseComponents.ItemSpecificsEnabledCodeType;
 import com.ebay.soap.eBLBaseComponents.ItemType;
 import com.ebay.soap.eBLBaseComponents.ListingTypeCodeType;
+import com.ebay.soap.eBLBaseComponents.NameRecommendationType;
+import com.ebay.soap.eBLBaseComponents.NameValueListArrayType;
+import com.ebay.soap.eBLBaseComponents.NameValueListType;
 import com.ebay.soap.eBLBaseComponents.PictureDetailsType;
+import com.ebay.soap.eBLBaseComponents.RecommendationsType;
 import com.ebay.soap.eBLBaseComponents.ReturnPolicyType;
 import com.ebay.soap.eBLBaseComponents.ReviseSellingManagerProductRequestType;
 import com.ebay.soap.eBLBaseComponents.ReviseSellingManagerProductResponseType;
@@ -76,6 +82,7 @@ import com.ebay.soap.eBLBaseComponents.S
 import com.ebay.soap.eBLBaseComponents.StoreCustomCategoryType;
 import com.ebay.soap.eBLBaseComponents.StorefrontType;
 import com.ebay.soap.eBLBaseComponents.VATDetailsType;
+import com.ebay.soap.eBLBaseComponents.ValueRecommendationType;
 import com.ebay.soap.eBLBaseComponents.WarningLevelCodeType;
 import com.ebay.soap.eBLBaseComponents.ListingDesignerType;
 import com.ebay.soap.eBLBaseComponents.ShippingDetailsType;
@@ -642,7 +649,33 @@ public class EbayEvents {
         String itemPkCateId = (String) requestParams.get("primaryCateId");
         String shippingService = (String) requestParams.get("ShippingService");
         String productStoreId = (String) requestParams.get("productStoreId");
-
+        
+        // initialize request parameter.
+        Map paramMap = UtilHttp.getParameterMap(request);
+        List<String> nameSpecificList = FastList.newInstance();
+        List<String> valueSpecificList = FastList.newInstance();
+        String nameValueListType = null;
+        String valueListType = null;
+        int rowCount = UtilHttp.getMultiFormRowCount(paramMap);
+        if (rowCount > 1) {
+            for (int i = 0; i < rowCount; i++) {
+                String thisSuffix = UtilHttp.MULTI_ROW_DELIMITER + i;        // current suffix after each field id
+                // get the NameSpecifics
+                if (paramMap.containsKey("nameValueListType" + thisSuffix)) {
+                    nameValueListType = (String) paramMap.remove("nameValueListType" + thisSuffix);
+                }
+                // get the ValueSpecifics
+                if (paramMap.containsKey("categorySpecifics" + thisSuffix)) {
+                    valueListType = (String) paramMap.remove("categorySpecifics" + thisSuffix);
+                }
+                
+                if ((UtilValidate.isNotEmpty(nameValueListType)) && (UtilValidate.isNotEmpty(valueListType))){
+                   nameSpecificList.add(nameValueListType);
+                   valueSpecificList.add(valueListType);
+                }
+            }
+        }
+        	
         try {
             ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
             Map<String,Object> addItemObject = getAddItemListingObject(request, apiContext);
@@ -677,7 +710,28 @@ public class EbayEvents {
                         attributeMapList.put("CategoryParentID", item.getPrimaryCategory().getCategoryParentID(0).toString());
                         attributeMapList.put("LeafCategory", "true");
                         attributeMapList.put("LSD", "true");
-
+                        
+                        // set Item Specifics.
+                        int itemSpecificsSize = nameSpecificList.size();
+                        int valueSpecificsSize = valueSpecificList.size();
+                        if ((itemSpecificsSize > 0) && (valueSpecificsSize > 0)) {
+                            NameValueListArrayType nameValueListArray = new NameValueListArrayType();
+                            NameValueListType[] nameValueListTypes = new NameValueListType[nameSpecificList.size()];
+                            for (int i = 0; i < itemSpecificsSize; i++) {
+                                String name = (String) nameSpecificList.get(i);
+                                String value = (String) valueSpecificList.get(i);
+                                String[] valueArray = new String[] { value };
+                                
+                                // set Name value list type.
+                                NameValueListType listType = new NameValueListType();
+                                listType.setName(name);
+                                listType.setValue(valueArray);
+                                nameValueListTypes[i] = listType;
+                            }
+                            nameValueListArray.setNameValueList(nameValueListTypes);
+                            item.setItemSpecifics(nameValueListArray);
+                        }
+                        
                         item.setUseTaxTable(false);
                         item.setDispatchTimeMax(3);
                         ReturnPolicyType policy = new ReturnPolicyType();
@@ -1052,4 +1106,49 @@ public class EbayEvents {
             Debug.logError(e.getMessage(), module);
         }
     }
+    
+    public static Map<String, Map> categorySpecifics(String categoryId, HttpServletRequest request) {
+        Map<String, Map> recommendationMap = FastMap.newInstance();
+        Delegator delegator = (Delegator) request.getAttribute("delegator");
+        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
+        Map<String,Object> requestParams = UtilHttp.getParameterMap(request);
+        Locale locale = UtilHttp.getLocale(request);
+        String productStoreId = (String) requestParams.get("productStoreId");
+        HttpSession session = request.getSession(true);
+        GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
+        
+        try {
+            ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+            GetCategorySpecificsCall categorySpecifics = new GetCategorySpecificsCall(apiContext);
+            String[] categoryIds = {categoryId};
+            categorySpecifics.setCategoryID(categoryIds);
+            DetailLevelCodeType[] detailLevel = new DetailLevelCodeType[] {
+                    DetailLevelCodeType.RETURN_ALL,
+                    DetailLevelCodeType.ITEM_RETURN_ATTRIBUTES,
+                    DetailLevelCodeType.ITEM_RETURN_DESCRIPTION
+            };
+            categorySpecifics.setDetailLevel(detailLevel);
+            RecommendationsType[] recommend =  categorySpecifics.getCategorySpecifics();
+            
+            for (int i = 0; i < recommend.length; i++) {
+                NameRecommendationType[] nameRecommend = recommend[i].getNameRecommendation();
+                Map<String, List> nameRecommendationMap = FastMap.newInstance();
+                for (int j = 0; j < nameRecommend.length; j++) {
+                    String name = nameRecommend[j].getName();
+                    List<String> valueList = FastList.newInstance();
+                    ValueRecommendationType[] valueRecommend = nameRecommend[j].getValueRecommendation();
+                    for (int k = 0; k < valueRecommend.length; k++) {
+                        String value = valueRecommend[k].getValue();
+                        valueList.add(value);
+                    }
+                    nameRecommendationMap.put(name, valueList);
+                }
+                recommendationMap.put("categorySpecifics", nameRecommendationMap);
+            }
+        } catch (Exception e) {
+            Debug.logError(e.getMessage(), module);
+            return null;
+        }
+        return recommendationMap;
+    }
 }
\ No newline at end of file

Modified: ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy?rev=957427&r1=957426&r2=957427&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/WEB-INF/actions/store/PrepareProductListing.groovy Thu Jun 24 06:10:29 2010
@@ -119,6 +119,20 @@
                  if (primaryCate) pkCateId = primaryCate.getCategoryID();
              }
          }
+         categorySpecificObject = EbayEvents.categorySpecifics(pkCateId, request);
+         Map<String, List> categorySpecificMap = categorySpecificObject.get("categorySpecifics");
+         int checkNameSpecific = null;
+         int checkValueSpecific = null;
+         Iterator<String> specificIterator = categorySpecificMap.keySet().iterator();
+         while(specificIterator.hasNext()){
+             String name = specificIterator.next();
+             List<String> valueList = categorySpecificMap.get(name);
+             checkValueSpecific = (valueList) ? 1 : 0 ;
+         }
+         checkNameSpecific = categorySpecificMap.size();
+         String checkSpecific = ((checkNameSpecific > 0) && (checkValueSpecific == 1)) ? "true" : "false";
+         context.checkSpecific = checkSpecific;
+         context.categorySpecifix = categorySpecificObject;
          context.stCate1ID = stCate1ID;
          context.stCate2ID = stCate2ID;
          if (pkCateId) {

Modified: ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl?rev=957427&r1=957426&r2=957427&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/webapp/ebaystore/store/productsearchExport.ftl Thu Jun 24 06:10:29 2010
@@ -71,7 +71,7 @@ under the License.
         if (cateId.indexOf(':')!= -1) {
             cateId = cateId.substring(0,cateId.indexOf(':'));
         }
-        var pars = 'ebayCategoryId='+cateId+'&amp;productStoreId='+productStoreId; 
+        var pars = 'ebayCategoryId='+cateId+'&productStoreId='+productStoreId; 
         var myAjax = new Ajax.Request( url, {
         method: 'get', 
         parameters: pars,
@@ -99,7 +99,7 @@ under the License.
     }
 
      function retrieveTemplateByTemGroupId(templateGroupId,productStoreId,pkCategoryId){
-        var pars = 'templateGroupId='+templateGroupId+'&amp;productStoreId='+productStoreId+'&amp;pkCategoryId='+pkCategoryId; 
+        var pars = 'templateGroupId='+templateGroupId+'&productStoreId='+productStoreId+'&pkCategoryId='+pkCategoryId; 
         var url = '<@o...@ofbizUrl>';
         var myAjax = new Ajax.Request( url, {
         method: 'get', 
@@ -448,12 +448,38 @@ under the License.
                           </div>
                           <!-- item specifices section -->
                           <#if primaryCate?has_content && primaryCate.getCategoryID()?exists && listingTypes?has_content>
+                             <#if checkSpecific == "true">
                              <div class="screenlet">
                                  <div class="screenlet-title-bar"><ul><li class="h3">Item specifices</li></ul><br class="clear"/></div>
-                                 <div class="screenlet-body">
-                                 
+                                     <div class="screenlet-body">
+                                        <table width="50%" height="100%" id="table2"  cellspacing="0">
+                                        <#list categorySpecifix?keys as key>
+                                            <#assign values = categorySpecifix.get(key)?if_exists/>
+                                            <#assign i = 0/>
+                                            <#list values?keys as nameSpecific>
+                                            <#assign itemSpecifics = values.get(nameSpecific)?if_exists/>
+                                                <#if itemSpecifics?has_content>
+                                                    <tr>
+                                                        <td class="label">${nameSpecific?if_exists}</td>
+                                                        <input type="hidden" name="nameValueListType_o_${i}" value="${nameSpecific?if_exists}"/>
+                                                        <td>
+                                                            <select id="categorySpecifics" name="categorySpecifics_o_${i}">
+                                                               <option  value="" ></option>
+                                                               <#list itemSpecifics as itemSpecific>
+                                                                   <option  value="${itemSpecific?if_exists}" >${itemSpecific?if_exists}</option>
+                                                               </#list>
+                                                            </select>
+                                                        </td>
+                                                    </tr>
+                                                    <#assign i = i + 1/>
+                                                </#if>
+                                            </#list>
+                                        </#list>
+                                        </table>
+                                     </div>
                                  </div>
                              </div>
+                             </#if>
                           </#if>
                           <!-- Setup ad templates section -->
                           <#if primaryCate?has_content && primaryCate.getCategoryID()?exists && listingTypes?has_content>
@@ -781,4 +807,4 @@ under the License.
     </#if-->
 </form>
 </div>
-</div>
\ No newline at end of file
+</div>