Subversion Repositories SmartDukaan

Rev

Rev 5350 | Rev 5362 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5350 Rev 5355
Line 122... Line 122...
122
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
122
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
123
		return parentCategory.getID() == Utils.LAPTOPS_CATEGORY;
123
		return parentCategory.getID() == Utils.LAPTOPS_CATEGORY;
124
	}
124
	}
125
	
125
	
126
	/**
126
	/**
-
 
127
	 * Checks whether a product is accessory or not
-
 
128
	 */
-
 
129
	private boolean isAccessory(Item item)	{
-
 
130
		in.shop2020.metamodel.definitions.Category parentCategory = defContainer.getCategory(item.getCategory()).getParentCategory();
-
 
131
		return parentCategory.getID() == Utils.MOBILE_ACCESSORIES_CATEGORY || parentCategory.getID() == Utils.LAPTOP_ACCESSORIES_CATEGORY;
-
 
132
	}
-
 
133
	
-
 
134
	/**
127
	 * 
135
	 * 
128
	 * @param item
136
	 * @param item
129
	 * @return
137
	 * @return
130
	 */
138
	 */
131
	private String getProductTitle(Item item){
139
	private String getProductTitle(Item item){
Line 248... Line 256...
248
		// Write it to file
256
		// Write it to file
249
		String productXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "saholicmobilephones.xml";
257
		String productXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "saholicmobilephones.xml";
250
		DBUtils.store(productDataXML, productXMLFilename);
258
		DBUtils.store(productDataXML, productXMLFilename);
251
	}
259
	}
252
 
260
 
-
 
261
	/**
-
 
262
	 * Generate the xml list of all the active accessories and store in a file
-
 
263
	 * @throws Exception
-
 
264
	 */
-
 
265
	public void generateAccessoriesXML() throws Exception	{
-
 
266
		LogisticsService.Client prod_client = null;
-
 
267
	
-
 
268
		try	{
-
 
269
			LogisticsClient logistics_prod = new LogisticsClient("logistics_service_prod_server_host","logistics_service_prod_server_port");
-
 
270
			prod_client = logistics_prod.getClient();
-
 
271
		
-
 
272
		} catch (Exception e) {
-
 
273
			prod_client = null;
-
 
274
			Utils.info("Logistics estimations can't be fetched as Logistics Service is inaccessible" + e);
-
 
275
		}
-
 
276
		List<Long> itemIds = new ArrayList<Long>();
-
 
277
		List<String> accessoriesXMLSnippets = new ArrayList<String>();
-
 
278
		
-
 
279
		accessoriesXMLSnippets.add("<saholic.com>");
-
 
280
		
-
 
281
		for(Long entityId: entityIdItemMap.keySet())	{
-
 
282
			
-
 
283
			List<Item> items = entityIdItemMap.get(entityId);
-
 
284
			Item firstItem = items.get(0);
-
 
285
			
-
 
286
			if(! isAccessory(firstItem))	{
-
 
287
				continue;
-
 
288
			}
-
 
289
			String title = getProductTitle(firstItem);
-
 
290
			String url = getProductURL(entityId, firstItem);
-
 
291
			String imageUrl = "http://static" + ((entityId+1)%3) + ".saholic.com" + File.separator + "images" + File.separator +
-
 
292
            "website" + File.separator + entityId + File.separator + "icon.jpg";
-
 
293
			
-
 
294
			accessoriesXMLSnippets.add(this.xmlIndentation[1] + "<products>");	
-
 
295
			accessoriesXMLSnippets.add(this.xmlIndentation[2] + "<ProductSKU>" + entityId + "</ProductSKU>");
-
 
296
			accessoriesXMLSnippets.add(this.xmlIndentation[2] + "<ProductName>" + title + "</ProductName>");
-
 
297
			accessoriesXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + url + "</ProductURL>");
-
 
298
			accessoriesXMLSnippets.add(this.xmlIndentation[2] + "<ProductPrice>" + getMinPrice(items) + "</ProductPrice>");
-
 
299
			accessoriesXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + getMinMRP(items) + "</ProductMRP>");
-
 
300
			
-
 
301
			LogisticsInfo logisticsInfo = null;
-
 
302
			if(prod_client != null){
-
 
303
				try {
-
 
304
					Long itemId = prod_client.getEntityLogisticsEstimation(entityId, DEFAULT_PINCODE, DeliveryType.PREPAID).get(0);
-
 
305
					logisticsInfo = prod_client.getLogisticsEstimation(itemId, DEFAULT_PINCODE, DeliveryType.PREPAID);
-
 
306
					accessoriesXMLSnippets.add(this.xmlIndentation[2] + "<ProductDeliveryEstimate>" + logisticsInfo.getDeliveryTime() + "</ProductDeliveryEstimate>");
-
 
307
				} catch (Exception e1) {
-
 
308
					Utils.info("Unable to get Estimation for Entity: " + entityId + "\n" + e1);
-
 
309
				}
-
 
310
			}
-
 
311
			accessoriesXMLSnippets.add(this.xmlIndentation[2] + "<ProductImageURL>" + imageUrl + "</ProductImageURL>");
-
 
312
			accessoriesXMLSnippets.add(this.xmlIndentation[1] + "</products>");		
-
 
313
		}
-
 
314
		
-
 
315
		accessoriesXMLSnippets.add("</saholic.com>");
253
 
316
 
-
 
317
		String accessoriesXML = StringUtils.join(accessoriesXMLSnippets, "\n");
-
 
318
		
-
 
319
		Utils.info(accessoriesXML);
254
 
320
		
-
 
321
		// Write it to file
-
 
322
		String accessoriesXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "saholicaccessories.xml";
-
 
323
		DBUtils.store(accessoriesXML, accessoriesXMLFilename);
-
 
324
	}
255
 
325
 
256
	/**
326
	/**
257
	 * get xml feed for partner sites
327
	 * get xml feed for partner sites
258
	 * @param irDataXMLSnippets
328
	 * @param irDataXMLSnippets
259
	 * @throws Exception
329
	 * @throws Exception
Line 531... Line 601...
531
//		items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED_BY_RISK));
601
//		items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED_BY_RISK));
532
 
602
 
533
		Map<Long, List<Item>> entityIdItemMap1 = new HashMap<Long, List<Item>>();
603
		Map<Long, List<Item>> entityIdItemMap1 = new HashMap<Long, List<Item>>();
534
		ProductListGenerator pl = new ProductListGenerator(entityIdItemMap1);
604
		ProductListGenerator pl = new ProductListGenerator(entityIdItemMap1);
535
		pl.populateEntityIdItemMap(items);
605
		pl.populateEntityIdItemMap(items);
536
		pl.generateProductsListXML();
606
		pl.generateAccessoriesXML();
537
	}
607
	}
538
}
608
}
539
609