| Line 51... |
Line 51... |
| 51 |
*/
|
51 |
*/
|
| 52 |
public class ProductListGenerator {
|
52 |
public class ProductListGenerator {
|
| 53 |
|
53 |
|
| 54 |
private String[] xmlIndentation = {"", " ", " ", " "," "};
|
54 |
private String[] xmlIndentation = {"", " ", " ", " "," "};
|
| 55 |
private Client cc = null;
|
55 |
private Client cc = null;
|
| 56 |
List <Long> catalogItemIds = new ArrayList<Long>();
|
56 |
List <Long> inStockCatalogItemIds = new ArrayList<Long>();
|
| - |
|
57 |
|
| 57 |
public Map<Long, List<Item>> entityIdItemMap;
|
58 |
public Map<Long, List<Item>> entityIdItemMap;
|
| 58 |
private static final String DEFAULT_PINCODE = "110001";
|
59 |
private static final String DEFAULT_PINCODE = "110001";
|
| 59 |
DefinitionsContainer defContainer = Catalog.getInstance().getDefinitionsContainer();
|
60 |
DefinitionsContainer defContainer = Catalog.getInstance().getDefinitionsContainer();
|
| 60 |
private List<Long> validParentCategories = Arrays.asList((long)Utils.LAPTOPS_CATEGORY, (long)Utils.CAMERAS_CATEGORY, (long)Utils.MOBILE_PHONES_CATAGORY, (long)Utils.TABLETS_CATEGORY);
|
61 |
private List<Long> validParentCategories = Arrays.asList((long)Utils.LAPTOPS_CATEGORY, (long)Utils.CAMERAS_CATEGORY, (long)Utils.MOBILE_PHONES_CATAGORY, (long)Utils.TABLETS_CATEGORY);
|
| 61 |
private List<Long> voucherEntities = new ArrayList<Long>();
|
62 |
private List<Long> voucherEntities = new ArrayList<Long>();
|
| Line 125... |
Line 126... |
| 125 |
}
|
126 |
}
|
| 126 |
}
|
127 |
}
|
| 127 |
return minPrice;
|
128 |
return minPrice;
|
| 128 |
}
|
129 |
}
|
| 129 |
|
130 |
|
| - |
|
131 |
public List<Long> getInStockCatalogItemIds() {
|
| - |
|
132 |
return inStockCatalogItemIds;
|
| - |
|
133 |
}
|
| - |
|
134 |
|
| - |
|
135 |
|
| 130 |
|
136 |
|
| 131 |
|
137 |
|
| 132 |
/**
|
138 |
/**
|
| 133 |
* Get the minimum price of the items
|
139 |
* Get the minimum price of the items
|
| 134 |
* @param items
|
140 |
* @param items
|
| Line 272... |
Line 278... |
| 272 |
|
278 |
|
| 273 |
String imageUrl = "http://static" + ((entityId+1)%3) + ".saholic.com" + File.separator + "images" + File.separator +
|
279 |
String imageUrl = "http://static" + ((entityId+1)%3) + ".saholic.com" + File.separator + "images" + File.separator +
|
| 274 |
"website" + File.separator + entityId + File.separator + "icon.jpg";
|
280 |
"website" + File.separator + entityId + File.separator + "icon.jpg";
|
| 275 |
|
281 |
|
| 276 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + url + "</ProductURL>");
|
282 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + url + "</ProductURL>");
|
| 277 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<Availability>" + (catalogItemIds.contains(entityId) ? "Y" : "N") + "</Availability>");
|
283 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<Availability>" + (inStockCatalogItemIds.contains(entityId) ? "Y" : "N") + "</Availability>");
|
| 278 |
double minPrice = getMinPrice(items);
|
284 |
double minPrice = getMinPrice(items);
|
| 279 |
|
285 |
|
| 280 |
if(couponsAndDiscounts.containsKey(firstItem.getId())) {
|
286 |
if(couponsAndDiscounts.containsKey(firstItem.getId())) {
|
| 281 |
|
287 |
|
| 282 |
int discountedPrice = (int)(minPrice - couponsAndDiscounts.get(firstItem.getId()).getDiscount());
|
288 |
int discountedPrice = (int)(minPrice - couponsAndDiscounts.get(firstItem.getId()).getDiscount());
|
| Line 430... |
Line 436... |
| 430 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductSKU>" + entityId + "</ProductSKU>");
|
436 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductSKU>" + entityId + "</ProductSKU>");
|
| 431 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductName>" + StringEscapeUtils.escapeXml(title) + "</ProductName>");
|
437 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductName>" + StringEscapeUtils.escapeXml(title) + "</ProductName>");
|
| 432 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + StringEscapeUtils.escapeXml(url) + "</ProductURL>");
|
438 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductURL>" + StringEscapeUtils.escapeXml(url) + "</ProductURL>");
|
| 433 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductPrice>" + getMinPrice(items) + "</ProductPrice>");
|
439 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductPrice>" + getMinPrice(items) + "</ProductPrice>");
|
| 434 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + getMinMRP(items) + "</ProductMRP>");
|
440 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + getMinMRP(items) + "</ProductMRP>");
|
| 435 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<Availability>" + (catalogItemIds.contains(entityId) ? "Y" : "N") + "</Availability>");
|
441 |
camerasXMLSnippets.add(this.xmlIndentation[2] + "<Availability>" + (inStockCatalogItemIds.contains(entityId) ? "Y" : "N") + "</Availability>");
|
| 436 |
|
442 |
|
| 437 |
LogisticsInfo logisticsInfo = null;
|
443 |
LogisticsInfo logisticsInfo = null;
|
| 438 |
if(prod_client != null){
|
444 |
if(prod_client != null){
|
| 439 |
try {
|
445 |
try {
|
| 440 |
Long itemId = prod_client.getEntityLogisticsEstimation(entityId, DEFAULT_PINCODE, DeliveryType.PREPAID).get(0);
|
446 |
Long itemId = prod_client.getEntityLogisticsEstimation(entityId, DEFAULT_PINCODE, DeliveryType.PREPAID).get(0);
|
| Line 683... |
Line 689... |
| 683 |
|
689 |
|
| 684 |
productXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + firstItem.getMrp() + "</ProductMRP>");
|
690 |
productXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + firstItem.getMrp() + "</ProductMRP>");
|
| 685 |
|
691 |
|
| 686 |
double minPrice = getMinPrice(items);
|
692 |
double minPrice = getMinPrice(items);
|
| 687 |
productXMLSnippets.add(this.xmlIndentation[2] + "<ProductSellingPrice>" + (int)minPrice + "</ProductSellingPrice>");
|
693 |
productXMLSnippets.add(this.xmlIndentation[2] + "<ProductSellingPrice>" + (int)minPrice + "</ProductSellingPrice>");
|
| 688 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Availability>" + (catalogItemIds.contains(entityId) ? "Y" : "N") + "</Availability>");
|
694 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Availability>" + (inStockCatalogItemIds.contains(entityId) ? "Y" : "N") + "</Availability>");
|
| 689 |
productXMLSnippets.add(this.xmlIndentation[2] + "<ProductDiscount>" + (int)((firstItem.getMrp()-minPrice)/firstItem.getMrp()*100) + "</ProductDiscount>");
|
695 |
productXMLSnippets.add(this.xmlIndentation[2] + "<ProductDiscount>" + (int)((firstItem.getMrp()-minPrice)/firstItem.getMrp()*100) + "</ProductDiscount>");
|
| 690 |
|
696 |
|
| 691 |
long itemId = firstItem.getId();
|
697 |
long itemId = firstItem.getId();
|
| 692 |
|
698 |
|
| 693 |
if(couponsAndDiscounts.containsKey(itemId)) {
|
699 |
if(couponsAndDiscounts.containsKey(itemId)) {
|
| Line 775... |
Line 781... |
| 775 |
List<Item> items = cc.getAllItemsByStatus(status.ACTIVE);
|
781 |
List<Item> items = cc.getAllItemsByStatus(status.ACTIVE);
|
| 776 |
Client catalogClientProd = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(), ConfigClientKeys.catalog_service_server_port.toString()).getClient();
|
782 |
Client catalogClientProd = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(), ConfigClientKeys.catalog_service_server_port.toString()).getClient();
|
| 777 |
for (Item item : items){
|
783 |
for (Item item : items){
|
| 778 |
Category parentCategory = Catalog.getInstance().getDefinitionsContainer().getCategory(item.getCategory()).getParentCategory();
|
784 |
Category parentCategory = Catalog.getInstance().getDefinitionsContainer().getCategory(item.getCategory()).getParentCategory();
|
| 779 |
boolean isActive = true;
|
785 |
boolean isActive = true;
|
| 780 |
if(validParentCategories.contains(parentCategory.getID()) && !catalogItemIds.contains(item.getCatalogItemId())) {
|
786 |
if(validParentCategories.contains(parentCategory.getID()) && !inStockCatalogItemIds.contains(item.getCatalogItemId())) {
|
| 781 |
if(item.isRisky()){
|
787 |
if(item.isRisky()){
|
| 782 |
try {
|
788 |
try {
|
| 783 |
ItemShippingInfo isi = catalogClientProd.isActive(item.getId());
|
789 |
ItemShippingInfo isi = catalogClientProd.isActive(item.getId());
|
| 784 |
isActive = isi.isIsActive();
|
790 |
isActive = isi.isIsActive();
|
| 785 |
} catch (Exception e) {
|
791 |
} catch (Exception e) {
|
| Line 793... |
Line 799... |
| 793 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Product_URL>" + getProductURL(item.getCatalogItemId(), item, 59) + "</Product_URL>");
|
799 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Product_URL>" + getProductURL(item.getCatalogItemId(), item, 59) + "</Product_URL>");
|
| 794 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Product_Price>" + (int)item.getSellingPrice() + "</Product_Price>");
|
800 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Product_Price>" + (int)item.getSellingPrice() + "</Product_Price>");
|
| 795 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Merchant_Name>" + "saholic.com" + "</Merchant_Name>");
|
801 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Merchant_Name>" + "saholic.com" + "</Merchant_Name>");
|
| 796 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Category_Name>" + parentCategory.getLabel() + "</Category_Name>");
|
802 |
productXMLSnippets.add(this.xmlIndentation[2] + "<Category_Name>" + parentCategory.getLabel() + "</Category_Name>");
|
| 797 |
productXMLSnippets.add(this.xmlIndentation[1] + "</products>");
|
803 |
productXMLSnippets.add(this.xmlIndentation[1] + "</products>");
|
| 798 |
catalogItemIds.add(item.getCatalogItemId());
|
804 |
inStockCatalogItemIds.add(item.getCatalogItemId());
|
| 799 |
}
|
805 |
}
|
| 800 |
}
|
806 |
}
|
| 801 |
}
|
807 |
}
|
| 802 |
productXMLSnippets.add("</root>");
|
808 |
productXMLSnippets.add("</root>");
|
| 803 |
String productDataXML = StringUtils.join(productXMLSnippets, "\n");
|
809 |
String productDataXML = StringUtils.join(productXMLSnippets, "\n");
|