Subversion Repositories SmartDukaan

Rev

Rev 5113 | Rev 5347 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1678 rajveer 1
package in.shop2020.util;
2
 
5113 amit.gupta 3
import in.shop2020.logistics.DeliveryType;
4
import in.shop2020.logistics.LogisticsInfo;
5
import in.shop2020.logistics.LogisticsService;
4188 varun.gupt 6
import in.shop2020.metamodel.core.Entity;
4802 amit.gupta 7
import in.shop2020.metamodel.definitions.Catalog;
8
import in.shop2020.metamodel.definitions.DefinitionsContainer;
4188 varun.gupt 9
import in.shop2020.metamodel.util.CreationUtils;
1678 rajveer 10
import in.shop2020.model.v1.catalog.Item;
4188 varun.gupt 11
import in.shop2020.model.v1.catalog.status;
12
import in.shop2020.model.v1.user.ItemCouponDiscount;
13
import in.shop2020.thrift.clients.CatalogClient;
5113 amit.gupta 14
import in.shop2020.thrift.clients.LogisticsClient;
4188 varun.gupt 15
import in.shop2020.thrift.clients.PromotionClient;
16
 
2130 rajveer 17
import java.io.File;
1678 rajveer 18
import java.util.ArrayList;
4188 varun.gupt 19
import java.util.Date;
4143 varun.gupt 20
import java.util.HashMap;
1678 rajveer 21
import java.util.List;
22
import java.util.Map;
23
 
4202 varun.gupt 24
import org.apache.commons.lang.StringEscapeUtils;
1678 rajveer 25
import org.apache.commons.lang.StringUtils;
4143 varun.gupt 26
import org.json.JSONObject;
1678 rajveer 27
 
28
/**
29
 * Command line utility to generate xml file for partners
30
 * 
31
 * @author rajveer
32
 *
33
 */
34
public class ProductListGenerator {
35
 
36
	private String[] xmlIndentation = {"", "    ", "        ", "            ","                "};
2367 rajveer 37
	public Map<Long, List<Item>> entityIdItemMap;
5113 amit.gupta 38
	private static final String DEFAULT_PINCODE = "110001";
4802 amit.gupta 39
	DefinitionsContainer defContainer = Catalog.getInstance().getDefinitionsContainer();
1678 rajveer 40
 
2367 rajveer 41
	public ProductListGenerator(Map<Long, List<Item>> entityIdItemMap) throws Exception {
42
		this.entityIdItemMap = entityIdItemMap;
1678 rajveer 43
	}
44
 
45
 
46
	/**
2367 rajveer 47
	 * Get the url of the entity
1678 rajveer 48
	 * @param expEntity
49
	 * @return url
50
	 */
2367 rajveer 51
	private String getProductURL(long entityId, Item item){
4802 amit.gupta 52
		//long rootCategoryId = catm.getCategory(item.getCategory()).getParent_category_id();
53
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
54
 
55
		String url = "http://www.saholic.com/" + parentCategory.getLabel().toLowerCase().replace(' ', '-') + "/";
2367 rajveer 56
		String productUrl = ((item.getBrand() != null) ? item.getBrand().trim() + " " : "").toLowerCase().replace(' ', '-')
57
        + "-" + ((item.getModelName() != null) ? item.getModelName().trim() + " " : "").toLowerCase().replace(' ', '-') 
58
	    + "-" + (( item.getModelNumber() != null ) ? item.getModelNumber().trim() + " ": "" ).toLowerCase().replace(' ', '-')
59
        + "-" + entityId;
1678 rajveer 60
		productUrl = productUrl.replaceAll("/", "-");
61
		url = url + productUrl;
2367 rajveer 62
		url = url.replaceAll("-+", "-");
1678 rajveer 63
		return url;
64
	}
65
 
2367 rajveer 66
 
67
 
1678 rajveer 68
	/**
3964 rajveer 69
	 * Get the minimum mrp of the items
70
	 * @param items
71
	 * @return
72
	 */
73
	private double getMinMRP(List<Item> items){
74
        double minPrice = Double.MAX_VALUE;
75
        for(Item item: items){
76
            if(minPrice > item.getMrp()){
77
                minPrice =  item.getMrp();
78
            }
79
        }
80
        return minPrice;
81
    }
82
 
83
 
84
 
85
	/**
2367 rajveer 86
	 * Get the minimum price of the items
87
	 * @param items
88
	 * @return
89
	 */
90
	private double getMinPrice(List<Item> items){
91
        double minPrice = Double.MAX_VALUE;
92
        for(Item item: items){
93
            if(minPrice > item.getSellingPrice()){
94
                minPrice = item.getSellingPrice();
95
            }
96
        }
97
        return minPrice;
98
    }
99
 
100
	/**
101
	 * Check whether product is mobile or not
102
	 * @param item
103
	 * @return
104
	 */
105
	private boolean isMobile(Item item){
4802 amit.gupta 106
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
107
		return parentCategory.getID() == Utils.MOBILE_PHONES_CATAGORY;
2367 rajveer 108
	}
109
 
110
	/**
5229 varun.gupt 111
	 * Checks whether a product is tablet or not
112
	 */
113
	private boolean isTablet(Item item) {
114
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
115
		return parentCategory.getID() == Utils.TABLETS_CATEGORY;
116
	}
117
 
118
	/**
4143 varun.gupt 119
	 * Checks whether a product is laptop or not
120
	 */
121
	private boolean isLaptop(Item item) {
4802 amit.gupta 122
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
123
		return parentCategory.getID() == Utils.LAPTOPS_CATEGORY;
4143 varun.gupt 124
	}
125
 
126
	/**
2367 rajveer 127
	 * 
128
	 * @param item
129
	 * @return
130
	 */
131
	private String getProductTitle(Item item){
2542 rajveer 132
		String title = ((item.getBrand() != null) ? item.getBrand().trim() + " " : "")
133
		+ ((item.getModelName() != null) ? item.getModelName().trim() + " " : "")
134
		+ (( item.getModelNumber() != null ) ? item.getModelNumber().trim() : "" );
2561 rajveer 135
		title = title.replaceAll("  ", " ");
2367 rajveer 136
		return title;
137
	}
138
 
139
	/**
1678 rajveer 140
	 * get xml feed for partner sites
141
	 * @param irDataXMLSnippets
142
	 * @throws Exception
143
	 */
2367 rajveer 144
	private void getProductsXML(ArrayList<String> irDataXMLSnippets) throws Exception{
5113 amit.gupta 145
		LogisticsService.Client prod_client = null;
146
		try {
147
			LogisticsClient logistics_prod = new LogisticsClient("logistics_service_prod_server_host","logistics_service_prod_server_port");
148
			prod_client = logistics_prod.getClient();
149
		} catch (Exception e) {
150
			prod_client = null;
151
			Utils.info("Logistics estimations can't be fetched as Logistics Service is inaccessible"
152
					+ e);
153
		}
2367 rajveer 154
		for(Long entityId: entityIdItemMap.keySet()){
155
			List<Item> items = entityIdItemMap.get(entityId);
156
			Item firstItem = items.get(0);
5229 varun.gupt 157
 
158
			if(!isMobile(firstItem) && !isTablet(firstItem))	{
1678 rajveer 159
				continue;
160
			}
161
 
162
			irDataXMLSnippets.add(this.xmlIndentation[1] + "<products>");	
163
 
2367 rajveer 164
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductSKU>" + entityId + "</ProductSKU>");
1678 rajveer 165
 
2367 rajveer 166
			String title = getProductTitle(firstItem);
1678 rajveer 167
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductName>" + title + "</ProductName>");
168
 
2367 rajveer 169
			String url = getProductURL(entityId, firstItem);
3929 mandeep.dh 170
 
171
			String imageUrl = "http://static" + ((entityId+1)%3) + ".saholic.com" + File.separator + "images" + File.separator +
172
			                  "website" + File.separator + entityId + File.separator + "icon.jpg";
173
 
1678 rajveer 174
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + url + "</ProductURL>");
175
 
176
 
2367 rajveer 177
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductPrice>" + getMinPrice(items) + "</ProductPrice>");
1678 rajveer 178
 
3964 rajveer 179
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + getMinMRP(items) + "</ProductMRP>");
180
 
5113 amit.gupta 181
			LogisticsInfo logisticsInfo = null;
182
			if(prod_client != null){
183
				try {
184
					Long itemId = prod_client.getEntityLogisticsEstimation(
185
							entityId, DEFAULT_PINCODE, DeliveryType.PREPAID)
186
							.get(0);
187
					logisticsInfo = prod_client.getLogisticsEstimation(itemId,
188
							DEFAULT_PINCODE, DeliveryType.PREPAID);
189
					irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductDeliveryEstimate>" + logisticsInfo.getDeliveryTime() + "</ProductDeliveryEstimate>");
190
				} catch (Exception e1) {
191
					Utils.info("Unable to get Estimation for Entity: " + entityId + "\n" + e1);
192
				}
193
			}
2130 rajveer 194
			irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductImageURL>" + imageUrl + "</ProductImageURL>");
195
 
1678 rajveer 196
			irDataXMLSnippets.add(this.xmlIndentation[1] + "</products>");		
197
		}
198
	}
199
 
200
	/**
201
	 * Generate the xml list of all the active phones and store in a file
202
	 * @throws Exception
203
	 */
2227 rajveer 204
	public void generateProductsListXML() throws Exception {
1678 rajveer 205
		ArrayList<String> productXMLSnippets = new ArrayList<String>();
206
		productXMLSnippets.add("<saholic.com>");
207
 
208
		getProductsXML(productXMLSnippets);
209
 
210
		productXMLSnippets.add("</saholic.com>");
211
 
212
		String productDataXML = StringUtils.join(productXMLSnippets, "\n");
213
 
214
		Utils.info(productDataXML);
215
 
216
		// Write it to file
2130 rajveer 217
		String productXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "saholicmobilephones.xml";
1678 rajveer 218
		DBUtils.store(productDataXML, productXMLFilename);
219
	}
2227 rajveer 220
 
221
 
222
 
223
 
224
	/**
225
	 * get xml feed for partner sites
226
	 * @param irDataXMLSnippets
227
	 * @throws Exception
228
	 */
229
	private void getProductsJavascript(StringBuffer sb) throws Exception{
4143 varun.gupt 230
 
231
		Map<String, Long> mobilePhones = new HashMap<String, Long>();
232
		Map<String, Long> laptops = new HashMap<String, Long>();
2367 rajveer 233
 
4143 varun.gupt 234
		for(Long entityId: entityIdItemMap.keySet())	{
235
			Item item = entityIdItemMap.get(entityId).get(0);
236
 
237
			if (isMobile(item))	{
238
				mobilePhones.put(getProductTitle(item), entityId);
2227 rajveer 239
			}
4143 varun.gupt 240
			else if (isLaptop(item))	{
241
				laptops.put(getProductTitle(item), entityId);
2233 rajveer 242
			}
2227 rajveer 243
		}
4143 varun.gupt 244
		Map<String, Map<String, Long>> products = new HashMap<String, Map<String,Long>>();
245
		products.put("mobiles", mobilePhones);
246
		products.put("laptops", laptops);
247
		sb.append(new JSONObject(products));
2227 rajveer 248
	}
249
 
250
 
251
	/**
252
	 * Generate the javascript list of all the active phones and store in a file
253
	 * @throws Exception
254
	 */
255
	public void generateProductListJavascript() throws Exception {
256
		StringBuffer productsJavascript = new StringBuffer();
257
 
4143 varun.gupt 258
		productsJavascript.append("var productIdNames=");
2227 rajveer 259
 
260
		getProductsJavascript(productsJavascript);
261
 
4143 varun.gupt 262
		productsJavascript.append(";");
2227 rajveer 263
 
264
		// Write it to file
265
		String productXMLFilename = Utils.EXPORT_JAVASCRIPT_CONTENT_PATH + "saholicmobilephones.js";
266
		DBUtils.store(productsJavascript.toString(), productXMLFilename);
267
	}
4188 varun.gupt 268
 
269
    private void populateEntityIdItemMap(List<Item> items){
270
        Date toDate = new Date();
271
        for(Item item: items){
272
            //TODO Can be removed as we are checking in calling function
273
            if(!(item.getItemStatus()==status.ACTIVE || item.getItemStatus()==status.CONTENT_COMPLETE || item.getItemStatus() == status.PAUSED)){
274
                continue;
275
            }
276
            if(toDate.getTime() < item.getStartDate() ||  item.getSellingPrice() == 0){
277
                continue;
278
            }
279
            List<Item> itemList = entityIdItemMap.get(item.getCatalogItemId());
280
            if(itemList == null){
281
                itemList = new ArrayList<Item>();
282
            }
283
            itemList.add(item);
284
            entityIdItemMap.put(item.getCatalogItemId(), itemList);
285
        }
286
 
287
        //Remove all items which have not been updated since last content generation.
288
        List<Long> removeEntities = new ArrayList<Long>();
289
        for(Long entityId:entityIdItemMap.keySet()){
290
            boolean isValidEntity = false;
291
            //If any one of the items has been updated before current timestamp, than we generate content for whole entity
292
            for(Item item: entityIdItemMap.get(entityId)){
293
                if(item.getUpdatedOn() > 0){
294
                    isValidEntity = true;
295
                }
296
            }
297
            if(!isValidEntity){
298
                removeEntities.add(entityId);
299
            }
300
        }
301
        for(Long entityId: removeEntities){
302
            entityIdItemMap.remove(entityId);
303
        }
304
    }
5229 varun.gupt 305
 
306
    /**
307
     * Generate XML feed for mobile site
308
     * @throws Exception
309
     */
310
    public void generateXMLFeedForMobileSite() throws Exception	{
311
    	List<String> productXMLSnippets = new ArrayList<String>();
312
		productXMLSnippets.add("<Products>");
313
		List<Long> itemIds = new ArrayList<Long>();
314
 
315
		for(Long entityId: entityIdItemMap.keySet()){
316
			List<Item> items = entityIdItemMap.get(entityId);
317
			Item firstItem = items.get(0);
318
			Utils.info("first Item: " + firstItem);
319
 
320
			if(isMobile(firstItem) || isLaptop(firstItem)) {
321
				itemIds.add(firstItem.getId());
322
			}
323
		}
4188 varun.gupt 324
 
5229 varun.gupt 325
		List<String> descriptions = new ArrayList<String>();
326
		descriptions.add("8MP camera, Super AMOLED Plus display, Android Gingerbread");
327
		descriptions.add("Android OS v2.2 Froyo, 800MHz processor, 3.5\" capacitive display");
328
		descriptions.add("Dual-SIM, Wi-Fi, Bluetooth, Social networking &amp; IM");
329
		descriptions.add("Android Gingerbread, Facebook button, 5MP camera");
330
		descriptions.add("Android Gingerbread, 1GHz processor, 3.7\" Gorilla Glass display");
331
		descriptions.add("2GB RAM, 500GB HDD, Intel Core 2 Duo T6570 processor, DOS");
332
		descriptions.add("4GB RAM, 500GB HDD, Intel Core i5 2410M processor, Windows 7 Basic");
333
		descriptions.add("3.2\" touchscreen, 2MP camera, IM &amp; social networking");
334
 
335
		for(Long entityId: entityIdItemMap.keySet()) {
336
			List<Item> items = entityIdItemMap.get(entityId);
337
			Item firstItem = items.get(0);
338
 
339
			if(!isMobile(firstItem) && !isLaptop(firstItem)){
340
				continue;
341
			}
4188 varun.gupt 342
 
5229 varun.gupt 343
			String url = getProductURL(entityId, firstItem);
344
			String imageUrl = "http://www.saholic.com/images/website" + File.separator + entityId + File.separator + "thumbnail.jpg";
345
			String description = descriptions.get((int) (8 * Math.random()));
346
			double minPrice = getMinPrice(items);
347
 
348
			String productType = "";
349
 
350
			if (firstItem.getCategory() == 10001 || firstItem.getCategory() == 10002 || firstItem.getCategory() == 10003 || firstItem.getCategory() == 10004 || firstItem.getCategory() == 10005)	{
351
				productType = "Mobile Phone";
352
 
353
			} else if (firstItem.getCategory() == 10010)	{
354
				productType = "Tablet";
355
 
356
			} else if (firstItem.getCategory() == 10050)	{
357
				productType = "Laptop";
358
			}
359
 
360
			productXMLSnippets.add(this.xmlIndentation[1] + "<Product>");	
361
 
362
			productXMLSnippets.add(this.xmlIndentation[2] + "<ID>" + entityId + "</ID>");
363
			productXMLSnippets.add(this.xmlIndentation[2] + "<Type>" + productType + "</Type>");
364
			productXMLSnippets.add(this.xmlIndentation[2] + "<Brand>" + firstItem.getBrand() + "</Brand>");
365
			productXMLSnippets.add(this.xmlIndentation[2] + "<ModelName>" + firstItem.getModelName() + "</ModelName>");
366
			productXMLSnippets.add(this.xmlIndentation[2] + "<ModelNumber>" + firstItem.getModelNumber() + "</ModelNumber>");
367
			productXMLSnippets.add(this.xmlIndentation[2] + "<URL>" + url + "</URL>");
368
			productXMLSnippets.add(this.xmlIndentation[2] + "<ImageURL>" + imageUrl + "</ImageURL>");
369
			productXMLSnippets.add(this.xmlIndentation[2] + "<ShortDesc>" + description + "</ShortDesc>");
370
			productXMLSnippets.add(this.xmlIndentation[2] + "<MRP>" + firstItem.getMrp() + "</MRP>");
371
			productXMLSnippets.add(this.xmlIndentation[2] + "<SellingPrice>" + (int)minPrice  + "</SellingPrice>");
372
 
373
			productXMLSnippets.add(this.xmlIndentation[1] + "</Product>");
374
		}
375
 
376
		productXMLSnippets.add("</Products>");
377
 
378
		String productDataXML = StringUtils.join(productXMLSnippets, "\n");
379
 
380
		Utils.info(productDataXML);
381
 
382
		// Write it to file
383
		String productXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "msitedata.xml";
384
		DBUtils.store(productDataXML, productXMLFilename);
385
    }
386
 
4188 varun.gupt 387
	/**
388
	 * Generate the xml list of all the active phones and store in a file
389
	 * @throws Exception
390
	 */
391
	public void generateProductXMLForDisplayAds() throws Exception {
4384 varun.gupt 392
		Utils.info("Generating Product XML for display ads");
4188 varun.gupt 393
		List<String> productXMLSnippets = new ArrayList<String>();
394
		productXMLSnippets.add("<saholic.com>");
395
		List<Long> itemIds = new ArrayList<Long>();
4384 varun.gupt 396
 
397
		Utils.info("Entity Ids: " + entityIdItemMap.keySet());
4188 varun.gupt 398
 
399
		for(Long entityId: entityIdItemMap.keySet()){
400
			List<Item> items = entityIdItemMap.get(entityId);
401
			Item firstItem = items.get(0);
4384 varun.gupt 402
			Utils.info("first Item: " + firstItem);
403
 
4383 varun.gupt 404
			if(isMobile(firstItem) || isLaptop(firstItem)) {
4188 varun.gupt 405
				itemIds.add(firstItem.getId());
406
			}
407
		}
408
 
409
		PromotionClient promotionClient = new PromotionClient();
410
		in.shop2020.model.v1.user.PromotionService.Client promotionServiceClient = promotionClient.getClient();
411
 
412
		List<ItemCouponDiscount> itemsCouponsAndDiscounts = promotionServiceClient.getItemDiscountMap(itemIds);
413
 
414
		Map<Long, ItemCouponDiscount> couponsAndDiscounts = new HashMap<Long, ItemCouponDiscount>();
415
 
416
		for (ItemCouponDiscount itemCouponDiscount: itemsCouponsAndDiscounts) {
417
			couponsAndDiscounts.put(itemCouponDiscount.getItemId(), itemCouponDiscount);
418
		}
4384 varun.gupt 419
		Utils.info("Entity IDs: " + entityIdItemMap.keySet());
4188 varun.gupt 420
 
421
		for(Long entityId: entityIdItemMap.keySet()) {
422
			List<Item> items = entityIdItemMap.get(entityId);
423
			Item firstItem = items.get(0);
4384 varun.gupt 424
 
425
			Utils.info("First Item: " + firstItem);
426
 
4382 varun.gupt 427
			if(!isMobile(firstItem) && !isLaptop(firstItem)){
4188 varun.gupt 428
				continue;
429
			}
430
 
431
			productXMLSnippets.add(this.xmlIndentation[1] + "<products>");	
432
 
433
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductSKU>" + entityId + "</ProductSKU>");
434
 
435
			String title = getProductTitle(firstItem);
436
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductName>" + title + "</ProductName>");
437
 
438
			String url = getProductURL(entityId, firstItem);
439
 
440
			String imageUrl = "http://static" + ((entityId+1)%3) + ".saholic.com" + File.separator + "images" + File.separator + entityId + File.separator + "icon.jpg";    
441
 
442
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + url + "</ProductURL>");
443
 
444
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductImageURL>" + imageUrl + "</ProductImageURL>");
445
 
446
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + firstItem.getMrp() + "</ProductMRP>");
447
 
448
			double minPrice = getMinPrice(items);
449
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductSellingPrice>" + (int)minPrice  + "</ProductSellingPrice>");
450
 
451
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductDiscount>" + (int)((firstItem.getMrp()-minPrice)/firstItem.getMrp()*100) + "</ProductDiscount>");
452
 
453
			long itemId = firstItem.getId();
454
 
455
			if(couponsAndDiscounts.containsKey(itemId))	{
456
 
457
				ItemCouponDiscount itemCouponDiscount = couponsAndDiscounts.get(itemId);
458
 
459
				productXMLSnippets.add(this.xmlIndentation[2] + "<ProductCoupons>");
460
				productXMLSnippets.add(this.xmlIndentation[3] + "<Coupon>");
461
				productXMLSnippets.add(this.xmlIndentation[4] + "<CouponCode>" + itemCouponDiscount.getCouponCode() + "</CouponCode>");
462
				productXMLSnippets.add(this.xmlIndentation[4] + "<PriceAfterCoupon>" + (int)(minPrice - itemCouponDiscount.getDiscount()) + "</PriceAfterCoupon>");
463
				productXMLSnippets.add(this.xmlIndentation[3] + "</Coupon>");
464
				productXMLSnippets.add(this.xmlIndentation[2] + "</ProductCoupons>");
465
 
466
			} else	{
467
				productXMLSnippets.add(this.xmlIndentation[2] + "<ProductCoupons />");
468
			}
469
 
470
			String description = "";
471
			Entity entity = CreationUtils.getEntity(entityId);
472
			if(entity!=null){
473
				if(entity.getSlide(130001) !=null){
4202 varun.gupt 474
					description = StringEscapeUtils.escapeXml(entity.getSlide(130001).getFreeformContent().getFreeformText());
4188 varun.gupt 475
				}
476
			}
477
 
478
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductDescription>" + description + "</ProductDescription>");
479
 
480
			productXMLSnippets.add(this.xmlIndentation[1] + "</products>");	
481
		}
482
 
483
		productXMLSnippets.add("</saholic.com>");
484
 
485
		String productDataXML = StringUtils.join(productXMLSnippets, "\n");
486
 
487
		Utils.info(productDataXML);
488
 
489
		// Write it to file
490
		String productXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "advertismentapi.xml";
491
		DBUtils.store(productDataXML, productXMLFilename);
492
	}
5229 varun.gupt 493
 
494
	public static void main(String[] args) throws Exception {
495
		CatalogClient cl = new CatalogClient();
496
		in.shop2020.model.v1.catalog.InventoryService.Client client = cl.getClient();
497
 
498
		List<Item> items = cl.getClient().getAllItemsByStatus(status.ACTIVE);
499
		items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED));
500
//		items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED_BY_RISK));
501
 
502
		Map<Long, List<Item>> entityIdItemMap1 = new HashMap<Long, List<Item>>();
503
		ProductListGenerator pl = new ProductListGenerator(entityIdItemMap1);
504
		pl.populateEntityIdItemMap(items);
505
		pl.generateXMLFeedForMobileSite();
506
	}
4143 varun.gupt 507
}