Subversion Repositories SmartDukaan

Rev

Rev 5229 | Rev 5350 | 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
 
5347 amit.gupta 231
		Map<String, Map<String, Long>> products = new HashMap<String, Map<String,Long>>();
2367 rajveer 232
 
5347 amit.gupta 233
		for(Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet())	{
234
			Item item = entry.getValue().get(0);
235
			in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
4143 varun.gupt 236
 
5347 amit.gupta 237
			if(parentCategory.isComparable()){
238
				String parentCat = parentCategory.getLabel();
239
				if(!products.containsKey(parentCategory.getLabel())){
240
					Map<String, Long> catMap = new HashMap<String, Long>();
241
					products.put(parentCat, catMap);
242
				}
243
				products.get(parentCat).put(getProductTitle(item), entry.getKey());
2227 rajveer 244
			}
245
		}
4143 varun.gupt 246
		sb.append(new JSONObject(products));
2227 rajveer 247
	}
248
 
249
 
250
	/**
251
	 * Generate the javascript list of all the active phones and store in a file
252
	 * @throws Exception
253
	 */
254
	public void generateProductListJavascript() throws Exception {
255
		StringBuffer productsJavascript = new StringBuffer();
256
 
4143 varun.gupt 257
		productsJavascript.append("var productIdNames=");
2227 rajveer 258
 
259
		getProductsJavascript(productsJavascript);
260
 
4143 varun.gupt 261
		productsJavascript.append(";");
2227 rajveer 262
 
263
		// Write it to file
264
		String productXMLFilename = Utils.EXPORT_JAVASCRIPT_CONTENT_PATH + "saholicmobilephones.js";
265
		DBUtils.store(productsJavascript.toString(), productXMLFilename);
266
	}
4188 varun.gupt 267
 
268
    private void populateEntityIdItemMap(List<Item> items){
269
        Date toDate = new Date();
270
        for(Item item: items){
271
            //TODO Can be removed as we are checking in calling function
272
            if(!(item.getItemStatus()==status.ACTIVE || item.getItemStatus()==status.CONTENT_COMPLETE || item.getItemStatus() == status.PAUSED)){
273
                continue;
274
            }
275
            if(toDate.getTime() < item.getStartDate() ||  item.getSellingPrice() == 0){
276
                continue;
277
            }
278
            List<Item> itemList = entityIdItemMap.get(item.getCatalogItemId());
279
            if(itemList == null){
280
                itemList = new ArrayList<Item>();
281
            }
282
            itemList.add(item);
283
            entityIdItemMap.put(item.getCatalogItemId(), itemList);
284
        }
285
 
286
        //Remove all items which have not been updated since last content generation.
287
        List<Long> removeEntities = new ArrayList<Long>();
288
        for(Long entityId:entityIdItemMap.keySet()){
289
            boolean isValidEntity = false;
290
            //If any one of the items has been updated before current timestamp, than we generate content for whole entity
291
            for(Item item: entityIdItemMap.get(entityId)){
292
                if(item.getUpdatedOn() > 0){
293
                    isValidEntity = true;
294
                }
295
            }
296
            if(!isValidEntity){
297
                removeEntities.add(entityId);
298
            }
299
        }
300
        for(Long entityId: removeEntities){
301
            entityIdItemMap.remove(entityId);
302
        }
303
    }
5229 varun.gupt 304
 
305
    /**
306
     * Generate XML feed for mobile site
307
     * @throws Exception
308
     */
309
    public void generateXMLFeedForMobileSite() throws Exception	{
310
    	List<String> productXMLSnippets = new ArrayList<String>();
311
		productXMLSnippets.add("<Products>");
312
		List<Long> itemIds = new ArrayList<Long>();
313
 
314
		for(Long entityId: entityIdItemMap.keySet()){
315
			List<Item> items = entityIdItemMap.get(entityId);
316
			Item firstItem = items.get(0);
317
			Utils.info("first Item: " + firstItem);
318
 
319
			if(isMobile(firstItem) || isLaptop(firstItem)) {
320
				itemIds.add(firstItem.getId());
321
			}
322
		}
4188 varun.gupt 323
 
5229 varun.gupt 324
		List<String> descriptions = new ArrayList<String>();
325
		descriptions.add("8MP camera, Super AMOLED Plus display, Android Gingerbread");
326
		descriptions.add("Android OS v2.2 Froyo, 800MHz processor, 3.5\" capacitive display");
327
		descriptions.add("Dual-SIM, Wi-Fi, Bluetooth, Social networking &amp; IM");
328
		descriptions.add("Android Gingerbread, Facebook button, 5MP camera");
329
		descriptions.add("Android Gingerbread, 1GHz processor, 3.7\" Gorilla Glass display");
330
		descriptions.add("2GB RAM, 500GB HDD, Intel Core 2 Duo T6570 processor, DOS");
331
		descriptions.add("4GB RAM, 500GB HDD, Intel Core i5 2410M processor, Windows 7 Basic");
332
		descriptions.add("3.2\" touchscreen, 2MP camera, IM &amp; social networking");
333
 
334
		for(Long entityId: entityIdItemMap.keySet()) {
335
			List<Item> items = entityIdItemMap.get(entityId);
336
			Item firstItem = items.get(0);
337
 
338
			if(!isMobile(firstItem) && !isLaptop(firstItem)){
339
				continue;
340
			}
4188 varun.gupt 341
 
5229 varun.gupt 342
			String url = getProductURL(entityId, firstItem);
343
			String imageUrl = "http://www.saholic.com/images/website" + File.separator + entityId + File.separator + "thumbnail.jpg";
344
			String description = descriptions.get((int) (8 * Math.random()));
345
			double minPrice = getMinPrice(items);
346
 
347
			String productType = "";
348
 
349
			if (firstItem.getCategory() == 10001 || firstItem.getCategory() == 10002 || firstItem.getCategory() == 10003 || firstItem.getCategory() == 10004 || firstItem.getCategory() == 10005)	{
350
				productType = "Mobile Phone";
351
 
352
			} else if (firstItem.getCategory() == 10010)	{
353
				productType = "Tablet";
354
 
355
			} else if (firstItem.getCategory() == 10050)	{
356
				productType = "Laptop";
357
			}
358
 
359
			productXMLSnippets.add(this.xmlIndentation[1] + "<Product>");	
360
 
361
			productXMLSnippets.add(this.xmlIndentation[2] + "<ID>" + entityId + "</ID>");
362
			productXMLSnippets.add(this.xmlIndentation[2] + "<Type>" + productType + "</Type>");
363
			productXMLSnippets.add(this.xmlIndentation[2] + "<Brand>" + firstItem.getBrand() + "</Brand>");
364
			productXMLSnippets.add(this.xmlIndentation[2] + "<ModelName>" + firstItem.getModelName() + "</ModelName>");
365
			productXMLSnippets.add(this.xmlIndentation[2] + "<ModelNumber>" + firstItem.getModelNumber() + "</ModelNumber>");
366
			productXMLSnippets.add(this.xmlIndentation[2] + "<URL>" + url + "</URL>");
367
			productXMLSnippets.add(this.xmlIndentation[2] + "<ImageURL>" + imageUrl + "</ImageURL>");
368
			productXMLSnippets.add(this.xmlIndentation[2] + "<ShortDesc>" + description + "</ShortDesc>");
369
			productXMLSnippets.add(this.xmlIndentation[2] + "<MRP>" + firstItem.getMrp() + "</MRP>");
370
			productXMLSnippets.add(this.xmlIndentation[2] + "<SellingPrice>" + (int)minPrice  + "</SellingPrice>");
371
 
372
			productXMLSnippets.add(this.xmlIndentation[1] + "</Product>");
373
		}
374
 
375
		productXMLSnippets.add("</Products>");
376
 
377
		String productDataXML = StringUtils.join(productXMLSnippets, "\n");
378
 
379
		Utils.info(productDataXML);
380
 
381
		// Write it to file
382
		String productXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "msitedata.xml";
383
		DBUtils.store(productDataXML, productXMLFilename);
384
    }
385
 
4188 varun.gupt 386
	/**
387
	 * Generate the xml list of all the active phones and store in a file
388
	 * @throws Exception
389
	 */
390
	public void generateProductXMLForDisplayAds() throws Exception {
4384 varun.gupt 391
		Utils.info("Generating Product XML for display ads");
4188 varun.gupt 392
		List<String> productXMLSnippets = new ArrayList<String>();
393
		productXMLSnippets.add("<saholic.com>");
394
		List<Long> itemIds = new ArrayList<Long>();
4384 varun.gupt 395
 
396
		Utils.info("Entity Ids: " + entityIdItemMap.keySet());
4188 varun.gupt 397
 
398
		for(Long entityId: entityIdItemMap.keySet()){
399
			List<Item> items = entityIdItemMap.get(entityId);
400
			Item firstItem = items.get(0);
4384 varun.gupt 401
			Utils.info("first Item: " + firstItem);
402
 
4383 varun.gupt 403
			if(isMobile(firstItem) || isLaptop(firstItem)) {
4188 varun.gupt 404
				itemIds.add(firstItem.getId());
405
			}
406
		}
407
 
408
		PromotionClient promotionClient = new PromotionClient();
409
		in.shop2020.model.v1.user.PromotionService.Client promotionServiceClient = promotionClient.getClient();
410
 
411
		List<ItemCouponDiscount> itemsCouponsAndDiscounts = promotionServiceClient.getItemDiscountMap(itemIds);
412
 
413
		Map<Long, ItemCouponDiscount> couponsAndDiscounts = new HashMap<Long, ItemCouponDiscount>();
414
 
415
		for (ItemCouponDiscount itemCouponDiscount: itemsCouponsAndDiscounts) {
416
			couponsAndDiscounts.put(itemCouponDiscount.getItemId(), itemCouponDiscount);
417
		}
4384 varun.gupt 418
		Utils.info("Entity IDs: " + entityIdItemMap.keySet());
4188 varun.gupt 419
 
420
		for(Long entityId: entityIdItemMap.keySet()) {
421
			List<Item> items = entityIdItemMap.get(entityId);
422
			Item firstItem = items.get(0);
4384 varun.gupt 423
 
424
			Utils.info("First Item: " + firstItem);
425
 
4382 varun.gupt 426
			if(!isMobile(firstItem) && !isLaptop(firstItem)){
4188 varun.gupt 427
				continue;
428
			}
429
 
430
			productXMLSnippets.add(this.xmlIndentation[1] + "<products>");	
431
 
432
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductSKU>" + entityId + "</ProductSKU>");
433
 
434
			String title = getProductTitle(firstItem);
435
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductName>" + title + "</ProductName>");
436
 
437
			String url = getProductURL(entityId, firstItem);
438
 
439
			String imageUrl = "http://static" + ((entityId+1)%3) + ".saholic.com" + File.separator + "images" + File.separator + entityId + File.separator + "icon.jpg";    
440
 
441
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + url + "</ProductURL>");
442
 
443
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductImageURL>" + imageUrl + "</ProductImageURL>");
444
 
445
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + firstItem.getMrp() + "</ProductMRP>");
446
 
447
			double minPrice = getMinPrice(items);
448
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductSellingPrice>" + (int)minPrice  + "</ProductSellingPrice>");
449
 
450
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductDiscount>" + (int)((firstItem.getMrp()-minPrice)/firstItem.getMrp()*100) + "</ProductDiscount>");
451
 
452
			long itemId = firstItem.getId();
453
 
454
			if(couponsAndDiscounts.containsKey(itemId))	{
455
 
456
				ItemCouponDiscount itemCouponDiscount = couponsAndDiscounts.get(itemId);
457
 
458
				productXMLSnippets.add(this.xmlIndentation[2] + "<ProductCoupons>");
459
				productXMLSnippets.add(this.xmlIndentation[3] + "<Coupon>");
460
				productXMLSnippets.add(this.xmlIndentation[4] + "<CouponCode>" + itemCouponDiscount.getCouponCode() + "</CouponCode>");
461
				productXMLSnippets.add(this.xmlIndentation[4] + "<PriceAfterCoupon>" + (int)(minPrice - itemCouponDiscount.getDiscount()) + "</PriceAfterCoupon>");
462
				productXMLSnippets.add(this.xmlIndentation[3] + "</Coupon>");
463
				productXMLSnippets.add(this.xmlIndentation[2] + "</ProductCoupons>");
464
 
465
			} else	{
466
				productXMLSnippets.add(this.xmlIndentation[2] + "<ProductCoupons />");
467
			}
468
 
469
			String description = "";
470
			Entity entity = CreationUtils.getEntity(entityId);
471
			if(entity!=null){
472
				if(entity.getSlide(130001) !=null){
4202 varun.gupt 473
					description = StringEscapeUtils.escapeXml(entity.getSlide(130001).getFreeformContent().getFreeformText());
4188 varun.gupt 474
				}
475
			}
476
 
477
			productXMLSnippets.add(this.xmlIndentation[2] + "<ProductDescription>" + description + "</ProductDescription>");
478
 
479
			productXMLSnippets.add(this.xmlIndentation[1] + "</products>");	
480
		}
481
 
482
		productXMLSnippets.add("</saholic.com>");
483
 
484
		String productDataXML = StringUtils.join(productXMLSnippets, "\n");
485
 
486
		Utils.info(productDataXML);
487
 
488
		// Write it to file
489
		String productXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "advertismentapi.xml";
490
		DBUtils.store(productDataXML, productXMLFilename);
491
	}
5229 varun.gupt 492
 
493
	public static void main(String[] args) throws Exception {
494
		CatalogClient cl = new CatalogClient();
495
		in.shop2020.model.v1.catalog.InventoryService.Client client = cl.getClient();
496
 
497
		List<Item> items = cl.getClient().getAllItemsByStatus(status.ACTIVE);
498
		items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED));
499
//		items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED_BY_RISK));
500
 
501
		Map<Long, List<Item>> entityIdItemMap1 = new HashMap<Long, List<Item>>();
502
		ProductListGenerator pl = new ProductListGenerator(entityIdItemMap1);
503
		pl.populateEntityIdItemMap(items);
504
		pl.generateXMLFeedForMobileSite();
505
	}
4143 varun.gupt 506
}