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/02/26 08:51:20 UTC

svn commit: r916603 - in /ofbiz/trunk/specialpurpose/ebaystore: config/ data/ script/org/ofbiz/ebaystore/ servicedef/ src/org/ofbiz/ebaystore/ widget/

Author: hansbak
Date: Fri Feb 26 07:51:20 2010
New Revision: 916603

URL: http://svn.apache.org/viewvc?rev=916603&view=rev
Log:
Ebaystore update: Reformat and grouped the source code (auto dispute and auto relisting) to EbayStoreAutoPreferences class and changed the service name of this function.

Modified:
    ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml
    ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml
    ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml
    ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml
    ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java
    ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml
    ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml

Modified: ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml?rev=916603&r1=916602&r2=916603&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/config/EbayStoreUiLabels.xml Fri Feb 26 07:51:20 2010
@@ -154,6 +154,9 @@
     <property key="EbayAutomationRelistItems">
         <value xml:lang="en">Automation Re-list Items</value>
     </property>
+    <property key="EbayAutomatiionDisputeItems">
+        <value xml:lang="en">Automation Dispute Items</value>
+    </property>
     
     <property key="EbayBoughtLeaveFeedback">
         <value xml:lang="en">Bought</value>

Modified: ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml?rev=916603&r1=916602&r2=916603&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/data/DemoEbayStoreData.xml Fri Feb 26 07:51:20 2010
@@ -23,6 +23,7 @@
     <Party partyId="DemoEbayAccount" partyTypeId="PERSON"/>
     <Person partyId="DemoEbayAccount" firstName="Demo ebay account" lastName="USA"/>
     <PartyRole partyId="DemoEbayAccount" roleTypeId="EBAY_ACCOUNT"/>
+    <PartyRole partyId="DemoEbayAccount" roleTypeId="VENDOR"/>
     <UserLogin userLoginId="esandbox10543" partyId="DemoEbayAccount" currentPassword="{SHA}bbf272ce445e1c48d94096afdba6a7888c1df1fe"/>
     <ProductStore productStoreId="90100" storeName="OFBiz Ebay Store-USA" companyName="Apache Ofbiz" title="Test esandbox10543 store"
         subtitle="Part of the Open For Business Family of Open Source Software" payTopartyId="DemoEbayAccount" daysToCancelNonPay="30" prorateShipping="Y" prorateTaxes="Y"

Modified: ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml?rev=916603&r1=916602&r2=916603&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/data/EbayStoreTypeData.xml Fri Feb 26 07:51:20 2010
@@ -33,4 +33,6 @@
     <Enumeration enumId="EBAY_AUTO_PIT_FB" description="Automatic leave positive feedback when buyer has paid for item" enumTypeId="EBAY_AUTO_PREF"/>
     <Enumeration enumId="EBAY_AUTO_FB_RMD" description="Automatic send reminder email if feedback has not been received after day? shipping" enumTypeId="EBAY_AUTO_PREF"/>
     
+    <ProductType productTypeId="EBAY_ITEM" description="Product From eBay"/>
+    
 </entity-engine-xml>

Modified: ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml?rev=916603&r1=916602&r2=916603&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/script/org/ofbiz/ebaystore/EbayServices.xml Fri Feb 26 07:51:20 2010
@@ -27,6 +27,10 @@
             <result-to-field result-name="partyId" field="parameters.partyId"/>
         </call-service>
         
+        <set field="parameters.roleTypeId" value="VENDOR" />
+        <set-service-fields service-name="createPartyRole" to-map="newPartyRole" map="parameters"/>
+        <call-service service-name="createPartyRole" in-map-name="newPartyRole"/>
+        
         <set field="parameters.storeName" value="${parameters.userLoginId}_store"/>
         <set-service-fields service-name="createProductStore" to-map="newProductStore" map="parameters"/>
         <call-service service-name="createProductStore" in-map-name="newProductStore">

Modified: ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml?rev=916603&r1=916602&r2=916603&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/servicedef/services.xml Fri Feb 26 07:51:20 2010
@@ -172,19 +172,6 @@
         <attribute name="period" mode="IN" type="String" optional="true"/>
         <attribute name="soldItems" mode="OUT" type="List" optional="true"/>
     </service>
-    <service name="automaticEbayRelistSoldItems" engine="java"  transaction-timeout="3600"
-        location="org.ofbiz.ebaystore.EbayStore" invoke="automaticEbayRelistSoldItems" auth="true">
-    </service>   
-    <service name="createEbayAutomaticRelistItems" engine="entity-auto" default-entity-name="JobSandbox" invoke="create">
-        <description>create eBay automatic re-list items</description>
-        <auto-attributes mode="IN" include="pk"/>
-        <auto-attributes mode="IN" optional="true" include="nonpk"/>
-    </service>
-    <service name="updateEbayAutomaticRelistItems" engine="entity-auto" default-entity-name="JobSandbox" invoke="update">
-        <description>create eBay automatic re-list items</description>
-        <auto-attributes mode="IN" include="pk"/>
-        <auto-attributes mode="IN" optional="true" include="nonpk"/>
-    </service>
     <!-- block out of stock items -->
     <service name="getSellingInventory" engine="java" transaction-timeout="7200"
         location="org.ofbiz.ebaystore.EbayStore" invoke="getSellingInventory" auth="true">
@@ -357,4 +344,18 @@
         location="org.ofbiz.ebaystore.EbayStoreAutoPreferences" invoke="autoSendFeedbackReminderEmail" auth="true">
         <attribute name="productStoreId" mode="IN" type="String" optional="false"/>
     </service>
+    <service name="automaticEbayRelistSoldItems" engine="java"  transaction-timeout="3600"
+        location="org.ofbiz.ebaystore.EbayStoreAutoPreferences" invoke="automaticEbayRelistSoldItems" auth="false">
+        <attribute name="jobId" mode="IN" type="String" optional="false"/>
+    </service>
+    <service name="automaticEbayDisputeNotComplete" engine="java"  transaction-timeout="3600"
+        location="org.ofbiz.ebaystore.EbayStoreAutoPreferences" invoke="automaticEbayDisputeNotComplete" auth="false">
+        <description>Create Dispute if checkout has not been completed</description>
+        <attribute name="jobId" mode="IN" type="String" optional="false"/>
+    </service>
+    <service name="automaticEbayDisputeNotPay" engine="java"  transaction-timeout="3600"
+        location="org.ofbiz.ebaystore.EbayStoreAutoPreferences" invoke="automaticEbayDisputeNotPay" auth="false">
+        <description>Create Dispute if checkout has been completed but no payment has been received</description>
+        <attribute name="jobId" mode="IN" type="String" optional="false"/>
+    </service>
 </services>
\ No newline at end of file

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java?rev=916603&r1=916602&r2=916603&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java Fri Feb 26 07:51:20 2010
@@ -48,6 +48,7 @@
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.transaction.TransactionUtil;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
@@ -63,6 +64,7 @@
 import com.ebay.sdk.SdkSoapException;
 import com.ebay.sdk.call.*;
 import com.ebay.soap.eBLBaseComponents.AmountType;
+import com.ebay.soap.eBLBaseComponents.CheckoutStatusCodeType;
 import com.ebay.soap.eBLBaseComponents.CurrencyCodeType;
 import com.ebay.soap.eBLBaseComponents.DeleteSellingManagerTemplateRequestType;
 import com.ebay.soap.eBLBaseComponents.DeleteSellingManagerTemplateResponseType;
@@ -108,6 +110,7 @@
 import com.ebay.soap.eBLBaseComponents.StoreThemeType;
 import com.ebay.soap.eBLBaseComponents.StoreType; 
 import com.ebay.soap.eBLBaseComponents.TaskStatusCodeType;
+import com.ebay.soap.eBLBaseComponents.UserType;
 import com.ebay.soap.eBLBaseComponents.VerifyAddSecondChanceItemResponseType;
 
 import java.sql.Timestamp;
@@ -1494,114 +1497,6 @@
 		}
 		return result;
 	}
-	public static Map<String, Object> automaticEbayRelistSoldItems(DispatchContext dctx, Map<String, ? extends Object> context) {
-		Map<String, Object>result = FastMap.newInstance();
-		LocalDispatcher dispatcher = dctx.getDispatcher();
-		GenericValue userLogin = (GenericValue) context.get("userLogin");
-		Delegator delegator = dctx.getDelegator();
-		Locale locale = (Locale) context.get("locale");
-		try {
-			Map<String, Object>serviceMap = FastMap.newInstance();
-			serviceMap.put("userLogin", userLogin);
-			List<GenericValue>stores = delegator.findByAnd("ProductStore", UtilMisc.toMap());
-			for(int storeCount=0;storeCount<stores.size();storeCount++) {
-				String productStoreId = stores.get(storeCount).getString("productStoreId");
-				serviceMap.put("productStoreId", productStoreId);
-				Map eBayUserLogin = dispatcher.runSync("getEbayStoreUser", serviceMap);
-				String eBayUserLoginId = (String)eBayUserLogin.get("userLoginId");
-				if(eBayUserLoginId != null) {
-					List<GenericValue>jobs = delegator.findByAnd("JobSandbox", UtilMisc.toMap("authUserLoginId", eBayUserLoginId));
-					if(jobs.size() != 0) {
-						GenericValue job = jobs.get(0);
-						Timestamp startDateTime = (Timestamp)job.get("startDateTime");
-						Timestamp finishDateTime = (Timestamp)job.get("finishDateTime");
-						//check can re-list items by eBay account setting
-						boolean canRelistItems = false;
-						Timestamp nowTime = UtilDateTime.nowTimestamp();
-						if(startDateTime!=null&&finishDateTime!=null) {
-							if(startDateTime.before(nowTime) && finishDateTime.after(nowTime)) {
-								canRelistItems = true;
-							}
-						}else if(startDateTime!=null&&finishDateTime==null) {
-							if(startDateTime.before(nowTime)) {
-								canRelistItems = true;
-							}
-						}
-						if(canRelistItems) {
-							//save sold items to OFbBiz product entity
-							Map resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
-							List soldItems = (List)resultService.get("soldItems");
-							if(soldItems.size()!=0) {
-								for(int itemCount=0;itemCount<soldItems.size();itemCount++) {
-									Map soldItemMap = (Map)soldItems.get(itemCount);
-									if(UtilValidate.isNotEmpty(soldItemMap.get("itemId"))) {
-										GenericValue productCheck = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", soldItemMap.get("itemId")));
-										if(productCheck == null) {
-											GenericValue product = delegator.makeValue("Product");
-											product.set("productId", soldItemMap.get("itemId"));
-											product.set("internalName", soldItemMap.get("title"));
-											product.set("productTypeId", "EBAY_ITEM");
-											product.create();
-										}
-									}
-								}
-							}
-							//check active items
-							serviceMap = FastMap.newInstance();
-							serviceMap.put("userLogin", userLogin);
-							serviceMap.put("productStoreId", productStoreId);
-							resultService = dispatcher.runSync("getEbayActiveItems", serviceMap);
-							List activeItems = (List)resultService.get("activeItems");
-							List<String> activeItemMaps = FastList.newInstance();
-							if(activeItems.size()!=0) {
-								for(int itemCount=0;itemCount<activeItems.size();itemCount++) {
-									Map activeItemMap = (Map)activeItems.get(itemCount);
-									if(UtilValidate.isNotEmpty(activeItemMap.get("itemId"))) {
-										activeItemMaps.add((String)activeItemMap.get("itemId"));
-									}
-								}
-							}
-							List andExpr = FastList.newInstance();
-							EntityCondition activeItemCond = EntityCondition.makeCondition("productId", EntityOperator.NOT_IN, activeItemMaps);
-							andExpr.add(activeItemCond);
-							EntityCondition productTypeCond = EntityCondition.makeCondition("productTypeId", EntityOperator.EQUALS, "EBAY_ITEM");
-							andExpr.add(productTypeCond);
-							EntityCondition isVirtualCond = EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, null);
-							andExpr.add(isVirtualCond);
-							EntityCondition andCond =  EntityCondition.makeCondition(andExpr, EntityOperator.AND);
-				
-							List itemsToRelist = delegator.findList("Product", andCond, null, null, null, false);
-							if(itemsToRelist.size() != 0) {
-								//re-list sold items and not active
-								Map<String, Object> inMap = FastMap.newInstance();
-								inMap.put("productStoreId", productStoreId);
-								inMap.put("userLogin", userLogin);
-								Map<String, Object> resultUser = dispatcher.runSync("getEbayStoreUser", inMap);
-								String userID = (String)resultUser.get("userLoginId");
-								ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
-								for(int itemRelist=0;itemRelist<itemsToRelist.size();itemRelist++) {
-									RelistItemCall relistItemCall = new RelistItemCall(apiContext);
-									ItemType itemToBeRelisted = new ItemType();
-									GenericValue product = (GenericValue)itemsToRelist.get(itemRelist);
-									itemToBeRelisted.setItemID(product.getString("productId"));
-									relistItemCall.setItemToBeRelisted(itemToBeRelisted);
-									relistItemCall.relistItem();
-									GenericValue productStore = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", product.getString("productId")));
-									productStore.set("isVirtual", "Y");
-									productStore.store();
-									Debug.logInfo("Relisted Item - "+product.getString("productId"), module);
-								}
-							}
-						}
-					}
-				}
-			}
-		} catch (Exception e) {
-			return ServiceUtil.returnError(e.getMessage());
-		}
-		return ServiceUtil.returnSuccess();
-	}
-	
 	/* ebay store block out of stock items */
 	public static Map<String,Object> getSellingInventory(DispatchContext dctx, Map<String,Object> context) {
 	       Locale locale = (Locale) context.get("locale");

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java?rev=916603&r1=916602&r2=916603&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java Fri Feb 26 07:51:20 2010
@@ -18,9 +18,11 @@
  */
 package org.ofbiz.ebaystore;
 
+import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -31,6 +33,7 @@
 import javax.servlet.http.HttpSession;
 
 import javolution.util.FastList;
+import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilDateTime;
@@ -40,6 +43,8 @@
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -48,18 +53,25 @@
 import com.ebay.sdk.ApiContext;
 import com.ebay.sdk.ApiException;
 import com.ebay.sdk.SdkException;
+import com.ebay.sdk.call.AddDisputeCall;
 import com.ebay.sdk.call.GetSellingManagerSoldListingsCall;
 import com.ebay.sdk.call.GetUserCall;
 import com.ebay.sdk.call.LeaveFeedbackCall;
+import com.ebay.sdk.call.RelistItemCall;
 import com.ebay.soap.eBLBaseComponents.AutomatedLeaveFeedbackEventCodeType;
 import com.ebay.soap.eBLBaseComponents.CommentTypeCodeType;
+import com.ebay.soap.eBLBaseComponents.DetailLevelCodeType;
+import com.ebay.soap.eBLBaseComponents.DisputeExplanationCodeType;
+import com.ebay.soap.eBLBaseComponents.DisputeReasonCodeType;
 import com.ebay.soap.eBLBaseComponents.FeedbackDetailType;
+import com.ebay.soap.eBLBaseComponents.ItemType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerOrderStatusType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerPaidStatusCodeType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerShippedStatusCodeType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerSoldListingsSortTypeCodeType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerSoldOrderType;
 import com.ebay.soap.eBLBaseComponents.SellingManagerSoldTransactionType;
+import com.ebay.soap.eBLBaseComponents.UserType;
 
 public class EbayStoreAutoPreferences {
 	public static String module = EbayStoreAutoPreferences.class.getName();
@@ -233,7 +245,6 @@
 
 		return "success";
 	}
-	
 	/* start automatically service send a Feedback Reminder email if feedback has not been received. and check how many days after shipping you want this email sent? */
 	public static Map<String, Object> autoSendFeedbackReminderEmail(DispatchContext dctx, Map<String, ? extends Object> context) throws ApiException, SdkException, Exception{
 		Delegator delegator = dctx.getDelegator();
@@ -309,4 +320,269 @@
 		
 		return ServiceUtil.returnSuccess();
 	}
+	public static Map<String, Object> automaticEbayRelistSoldItems(DispatchContext dctx, Map<String, ? extends Object> context) {
+		Map<String, Object>result = FastMap.newInstance();
+		LocalDispatcher dispatcher = dctx.getDispatcher();
+		Delegator delegator = dctx.getDelegator();
+		Locale locale = (Locale) context.get("locale");
+		String jobId = (String) context.get("jobId");
+		try {
+			GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+			Map<String, Object>serviceMap = FastMap.newInstance();
+			serviceMap.put("userLogin", userLogin);
+			List<GenericValue>stores = delegator.findByAnd("ProductStore", UtilMisc.toMap());
+			//ProductStore
+			List<GenericValue> productStores = delegator.findByAnd("EbayProductStorePref", UtilMisc.toMap("autoPrefJobId", jobId));
+			if (productStores.size() != 0) {
+				// get auto preference setting
+				String productStoreId = productStores.get(0).getString("productStoreId");
+				String condition1 = productStores.get(0).getString("condition1");
+				String condition2 = productStores.get(0).getString("condition2");
+				// convert preference setting
+				Timestamp fromDate = UtilDateTime.toTimestamp(condition1);
+				Timestamp thruDate = UtilDateTime.toTimestamp(condition2);
+				Timestamp nowTime = UtilDateTime.nowTimestamp();
+				if (nowTime.after(fromDate) && nowTime.before(thruDate)) {
+					serviceMap.put("productStoreId", productStoreId);
+					Map eBayUserLogin = dispatcher.runSync("getEbayStoreUser", serviceMap);
+					String eBayUserLoginId = (String)eBayUserLogin.get("userLoginId");
+					GenericValue party =  delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", eBayUserLoginId));
+					String partyId = party.getString("partyId");
+					//save sold items to OFbBiz product entity
+					Map resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
+					List soldItems = (List) resultService.get("soldItems");
+					if (soldItems.size()!=0) {
+						for (int itemCount = 0; itemCount < soldItems.size(); itemCount++) {
+							Map soldItemMap = (Map)soldItems.get(itemCount);
+							if (UtilValidate.isNotEmpty(soldItemMap.get("itemId"))) {
+								GenericValue productCheck = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", soldItemMap.get("itemId")));
+								if (productCheck == null) {
+									Map<String, Object>inMap = FastMap.newInstance();
+									inMap.put("productId", soldItemMap.get("itemId"));
+									inMap.put("productTypeId", "EBAY_ITEM");
+									inMap.put("internalName", "eBay Item " + soldItemMap.get("title"));
+									inMap.put("userLogin", userLogin);
+									dispatcher.runSync("createProduct", inMap);
+									// ProductRole (VENDOR)
+									List productRole = delegator.findByAnd("ProductRole", UtilMisc.toMap("partyId", partyId, "productId", soldItemMap.get("itemId"), "roleTypeId", "VENDOR"));
+									if (productRole.size() == 0) {
+										Map<String, Object>addRole = FastMap.newInstance();
+										addRole.put("productId", soldItemMap.get("itemId"));
+										addRole.put("roleTypeId", "VENDOR");
+										addRole.put("partyId", partyId);
+										addRole.put("fromDate", UtilDateTime.nowTimestamp());
+										addRole.put("userLogin", userLogin);
+										dispatcher.runSync("addPartyToProduct", addRole);
+									}
+								}
+							}
+						}
+					}
+					//check active items
+					serviceMap = FastMap.newInstance();
+					serviceMap.put("userLogin", userLogin);
+					serviceMap.put("productStoreId", productStoreId);
+					resultService = dispatcher.runSync("getEbayActiveItems", serviceMap);
+					List activeItems = (List) resultService.get("activeItems");
+					List<String> activeItemMaps = FastList.newInstance();
+					if (activeItems.size() != 0) {
+						for (int itemCount = 0; itemCount < activeItems.size(); itemCount++) {
+							Map activeItemMap = (Map)activeItems.get(itemCount);
+							if (UtilValidate.isNotEmpty(activeItemMap.get("itemId"))) {
+								activeItemMaps.add((String)activeItemMap.get("itemId"));
+							}
+						}
+					}
+					//check product role
+					List<GenericValue>productRoles = delegator.findByAnd("ProductRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", "VENDOR"));
+					List<String>productRoleIds = FastList.newInstance();
+					if (productRoles.size() != 0) {
+						for (int itemCount = 0; itemCount < productRoles.size(); itemCount++) {
+							String productId = productRoles.get(itemCount).getString("productId");
+							productRoleIds.add(productId);
+						}
+					}
+					List andExpr = FastList.newInstance();
+					EntityCondition activeItemCond = EntityCondition.makeCondition("productId", EntityOperator.NOT_IN, activeItemMaps);
+					andExpr.add(activeItemCond);
+					EntityCondition productTypeCond = EntityCondition.makeCondition("productTypeId", EntityOperator.EQUALS, "EBAY_ITEM");
+					andExpr.add(productTypeCond);
+					EntityCondition isVirtualCond = EntityCondition.makeCondition("isVirtual", EntityOperator.NOT_EQUAL, "Y");
+					andExpr.add(isVirtualCond);
+					EntityCondition productRole = EntityCondition.makeCondition("productId", EntityOperator.IN, productRoleIds);
+					andExpr.add(productRole);
+					EntityCondition andCond =  EntityCondition.makeCondition(andExpr, EntityOperator.AND);
+					List itemsToRelist = delegator.findList("Product", andCond, null, null, null, false);
+					if (itemsToRelist.size() != 0) {
+						//re-list sold items and not active
+						Map<String, Object> inMap = FastMap.newInstance();
+						inMap.put("productStoreId", productStoreId);
+						inMap.put("userLogin", userLogin);
+						Map<String, Object> resultUser = dispatcher.runSync("getEbayStoreUser", inMap);
+						String userID = (String) resultUser.get("userLoginId");
+						ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+						for (int itemRelist = 0; itemRelist < itemsToRelist.size(); itemRelist++) {
+							RelistItemCall relistItemCall = new RelistItemCall(apiContext);
+							ItemType itemToBeRelisted = new ItemType();
+							GenericValue product = (GenericValue)itemsToRelist.get(itemRelist);
+							itemToBeRelisted.setItemID(product.getString("productId"));
+							relistItemCall.setItemToBeRelisted(itemToBeRelisted);
+							relistItemCall.relistItem();
+							GenericValue productStore = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", product.getString("productId")));
+							productStore.set("isVirtual", "Y");
+							productStore.store();
+							Debug.logInfo("Relisted Item - " + product.getString("productId"), module);
+						}
+					}
+				}
+			}
+		} catch (Exception e) {
+			return ServiceUtil.returnError(e.getMessage());
+		}
+		return ServiceUtil.returnSuccess();
+	}
+	public static Map<String, Object> automaticEbayDisputeNotComplete(DispatchContext dctx, Map<String, ? extends Object> context) {
+		Map<String, Object>result = FastMap.newInstance();
+		LocalDispatcher dispatcher = dctx.getDispatcher();
+		Delegator delegator = dctx.getDelegator();
+		Locale locale = (Locale) context.get("locale");
+		String jobId = (String) context.get("jobId");
+		try {
+			GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+			List<GenericValue> productStores = delegator.findByAnd("EbayProductStorePref", UtilMisc.toMap("autoPrefJobId", jobId));
+			if (productStores.size() != 0) {
+				// get automatic setting
+				String productStoreId = productStores.get(0).getString("productStoreId");
+				String condition1 = productStores.get(0).getString("condition1");
+				String condition2 = productStores.get(0).getString("condition2");
+				String condition3 = productStores.get(0).getString("condition3");
+				// convert automatic setting for usage
+				int afterDays = 0;
+				if (UtilValidate.isInteger(condition1)) {
+					afterDays = Integer.parseInt(condition1);
+				}
+				DisputeReasonCodeType disputeReason = null;
+				if (UtilValidate.isNotEmpty(condition2)) {
+					disputeReason = DisputeReasonCodeType.valueOf(condition2);
+				}
+				DisputeExplanationCodeType disputeExplanation = null;
+				if (UtilValidate.isNotEmpty(condition3)) {
+					disputeExplanation = DisputeExplanationCodeType.valueOf(condition3);
+				}
+				// get sold items
+				Map<String, Object>serviceMap = FastMap.newInstance();
+				serviceMap.put("productStoreId", productStoreId);
+				serviceMap.put("userLogin", userLogin);
+				Map resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
+				List soldItems = (List) resultService.get("soldItems");
+				// check items to dispute
+				List<Map>itemsToDispute = FastList.newInstance();
+				for (int itemCount = 0; itemCount < soldItems.size(); itemCount++) {
+					Map item = (Map) soldItems.get(itemCount);
+					String checkoutStatus = (String) item.get("checkoutStatus");
+					Date creationTime = (Date) item.get("creationTime");
+					Date paidTime = (Date) item.get("paidTime");
+					String unpaidItemStatus = (String) item.get("unpaidItemStatus");
+					int checkDays = UtilDateTime.getIntervalInDays(UtilDateTime.toTimestamp(creationTime), UtilDateTime.nowTimestamp());
+					if (checkDays > afterDays && "CheckoutIncomplete".equals(checkoutStatus) && unpaidItemStatus == null && paidTime == null && checkoutStatus != "CheckoutComplete") {
+						itemsToDispute.add(item);
+					}
+				}
+				// Dispute items
+				if (disputeReason != null && disputeExplanation != null && itemsToDispute.size() != 0) {
+					ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+					DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
+					          DetailLevelCodeType.RETURN_ALL,
+					          DetailLevelCodeType.ITEM_RETURN_ATTRIBUTES,
+					          DetailLevelCodeType.ITEM_RETURN_DESCRIPTION
+					      };
+					for (int count = 0; count < itemsToDispute.size(); count++) {
+						Map<String, Object>item = itemsToDispute.get(count);
+						AddDisputeCall api = new AddDisputeCall(apiContext);
+					    api.setDetailLevel(detailLevels);
+					    api.setItemID((String)item.get("itemId"));
+					    api.setTransactionID((String)item.get("transactionId"));
+					    api.setDisputeExplanation(disputeExplanation);
+					    api.setDisputeReason(disputeReason);
+					    String id = api.addDispute();
+					}
+				}
+			}
+		} catch (Exception e) {
+			return ServiceUtil.returnError(e.getMessage());
+		}
+		return ServiceUtil.returnSuccess();
+	}
+	public static Map<String, Object> automaticEbayDisputeNotPay(DispatchContext dctx, Map<String, ? extends Object> context) {
+		Map<String, Object>result = FastMap.newInstance();
+		LocalDispatcher dispatcher = dctx.getDispatcher();
+		Delegator delegator = dctx.getDelegator();
+		Locale locale = (Locale) context.get("locale");
+		String jobId = (String) context.get("jobId");
+		try {
+			GenericValue userLogin = delegator.findOne("UserLogin", false, "userLoginId", "system");
+			List<GenericValue> productStores = delegator.findByAnd("EbayProductStorePref", UtilMisc.toMap("autoPrefJobId", jobId));
+			if (productStores.size() != 0) {
+				// get automatic setting
+				String productStoreId = productStores.get(0).getString("productStoreId");
+				String condition1 = productStores.get(0).getString("condition1");
+				String condition2 = productStores.get(0).getString("condition2");
+				String condition3 = productStores.get(0).getString("condition3");
+				// convert automatic setting for usage
+				int afterDays = 0;
+				if (UtilValidate.isInteger(condition1)) {
+					afterDays = Integer.parseInt(condition1);
+				}
+				DisputeReasonCodeType disputeReason = null;
+				if (UtilValidate.isNotEmpty(condition2)) {
+					disputeReason = DisputeReasonCodeType.valueOf(condition2);
+				}
+				DisputeExplanationCodeType disputeExplanation = null;
+				if (UtilValidate.isNotEmpty(condition3)) {
+					disputeExplanation = DisputeExplanationCodeType.valueOf(condition3);
+				}
+				// get sold items
+				Map<String, Object>serviceMap = FastMap.newInstance();
+				serviceMap.put("productStoreId", productStoreId);
+				serviceMap.put("userLogin", userLogin);
+				Map resultService = dispatcher.runSync("getEbaySoldItems", serviceMap);
+				List soldItems = (List) resultService.get("soldItems");
+				// check items to dispute
+				List<Map>itemsToDispute = FastList.newInstance();
+				for (int itemCount = 0; itemCount < soldItems.size(); itemCount++) {
+					Map item = (Map) soldItems.get(itemCount);
+					String checkoutStatus = (String) item.get("checkoutStatus");
+					Date creationTime = (Date) item.get("creationTime");
+					Date paidTime = (Date) item.get("paidTime");
+					String unpaidItemStatus = (String) item.get("unpaidItemStatus");
+					int checkDays = UtilDateTime.getIntervalInDays(UtilDateTime.toTimestamp(creationTime), UtilDateTime.nowTimestamp());
+					if (checkDays > afterDays && unpaidItemStatus == null && paidTime == null && checkoutStatus == "CheckoutComplete") {
+						itemsToDispute.add(item);
+					}
+				}
+				// Dispute items
+				if (disputeReason != null && disputeExplanation != null && itemsToDispute.size() != 0) {
+					ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+					DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
+					          DetailLevelCodeType.RETURN_ALL,
+					          DetailLevelCodeType.ITEM_RETURN_ATTRIBUTES,
+					          DetailLevelCodeType.ITEM_RETURN_DESCRIPTION
+					      };
+					for (int count = 0; count < itemsToDispute.size(); count++) {
+						Map<String, Object>item = itemsToDispute.get(count);
+						AddDisputeCall api = new AddDisputeCall(apiContext);
+					    api.setDetailLevel(detailLevels);
+					    api.setItemID((String)item.get("itemId"));
+					    api.setTransactionID((String)item.get("transactionId"));
+					    api.setDisputeExplanation(disputeExplanation);
+					    api.setDisputeReason(disputeReason);
+					    String id = api.addDispute();
+					}
+				}
+			}
+		} catch (Exception e) {
+			return ServiceUtil.returnError(e.getMessage());
+		}
+		return ServiceUtil.returnSuccess();
+	}
 }

Modified: ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml?rev=916603&r1=916602&r2=916603&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerForms.xml Fri Feb 26 07:51:20 2010
@@ -27,9 +27,8 @@
     	<alt-target use-when="ebayPrefRelisting!=null" target="updateEbayProductStorePref"/>
         <field name="productStoreId"><hidden value="${parameters.productStoreId}"/></field>
         <field name="enabled" tooltip="${uiLabelMap.EbayAutoRelisting}" tooltip-style="h3"><check/></field>
-        <field name="condition1"><hidden value="${userLoginId}"/></field>
-        <field name="condition2" title="${uiLabelMap.CommonFromDate}"><date-time/></field>
-        <field name="condition3" title="${uiLabelMap.CommonThruDate}"><date-time/></field>
+        <field name="condition1" title="${uiLabelMap.CommonFromDate}"><date-time/></field>
+        <field name="condition2" title="${uiLabelMap.CommonThruDate}"><date-time/></field>
         <field name="serviceName"><hidden value="${serviceName}"/></field>
         <field name="autoPrefEnumId"><hidden value="${autoPrefEnumId}"/></field>
         <field name="submit" title="${uiLabelMap.CommonApply}"><submit/></field>

Modified: ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml?rev=916603&r1=916602&r2=916603&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/widget/EbaySellingManagerScreens.xml Fri Feb 26 07:51:20 2010
@@ -289,8 +289,8 @@
                 <set field="tabButtonItem" value="automaticEbayDisputeItems"/>
                 <set field="autoPrefEnumId1" value="EBAY_AUTO_DISPUTE1"/>
                 <set field="autoPrefEnumId2" value="EBAY_AUTO_DISPUTE2"/>
-                <set field="serviceName1" value="eBayAutomaticDisputeNotComplete"/>
-                <set field="serviceName2" value="eBayAutomaticDisputeNotPay"/>
+                <set field="serviceName1" value="automaticEbayDisputeNotComplete"/>
+                <set field="serviceName2" value="automaticEbayDisputeNotPay"/>
                 <entity-one value-field="ebayPrefDispute1" entity-name="EbayProductStorePref">
                 	<field-map field-name="productStoreId" from-field="parameters.productStoreId"/>
                 	<field-map field-name="autoPrefEnumId" from-field="autoPrefEnumId1"/>
@@ -302,7 +302,7 @@
                 <script location="component://ebaystore/webapp/ebaystore/WEB-INF/actions/automationPreferences/GetDisputeInfo.groovy"/>
             </actions>
             <widgets>
-                <screenlet title="${uiLabelMap.EbayAutomaticDispute}" collapsible="true" name="AutomationDispute">
+                <screenlet title="${uiLabelMap.EbayAutomatiionDisputeItems}" collapsible="true" name="AutomationDispute">
                     <include-form name="AutomationDisputeNotComplete"  location="component://ebaystore/widget/EbaySellingManagerForms.xml"/>
                     <include-form name="AutomationDisputeNotPay"  location="component://ebaystore/widget/EbaySellingManagerForms.xml"/>
                 </screenlet>