Subversion Repositories SmartDukaan

Rev

Rev 9855 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9855 Rev 12290
Line 1... Line 1...
1
package in.shop2020.inventory.controllers;
1
package in.shop2020.inventory.controllers;
2
 
2
 
3
import in.shop2020.googleadwords.feedshandler.ContentFeedsHandler;
-
 
4
import in.shop2020.googleadwords.model.Product;
-
 
5
import in.shop2020.googleadwords.util.UserInformation;
-
 
-
 
3
 
6
import in.shop2020.logistics.DeliveryType;
4
import in.shop2020.logistics.DeliveryType;
7
import in.shop2020.logistics.LogisticsService;
5
import in.shop2020.logistics.LogisticsService;
8
import in.shop2020.model.v1.catalog.CatalogService;
6
import in.shop2020.model.v1.catalog.CatalogService;
9
import in.shop2020.model.v1.catalog.CatalogServiceException;
7
import in.shop2020.model.v1.catalog.CatalogServiceException;
10
import in.shop2020.model.v1.catalog.Item;
8
import in.shop2020.model.v1.catalog.Item;
Line 32... Line 30...
32
import org.apache.poi.hssf.usermodel.HSSFSheet;
30
import org.apache.poi.hssf.usermodel.HSSFSheet;
33
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
31
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
34
import org.apache.thrift.TException;
32
import org.apache.thrift.TException;
35
import org.apache.thrift.transport.TTransportException;
33
import org.apache.thrift.transport.TTransportException;
36
 
34
 
-
 
35
import com.google.api.services.content.handler.ContentFeedsHandler;
-
 
36
import com.google.api.services.content.model.Product;
-
 
37
 
37
 
38
 
38
public class ProductFeedsController extends BaseController{
39
public class ProductFeedsController extends BaseController{
39
	
40
	
40
	private String cataLogItemId;
41
	private String cataLogItemId;
41
	private String sentFeedResult;
42
	private String sentFeedResult;
Line 145... Line 146...
145
			e1.printStackTrace();
146
			e1.printStackTrace();
146
		}
147
		}
147
		
148
		
148
		if(cataLogItemId!=null && !("").equalsIgnoreCase(cataLogItemId)){
149
		if(cataLogItemId!=null && !("").equalsIgnoreCase(cataLogItemId)){
149
			List<Long> itemIdList = getEntityLogisticsEstimation(Long.parseLong(cataLogItemId));
150
			List<Long> itemIdList = getEntityLogisticsEstimation(Long.parseLong(cataLogItemId));
150
			UserInformation userInformation = new UserInformation("8587366",
-
 
151
					"http://www.saholic.com",
-
 
152
					"adwords@shop2020.in", "adwords_shop2020");
-
 
153
			ContentFeedsHandler sample = new ContentFeedsHandler(userInformation,
151
			ContentFeedsHandler sample = new ContentFeedsHandler();
154
					"https://content.googleapis.com/content/v1/");
-
 
155
			
152
			
156
			if(catalogClient!= null){
153
			if(catalogClient!= null){
157
				if(itemIdList!=null && itemIdList.size()>0){
154
				if(itemIdList!=null && itemIdList.size()>0){
158
					try {
155
					try {
159
						Item item = catalogClient.getClient().getItem(itemIdList.get(0));
156
						Item item = catalogClient.getClient().getItem(itemIdList.get(0));
Line 171... Line 168...
171
					return "output";
168
					return "output";
172
				}
169
				}
173
			}
170
			}
174
		}
171
		}
175
		if(insertedProduct!=null){
172
		if(insertedProduct!=null){
176
			if(insertedProduct.content!=null && insertedProduct.content.value.indexOf("Error:")>-1){
173
			if(insertedProduct.getDescription()!=null && insertedProduct.getDescription().indexOf("Error:")>-1){
177
				sentFeedResult = insertedProduct.content.value;
174
				sentFeedResult = insertedProduct.getDescription();
178
				return "output";
175
				return "output";
179
			}
176
			}
180
			
177
			
181
			sentFeedResult = "Product Feeds are sent Successfully and Product Details are Given Below:\nProduct Id- "
178
			sentFeedResult = "Product Feeds are sent Successfully and Product Details are Given Below:\nProduct Id- "
182
				+insertedProduct.externalId+" Product Title- "+insertedProduct.title;
179
				+insertedProduct.getId()+" Product Title- "+insertedProduct.getTitle();
183
			
180
			
184
			if(catalogClient!=null){
181
			if(catalogClient!=null){
185
				ProductFeedSubmit feedSubmit = null;
182
				ProductFeedSubmit feedSubmit = null;
186
				try {
183
				try {
187
					feedSubmit= catalogClient.getClient().getProductFeedSubmit(Long.parseLong(cataLogItemId));
184
					feedSubmit= catalogClient.getClient().getProductFeedSubmit(Long.parseLong(cataLogItemId));
Line 236... Line 233...
236
		if(catalogClient!=null){
233
		if(catalogClient!=null){
237
			ProductFeedSubmit feedSubmit = null;
234
			ProductFeedSubmit feedSubmit = null;
238
			try {
235
			try {
239
				feedSubmit= catalogClient.getClient().getProductFeedSubmit(Long.parseLong(catalogItemIdDelete));
236
				feedSubmit= catalogClient.getClient().getProductFeedSubmit(Long.parseLong(catalogItemIdDelete));
240
				if(feedSubmit!=null && feedSubmit.getCatalogItemId() > 0l){
237
				if(feedSubmit!=null && feedSubmit.getCatalogItemId() > 0l){
241
					UserInformation userInformation = new UserInformation("8587366",
-
 
242
							"http://www.saholic.com",
238
					
243
							"adwords@shop2020.in", "adwords_shop2020");
-
 
244
					ContentFeedsHandler sample = new ContentFeedsHandler(userInformation,
239
					ContentFeedsHandler sample = new ContentFeedsHandler();
245
							"https://content.googleapis.com/content/v1/");
-
 
246
					boolean deleteFeedResultBool = sample.deleteProduct(Long.parseLong(catalogItemIdDelete));
240
					boolean deleteFeedResultBool = sample.deleteProductFeed(Long.parseLong(catalogItemIdDelete));
247
					if(deleteFeedResultBool){
241
					if(deleteFeedResultBool){
248
						deleteFeedResult = "Product Feeds are deleted Successfully For Product Id "+ catalogItemIdDelete;
242
						deleteFeedResult = "Product Feeds are deleted Successfully For Product Id "+ catalogItemIdDelete;
249
						boolean deleteResult = catalogClient.getClient().deleteProductFeedSubmit(Long.parseLong(catalogItemIdDelete));
243
						boolean deleteResult = catalogClient.getClient().deleteProductFeedSubmit(Long.parseLong(catalogItemIdDelete));
250
						if(deleteResult){
244
						if(deleteResult){
251
							deleteFeedResult = deleteFeedResult + "\n And Deleted from our System Successfully";
245
							deleteFeedResult = deleteFeedResult + "\n And Deleted from our System Successfully";